Module:Sandbox/SWinxy AfC submission

require('strict')

local arguments = require("Module:Arguments") local messageBox = require("Module:Message box") local ipAddress = require("Module:IPAddress") local noPing = require("Module:No ping") local mRedirect = require('Module:Redirect')

-- text local createdText = "This article, $1, has recently been created via the Articles for creation process. Please check to see if the reviewer has accidentally left this template after accepting the draft and take appropriate action as necessary." local reviewingText = "Review in progress." local draftText = "Draft article not currently submitted for review.\nThis is a draft Articles for creation (AfC) submission. It is not currently pending review. While there are no deadlines, abandoned drafts may be deleted after six months. To edit the draft click on the \"Edit\" tab at the top of the window.\n\nTo be accepted, a draft should:\n* Show the subject qualifies for a Wikipedia article by using multiple sources that meet four criteria. The sources should be (1) reliable (2) secondary (3) independent of the subject (4) talk about the subject in some depth. For some topics, there are alternative criteria.\n* Be written from a neutral point of view\n* Respect copyright, and not plagiarize. Do not copy-paste.\nIt is strongly discouraged to write about yourself, your business or employer. If you do so, you must declare it." local rejectedText = "Submission rejected" local declinedText = "Submission declined$1$2.\n$3\n* If you would like to continue working on the submission, click on the \"Edit\" tab at the top of the window.\n*If you have not resolved the issues listed above, your draft will be declined again and potentially deleted.\n*If you need extra help, please ask us a question at the AfC Help Desk or get live help from experienced editors.\n* Please do not remove reviewer comments or this notice until the submission is accepted." local pendingText = "Review waiting, please be patient.\nThis may take $1, since drafts are reviewed in no particular order. There are $2 pending submissions waiting for review.\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 = "",			text = createdText		}) elseif args[1] == "R" then -- reviewing box = messageBox.main("ombox", {			name = "AfC submission",			type = "notice",			image = "",			imageright = "",			style = "background-color: #b1dae8;",			textstyle = "CSS values",			text = reviewingText		}) elseif args[1] == "T" then -- draft box = messageBox.main("ombox", {			type = "notice",			image = "",			style = "background-color: #eaebe4;",			textstyle = "CSS values",			text = draftText		}) elseif args[1] == "D" and args.reject then -- rejected box = messageBox.main("ombox", {			type = "notice",			image = "none",			imageright = "",			style = "background-color: #FEE;",			text = rejectedText		}) elseif args[1] == "D" then -- delcined box = messageBox.main("ombox", {			type = "notice",			image = "none",			imageright = "",			style = "background-color: #FEE",			text = declinedText					:gsub("$1", args.declinets and " on " .. mw.language.getContentLanguage:formatDate("j F Y", args.declinets) or "")					:gsub("$2", args.decliner and " by " .. noPing._main({args.decliner}) .. " (talk)" or "")		}) else -- "pending" box = messageBox.main("ombox", {			type = "notice",			image = "",			style = "background-color: #f3eba3;",			text = pendingText					:gsub("$1", reviewTime)					:gsub("$2", mw.site.stats.pagesInCategory("Pending AfC submissions", "pages") - 3)		}) end if not args.demo then if args[1] ~= "T" then local date if args.ts then date = "AfC submissions by date/" .. mw.language.getContentLanguage:formatDate("d M Y", args.ts) else date = "Undated AfC submissions" end box = box .. ""		end if args.u and ipAddress._isIP(args.u) then if args[1] == 'D' and args.reject then box = box .. ""			elseif args[1] == 'D' then box = box .. ""			elseif args[1] ~= 'R' then box = box .. ""			end end local content = title:getContent -- phab:T50175 if content and content :gsub("", "") :gsub(" .- ", "") :gsub("", "") :gsub("", "") :gsub("%[%[Category:Unsuitable for Wikipedia AfC submissions%]%]", "") :gsub("%[%[Category:[Dd]rafts?.-%]%]", "") :gsub("%[%[Category:.-drafts?%]%]", "") :match("%[%[%s-[Cc]ategory:") then box = box .. ""		end end return box end

function p.main(frame) local args = arguments.getArgs(frame) return p._main(args, frame) end

return p