跳转到内容

模組:沙盒/Lopullinen

维基百科,自由的百科全书

这是本页的一个历史版本,由Lopullinen留言 | 贡献2022年12月29日 (四) 06:26编辑。这可能和当前版本存在着巨大的差异。

require("Module:No globals")

local getArgs = require("Module:Arguments").getArgs
local p = {}

local function get_icon(str, text)
    local images = {
        pass = {filename = "Artículo bueno.svg", alt = "通过"},
        fail = {filename = "Symbol delete vote oversat.svg", alt = "未通过"},
        partly = {filename = "Symbol dot dot dot.svg", alt = "部分检查通过"},
        unsure = {filename = "Symbol question.svg", alt = "不确定"},
        nointention = {filename = "Symbol neutral vote.svg", alt = "无意检查"},
        checking = {filename = "Symbol_wait.svg", alt = "检查中"}
    }

    local alias_table = {
        ["1"] = "pass",
        ["0"] = "fail",
        ["..."] = "partly",
        ["0.5"] = "partly",
        ["?"] = "unsure",
        ["="] = "nointention"
    }

    local status = nil
    for k, v in pairs(alias_table) do
        if k == str then
            status = v
            break
        end
    end
    status = status or "checking"

    local image = images[status]
    return "[[File:" .. image.filename .. "|24px|" .. image.alt .. "|alt=" .. image.alt .. "]]" .. (text and ' ' .. image.alt or '')
end

local function build_row(args, rev_num)
    local str_frags, str = {}, ''
    table.insert(str_frags, '|-')
    
    local revn = 'rev' .. tostring(rev_num)
    
    local username = args[revn]
    str = str .. '[[User:' .. username .. '|' .. username .. ']]'
    str = str .. ' ([[User talk:' .. username .. '|讨论]])'
    table.insert(str_frags, '! scope="row" | ' .. str)
    
    for i = 1, 6 do
        str = get_icon(args[revn .. '_' .. tostring(i)])
        table.insert(str_frags, '| ' .. str)
    end
    
    str = get_icon(args[revn .. '_' .. 'overall'], true)
    table.insert(str_frags, '| style="font-weight: bold;" | ' .. str)
    
    str = args[revn .. '_' .. 'updated'] or ''
    table.insert(str_frags, '| ' .. str)
    
    return table.concat(str_frags, '\n')
end

function p.main(frame)
    local args = getArgs(frame)
    return p._main(args)
end

function p._main(args)
    local str_frags = {}

    -- Header
    table.insert(str_frags, '{| class="wikitable plainrowheaders" style="float: right; text-align: center;"')
    table.insert(str_frags, '|+ 乙上级标准检查表')
    table.insert(str_frags, '! scope="col" | 评审人')
    table.insert(str_frags, '! scope="col" | BP1<br><small>來源引用</small>')
    table.insert(str_frags, '! scope="col" | BP2<br><small>涵蓋精度</small>')
    table.insert(str_frags, '! scope="col" | BP3<br><small>組織結構</small>')
    table.insert(str_frags, '! scope="col" | BP4<br><small>格式文法</small>')
    table.insert(str_frags, '! scope="col" | BP5<br><small>輔助材料</small>')
    table.insert(str_frags, '! scope="col" | BP6<br><small>術語用字</small>')
    table.insert(str_frags, '! scope="col" | 总评')    
    table.insert(str_frags, '! scope="col" | 更新时间')
    
    -- Body
    local counter = 0
    for i = 1, 30 do
        if args['rev' .. tostring(i)] ~= nil then
            counter = counter + 1
            table.insert(str_frags, build_row(args, counter))
        end
    end

    -- Footer
    table.insert(str_frags, '|}')
    
    return table.concat(str_frags, '\n')
end

return p