Module:NUMBEROF
- Afrikaans
- العربية
- الدارجة
- অসমীয়া
- Asturianu
- Авар
- تۆرکجه
- Башҡортса
- Basa Bali
- Bikol Central
- Беларуская (тарашкевіца)
- Betawi
- Български
- ပအိုဝ်ႏဘာႏသာႏ
- বাংলা
- Català
- Нохчийн
- Cebuano
- کوردی
- Qırımtatarca
- Čeština
- Чӑвашла
- Cymraeg
- Dansk
- Kadazandusun
- Ελληνικά
- Esperanto
- Eesti
- Euskara
- فارسی
- Suomi
- Français
- Frysk
- Gaeilge
- Bahasa Hulontalo
- हिन्दी
- Hrvatski
- Magyar
- Հայերեն
- Jaku Iban
- Bahasa Indonesia
- 日本語
- Jawa
- ქართული
- Qaraqalpaqsha
- Қазақша
- 한국어
- Кыргызча
- Лезги
- ລາວ
- मैथिली
- Māori
- മലയാളം
- Монгол
- ဘာသာမန်
- Bahasa Melayu
- မြန်မာဘာသာ
- नेपाली
- Chi-Chewa
- ਪੰਜਾਬੀ
- Papiamentu
- Polski
- Ποντιακά
- Português
- ရခိုင်
- Română
- Scots
- سنڌي
- Srpskohrvatski / српскохрватски
- တႆး
- Simple English
- Slovenčina
- Anarâškielâ
- Српски / srpski
- Svenska
- தமிழ்
- తెలుగు
- Тоҷикӣ
- ไทย
- ትግርኛ
- Türkmençe
- Tagalog
- Toki pona
- Tok Pisin
- Türkçe
- Татарча / tatarça
- Українська
- اردو
- Oʻzbekcha / ўзбекча
- Vepsän kel’
- Tiếng Việt
- მარგალური
- Yorùbá
- 中文
Appearance
From Wikipedia, the free encyclopedia
[画像:Warning] This Lua module is used in MediaWiki:Statistics-files-desc .
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on the talk page before implementing them.
This module is rated as ready for general use. It has reached a mature state, is considered relatively stable and bug-free, and may be used wherever appropriate. It can be mentioned on help pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed through sandbox testing rather than repeated trial-and-error editing.
Page protected This module is currently protected from editing.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
See the protection policy and protection log for more details. Please discuss any changes on the talk page; you may submit an edit request to ask an administrator to make an edit if it is uncontroversial or supported by consensus. You may also request that this page be unprotected.
This module depends on the following other modules:
- Module:NUMBEROF implements templates {{NUMBEROF }} and {{Wikipedia rank by size }}.
- It includes sub-modules Module:NUMBEROF/data, Module:NUMBEROF/rank, Module:NUMBEROF/other and Module:NUMBEROF/meta which are used once per page [not per template invocation]. These sub-modules pull data from Wikimedia Commons:
- c:Data:Wikipedia statistics/meta.tab for classification of wikis,
- c:Data:Wikipedia statistics/data.tab for statistics of all wikis,
- c:Data:Wikipedia statistics/rank/*.tab for rankings of languages in each project.
- data.tab, meta.tag and rank/*.tab are updated by a bot multiple times each day.
- The module was originally developed on Enwiki.
The above documentation is transcluded from Module:NUMBEROF/doc. (edit | history)
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
Editors can experiment in this module's sandbox (edit | diff) and testcases (create) pages.
Subpages of this module.
localaliases={ commons='commons.wikimedia', donate='donate.wikimedia', foundation='foundation.wikimedia', incubator='incubator.wikimedia', meta='meta.wikimedia', species='species.wikimedia', wikidata='www.wikidata', wikifunctions='www.wikifunctions', wikimania='wikimania.wikimedia', wikitech='wikitech.wikimedia', } localfunctiontrimArg(arg,i) arg=mw.text.trim(argor'') ifarg==''then ifithen error('Parameter '..i..' is missing. See template documentation') end returnnil end returnmw.ustring.lower(arg) end localfunctiongetValue(stats,action,map) ifaction=='depth'then -- https://meta.wikimedia.org/wiki/Wikipedia_article_depth -- This gives silly results if, for example, the number of articles is small. localn={'articles','edits','pages'} ifmapthen fori,vinipairs(n)do n[i]=map[v] end end fori,vinipairs(n)do n[i]=stats[v]or0 end localarticles,edits,pages=n[1],n[2],n[3] ifpages==0orarticles==0then return0 end returnmath.floor((edits/pages)*((pages-articles)/articles)^2) end ifmapthen action=map[action] end returnstats[action] end localfunctiongetIfLocal(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. locallocalSite=string.match(mw.site.server,'.*//(.*)%.org$')-- examples: 'af.wikipedia', 'commons.wikimedia' ifsite==localSitethen ifaction=='activeusers'then action='activeUsers' end returngetValue(mw.site.stats,action) end end localfunctionmain(frame) localmetaWords={active=true,closed=true,languages=true,} localargs=frame:getParent().args localaction=trimArg(args[1],1)-- activeusers, admins, articles, edits, files, pages, users, depth, active, closed, languages ifaction:sub(1,8)=='numberof'then-- numberofX is an alias for X action=trimArg(action:sub(9),1) end localwantMeta=metaWords[action] localsite=trimArg(args[2],2) site=aliases[site]orsite ifnotwantMetaandnotsite:find('.',1,true)then -- site is like "af" or "af.wikipedia" or "af.wikiquote" etc., including "total" site=site..'.wikipedia' end localwantComma=trimArg(args[3])-- nil for no commas in output; "N" or anything nonblank inserts commas localresult ifwantMetathen localdata=mw.loadData('Module:NUMBEROF/meta') localnrActive=data.nrActive[site] localnrClosed=data.nrClosed[site] ifnrActiveornrClosedthen -- If either is set, site is valid but there may not be an entry for both active and closed. nrActive=nrActiveor0 nrClosed=nrClosedor0 ifaction=='active'then result=nrActive elseifaction=='closed'then result=nrClosed elseifaction=='languages'then result=nrActive+nrClosed end end else result=getIfLocal(site,action) ifnotresultthen localdata=mw.loadData('Module:NUMBEROF/data') localmap=data.map data=data.data result=data[site] ifresultthen result=getValue(result,action,map) end end end ifresultthen ifwantCommathen result=mw.language.getContentLanguage():formatNum(result) end returnresult-- number or formatted string end return-1 end localfunctionrank(frame) -- Rank sites in a specified sister project by their number of articles. localargs=frame:getParent().args localparm=trimArg(args[1],1)-- a number like 12 or a site name like "af" (not "af.wikipedia") localbase=trimArg(args[2])or'wikipedia'-- base of full site name like "wikipedia" or "wikiquote" localwantComma=trimArg(args[3]) localdata=mw.loadData('Module:NUMBEROF/'..(base=='wikipedia'and'rank'or'other')) data=data[base] ifdatathen localresult parm=tonumber(parm)orparm iftype(parm)=='number'then result=data.rankByIndex[parm] else result=data.rankBySite[parm] ifresultandwantCommathen result=mw.language.getContentLanguage():formatNum(result) end end ifresultthen returnresult-- number or string end end return-1 end return{ main=main, rank=rank, }