模組:Articles by Quality and Importance/sandbox
外观
![]() | 这是Module:Articles by Quality and Importance(差异)的沙盒。 |
local getArgs = require('Module:Arguments').getArgs
local yesno = require('Module:Yesno')
local classList = {
{'fa', '特色'},
{'a', '甲'},
{'ga', '优良'},
{'b', '乙'},
{'c', '丙'},
{'start', '初'},
{'stub', '小作品'},
{'fl', '特色列表'},
{'list', '列表'},
{'category', '分类'},
{'disambig', '消歧义'},
{'file', '文件'},
{'portal', '主题'},
{'project', '专题'},
{'template', '模板'},
{'na', '不适用'},
{'unassessed', '未评'}
}
local importanceList = {
{'top', '极高'},
{'high', '高'},
{'mid', '中'},
{'low', '低'},
{'na', '不适用'},
{'unknown', '未知'}
}
local classExtendedList = { 'category', 'disambig', 'file', 'portal', 'project', 'template' }
local function number(args, x, y)
local l = mw.language.new( 'zh' )
return l:formatNum( tonumber( args[x ..'_' ..y] ) )
end
local p = {}
function p.main(frame)
local args = getArgs(frame, {
valueFunc = function (key, value)
if value == '' then
return nil
else
return value
end
end
})
for i, v in ipairs( classList ) do
if yesno( args[v[1] .. '_'] ) ~= false then
for j, w in ipairs( importanceList ) do
if yesno( args['_' .. w[1]] ) ~= false then
args[v[1] .. '_total'] = ( args[v[1] .. '_total'] or '0' ) + ( args[v[1] .. '_' .. w[1]] or '0' )
args['total_' .. w[1]] = ( args['total_' .. w[1]] or '0' ) + ( args[v[1] .. '_' .. w[1]] or '0' )
end
end
end
end
return p._main(args)
end
function p._main(args)
return number(args, 'stub', 'low')
-- Main module code goes here.
end
return p