Module:Portal bar
- العربية
- Авар
- Azərbaycanca
- تۆرکجه
- Basa Bali
- বাংলা
- 閩南語 / Bân-lâm-gí
- Беларуская
- भोजपुरी
- Bosanski
- Cebuano
- Ελληνικά
- Esperanto
- فارسی
- Galego
- 한국어
- हिन्दी
- Bahasa Indonesia
- IsiZulu
- Jawa
- ქართული
- Kurdî
- Македонски
- മലയാളം
- Bahasa Melayu
- Minangkabau
- Монгол
- မြန်မာဘာသာ
- नेपाली
- 日本語
- Нохчийн
- ଓଡ଼ିଆ
- Oʻzbekcha / ўзбекча
- Português
- Qaraqalpaqsha
- Scots
- සිංහල
- سنڌي
- Slovenščina
- کوردی
- Српски / srpski
- Srpskohrvatski / српскохрватски
- Sunda
- Svenska
- ไทย
- Тоҷикӣ
- Türkçe
- Українська
- Tiếng Việt
- 吴语
- 粵語
- Zazaki
- 中文
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 177,000 pages .
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
To avoid major disruption and server load, any changes should be tested in the module's /sandbox or /testcases subpages, or in your own module sandbox. The tested changes can be added to this page in a single edit. Consider discussing changes on the talk page before implementing them.
This module depends on the following other modules:
This module implements the {{portal bar }} template. It displays a horizontal bar of portals.
See here and here for testcases.
Note: in order to make the test cases work, the Sandbox CSS classes have "-sand" appended to their names. If you wish to update the CSS, copy the contents of each class from Module:Portal bar/sandbox/styles.css to Module:Portal bar/styles.css, but do not alter the class names, nor just copy-paste the entire CSS file. For the current difference in CSS between Sandbox and Main, see here.
Usage
{{#invoke:Portal bar|main|''portal 1''|''portal 2 ''|...|border=''no''}}
- Positional parameters - the names of the portals to be displayed.
border
- if|border=
is equal tono
,n
,false
, or0
, then the portal box will have no border.redlinks
- if|redlinks=
is equal toyes
,y
,true
orinclude
, then the portal box will show redlinked portals
Examples
{{#invoke:portal bar|main|Visual arts|Science|Literature}}
Produces:
{{#invoke:portal bar|main|Visual arts|Science|Literature|border=no}}
Produces:
For further examples, see Template:Portal bar/testcases.
Images
This module uses Module:Portal to get portal images. To add, change, or remove images, please see the instructions at Module:Portal#Image.
The above documentation is transcluded from Module:Portal bar/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.
-- This module implements {{portal bar}}. require('strict') -- determine whether we're being called from a sandbox localisSandbox=mw.getCurrentFrame():getTitle():find('sandbox',1,true) localsandbox=isSandboxand'/sandbox'or'' localportalModule=require('Module:Portal'..sandbox) localgetImageName=portalModule._image localcheckPortals=portalModule._checkPortals localprocessPortalArgs=portalModule._processPortalArgs localyesno=require('Module:Yesno') localgetArgs=require('Module:Arguments').getArgs localp={} localfunctionsandboxVersion(s) returnisSandboxands.."-sand"ors end -- Builds the portal bar used by {{portal bar}}. functionp._main(portals,args) -- check for sensible args args=type(args)=="table"andargsor{} -- Normalize arguments forkey,defaultinpairs({border=true,redlinks=false,tracking=true})do ifargs[key]==nilthenargs[key]=defaultend args[key]=yesno(args[key],default) end localnav=mw.html.create('div') :addClass(sandboxVersion('portal-bar')) :addClass('noprint metadata noviewer') :attr('role','navigation') :attr('aria-label','Portals') :addClass(sandboxVersion(args.borderand'portal-bar-bordered'or'portal-bar-unbordered')) localtrackingCat='' -- Allow any number of portals args.minPortals=0 args.maxPortals=-1 -- Check to see whether there are redlinks, filter out unless args.redlink is true portals,trackingCat=checkPortals(portals,args) nav:wikitext(trackingCat) if#portals==0then returntrackingCat end localrelated=yesno(args.related) ifrelatedthen nav:addClass(sandboxVersion('portal-bar-related')) else localheader=nav:tag('span') header:addClass(sandboxVersion('portal-bar-header')) header:wikitext('[[Wikipedia:Contents/Portals|Portal]]') if#portals>1then header:wikitext('s') end header:wikitext(':') end localcontainer=nav:tag('ul') container:addClass(sandboxVersion('portal-bar-content')) ifrelatedthen container:addClass(sandboxVersion('portal-bar-content-related')) end localsize=relatedand'28x24px'or'21x19px' for_,portalinipairs(portals)do container :tag('li') :addClass(sandboxVersion('portal-bar-item')) :wikitext(string.format('<span class="nowrap">[[File:%s|%s]] </span>[[Portal:%s|%s]]', getImageName(portal,true),size,portal,portal)) end localstyleFile='Module:Portal bar'..sandbox..'/styles.css' returnmw.getCurrentFrame():extensionTag{ name='templatestyles',args={src=styleFile} }..tostring(nav) end -- Processes external arguments and sends them to the other functions. functionp.main(frame) localorigArgs=getArgs(frame) localportals,args=processPortalArgs(origArgs) returnp._main(portals,args) end returnp