请输入您要查询的百科知识:

 

词条 Module:XfD old/sandbox
释义

local p = {}

local tableTools = require("Module:TableTools")

local ymd = require("Module:YMD to ISO")._main

local lang = mw.getContentLanguage()

local function getlog(name)

return mw.ustring.match(name, "Log/(.*)")

end

function sortkey(name1, name2)

local key1 = ymd(getlog(name1))

local key2 = ymd(getlog(name2))

return key1 > key2

end

function p._main(frame, makeoutput)

local t = frame.args.title or frame:getParent():getTitle()

local content = mw.title.new(t .. "/Old unclosed discussions"):getContent();

local m = mw.ustring.gmatch(content, "* %[%[(" .. t .. "/Log/[^#]*)#%{%{anchorencode:([^}]*)")

local seen = {}

while true do

local logpage, header = m()

if not logpage then

break

end

if seen[logpage] == nil then

seen[logpage] = {}

end

seen[logpage][#seen[logpage]+1] = header

end

local out = ""

for k, v in tableTools.sortedPairs(seen, sortkey) do

out = out .. (makeoutput(k, v) or "")

end

return mw.text.trim(out)

end

function p.list(frame)

local function listoutput(k, v)

return "* " .. k .. " (" .. tostring(#v) .. " open) \"

end

return p._main(frame, listoutput)

end

function p.bymonth(frame)

local currentmonth = nil

local currentcount = 0

local function bymonthoutput(k, v)

local monthname = lang:formatDate("F Y",ymd(getlog(k)))

local out

if currentmonthname == nil then

currentmonthname = monthname

elseif currentmonthname ~= monthname then

local o = string.format("\* %s (%i)", currentmonthname, currentcount)

currentmonthname = monthname

currentcount = #v

return o

end

currentcount = currentcount + #v

end

local out = p._main(frame, bymonthoutput)

if currentcount > 0 then

out = out .. string.format("\* %s (%i)", currentmonthname, currentcount)

end

return out

end

function p.onemonth(frame)

local month = frame.args.month

if not month then

error("|month= is required")

elseif month ~= lang:formatDate("F Y",month) then

error("Illegal month format")

end

local count = 0

local function bymonthoutput(k, v)

if lang:formatDate("F Y",ymd(getlog(k))) == month then

count = count + #v

end

end

p._main(frame, bymonthoutput)

return count

end

function p.transclude(frame)

local function transoutput(k, v)

local out = ""

out = out .. "=== " .. getlog(k):sub(5) .. " ===\"

for _, discussion in pairs(v) do

out = out .. "==== " .. discussion .. " ====\"

out = out .. frame:callParserFunction("#section-h", k, discussion)

out = out .. "\"

end

return out

end

return p._main(frame, transoutput)

end

function p.total(frame)

local total = 0

local function dototal(k, v)

total = total + #v

end

p._main(frame, dototal)

return total

end

return p

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/12 6:37:30