Module:XfD old/AfD and MfD and Module:XfD old/AfD and MfD/sandbox: Difference between pages
Appearance
(Difference between pages)
Content deleted Content added
Add RfD |
mNo edit summary |
||
Line 1: | Line 1: | ||
-- Various hacky solutions to allow AfD and MfD to show up on [[Template:XFD Backlog]] |
|||
-- AfD is easy, as [[User:Mathbot]] already summarizes the total on each day |
|||
local p = {} |
local p = {} |
||
⚫ | |||
local lang = mw.getContentLanguage() |
|||
function p.afd(frame) |
|||
local month = frame.args.month |
|||
⚫ | |||
⚫ | |||
pat = "%(([0-9]+) open" |
|||
⚫ | |||
month = lang:formatDate("Y F", month) |
|||
pat = "%[%[Wikipedia:Articles for deletion/Log/" .. month .. "[^%]]*%]%] %(([0-9]+) open /" |
|||
⚫ | |||
⚫ | |||
local count = 0 |
|||
⚫ | |||
count = count + daycount |
|||
⚫ | |||
⚫ | |||
⚫ | |||
-- MfD is much harder, because the only list of all active MfDs is the main |
|||
-- [[Wikipedia:Miscellany for deletion]] page itself |
|||
function p.mfd(frame) |
|||
local month = frame.args.month |
|||
⚫ | |||
local rightmonth = true |
|||
local pat; |
|||
if month ~= "total" then |
|||
pat = lang:formatDate("^=== ?F [0-9]*, Y ?===$", month) |
|||
rightmonth = false |
|||
end |
|||
local _, endindex = content:find("==Old business==") |
|||
local count = 0 |
|||
for line in mw.text.gsplit(content:sub(endindex,#content), "\n") do |
|||
if line:find("{{Wikipedia:Miscellany for deletion/") and rightmonth then |
|||
count = count + 1 |
|||
elseif month == "total" then |
|||
-- don't worry about month section headers |
|||
elseif line:find(pat) then |
|||
rightmonth = true |
|||
elseif line:find("=== ?.* ?===") then |
|||
-- A section header for the wrong month |
|||
⚫ | |||
-- We're now looking at MfDs before the month in question |
|||
break |
|||
end |
|||
-- We still haven't reached the month in question yet |
|||
end |
|||
end |
|||
return count |
|||
end |
|||
⚫ | |||
-- 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" |
||
⚫ | |||
⚫ | |||
-- threshold is 7 days ago |
|||
⚫ | |||
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 dayPattern = "{{" .. logprefix .. "(.-)}}"; |
|||
local total = 0 |
local total = 0 |
||
⚫ | |||
for line in content:gmatch("{{Wikipedia:Redirects for discussion/Log/.-}}") 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 dayTitle = logprefix .. day; |
|||
local dayContent = mw.title.new(line:match("{{(.*)}}")):getContent() |
|||
⚫ | |||
-- unreliable but performance is important |
|||
-- Match only title sections starting with lists or templates |
|||
local |
local titlePattern = "==== ?([^\n]-) ?====%s+[%*#{]"; |
||
local _, closeBoxes = dayContent:gsub("boilerplate rfd vfd xfd%-closed", "") |
|||
for title in dayContent:gmatch(titlePattern) do |
|||
local _, relisted = dayContent:gsub("%[%[File:Symbol move vote.svg|16px|link=|alt=%]%] '''Relisted'''", "") |
|||
total = total + |
total = total + 1 |
||
lastTitle = title |
|||
-- else discussion is wrong month |
|||
⚫ | |||
end |
end |
||
end |
end |
||
return total |
|||
⚫ | |||
⚫ | |||
return "[[" .. rfd .. "#" .. lastTitle .. "|" .. total .. "]]" |
|||
else |
|||
return "[[" .. rfd .. "|0]]" |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
return p |
return p |