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:32, 28 July 2016 (fix broken template). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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: 120%;>%s</span>'
			table.insert(list,  string.format(tag, month:text("%Y")))
		end

		local line = "* [[%s|%s]]: %s"
		local title = baseTitle .. "/" .. month:text("%B %Y")
		local count = lang:formatNum(frame:extensionTag("lst", title, "count"))
		local item = string.format(line, title, month:text("%b"), count)
		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