Module:Lua banner
Appearance
![]() | This Lua module is used on approximately 10,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: |
This module implements the {{lua}} template.
Usage from wikitext
This module cannot be used directly from wikitext. It can only be used through the {{lua}} template. Please see the template page for documentation.
Usage from Lua modules
To use this module from other Lua modules, first load the module.
localmLuaBanner=require('Module:Lua banner')
You can then generate a side box using the _main function.
mLuaBanner._main(args)
The args variable should be a table containing the arguments to pass to the module. To see the different arguments that can be specified and how they affect the module output, please refer to the {{lua}} template documentation.
Tracking category
-- This module implements the {{lua}} template.localyesno=require('Module:Yesno')localmList=require('Module:List')localmTableTools=require('Module:TableTools')localmMessageBox=require('Module:Message box')localp={}functionp.main(frame)localorigArgs=frame:getParent().argslocalargs={}fork,vinpairs(origArgs)dov=v:match('^%s*(.-)%s*$')ifv~=''thenargs[k]=vendendreturnp._main(args)endfunctionp._main(args)localmodules=mTableTools.compressSparseArray(args)localbox=p.renderBox(modules)localtrackingCategories=p.renderTrackingCategories(args,modules)returnbox..trackingCategoriesendfunctionp.renderBox(modules)localboxArgs={}if#modules<1thenboxArgs.text='<strong class="error">Error: no modules specified</strong>'elselocalmoduleLinks={}fori,moduleinipairs(modules)domoduleLinks[i]=string.format('[[:%s]]',module)localmaybeSandbox=mw.title.new(module..'/sandbox')ifmaybeSandboxandmaybeSandbox.existsthenmoduleLinks[i]=moduleLinks[i]..string.format(' ([[:%s|sandbox]])',maybeSandbox.fullText)endendlocalmoduleList=mList.makeList('bulleted',moduleLinks)localtitle=mw.title.getCurrentTitle()iftitle.subpageText=="doc"thentitle=title.basePageTitleendiftitle.contentModel=="Scribunto"thenboxArgs.text='This module depends on the following other modules:'..moduleListelseboxArgs.text='This template uses [[Wikipedia:Lua|Lua]]:\n'..moduleListendendboxArgs.type='notice'boxArgs.small=trueboxArgs.image='[[File:Lua-Logo.svg|30px|alt=|link=]]'returnmMessageBox.main('mbox',boxArgs)endfunctionp.renderTrackingCategories(args,modules,titleObj)ifyesno(args.nocat)thenreturn''endlocalcats={}-- Error categoryif#modules<1thencats[#cats+1]='Lua templates with errors'end-- Lua templates categorytitleObj=titleObjormw.title.getCurrentTitle()localsubpageBlacklist={doc=true,sandbox=true,sandbox2=true,testcases=true}ifnotsubpageBlacklist[titleObj.subpageText]thenlocalprotCatNameiftitleObj.namespace==10thenlocalcategory=args.categoryifnotcategorythenlocalcategories={['Module:String']='Templates based on the String Lua module',['Module:Math']='Templates based on the Math Lua module',['Module:BaseConvert']='Templates based on the BaseConvert Lua module',['Module:Citation/CS1']='Templates based on the Citation/CS1 Lua module'}category=modules[1]andcategories[modules[1]]category=categoryor'Lua-based templates'endcats[#cats+1]=categoryprotCatName="Templates using under-protected Lua modules"elseiftitleObj.namespace==828thenprotCatName="Modules depending on under-protected modules"endifnotargs.noprotcatandprotCatNamethenlocalprotLevels={autoconfirmed=1,extendedconfirmed=2,templateeditor=3,sysop=4}localcurrentProtiftitleObj.id~=0then-- id is 0 (page does not exist) if am previewing before creating a template.currentProt=titleObj.protectionLevels["edit"][1]endifcurrentProt==nilthencurrentProt=0elsecurrentProt=protLevels[currentProt]endfori,moduleinipairs(modules)doifmodule~="WP:libraryUtil"thenlocalmoduleTitle=mw.title.new(module)localmoduleProt=moduleTitleandmoduleTitle.protectionLevels["edit"][1]ifmoduleProt==nilthenmoduleProt=0elsemoduleProt=protLevels[moduleProt]endifmoduleProt<currentProtthencats[#cats+1]=protCatNamebreakendendendendendfori,catinipairs(cats)docats[i]=string.format('[[Category:%s]]',cat)endreturntable.concat(cats)endreturnp