词条 | Module:Sandbox/pppery/noinclude tfd |
释义 | local redr = require("Module:Redirect") local function stringCount(string, pattern) local _dump, cnt = mw.ustring.gsub(string, pattern, "") return cnt end local function parse(frame, links) local output = "" for _, object in ipairs(links) do if object then local title = "Template:" .. object; local rtarget; errorvalue, rtarget = pcall(redr.getTarget, title) if errorvalue then title = rtarget or title end local code = mw.title.new(title):getContent(); if code then local unsubstified = mw.ustring.match(code, "#invoke:Unsubst|"); local nmg = stringCount(code, " local ndel = stringCount(code, " local disabled = stringCount(code,"type=disabled") local safesubst = mw.ustring.match(code,"{{{|safesubst:}}}") or mw.ustring.match(code, " safesubst = safesubst or mw.ustring.match(code,"[Ss][Aa][Ff][Ee][Ss][Uu][bB][sS][Tt]:%s* local oldstylesubst = mw.ustring.match(code, "{{{subst|}}}") or mw.ustring.match(code, " local tagCnt = stringCount(code,"{{Tfm") + stringCount(code,"{{Template for merging") tagCnt = tagCnt + stringCount(code,"{{Template for discussion"); if not tagCnt or ((nmg + ndel + disabled >= tagCnt) and (unsubstified or not (safesubst or oldstylesubst))) then output = output .. "\* {{tfd links|" .. object .. "}}"; end end end end return frame:preprocess(output); end local function parseDay(day, links) local daytext = mw.title.new(day):getContent(); daytext = mw.ustring.gsub(daytext,"Please do not modify it","{{tfd links|this is closed}}"); daytext = mw.ustring.gsub(daytext,"{{[tT]fd links|([^}|]+)[^}]-|module=Module:[^}]-}}", ""); local daymatcher = mw.ustring.gmatch(daytext, "{{[tT]fd links|([^}|]+)[^}]-}}") local closed = false while true do local link = daymatcher(); if not link then return links; end if link == "this is closed" then closed = not closed elseif not closed then links[#links+1] = link; end end end local p = {} function p.main(frame) local links = {}; local lang = mw.getContentLanguage() local logpage = "Wikipedia:Templates for discussion/Log/" for a = 0, 20 do parseDay(logpage .. lang.formatDate(lang, "Y F j", "-" .. tostring(a) .. "days"), links) end return parse(frame, links) end return p |
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。