require('strict')
local arguments = require("Module:Arguments")
local messageBox = require("Module:Message box")
local mRedirect = require('Module:Redirect')
-- text
local createdText = "This article, '''$1''', has recently been created via the [[Wikipedia:Articles for creation|Articles for creation process]]. Please check to see if the reviewer has accidentally left this template after accepting the draft and [[Template:AfC_submission/created#What to do if you see this template|take appropriate action]] as necessary."
local reviewingText = "'''Review in progress.'''"
local draftText = "'''Draft article not currently submitted for review.'''"
local rejectedText = "'''Submission rejected'''"
local declinedText = "'''Submission declined'''"
local pendingText = "'''Review waiting, please be patient.'''\n\nThis may take $1, since drafts are reviewed in no particular order. There are $2 pending submissions [[:Category:Pending AfC submissions|waiting for review]].\n\n----\n\n* If the submission is '''accepted''', then this page will be moved into the article space.\n* If the submission is '''declined''', then the reason will be posted here.\n* In the meantime, you can continue to improve this submission by editing normally."
local p = {}
local function pagesInSubcat(subcat)
return mw.site.stats.pagesInCategory("AfC pending submissions by age/" .. subcat, "pages")
end
local function reviewTime()
if pagesInSubcat("Very old") > 0 then
return "more than six months"
elseif pagesInSubcat("5 months ago") > 0 then
return "five months or more"
elseif pagesInSubcat("4 months ago") > 0 then
return "four months or more"
elseif pagesInSubcat("3 months ago") > 0 then
return "three months or more"
elseif pagesInSubcat("2 months ago") > 0 then
return "two months or more"
elseif pagesInSubcat("8 weeks ago") > 0 then
return "eight weeks or more"
elseif pagesInSubcat("7 weeks ago") > 0 then
return "seven weeks or more"
elseif pagesInSubcat("6 weeks ago") > 0 then
return "six weeks or more"
elseif pagesInSubcat("5 weeks ago") > 0 then
return "five weeks or more"
elseif pagesInSubcat("4 weeks ago") > 0 then
return "four weeks or more"
elseif pagesInSubcat("20 days ago") + pagesInSubcat("19 days ago") + pagesInSubcat("18 days ago") + pagesInSubcat("17 days ago") + pagesInSubcat("16 days ago") + pagesInSubcat("15 days ago") > 0 then
return "2–3 weeks or more"
elseif pagesInSubcat("14 days ago") + pagesInSubcat("13 days ago") + pagesInSubcat("12 days ago") + pagesInSubcat("11 days ago") + pagesInSubcat("10 days ago") + pagesInSubcat("9 days ago") > 0 then
return "a week or more"
else
return "up to a week"
end
end
function p._main(args, frame)
local box
local title = mw.title.getCurrentTitle()
if title.namespace == 0 then -- created
box = messageBox.main("ambox", {
name = "AfC submission",
type = "notice",
image = "[[File:AFC-Logo.svg|50px|link=|alt=]]",
text = createdText
})
elseif args[1] == "R" then -- reviewing
box = messageBox.main("ombox", {
name = "AfC submission",
type = "notice",
image = "[[File:AFC-Logo Pending.svg|75px|link=|alt=]]",
imageright = "[[File:Ambox clock.svg|75px|link=|alt=]]",
style = "background-color: #b1dae8;",
textstyle = "CSS values",
text = reviewingText
})
elseif args[1] == "T" then -- draft
box = messageBox.main("ombox", {
type = "notice",
image = "[[File:AFC-Logo Hold.svg|75px|link=|alt=]]",
style = "background-color: #eaebe4;",
textstyle = "CSS values",
text = draftText
})
elseif args[1] == "D" and args["reject"] ~= nil then -- rejected
box = messageBox.main("ombox", {
type = "notice",
image = "none",
imageright = "[[File:Dialog-STOP.svg|60px|link=|alt=]]",
style = "background-color: #FEE;",
text = rejectedText
})
elseif args[1] == "D" then -- delcined
box = messageBox.main("ombox", {
type = "notice",
image = "none",
imageright = "[[File:AFC-Logo_Decline.svg|75px|link=|alt=]]",
style = "background-color: #FEE",
text = declinedText
})
else -- "pending"
box = messageBox.main("ombox", {
type = "notice",
image = "[[File:AFC-Logo.svg|75px|link=|alt=]]",
style = "background-color: #f3eba3;",
text = mw.ustring.gsub(mw.ustring.gsub(pendingText, "$1", reviewTime()), "$2", mw.site.stats.pagesInCategory("Pending AfC submissions", "pages") - 3)
})
end
return box
end
function p.main(frame)
local args = arguments.getArgs(frame)
return p._main(args, frame)
end
return p