Module:User:Happy5214/FTBox
local p = {}
local format = string.format
local insert = table.insert
local function classWithName(class, name)
return format("{{icon|%s}} [[%s]]", class, name)
end
function p._ftbox(args)
local featuredCount = 0
local goodCount = 0
local topicName = args.title
local topicImage = args.image
local topicImageSize = args.imagesize
local topicLeadClass = args.leadClass
if topicLeadClass == 'FA' or topicLeadClass == 'FL' then
featuredCount = featuredCount + 1
goodCount = goodCount + 1
elseif topicLeadClass == 'A' or topicLeadClass == 'GA' then
goodCount = goodCount + 1
end
local topicLeadName = args.leadName
local articleArgs = {}
local articleCount = 1
while true do
local articleClass = args[articleCount * 2 - 1]
if not articleClass then break end
if articleClass == 'FA' or articleClass == 'FL' then
featuredCount = featuredCount + 1
goodCount = goodCount + 1
elseif articleClass == 'A' or articleClass == 'GA' then
goodCount = goodCount + 1
end
local article = {class = articleClass, name = args[articleCount * 2]}
insert(articleArgs, article)
articleCount = articleCount + 1
end
local column2Start = args.column2start
local column3Start = args.column3start
-- Start generating output
-- Topic box
local lines = {}
insert(lines, format("{{Featured topic box|title=%s", topicName))
insert(lines, "|lead=" .. classWithName(topicLeadClass, topicLeadName))
insert(lines, "|image=" .. topicImage)
insert(lines, "|imagesize=" .. topicImageSize)
insert(lines, "|count=" .. articleCount)
insert(lines, "|column1=")
for i = 1, column2Start - 1 do
insert(lines, "*" .. classWithName(articleArgs[i].class, articleArgs[i].name))
end
insert(lines, "|column2=")
for i = column2Start, column3Start - 1 do
insert(lines, "*" .. classWithName(articleArgs[i].class, articleArgs[i].name))
end
insert(lines, "|column3=")
for i = column3Start, articleCount - 1 do
insert(lines, "*" .. classWithName(articleArgs[i].class, articleArgs[i].name))
end
insert(lines, "}}")
-- Progress bars
insert(lines, format("{{Progress bar|%d|total=%d|text=Featured Articles, Featured Lists <small>(50%% required for FT)</small>}}", featuredCount, articleCount))
insert(lines, format("{{Progress bar|%d|total=%d|text=Featured or Good Articles, Featured Lists <small>(100%% required for GT)</small>}}", goodCount, articleCount))
local wikitext = table.concat(lines, '\n')
return wikitext
end
function p.ftbox(frame)
local argModule = require('Module:Arguments')
local args = argModule.getArgs(frame)
return frame:preprocess(p._ftbox(args))
end
return p
Content Disclaimer
Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.
- The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
- There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
- It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
- Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
- Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.