Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:High-use

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
Thismodule is rated asready 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 onhelp pages and other Wikipedia resources as an option for new users. To minimise server load and avoid disruptive output, improvements should be developed throughsandbox testing rather than repeated trial-and-error editing.
Page template-protectedThis module is currentlyprotected from editing.
See theprotection policy andprotection log for more details. Please discuss any changes on thetalk page; you maysubmit an edit request to ask anadministrator to make an edit if it isuncontroversial or supported byconsensus. You may alsorequest that this page be unprotected.
WarningThis Lua module is used onapproximately 63,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.
This module depends on the following other modules:

Implements{{High-use}}. Uses bot-updated values fromsubpages 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 toWP:VPT),
  • |info=extra information: When set to non-blank, will insertextra 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 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/.
  • |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 usingModule:Transclusion count

Other functions

num
Produces the text and and link to toolforge surrounding the amount of transclusions.
risk
With this function, ifrisk 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 abovedocumentation istranscluded fromModule:High-use/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) and testcases(create) pages.
Subpages of this module.

require('strict')localp={}localgetArgs=require('Module:Arguments').getArgslocal_fetch=require('Module:Transclusion_count')._fetch-- _fetch looks at the 'demo' argumentlocalyesno=require('Module:Yesno')locallang_obj=mw.getContentLanguage()-- this here because the language object is used multiple places in the modulelocallarge_count_cutoff=100000localapprox_num_total_pages=63000000localuser_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 usedreturntonumber(args.count)-- early exit if soendlocalcountifyesno(args['fetch'])~=falsethencount=_fetch(args)-- fetch transclusion countend-- use explicitly-provided count when fetch failsifcount==nilandargs[1]~=nilandargs[1]~=''then-- convert local language number string to a number understandable by Luacount=mw.ustring.gsub(args[1],'+$','')count=lang_obj:parseFormattedNumber(args[1])end-- in case someone writes a non-positive numberifcountandcount>0thenreturncountendreturnnilend-- Actions if there is a large (greater than or equal to 100,000) transclusion countlocalfunctionrisk_boolean(args)ifargs.risk==trueorargs.risk==falsethenreturnargs.riskelseifargs[1]=='risk'thenreturntrueelselocalcount=count_from_args(args)ifcountandcount>=large_count_cutoffthenreturntrueendendreturnfalseend-- function retained for backwards compatibilityfunctionp._risk(args)returnrisk_boolean(args)and'risk'or''end-- function retained for backwards compatibilityfunctionp.risk(frame)returnp._risk(getArgs(frame))end-- count and no_percent arguments retained for backwards compatibilityfunctionp._num(args,count,no_percent)ifcount==nilthencount=count_from_args(args)endargs.count=countargs.risk=risk_boolean(args)-- Build output stringlocalreturn_value=''ifargs.count==nilandargs.riskthenreturn'a very large number of'elseifargs.count==nilthenreturn'many'else-- Use 2 significant figures for smaller numbers and 3 for larger oneslocalsigfig=2ifargs.count>=large_count_cutoffthensigfig=3end-- Prepare to round to appropriate number of sigfigslocalf=math.floor(math.log10(args.count))-sigfig+1-- Round and insert 'approximately' or '+' when appropriateifyesno(args[2])==trueor(type(args[1])=='string'and(mw.ustring.sub(args[1],-1)=='+'))then-- Round downreturn_value=string.format('%s+',lang_obj:formatNum(math.floor((args.count/10^(f)))*(10^(f))))else-- Round to nearestreturn_value=string.format('approximately&#x20;%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 yesno_percent=yesno(no_percentorargs['no-percent'])ifargs.countandargs.count>=approx_num_total_pages/100andnotno_percentthenlocalnum_total_pages=mw.getCurrentFrame():callParserFunction('NUMBEROFPAGES','R')localtotal_percent=math.floor(((args.count/num_total_pages)*100)+0.5)iftotal_percent>=1thenreturn_value=string.format('%s&#x20;pages, or roughly %s%% of all',return_value,total_percent)endendendreturnreturn_valueend-- used by [[Template:Stub documentation]] and other pages-- count argument retained for backwards compatibilityfunctionp.num(frame,count)returnp._num(getArgs(frame),count)end-- count argument retained for backwards compatibilityfunctionp._text(args,count)--[=[Only show the information about how this template gets updatedif 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==nilthencount=count_from_args(args)endargs.count=countargs.risk=risk_boolean(args)-- trim /doc, /sandbox and /testcaseslocaltitle=args.titleor(args.demoandargs.demo~=''andmw.title.new(args.demo,'Template'))ormw.title.getCurrentTitle()iftitle.subpageText==doc_wordortitle.subpageText==sandbox_wordortitle.subpageText==testcases_wordthentitle=title.basePageTitleend-- use /testcases of base templatelocaltestcases_page=mw.title.new(title.prefixedText..'/'..testcases_word)-- exists is expensivewhiletestcases_page.basePageTitle.isSubpageandnottestcases_page.existsdotestcases_page=mw.title.new(testcases_page.basePageTitle.basePageTitle.prefixedText..'/'..testcases_word)endlocalsystemMessages=(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 'ifsystemMessagesthenused_on_text=used_on_text..args['system']..((args.countandargs.count>2000)and("''', and "..templateCount)or("'''"))elseused_on_text=used_on_text..templateCount.."'''"endlocalsandbox_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)thenlocalinfo='.'ifsystemMessagestheninfo=info..'<br />Changes to it can cause immediate changes to the '..mw.site.namespaces.Project.name..' user interface.'endifinfoArgtheninfo=info..'<br />'..infoArgendsandbox_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. 'elsesandbox_text=(infoArgand('.<br />'..infoArg..' C')or' and c')..'hanges may be widely noticed. Test changes in the '..sandbox_textendlocaldiscussion_text=systemMessagesand'Please discuss changes 'or'Consider discussing changes 'ifargs[2]~=nilandargs[2]~=''andyesno(args[2])==nilthendiscussion_text=string.format('%sat [[%s]]',discussion_text,args[2])elsediscussion_text=string.format('%son the [[%s|talk page]]',discussion_text,title.talkPageTitle.fullText)endreturnused_on_text..sandbox_text..discussion_text..' before implementing them.'..bot_textend-- used by [[Template:R from high-use template]]-- count argument retained for backwards compatibilityfunctionp.text(frame,count)returnp._text(getArgs(frame),count)end-- nocat argument retained for backwards compatibilityfunctionp._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']~=''thenimage='Ambox important.svg'type_param='content'ifyesno(nocatorargs['nocat'])~=trueandnotargs.title.isRedirectthenlocalprotection_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'thenepilogue=mw.getCurrentFrame():expandTemplate{title='sandbox other',args={[2]='[[Category:'..system_messages_cat..']]'}}endendelseifargs.riskthenimage='Ambox warning orange.svg'type_param='content'endimage='[[File:'..image..'|40px|alt=Warning|link=]]'ifargs['form']=='editnotice'thenreturnmw.getCurrentFrame():expandTemplate{title='editnotice',args={['image']=image,['text']=p._text(args),['expiry']=(args['expiry']or'')}}..epilogueelsereturnrequire('Module:Message box').main('ombox',{type=type_param,image=image,text=p._text(args),expiry=(args['expiry']or'')})..epilogueendendfunctionp.main(frame)returnp._main(getArgs(frame))endreturnp
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:High-use&oldid=1315814017"
Category:
Hidden category:

[8]ページ先頭

©2009-2026 Movatter.jp