Module:Navbar: Difference between revisions

Content added Content deleted
(Does not work, now hidden in MediaWiki:Print.css)
(Per edit request)
Line 3: Line 3:
local HtmlBuilder = require('Module:HtmlBuilder')
local HtmlBuilder = require('Module:HtmlBuilder')


function trim(s)
local function trim(s)
return mw.ustring.match( s, "^%s*(.-)%s*$" )
return mw.ustring.match( s, "^%s*(.-)%s*$" )
end
end


function error(s)
local function htmlError(s)
local span = HtmlBuilder.create('span')
local span = HtmlBuilder.create('span')


Line 19: Line 19:
end
end


function getTitle( pageName )
local function getTitle( pageName )
pageName = trim( pageName );
pageName = trim( pageName );
local page_title, talk_page_title;
local page_title, talk_page_title;
Line 38: Line 38:
end
end


function _navbar( args )
local function _navbar( args )
if not args[1] then
if not args[1] then
return error('No name provided')
return htmlError('No name provided')
end
end
Line 46: Line 46:
good, title, talk_title = pcall( getTitle, args[1] );
good, title, talk_title = pcall( getTitle, args[1] );
if not good then
if not good then
return error(title);
return htmlError(title);
end
end


if not title then
if not title then
return error('Page does not exist')
return htmlError('Page does not exist')
end
end
Line 150: Line 150:
-- behavior of {{navbar}}, change any empty arguments to nil, so Lua will consider
-- behavior of {{navbar}}, change any empty arguments to nil, so Lua will consider
-- them false too.
-- them false too.
args = {}
local args = {}
for k, v in pairs(origArgs) do
for k, v in pairs(origArgs) do
if v ~= '' then
if v ~= '' then