Home
Random
Log in
Settings
About the Deadlock Wiki
Search
Editing
Module:Tnavbar
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
-- <nowiki> -- -- Implements {{tnavbar}} and variants -- -- @todo move the hardcoded css to [[MediaWiki:Common.css]] given how many pages it's found on -- local p = {} local yesno = require( 'Module:Yesno' ) function p._navbar( args ) local tag tag = mw.html.create( 'div' ) :css( { ['background-color'] = 'transparent', padding = '0' } ) tag :addClass( 'plainlinks' ) :addClass( 'noprint' ) :css( { ['white-space'] = 'nowrap', ['font-weight'] = 'normal', ['font-size'] = 'xx-small' } ) viewSpan = mw.html.create( 'span' ) :attr( 'title', 'View this template' ) :cssText( fontstyle ) :wikitext( 'v' ) talkSpan = mw.html.create( 'span' ) :attr( 'title', 'Discussion about this template' ) :cssText( fontstyle ) :wikitext( 'd' ) editSpan = mw.html.create( 'span' ) :attr( 'title', 'You can edit this template. Please use the preview button before saving.' ) :cssText( fontstyle ) :wikitext( 'e' ) local title = mw.text.trim( args[1] ) local ns, titleTbl, page, talk if mw.ustring.sub( title, 1, 1 ) == ':' then -- mainspace title = mw.ustring.sub( title, 2 ) page = title talk = 'Talk:' .. title elseif mw.ustring.match( title, ':' ) then -- split title to see if it has a valid namespace titleTbl = mw.text.split( title, ':' ) ns = mw.site.namespaces[titleTbl[1]] if ns ~= nil then page = ns.name .. ':' .. table.concat( titleTbl, '', 2 ) if ns.isTalk then talk = page else talk = ns.talk.name .. ':' .. table.concat( titleTbl, '', 2 ) end end end -- this happens if there's no semi-colons in title -- or if there is semi-colons but it didn't have valid ns name if not page then page = 'Template:' .. title talk = 'Template talk:' .. title end tag :wikitext( '[[' .. page .. '|' .. tostring( viewSpan ) .. ']]' ) :wikitext( ' ' ) :tag( 'span' ) :css( 'font-size', '80%' ) :wikitext( '•' ) :done() :wikitext( ' ' ) :wikitext( '[' .. tostring( mw.uri.fullUrl( talk ) ) .. ' ' .. tostring( talkSpan ) .. ']' ) :wikitext( ' ' ) :tag( 'span' ) :css( 'font-size', '80%' ) :wikitext( '•' ) :done() :wikitext( ' ' ) :wikitext( '[' .. tostring( mw.uri.fullUrl( page, 'action=edit' ) ) .. ' ' .. tostring( editSpan ) .. ']' ) return tostring( tag ) end function p._collapsible( args ) local nav_args = { [1] = args[2] } local div = mw.html.create( 'div' ) :css( { float = 'left', ['text-align'] = 'left', width = '6em' } ) :addClass( 'navbar' ) :wikitext(p._navbar(nav_args)) local span = mw.html.create('span'):wikitext(args[1]) return tostring( div ) .. tostring( span ) end return p
Summary:
Please note that all contributions to Deadlock Wiki are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
Deadlock:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Preview page with this template
Template used on this page:
Module:Tnavbar/doc
(
edit
)