Module:High-use
- Ænglisc
- Аԥсшәа
- العربية
- Авар
- تۆرکجه
- Basa Bali
- Banjar
- Беларуская
- བོད་ཡིག
- ChiTumbuka
- Corsu
- Dansk
- الدارجة
- Ελληνικά
- فارسی
- Gaelg
- Gĩkũyũ
- ગુજરાતી
- गोंयची कोंकणी / Gõychi Konknni
- 한국어
- Bahasa Indonesia
- Íslenska
- ಕನ್ನಡ
- کٲشُر
- Қазақша
- Kurdî
- Latina
- മലയാളം
- Māori
- Bahasa Melayu
- Мокшень
- Монгол
- नेपाली
- ଓଡ଼ିଆ
- Oʻzbekcha / ўзбекча
- ਪੰਜਾਬੀ
- ပအိုဝ်ႏဘာႏသာႏ
- پښتو
- Português
- Qaraqalpaqsha
- Русиньскый
- سرائیکی
- Scots
- Shqip
- සිංහල
- Simple English
- سنڌي
- کوردی
- Srpskohrvatski / српскохрватски
- தமிழ்
- Taclḥit
- Татарча / tatarça
- တႆး
- ไทย
- ತುಳು
- Türkçe
- Українська
- اردو
- Tiếng Việt
- Yorùbá
- 中文
- Kumoring
Appearance
From Wikipedia, the free encyclopedia
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 template-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.
Warning This Lua module is used on approximately 61,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them.
This module depends on the following other modules:
Implements {{High-use }}. Uses bot-updated values from subpages of Module:Transclusion_count/data/ when available.
Usage
{{#invoke:High-use|main|1=number of transclusions|2=discussion page, or use + notation|info=|demo=|form=|expiry=}}
number of transclusions
: The first parameter is either a static number of times the template has been transcluded, or the word "risk" (without quotes) to display "a very large number of" instead of the actual value. This value will be ignored if transclusion data is available for the current page.discussion page, or use + notation
: The second parameter is overloaded. It will cause the number of transclusions to display as "#,###+" instead of "approximately #,###" when set equal to "yes" (without quotes). When used in this manner, values will be rounded down, instead of rounded to the nearest number with the appropriate number of significant figures. When set to any other non-blank value, it will replace the link to the template's talk page to the value of the parameter (for example,2=WP:VPT
will insert a link to WP:VPT),|info=extra information
: When set to non-blank, will insert extra information into the template text if the template has more than 100,000 transclusions or parameter 1 is set to "risk".|demo=Template_name
: Will use the transclusion count for the template at Template:Template_name instead of detecting what template it is being used on. Capitalization must exactly match the value used in Special:PrefixIndex/Module:Transclusion_count/data/.|form=
: When set to "editnotice", will display the message using {{editnotice }} instead of {{ombox }}.|expiry=
: Sets the|expiry=
parameter for {{editnotice }}.|system=in system messages
: if set, this module looks like {{Used in system }}. Use that template directly as it performs some checks.|fetch=
: if set to false, the module will not attempt to fetch transclusion counts using Module:Transclusion count
Other functions
- num
- Produces the text and and link to toolforge surrounding the amount of transclusions.
- risk
- With this function, if
risk
is passed into the first unnamed parameter, or there are more than 100k transclusions, this will returnrisk
. - text
- Returns the body text of this template, with nil or a number of transclusions.
The above documentation is transcluded from Module:High-use/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.
require('strict') localp={} localgetArgs=require('Module:Arguments').getArgs local_fetch=require('Module:Transclusion_count')._fetch-- _fetch looks at the 'demo' argument localyesno=require('Module:Yesno') locallang_obj=mw.getContentLanguage()-- this here because the language object is used multiple places in the module locallarge_count_cutoff=100000 localapprox_num_total_pages=63000000 localuser_subpage_info_page='Wikipedia:User pages#SUB' localsandbox_module_page='Module:Sandbox' localsystem_messages_cat='Pages used in system messages needing protection' localsandbox_word='sandbox' localtestcases_word='testcases' localdoc_word='doc' localfunctioncount_from_args(args) iftonumber(args.count)then-- check if function has already been used returntonumber(args.count)-- early exit if so end localcount ifyesno(args['fetch'])~=falsethen count=_fetch(args)-- fetch transclusion count end -- use explicitly-provided count when fetch fails ifcount==nilandargs[1]~=nilandargs[1]~=''then -- convert local language number string to a number understandable by Lua count=mw.ustring.gsub(args[1],'+$','') count=lang_obj:parseFormattedNumber(args[1]) end -- in case someone writes a non-positive number ifcountandcount>0then returncount end returnnil end -- Actions if there is a large (greater than or equal to 100,000) transclusion count localfunctionrisk_boolean(args) ifargs.risk==trueorargs.risk==falsethen returnargs.risk elseifargs[1]=='risk'then returntrue else localcount=count_from_args(args) ifcountandcount>=large_count_cutoffthen returntrue end end returnfalse end -- function retained for backwards compatibility functionp._risk(args) returnrisk_boolean(args)and'risk'or'' end -- function retained for backwards compatibility functionp.risk(frame) returnp._risk(getArgs(frame)) end -- count and no_percent arguments retained for backwards compatibility functionp._num(args,count,no_percent) ifcount==nilthen count=count_from_args(args) end args.count=count args.risk=risk_boolean(args) -- Build output string localreturn_value='' ifargs.count==nilandargs.riskthen return'a very large number of' elseifargs.count==nilthen return'many' else -- Use 2 significant figures for smaller numbers and 3 for larger ones localsigfig=2 ifargs.count>=large_count_cutoffthen sigfig=3 end -- Prepare to round to appropriate number of sigfigs localf=math.floor(math.log10(args.count))-sigfig+1 -- Round and insert 'approximately' or '+' when appropriate ifyesno(args[2])==trueor(type(args[1])=='string'and(mw.ustring.sub(args[1],-1)=='+'))then -- Round down return_value=string.format('%s+',lang_obj:formatNum(math.floor((args.count/10^(f)))*(10^(f)))) else -- Round to nearest return_value=string.format('approximately %s',lang_obj:formatNum(math.floor((args.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 no_percent=yesno(no_percentorargs['no-percent']) ifargs.countandargs.count>=approx_num_total_pages/100andnotno_percentthen localnum_total_pages=mw.getCurrentFrame():callParserFunction('NUMBEROFPAGES','R') localtotal_percent=math.floor(((args.count/num_total_pages)*100)+0.5) iftotal_percent>=1then return_value=string.format('%s pages, or roughly %s%% of all',return_value,total_percent) end end end returnreturn_value end -- used by [[Template:Stub documentation]] and other pages -- count argument retained for backwards compatibility functionp.num(frame,count) returnp._num(getArgs(frame),count) end -- count argument retained for backwards compatibility functionp._text(args,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=(mw.getCurrentFrame():preprocess('{{REVISIONID}}')=='')and("\n\n----\n'''Preview message''':"..' Transclusion count updated automatically ([[Template:High-use/doc#Technical details|see documentation]]).')or'' ifcount==nilthen count=count_from_args(args) end args.count=count args.risk=risk_boolean(args) -- trim /doc, /sandbox and /testcases localtitle=args.titleor(args.demoandargs.demo~=''andmw.title.new(args.demo,'Template'))ormw.title.getCurrentTitle() iftitle.subpageText==doc_wordortitle.subpageText==sandbox_wordortitle.subpageText==testcases_wordthen title=title.basePageTitle end -- use /testcases of base template localtestcases_page=mw.title.new(title.prefixedText..'/'..testcases_word) -- exists is expensive whiletestcases_page.basePageTitle.isSubpageandnottestcases_page.existsdo testcases_page=mw.title.new(testcases_page.basePageTitle.basePageTitle.prefixedText..'/'..testcases_word) end localsystemMessages=(args['system']or'')~='' -- This retrieves the project URL automatically to simplify localization. localtemplateCount=('on [https://linkcount.toolforge.org/?project=%s&page=%s#transclusions %s pages]'):format( title:fullUrl():gsub('//(.-)/.*','%1'), mw.uri.encode(title.fullText),p._num(args)) localused_on_text="'''This "..(title:inNamespace('Module')and'Lua module'or'template')..' is used ' ifsystemMessagesthen used_on_text=used_on_text..args['system'].. ((args.countandargs.count>2000)and("''', and "..templateCount)or("'''")) else used_on_text=used_on_text..templateCount.."'''" end localsandbox_text=('%s\'s [[%s/sandbox|/sandbox]] or [[%s|/testcases]] subpages, or in your own [[%s]]. '):format( title:inNamespace('Module')and'module'or'template', title.fullText, testcases_page.fullText, title:inNamespace('Module')and(sandbox_module_page..'|module sandbox')or(user_subpage_info_page..'|user subpage') ) localinfoArg=args['info']~=''andargs['info'] if(systemMessagesorargs.risk)then localinfo='.' ifsystemMessagesthen info=info..'<br />Changes to it can cause immediate changes to the '..mw.site.namespaces.Project.name..' user interface.' end ifinfoArgthen info=info..'<br />'..infoArg end sandbox_text=info..'<br /> To avoid major disruption'.. (args.countandargs.count>=large_count_cutoffand' and server load'or'')..-- should this use args.risk? ', 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 ' ifargs[2]~=nilandargs[2]~=''andyesno(args[2])==nilthen discussion_text=string.format('%sat [[%s]]',discussion_text,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 -- used by [[Template:R from high-use template]] -- count argument retained for backwards compatibility functionp.text(frame,count) returnp._text(getArgs(frame),count) end -- nocat argument retained for backwards compatibility functionp._main(args,nocat) args.count=count_from_args(args) args.risk=risk_boolean(args) args.title=(args.demoandargs.demo~=''andmw.title.new(args.demo,'Template'))ormw.title.getCurrentTitle() localimage='Ambox warning yellow.svg' localtype_param='style' localepilogue='' ifargs['system']andargs['system']~=''then image='Ambox important.svg' type_param='content' ifyesno(nocatorargs['nocat'])~=trueandnotargs.title.isRedirectthen localprotection_action=(args.title:inNamespace('File')and'upload')or'edit' localprotection_level=require('Module:Effective protection level')._main(protection_action,args.title.fullText) ifprotection_level~='sysop'andprotection_level~='templateeditor'andprotection_level~='interfaceadmin'then epilogue=mw.getCurrentFrame():expandTemplate{ title='sandbox other', args={ [2]='[[Category:'..system_messages_cat..']]' } } end end elseifargs.riskthen image='Ambox warning orange.svg' type_param='content' end image='[[File:'..image..'|40px|alt=Warning|link=]]' ifargs['form']=='editnotice'then returnmw.getCurrentFrame():expandTemplate{ title='editnotice', args={ ['image']=image, ['text']=p._text(args), ['expiry']=(args['expiry']or'') } }..epilogue else returnrequire('Module:Message box').main('ombox',{ type=type_param, image=image, text=p._text(args), expiry=(args['expiry']or'') })..epilogue end end functionp.main(frame) returnp._main(getArgs(frame)) end returnp