Moduł:Statystyki Wikipedii
- Ten moduł służy do obsługi Szablon:Statystyki Wikipedii.
- Ten moduł korzysta ze strony commons:Data:Wikipedia statistics/data.tab zawierającej dane.
- strona data.tab jest aktualizowana przez bota kilka razy dziennie.
- Moduł ładuje stronę Moduł:Statystyki Wikipedii/data, Moduł:Statystyki Wikipedii/meta, Moduł:Statystyki Wikipedii/rank, Moduł:Statystyki Wikipedii/other tylko jeden raz na stronie (a nie z każdym wywołaniem szablonu).
- Ten moduł pierwotnie powstał dla Wikipedii w języku angielskim.
Powyższy opis jest dołączany ze strony Moduł:Statystyki Wikipedii/opis. (edytuj | historia) Zobacz podstrony tego modułu. |
local aliases = {['h'] = 'numberofarticles',['p'] = 'numberoffiles',['s'] = 'numberofpages',['u'] = 'numberofusers',['au'] = 'numberofactiveusers',['a'] = 'numberofadmins',['e'] = 'numberofedits',['łącznie'] = 'total',}local function trimArg(arg, i)arg = mw.text.trim(arg or '')if arg == '' thenif i thenerror('Parameter ' .. i .. ' is missing. See [[Template:NUMBEROF]] documentation')endreturn nilendreturn mw.ustring.lower(arg)endlocal function getValue(stats, action, map)if action == 'depth' then-- https://meta.wikimedia.org/wiki/Wikipedia_article_depth-- This gives silly results if, for example, the number of articles is small.local n = { 'articles', 'edits', 'pages' }if map thenfor i, v in ipairs(n) don[i] = map[v]endendfor i, v in ipairs(n) don[i] = stats[v] or 0endlocal articles, edits, pages = n[1], n[2], n[3]if pages == 0 or articles == 0 thenreturn 0endreturn math.floor((edits/pages) * ((pages - articles)/articles)^2)endif map thenaction = map[action]endreturn stats[action]endlocal function getIfLocal(site, action)-- If wanted site is the local site where module is running,-- return numberof result for given action, or nil.-- This is faster than reading the cached table, and gives the current value.local localSite = string.match(mw.site.server, '.*//(.*)%.org$') -- examples: 'af.wikipedia', 'commons.wikimedia'if site == localSite thenif action == 'activeusers' thenaction = 'activeUsers'endreturn getValue(mw.site.stats, action)endendlocal function main(frame)local args = frame:getParent().argsif args[2] == "data" thenreturn mw.loadData('Module:Statystyki Wikipedii/data').dateendlocal action = trimArg(args[1], 1) -- activeusers, admins, articles, edits, files, pages, users, depthaction = aliases[action] or actionif action:sub(1, 8) == 'numberof' then -- numberofX is an alias for Xaction = trimArg(action:sub(9), 1)endlocal site = trimArg(args[2], 2) -- "af" or "af.wikipedia" or "af.wikiquote" etc., including "total"if not site:find('.', 1, true) thensite = site .. '.wikipedia'endlocal wantComma = trimArg(args[3]) -- nil for no commas in output; "N" or anything nonblank inserts commaslocal result = getIfLocal(site, action)if not result thenlocal data = mw.loadData('Module:Statystyki Wikipedii/data')local map = data.mapdata = data.dataresult = data[site]if result thenresult = getValue(result, action, map)endendif result thenif wantComma thenresult = mw.getContentLanguage():formatNum(result)endreturn result -- number or formatted stringendreturn -1endlocal function rank(frame)-- Rank sites in a specified sister project by their number of articles.local args = frame:getParent().argslocal parm = trimArg(args[1], 1) -- a number like 12 or a site name like "af" (not "af.wikipedia")local base = trimArg(args[2]) or 'wikipedia' -- base of full site name like "wikipedia" or "wikiquote"local wantComma = trimArg(args[3])local data = mw.loadData('Module:Statystyki Wikipedii/' .. (base == 'wikipedia' and 'rank' or 'other'))data = data[base]if data thenlocal resultparm = tonumber(parm) or parmif type(parm) == 'number' thenresult = data.rankByIndex[parm]elseresult = data.rankBySite[parm]if result and wantComma thenresult = mw.getContentLanguage():formatNum(result)endendif result thenreturn result -- number or stringendendreturn -1endreturn {main = main,rank = rank,}
🔥 Top keywords: Wikipedia:Strona głównaMistrzostwa Europy w Piłce Nożnej 2024Specjalna:SzukajWikipedia:O WikipediiCristiano RonaldoSłoweniaJan OblakMarine Le PenPepe (ur. 1983)Mistrzostwa Europy w piłce nożnejMistrzostwa Europy w Piłce Nożnej 2020Diogo CostaKylian MbappéZjednoczenie Narodowe (Francja)PortugaliaJordan BardellaPolskaMistrzostwa świata w piłce nożnej mężczyznJean-Marie Le PenJózef PiłsudskiLamine YamalRoberto MartínezMount EverestMistrzostwa Świata w Piłce Nożnej 20261 lipcaEmmanuel MacronGruzjaAntoine GriezmannLionel MessiCéline DionMistrzostwa Świata w Piłce Nożnej 2022Mistrzostwa Europy w Piłce Nożnej 2016Reprezentacja Portugalii w piłce nożnej mężczyznBelgiaRomelu LukakuJosip IličićJoe BidenWilfredo LeónLiga Narodów w Piłce Siatkowej Mężczyzn 2024