Abrir menú principal

WikiShia β

Cambios

Módulo:Navbar

1751 bytes eliminados, 07:43 5 nov 2018
sin resumen de edición
local p = {}
local HtmlBuilder = require('Module:HtmlBuilder')getArgs
function trim(s) return mw.ustring.match( s, "^%s*(p.-)%s*$" )end function error_navbar(sargs) local span titleArg = HtmlBuilder.create('span')  span .addClass('error') .css('float', 'left') .css('white-space', 'nowrap') .wikitext('Error: ' .. s)  return tostring(span)end function getTitle( pageName ) pageName = trim( pageName ); local page_title, talk_page_title;  if mw.ustring.sub(pageName, 1, 1) == ':' then page_title = mw.title.new( mw.ustring.sub(pageName, 2) ); else page_title = mw.title.new( pageName, 'Template' ); end  if page_title then talk_page_title = page_title.talkPageTitle; else talk_page_title = nil; end  return page_title, talk_page_title;end
function _navbar( if args ).collapsible then titleArg = 2 if not args[.plain then args.mini = 1] end if args.fontcolor then return error( args.fontstyle = 'color:' .. args.fontcolor .. ';' end args.style = 'No name providedfloat:left; text-align:left; width:6em;') end
local good, title, talk_title; good, title, talk_title titleText = pcall( getTitle, args[1titleArg] or (':' .. mw.getCurrentFrame():getParent():getTitle()); if not good then return error local title = mw.title.new(mw.text.trim(titletitleText), 'Template'); end
if not title then return error('Page does not existInvalid title '.. titleText) end
local mainpage talkpage = title.fullText; local talkpage = talk_title talkPageTitle and talk_titletitle.talkPageTitle.fullText or '' local editurl = title:fullUrl( 'action=edit' );
local viewLink, talkLink, editLink div = mw.html.create():tag('view', 'talk', 'editdiv') if args.mini then div viewLink, talkLink, editLink = :addClass('vplainlinks', ) :addClass('thlist', ) :addClass('enavbar') end :cssText(args.style)
local div = HtmlBuilder if args.create( 'mini then div' ) div .:addClass( 'plainlinks' ) .addClass( mini'hlist' ) .addClass( 'navbar') .cssText( args.style )end
if not (args.mini or args.plain) then div :tag('span') :css('word-spacing', 0) :cssText(args.addClassfontstyle) :wikitext(args.text or 'This box:') :wikitext('mini') end
if not (args.mini or args.plain) brackets then div . :tag( 'span' ) . :css( 'wordmargin-spacingright', '-0 .125em') . :cssText( args.fontstyle ) . :wikitext( args.text or 'This box:[' ) .wikitext :newline( ' ' ); end
if args.brackets then local ul = div .:tag('spanul') .css('margin-right', '-0.125em') .cssText( args.fontstyle ) .wikitext( '[' ) .newline(); end
local ul = div :tag('li') :addClass('nv-view') :wikitext('[[' .. title.fullText .. '|') :tag(args.mini and 'abbr' or 'span') :attr('title', 'View this template') :cssText(args.fontstyle) :wikitext(args.mini and 'v' or 'view') :done() :wikitext(']]') :done() :tag('li') :addClass('nv-talk') :wikitext('[[' .. talkpage ..'|') :tag(args.mini and 'ulabbr' or 'span') :attr('title', 'Discuss this template') :cssText(args.fontstyle) :wikitext(args.mini and 't' or 'talk') :done() :wikitext(']]');
if not args.noedit then ul . :tag( 'li' ) . :addClass( 'nv-viewedit' ) . :wikitext( '[[' .. mainpage .. '|' ) .tag( 'span ' ) .attr( 'title', 'View this template' ) .cssText:fullUrl( args.fontstyle or 'action=edit' ) .wikitext( viewLink ) .done() .wikitext( ']]' ) .done() . :tag( 'li' ) args.addClass( mini and 'nv-talkabbr' ) .wikitext( '[[' .. talkpage .. '|' ) .tag( or 'span ' ) . :attr( 'title', 'Discuss Edit this template' ) . :cssText( args.fontstyle or '' ) . :wikitext( talkLink args.mini and 'e' or 'edit') . :done() . :wikitext( ']]' ); end
if not args.noedit brackets then ul div . :tag( 'lispan' ) .addClass :css( 'nvmargin-editleft' ) .wikitext( , '[' .. editurl .. ' ' ) -0.tag( 'span 125em' ) .attr( 'title', 'Edit this template' ) . :cssText( args.fontstyle or '' ) . :wikitext( editLink ']') .done :newline() .wikitext( ']' ); end
if args.brackets collapsible then div . :done() :tag('span') . :css('marginfont-leftsize', '-0.125em110%') . :cssText( args.fontstyle or '' ) . :wikitext( ']' ) .newline(args[1]); end
return tostring(div:done())
end
function p.navbar(frame)
local origArgs -- If called via #invoke, use the args passed into the invoking template. -- Otherwise, for testing purposes, assume args are being passed directly in. if frame == mw.getCurrentFrame() not getArgs then origArgs getArgs = framerequire('Module:getParent(Arguments').args else origArgs = framegetArgs end  -- ParserFunctions considers the empty string to be false, so to preserve the previous -- behavior of {{navbar}}, change any empty arguments to nil, so Lua will consider -- them false too return p. args = {} for k, v in pairs_navbar(getArgs(origArgsframe) do if v ~= '' then args[k] = v end end  return _navbar(args)
end
return p