Jump to content

Module:Navbar and Module:Navbar/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
Content deleted Content added
Per edit request on talk
 
Test using Special pages for hist and edit
 
Line 1: Line 1:
local p = {}
local p = {}
local cfg = mw.loadData('Module:Navbar/configuration')
local cfg = mw.loadData('Module:Navbar/configuration/sandbox')


local function get_title_arg(is_collapsible, template)
local function get_title_arg(is_collapsible, template)
Line 28: Line 28:
local remove_edit_link = args.noedit
local remove_edit_link = args.noedit
if remove_edit_link then show[3] = false end
if remove_edit_link then show[3] = false end

return show
return show

end
end


Line 53: Line 53:


local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)
local function make_list(title_text, has_brackets, displayed_links, is_mini, font_style)

local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
local title = mw.title.new(mw.text.trim(title_text), cfg.title_namespace)
if not title then
if not title then
Line 59: Line 59:
end
end
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''
local talkpage = title.talkPageTitle and title.talkPageTitle.fullText or ''

-- TODO: Get link_descriptions and show into the configuration module.
-- TODO: Get link_descriptions and show into the configuration module.
-- link_descriptions should be easier...
-- link_descriptions should be easier...
Line 73: Line 73:
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
{ ['mini'] = 'm', ['full'] = 'move', ['html_title'] = 'Move this template',
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
['link'] = mw.title.new('Special:Movepage'):fullUrl('target='..title.fullText), ['url'] = true },
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
{ ['mini'] = 'w', ['full'] = 'watch', ['html_title'] = 'Watch this template',
['link'] = title:fullUrl('action=watch'), ['url'] = true }
['link'] = title:fullUrl('action=watch'), ['url'] = true }
}
}
Line 82: Line 82:
:cssText(font_style)
:cssText(font_style)
end
end

for i, _ in ipairs(displayed_links) do
for i, _ in ipairs(displayed_links) do
if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
if displayed_links[i] then add_link(link_descriptions[i], ul, is_mini, font_style) end
end
end
return ul:done()
return ul:done()

end
end


function p._navbar(args)
function p._navbar(args)

-- TODO: We probably don't need both fontstyle and fontcolor...
-- TODO: We probably don't need both fontstyle and fontcolor...
local font_style = args.fontstyle
local font_style = args.fontstyle
Line 98: Line 98:
local is_mini = args.mini
local is_mini = args.mini
local is_plain = args.plain
local is_plain = args.plain

local collapsible_class = nil
local collapsible_class = nil
if is_collapsible then
if is_collapsible then
Line 107: Line 107:
end
end
end
end

local navbar_style = args.style
local navbar_style = args.style
local div = mw.html.create():tag('div')
local div = mw.html.create():tag('div')
Line 119: Line 119:
if is_mini then div:addClass(cfg.classes.mini) end
if is_mini then div:addClass(cfg.classes.mini) end


local box_text = (args.text or cfg.box_text) .. ' '
local box_text = (args.text or cfg.box_text) .. ' ' -- space separates the box text
-- the concatenated space guarantees the box text is separated
if not (is_mini or is_plain) then
if not (is_mini or is_plain) then
div
div
Line 128: Line 127:
:wikitext(box_text)
:wikitext(box_text)
end
end

local template = args.template
local template = args.template
local displayed_links = choose_links(template, args)
local displayed_links = choose_links(template, args)
Line 150: Line 149:
:wikitext(args[1])
:wikitext(args[1])
end
end

local frame = mw.getCurrentFrame()
local frame = mw.getCurrentFrame()
-- hlist -> navbar is best-effort to preserve old Common.css ordering.
-- hlist -> navbar is best-effort to preserve old Common.css ordering.