Jump to content

Module:WikiProjects for deletion

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by CX Zoom (talk | contribs) at 07:59, 30 January 2023 (sp). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local A = {}

function A.main( frame )
	local content = mw.title.new ("Wikipedia:Miscellany for deletion"):getContent();	-- get source code from parent MfD page
	local temps = {}															-- table to hold all templates on MfD page
	local wp = {}																-- table to hold all WikiProject deletion discussions
	local i = 1
	local store = {}															-- store transclusions before final output
	
	for t in string.gmatch(content, "{{(.-)}}") do
		temps[i] = mw.text.trim(t)												-- store content between {{}} in temps
		
		if string.find(temps[i], "WikiProject") then
			wp[i] = temps[i]													-- store "WikiProject"-string-containing templates in wp
		end
		
		if (wp[i] ~= nil) and (wp[i] ~= "") then								-- if wp[i] has some content, only then do
			table.insert (store, table.concat ({"\n" .. frame:expandTemplate{ title = wp[i] } .. "\n----"}));
			-- done via table.concat to parse \n as newline; what we get after concat is passed into the table "store" 
		end
		
		i = i + 1																-- after one template has gone through the above process, bring on the next one
	end
	
	local n = table.maxn(store)													-- # of items in table "store" = # of WP discussions
	local transclude = table.concat (store)										-- concat the table "store" and store it in var transclude
	
	local number = frame.args["number"]											-- check if "number" parameter is answered
	if (number == "Yes") or (number == "yes") or (number == "y") or (number == "Y") or (number == "1") then
		return n																-- print number of WP discussions, if number is wanted
	else
		return transclude														-- print transclusion, if number isn't wanted
	end
end

return A