Stats
The wiki's numbers, counted live: articles, edits, files and the people who write. Use it on any page; the numbers are counted at most once a minute.
Use
The cards, as on the front page:
:::Module:Stats:cards
:::
One line of text:
:::Module:Stats:line
:::
cards takes an optional title:
:::Module:Stats:cards
title = The wiki in numbers
:::
Code
// Words in the page's language. A wiki in another language falls back to English.
const WORDS = {
en: {
articles: (n) => plural(n, "article", "articles"),
edits: (n) => plural(n, "edit", "edits"),
files: (n) => plural(n, "file", "files"),
editors: (n) => plural(n, "editor", "editors"),
active: "active this month",
},
ru: {
articles: (n) => plural(n, "статья", "статьи", "статей"),
edits: (n) => plural(n, "правка", "правки", "правок"),
files: (n) => plural(n, "файл", "файла", "файлов"),
editors: (n) => plural(n, "автор", "автора", "авторов"),
active: "пишут в этом месяце",
},
};
function words(wiki) {
return WORDS[wiki.lang] || WORDS.en;
}
// A grid of cards: the big number over its word.
function cards(args, wiki) {
const s = wiki.stats;
const w = words(wiki);
const card = (n, label) =>
`<div class="wiki-card wiki-stat"><strong>${fmt(n)}</strong><span>${label}</span></div>`;
const title = args.title ? `**${args.title}**\n\n` : "";
return (
title +
'<div class="wiki-grid">' +
card(s.articles, w.articles(s.articles)) +
card(s.edits, w.edits(s.edits)) +
card(s.files, w.files(s.files)) +
card(s.activeEditors, w.active) +
"</div>"
);
}
// The same numbers in one line, for a sentence or a footer.
function line(args, wiki) {
const s = wiki.stats;
const w = words(wiki);
return [
`${fmt(s.articles)} ${w.articles(s.articles)}`,
`${fmt(s.edits)} ${w.edits(s.edits)}`,
`${fmt(s.files)} ${w.files(s.files)}`,
].join(" · ");
}