Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Transclusion count

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
BetaThis module is rated asbeta, and is ready for widespread use. It is still new and should be used with some caution to ensure the results are as expected.
ProtectedThis module issubject to page protection. It is ahighly visible module in use by a very large number of pages, or issubstituted very frequently. Because vandalism or mistakes would affect many pages, and even trivial editing might cause substantial load on the servers, it isprotected from editing.
WarningThis Lua module is used onapproximately 61,000 pages and changes may be widely noticed. Test changes in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. Consider discussing changes on thetalk page before implementing them.

Fetches usage data for highly-transcluded templates. Uses bot-updated values fromsubpages of Module:Transclusion_count/data/ when available.

Usage

{{#invoke:Transclusion count|fetch|number of transclusions|use + notation|all-pages=|demo=}}

  • number of transclusions: is a static number of times the template has been transcluded, to use when values cannot be read from the database. This value will be ignored if transclusion data is available for the current page.
  • demo=Template_name: will use the transclusion count for the template atTemplate:Template_name instead of detecting what template it is being used on. Capitalization must exactly match the value used inSpecial:PrefixIndex/Module:Transclusion_count/data/.

{{#invoke:Transclusion count|tabulate}}

Notices

The abovedocumentation istranscluded fromModule:Transclusion count/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) and testcases(create) pages.
Subpages of this module.

localp={}functionp._fetch(args)localtemplate=nillocalreturn_value=nil-- Use demo parameter if it exists, otherwise use current template namelocalnamespace=mw.title.getCurrentTitle().namespaceifargs["demo"]andargs["demo"]~=""thentemplate=mw.ustring.gsub(args["demo"],"^[Tt]emplate:","")elseifnamespace==10then-- Template namespacetemplate=mw.title.getCurrentTitle().textelseifnamespace==828then-- Module namespacetemplate=(mw.site.namespaces[828].name..":"..mw.title.getCurrentTitle().text)end-- If in template or module namespace, look up count in /dataiftemplate~=nilthennamespace=mw.title.new(template,"Template").namespaceifnamespace==10ornamespace==828thentemplate=mw.ustring.gsub(template,"/doc$","")-- strip /doc from endtemplate=mw.ustring.gsub(template,"/sandbox$","")-- strip /sandbox from endlocalindex=mw.ustring.sub(mw.title.new(template).text,1,1)localstatus,data=pcall(function()return(mw.loadData('Module:Transclusion_count/data/'..(mw.ustring.find(index,"%a")andindexor"other")))end)ifstatusthenreturn_value=tonumber(data[mw.ustring.gsub(template," ","_")])endendend-- If database value doesn't exist, use value passed to templateifreturn_value==nilandargs[1]~=nilthenlocalarg1=mw.ustring.match(args[1],'[%d,]+')ifarg1andarg1~=''thenreturn_value=tonumber(mw.getCurrentFrame():callParserFunction('formatnum',arg1,'R'))endendreturnreturn_valueendfunctionp.fetch(frame)returnp._fetch(frame.args)end-- Tabulate this data for [[Wikipedia:Database reports/Templates transcluded on the most pages]]functionp.tabulate()locallist={}fori=65,91dolocaldata=mw.loadData('Module:Transclusion count/data/'..((i==91)and'other'orstring.char(i)))forname,countinpairs(data)dotable.insert(list,{mw.title.new(name,"Template").fullText,count})endendtable.sort(list,function(a,b)return(a[2]==b[2])and(a[1]<b[1])or(a[2]>b[2])end)locallang=mw.getContentLanguage();fori=1,#listdolist[i]=('|-\n| %d || [[%s]] || %s\n'):format(i,list[i][1]:gsub('_',' '),lang:formatNum(list[i][2]))endreturntable.concat(list)endreturnp
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Transclusion_count&oldid=1260691518"
Categories:
Hidden category:

[8]ページ先頭

©2009-2025 Movatter.jp