Module:WikiProject metrics
Appearance
![]() | This module is rated as ready for general use. It has reached a mature form and is thought to be relatively bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other Wikipedia resources as an option for new users to learn. To reduce server load and bad output, it should be improved by sandbox testing rather than repeated trial-and-error editing. |
This module contains assorted tools for building WikiProject X metrics pages.
Usage
{{#invoke:WikiProject metrics|list|start month}}
Generates a list of months and the number of pages created in each month, starting with the given month
{{#invoke:WikiProject metrics|recent}}
Transcludes the current month's article list; if the month has just started, it may show last month's as well
{{#invoke:WikiProject metrics|chart|start month}}
Generates a line chart showing article creations over time, starting with the given month
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