Jump to content

Module:WikiProject metrics

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by The Earwig (talk | contribs) at 13:24, 28 July 2016 (create). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)

local p = {}

local Date = require('Module:Date')._Date

local function getMonths(start)
	local month = Date("1 " .. start)
	local current = Date("currentdate")
	current = Date(current.year, current.month, 1)
	
	if month > current then
		return {}
	end
	
	local months = {month}

	while month < current do
		month = month + "1 month"
		table.insert(months, month)
	end

	return months
end

function p.list(frame)
	local baseTitle = frame:getParent():getTitle()
	local startMonth = frame.args[1]
	
	local months = getMonths(startMonth)
	local list = {}
	
	for i, month in pairs(months) do
		if i == 1 or month:text("%B") == "January" then
			local tag = '<span style="font-size: large;>"%s</span>'
			table.insert(list,  string.format(tag, month:text("%Y")))
		end
		
		local line = "* [[%s|%s]]: {{formatnum:{{#lst:%s|count}}}}"
		local title = baseTitle .. "/" .. month:text("%B %Y")
		local item = string.format(line, title, month:text("%b"), title)
		table.insert(list, item)
	end
	
	return table.concat(list, "\n")
end

function p.recent(frame)
	return "nothing at all! :("
end

function p.chart(frame)
	return "who needs graphs anyway?"
end

return p