Module:XfD old/AfD and MfD and Module:XfD old/AfD and MfD/sandbox: Difference between pages
(Difference between pages)
imported>Pppery Add RfD |
imported>RAN1 mNo edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
-- RfD is even worse, since we have to manually parse all log pages | |||
-- RfD is even worse, since | |||
-- and "Old" discussions aren't displayed separately from "Current" ones | -- and "Old" discussions aren't displayed separately from "Current" ones | ||
function p.rfd(frame) | function p.rfd(frame) | ||
local month = frame.args.month | local month = frame.args.month | ||
local | local rfd = "Wikipedia:Redirects for discussion" | ||
-- | local logprefix = "Wikipedia:Redirects for discussion/Log/" | ||
-- threshold is 7 days ago | |||
local threshold = os.date("%F",os.time() - (86400*7)) | |||
local ymd = require("Module:YMD to ISO")._main | local ymd = require("Module:YMD to ISO")._main | ||
local lang = mw.getContentLanguage() | local lang = mw.getContentLanguage() | ||
local | -- Find the daily pages | ||
local content = mw.title.new(rfd):getContent() | |||
local dayPattern = "{{" .. logprefix .. "(.-)}}"; | |||
local total = 0 | local total = 0 | ||
for | local lastTitle | ||
local datestamp = ymd( | for day in content:gmatch(dayPattern) do | ||
local datestamp = ymd(day) | |||
if datestamp >= threshold then | if datestamp >= threshold then | ||
-- These | -- These discussions aren't seven days old yet | ||
elseif month == "total" or month == lang:formatDate("F Y", datestamp) then | elseif month == "total" or month == lang:formatDate("F Y", datestamp) then | ||
local dayContent = mw.title.new( | local dayTitle = logprefix .. day; | ||
-- | local dayContent = mw.title.new(dayTitle):getContent() | ||
local | -- Match only title sections starting with lists or templates | ||
local titlePattern = "==== ?([^\n]-) ?====%s+[%*#{]"; | |||
for title in dayContent:gmatch(titlePattern) do | |||
total = total + 1 | |||
lastTitle = title | |||
end | |||
end | |||
end | |||
if month == "total" then | |||
if total > 0 then | |||
return "[[" .. rfd .. "#" .. lastTitle .. "|" .. total .. "]]" | |||
else | |||
return "[[" .. rfd .. "|0]]" | |||
end | end | ||
else | |||
return total | |||
end | end | ||
end | end | ||
return p | return p |