Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

Module:Navbar

Permanently protected module
From Wikipedia, the free encyclopedia
Module documentation[view] [edit] [history] [purge]
WarningThis Lua module is used in system messages, and onapproximately 5,120,000 pages, or roughly 8% of all pages.
Changes to it can cause immediate changes to the Wikipedia user interface.
To avoid major disruption and server load, any changes should be tested in the module's/sandbox or/testcases subpages, or in your ownmodule sandbox. The tested changes can be added to this page in a single edit. Please discuss changes on thetalk page before implementing them.
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 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.
This module depends on the following other modules:
CSSThis module usesTemplateStyles:

This is aLua implementation of{{Navbar}}. It is used inModule:Navbox.

The abovedocumentation istranscluded fromModule:Navbar/doc.(edit |history)
Editors can experiment in this module'ssandbox(edit |diff) andtestcases(edit |run) pages.
Subpages of this module.

localp={}localcfg=mw.loadData('Module:Navbar/configuration')localfunctionget_title_arg(is_collapsible,template)localtitle_arg=1ifis_collapsiblethentitle_arg=2endiftemplatethentitle_arg='template'endreturntitle_argendlocalfunctionchoose_links(template,args)-- The show table indicates the default displayed items.-- view, talk, edit, hist, move, watch-- TODO: Move to configuration.localshow={true,true,true,false,false,false}iftemplatethenshow[2]=falseshow[3]=falselocalindex={t=2,d=2,e=3,h=4,m=5,w=6,talk=2,edit=3,hist=4,move=5,watch=6}-- TODO: Consider removing TableTools dependency.for_,vinipairs(require('Module:TableTools').compressSparseArray(args))dolocalnum=index[v]ifnumthenshow[num]=trueendendendlocalremove_edit_link=args.noeditifremove_edit_linkthenshow[3]=falseendreturnshowendlocalfunctionadd_link(link_description,ul,is_mini,font_style)localliflink_description.urlthenl={'[','',']'}elsel={'[[','|',']]'}endul:tag('li'):addClass('nv-'..link_description.full):wikitext(l[1]..link_description.link..l[2]):tag(is_miniand'abbr'or'span'):attr('title',link_description.html_title):cssText(font_style):wikitext(is_miniandlink_description.miniorlink_description.full):done():wikitext(l[3]):done()endlocalfunctionmake_list(title_text,has_brackets,displayed_links,is_mini,font_style)localtitle=mw.title.new(mw.text.trim(title_text),cfg.title_namespace)ifnottitlethenerror(cfg.invalid_title..title_text)endlocaltalkpage=title.talkPageTitleandtitle.talkPageTitle.fullTextor''-- TODO: Get link_descriptions and show into the configuration module.-- link_descriptions should be easier...locallink_descriptions={{['mini']='v',['full']='view',['html_title']='View this template',['link']=title.fullText,['url']=false},{['mini']='t',['full']='talk',['html_title']='Discuss this template',['link']=talkpage,['url']=false},{['mini']='e',['full']='edit',['html_title']='Edit this template',['link']='Special:EditPage/'..title.fullText,['url']=false},{['mini']='h',['full']='hist',['html_title']='History of this template',['link']='Special:PageHistory/'..title.fullText,['url']=false},{['mini']='m',['full']='move',['html_title']='Move this template',['link']=mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText),['url']=true},{['mini']='w',['full']='watch',['html_title']='Watch this template',['link']=title:fullUrl('action=watch'),['url']=true}}localul=mw.html.create('ul')ifhas_bracketsthenul:addClass(cfg.classes.brackets):cssText(font_style)endfori,_inipairs(displayed_links)doifdisplayed_links[i]thenadd_link(link_descriptions[i],ul,is_mini,font_style)endendreturnul:done()endfunctionp._navbar(args)-- TODO: We probably don't need both fontstyle and fontcolor...localfont_style=args.fontstylelocalfont_color=args.fontcolorlocalis_collapsible=args.collapsiblelocalis_mini=args.minilocalis_plain=args.plainlocalcollapsible_class=nilifis_collapsiblethencollapsible_class=cfg.classes.collapsibleifnotis_plainthenis_mini=1endiffont_colorthenfont_style=(font_styleor'')..'; color: '..font_color..';'endendlocalnavbar_style=args.stylelocaldiv=mw.html.create():tag('div')div:addClass(cfg.classes.navbar):addClass(cfg.classes.plainlinks):addClass(cfg.classes.horizontal_list):addClass(collapsible_class)-- we made the determination earlier:cssText(navbar_style)ifis_minithendiv:addClass(cfg.classes.mini)endlocalbox_text=(args.textorcfg.box_text)..' '-- the concatenated space guarantees the box text is separatedifnot(is_minioris_plain)thendiv:tag('span'):addClass(cfg.classes.box_text):cssText(font_style):wikitext(box_text)endlocaltemplate=args.templatelocaldisplayed_links=choose_links(template,args)localhas_brackets=args.bracketslocaltitle_arg=get_title_arg(is_collapsible,template)localtitle_text=args[title_arg]or(':'..mw.getCurrentFrame():getParent():getTitle())locallist=make_list(title_text,has_brackets,displayed_links,is_mini,font_style)div:node(list)ifis_collapsiblethenlocaltitle_text_classifis_minithentitle_text_class=cfg.classes.collapsible_title_minielsetitle_text_class=cfg.classes.collapsible_title_fullenddiv:done():tag('div'):addClass(title_text_class):cssText(font_style):wikitext(args[1])endlocalframe=mw.getCurrentFrame()-- hlist -> navbar is best-effort to preserve old Common.css ordering.returnframe:extensionTag{name='templatestyles',args={src=cfg.hlist_templatestyles}}..frame:extensionTag{name='templatestyles',args={src=cfg.templatestyles}}..tostring(div:done())endfunctionp.navbar(frame)returnp._navbar(require('Module:Arguments').getArgs(frame))endreturnp
Retrieved from "https://en.wikipedia.org/w/index.php?title=Module:Navbar&oldid=1179557823"
Category:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp