Content deleted Content added
poke |
let's see how completely broken this is |
||
Line 14:
local function class_percent(param, total)
return string.format('%s %%', tostring(round(100 * param / total))
end
local function percent_remaining(sum, total)
local remaining = sum - total
if remaining
return string.format('%s %%', tostring(round(-100 * remaining / total))
else
return nil
Line 28:
local function category_count(category, project)
return mw.site.stats.pagesInCategory(
'pages'
)
-- This is only done once in this module, here for demonstration
local function set_or_default (args, from_arg, default)
return args[from_arg]
else▼
return default
end
end
Line 39 ⟶ 48:
function p._main(args, frame)
-- frame needs to be passed to p._main for extensionTag and expandTemplate
local classes = {
Line 58 ⟶ 66:
}
local project = set_or_default(args, "project", nil)
▲ if args.project and args.project ~= '' then
▲ else
▲ end
local sum_classes = 0
if project then
for _, class in
class.count = category_count(class.category, project)
if class.class == 'FA' then
Line 82 ⟶ 81:
end
else
▲ -- parameter 9, which is the total non-project
-- whether to error here.
▲ for i, class in pairs(classes) do
▲ if args[i] then
▲ -- 'or 0' to keep us safe from some maniac putting non-numeric
▲ class.count = tonumber(args[i]) or 0
sum_classes = sum_classes + class.count
end
Line 99 ⟶ 94:
local total
if project then
--
--
total = sum_classes + category_count(
project_classes[2].category,
Line 125 ⟶ 119:
:tag('span')
-- wikitext accessibly-hidden by CSS
:wikitext(
:done()
:done()
Line 139 ⟶ 132:
:css('width', remaining)
:tag('span')
:wikitext(
:done()
:done()
:newline()
end
return frame:extensionTag{
name = 'templatestyles',
args = { src = 'Progression rainbow/styles.css'}
} .. '\n' .. tostring(root)
end
|