FANDOM


local export = {}
 
local timestamp = "[0-9][0-9]?:[0-9][0-9], [1-9][0-9]? [A-Z][a-z]+ 20[0-9][0-9] %(UTC%)"
 
local lang = mw.getContentLanguage()
 
local function isotime(stamp)
	return lang:formatDate("c", stamp)
end
 
local function humandate(stamp)
	return lang:formatDate("d xg Y", stamp)	
end
 
local function collect_info(discussion_page_name)
	local pageobj = mw.title.new(discussion_page_name)
	local content = pageobj:getContent()
	local info = {}
 
	info.type = pageobj.rootText -- XXX
 
	local earliest = 'INFINITY' -- hack
	for stamp in content:gmatch(timestamp) do
		stamp = isotime(stamp)
		if stamp < earliest then
			earliest = stamp
		end
	end
 
	if earliest ~= 'INFINITY' then
		info.nominated = earliest
	end
 
	for line in content:gmatch("[^\n]+") do
		if line:match("^=") then
			break
		else
			local r = line:match("^:*The%s+result[%sa-z,]*%swas%s+'''([^.\n]-)%.?'''")
			if r then
				info.result = r
				info.result_date = isotime(line:match("(" .. timestamp .. ")%s*$"))
				break
			end
		end
	end
 
	return info
end
 
function export.render_box(frame)
	local text = { "This page was previously nominated for deletion:" }
	local pargs = frame:getParent().args
 
	for i, page in ipairs(pargs) do
		page = mw.text.trim(page)
		local info = collect_info(page)
		local line = ("* [[%s|%s %s]]"):format(page, info.type, humandate(info.nominated))
 
		if info.result then
			line = line .. ("; result: '''%s''' (%s)"):format(info.result, humandate(info.result_date))
		end
 
		table.insert(text, line)
	end
 
	return frame:expandTemplate { title = "tmbox"; args = {
		image = "[[File:Clipboard.svg|35px|link=]]";
		text = table.concat(text, "\n");
	} }
end
 
return export

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.