[go: nahoru, domu]

Yiɣi chaŋ yɛligu maŋamaŋa puuni

Module:AfC submission

Diyila Dagbani Wikipedia

Implements {{AfC submission}}.

{{#invoke:AfC submission|main}}



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 [[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.'''\nThis is a draft [[Wikipedia:Articles for creation|Articles for creation]] (AfC) submission. It is '''not''' currently pending review. While there are [[Wikipedia:There is no deadline|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 '''[[WP:notability|qualifies for a Wikipedia article]]'''  by using multiple sources that meet four criteria. The sources should be (1) [[Wikipedia:Reliable sources|reliable]] (2) [[WP:SECONDARY|secondary]] (3) [[Wikipedia:Identifying and using independent sources|independent of the subject]] (4) talk about the subject in some depth. For some topics, [[WP:SNG|there are alternative criteria]].\n* Be written from a [[WP:Neutral point of view|neutral point of view]]\n* Respect [[Wikipedia:Copyright violations|copyright]], and not [[Wikipedia:Plagiarism|plagiarize]]. Do not copy-paste.\nIt is '''[[Wikipedia:Conflict of interest|strongly discouraged]]''' to write about [[Wikipedia:Autobiography|yourself]], [[Wikipedia:FAQ/Organizations|your business or employer]]. If you do so, you '''[[Wikipedia:Conflict of interest#How to disclose a COI|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 '''[[Wikipedia:IRC help disclaimer|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 [[:Category:Pending AfC 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 = "[[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 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
					: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}) .. " ([[User talk:" .. args.decliner .. "|talk]])" or "")
		})
	else -- "pending"
		box = messageBox.main("ombox", {
			type = "notice",
			image = "[[File:AFC-Logo.svg|75px|link=|alt=]]",
			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 .. "[[Category:" .. date .. "|" .. title.text .. "]]"
		end
		
		if args.u and ipAddress._isIP(args.u) then
			if args[1] == 'D' and args.reject then
				box = box .. "[[Category:Rejected draft pages submitted for review by an IP]]"
			elseif args[1] == 'D' then
				box = box .. "[[Category:Declined draft pages submitted for review by an IP]]"
			elseif args[1] ~= 'R' then
				box = box .. "[[Category:Draft pages submitted for review by an IP]]"
			end
		end
		
		local content = title:getContent() -- phab:T50175
		if content and content
				:gsub("<!--.--->", "")
				:gsub("<nowiki>.-</nowiki>", "")
				:gsub("{{[Dd]raft [Cc]ategories[^{}]-{{[^{}]-}}[^{}]-}}", "")
				:gsub("{{[Dd]raft [Cc]ategories.-}}", "")
				:gsub("%[%[Category:Unsuitable for Wikipedia AfC submissions%]%]", "")
				:gsub("%[%[Category:[Dd]rafts?.-%]%]", "")
				:gsub("%[%[Category:.-drafts?%]%]", "")
				:match("%[%[%s-[Cc]ategory:") then
			box = box .. "[[Category:AfC submissions with categories]]"
		end
	end
	
	return box
end

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

return p