跳转到内容

模組:VGNL

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

这是本页的一个历史版本,由Lopullinen留言 | 贡献2023年2月12日 (日) 14:45 (没有编辑摘要 // IPE编辑。这可能和当前版本存在着巨大的差异。

require('strict')

local p = {}
local getArgs = require('Module:Arguments').getArgs
local function makeInvokeFunc(funcName)
    return function(frame)
        local args = getArgs(frame)
        return p[funcName](args)
    end
end

p.target = makeInvokeFunc('_target')
function p._target(args)
    local cur_date = '00000000'
    local text = mw.title.new('WikiProject:電子遊戲/簡訊/目錄'):getContent()
    local published_dates = text:gmatch('data%-sort%-value%s*=%s*"(%d%d%d%d%d%d%d%d)"')
    for v in published_dates do
        if (v > cur_date) and (v < '29999999') then
            cur_date = v
        end
    end
    local issue = cur_date:sub(1, 4) .. '-' .. cur_date:sub(5, 6)
    return 'WikiProject:電子遊戲/簡訊/' .. issue
end

p.label = makeInvokeFunc('_label')
function p._label(args)
    local target = p._target(args)
    local text = mw.title.new(target):getContent()
    return text:match('%d%d%d%d年第.-季')
end

p.link = makeInvokeFunc('_link')
function p._link(args)
    local target = p._target(args)
    local label = p._label(args)
    return '[[' .. target .. '|' .. label .. ']]'
end

p.content = makeInvokeFunc('_content')
function p._content(args)
    local target = p._target(args)
    return mw.getCurrentFrame():expandTemplate { title = target }
end

return p