Module:High-use
- Аԥсшәа
- Ænglisc
- العربية
- الدارجة
- Авар
- تۆرکجه
- Basa Bali
- Беларуская
- Banjar
- ပအိုဝ်ႏဘာႏသာႏ
- བོད་ཡིག
- Нохчийн
- کوردی
- Corsu
- Dansk
- Ελληνικά
- English
- فارسی
- गोंयची कोंकणी / Gõychi Konknni
- ગુજરાતી
- Gaelg
- हिन्दी
- Bahasa Indonesia
- Íslenska
- Qaraqalpaqsha
- Kumoring
- Gĩkũyũ
- Қазақша
- ಕನ್ನಡ
- 한국어
- کٲشُر
- Kurdî
- Latina
- Мокшень
- Māori
- മലയാളം
- Монгол
- Bahasa Melayu
- नेपाली
- ଓଡ଼ିଆ
- ਪੰਜਾਬੀ
- Ποντιακά
- پښتو
- Português
- Русиньскый
- Scots
- سنڌي
- Srpskohrvatski / српскохрватски
- Taclḥit
- တႆး
- සිංහල
- Simple English
- سرائیکی
- Soomaaliga
- Shqip
- Српски / srpski
- தமிழ்
- ತುಳು
- ไทย
- Türkçe
- Татарча / tatarça
- ChiTumbuka
- Українська
- اردو
- Oʻzbekcha / ўзбекча
- Tiếng Việt
- Yorùbá
- 中文
Appearance
From Meta, a Wikimedia project coordination wiki
This module is rated as ready for general use. It has reached a mature form and is thought to be bug-free and ready for use wherever appropriate. It is ready to mention on help pages and other MetaWiki 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.
Usage
[edit ]See Module:High-use/doc for documentation.
The above documentation is transcluded from Module:High-use/doc. (edit | history)
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
Editors can experiment in this module’s sandbox (create | mirror) and testcases (create) pages.
Please add categories to the /doc subpage. Subpages of this module.
localp={} -- _fetch looks at the "demo" argument. local_fetch=require('Module:Transclusion_count').fetch localyesno=require('Module:Yesno') functionp.num(frame,count) ifcount==nilthen ifyesno(frame.args['fetch'])==falsethen if(frame.args[1]or'')~=''thencount=tonumber(frame.args[1])end else count=_fetch(frame) end end -- Build output string localreturn_value="" ifcount==nilthen ifframe.args[1]=="risk"then return_value="a very large number of" else return_value="many" end else -- Use 2 significant figures for smaller numbers and 3 for larger ones localsigfig=2 ifcount>=100000then sigfig=3 end -- Prepare to round to appropriate number of sigfigs localf=math.floor(math.log10(count))-sigfig+1 -- Round and insert "approximately" or "+" when appropriate if(frame.args[2]=="yes")or(mw.ustring.sub(frame.args[1],-1)=="+")then -- Round down return_value=string.format("%s+",mw.getContentLanguage():formatNum(math.floor((count/10^(f)))*(10^(f)))) else -- Round to nearest return_value=string.format("approximately %s",mw.getContentLanguage():formatNum(math.floor((count/10^(f))+0.5)*(10^(f)))) end -- Insert percentage of pages if that is likely to be >= 1% and when |no-percent= not set to yes ifcountandcount>250000andnotyesno(frame:getParent().args['no-percent'])then localpercent=math.floor(((count/frame:callParserFunction('NUMBEROFPAGES','R'))*100)+0.5) ifpercent>=1then return_value=string.format("%s pages, or roughly %s%% of all",return_value,percent) end end end returnreturn_value end -- Actions if there is a large (greater than or equal to 100,000) transclusion count functionp.risk(frame) localreturn_value="" ifframe.args[1]=="risk"then return_value="risk" else localcount=_fetch(frame) ifcountandcount>=100000thenreturn_value="risk"end end returnreturn_value end functionp.text(frame,count) -- Only show the information about how this template gets updated if someone -- is actually editing the page and maybe trying to update the count. localbot_text=(frame:preprocess("{{REVISIONID}}")=="")and"\n\n----\n'''Preview message''': Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]])."or'' ifcount==nilthen ifyesno(frame.args['fetch'])==falsethen if(frame.args[1]or'')~=''thencount=tonumber(frame.args[1])end else count=_fetch(frame) end end localtitle=mw.title.getCurrentTitle() iftitle.subpageText=="doc"ortitle.subpageText=="sandbox"then title=title.basePageTitle end localsystemMessages=frame.args['system'] ifframe.args['system']==''then systemMessages=nil end -- This retrieves the project URL automatically to simplify localiation. localtemplateCount=('on [https://linkcount.toolforge.org/index.php?project=%s&page=%s %s pages]'):format( mw.title.getCurrentTitle():fullUrl():gsub('//(.-)/.*','%1'), mw.uri.encode(title.fullText),p.num(frame,count)) localused_on_text="'''This "..(mw.title.getCurrentTitle().namespace==828and"Lua module"or"template")..' is used '; ifsystemMessagesthen used_on_text=used_on_text..systemMessages.. ((countandcount>2000)and(",''' and "..templateCount)or("'''")) else used_on_text=used_on_text..templateCount.."'''" end localsandbox_text=("%s's [[%s/sandbox|/sandbox]] or [[%s/testcases|/testcases]] subpages, or in your own [[%s]]. "):format( (mw.title.getCurrentTitle().namespace==828and"module"or"template"), title.fullText,title.fullText, mw.title.getCurrentTitle().namespace==828and"Module:Sandbox|module sandbox"or"mw:Help:User page|user subpage" ) localinfoArg=frame.args["info"]~=""andframe.args["info"] if(systemMessagesorframe.args[1]=="risk"or(countandcount>=100000))then localinfo=systemMessagesand'.<br/>Changes to it can cause immediate changes to the Meta-Wiki user interface.'or'.' ifinfoArgthen info=info.."<br />"..infoArg end sandbox_text=info..'<br /> To avoid major disruption'.. (countandcount>=100000and' and server load'or'').. ', any changes should be tested in the '..sandbox_text.. 'The tested changes can be added to this page in a single edit. ' else sandbox_text=(infoArgand('.<br />'..infoArg..' C')or' and c').. 'hanges may be widely noticed. Test changes in the '..sandbox_text end localdiscussion_text=systemMessagesand'Please discuss changes 'or'Consider discussing changes ' ifframe.args["2"]andframe.args["2"]~=""andframe.args["2"]~="yes"then discussion_text=string.format("%sat [[%s]]",discussion_text,frame.args["2"]) else discussion_text=string.format("%son the [[%s|talk page]]",discussion_text,title.talkPageTitle.fullText) end returnused_on_text..sandbox_text..discussion_text.." before implementing them."..bot_text end functionp.main(frame) localcount=nil ifyesno(frame.args['fetch'])==falsethen if(frame.args[1]or'')~=''thencount=tonumber(frame.args[1])end else count=_fetch(frame) end localimage="[[File:Ambox warning yellow.svg|40px|alt=Warning|link=]]" localtype_param="style" localepilogue='' ifframe.args['system']andframe.args['system']~=''then image="[[File:Ambox important.svg|40px|alt=Warning|link=]]" type_param="content" localnocat=frame:getParent().args['nocat']orframe.args['nocat'] localcategorise=(nocat==''ornotyesno(nocat)) ifcategorisethen epilogue=frame:preprocess('{{Sandbox other||{{#switch:{{#invoke:Effective protection level|{{#switch:{{NAMESPACE}}|File=upload|#default=edit}}|{{FULLPAGENAME}}}}|sysop|templateeditor|interfaceadmin=|#default=[[Category:Pages used in system messages needing protection]]}}}}') end elseif(frame.args[1]=="risk"or(countandcount>=100000))then image="[[File:Ambox warning pn.svg|40px|alt=Warning|link=]]" type_param="content" end ifframe.args["form"]=="editnotice"then returnframe:expandTemplate{ title='editnotice', args={ ["image"]=image, ["text"]=p.text(frame,count), ["expiry"]=(frame.args["expiry"]or"") } }..epilogue else returnrequire('Module:Message box').main('ombox',{ type=type_param, image=image, text=p.text(frame,count), expiry=(frame.args["expiry"]or"") })..epilogue end end returnp