Module:Navboxes: Difference between revisions
Appearance
Content deleted Content added
test |
No edit summary |
||
Line 8: | Line 8: | ||
end |
end |
||
function |
local function navboxes(args, list) |
||
⚫ | |||
local navbar = (args['state'] and args['state'] == 'off') and 'off' or 'plain' |
local navbar = (args['state'] and args['state'] == 'off') and 'off' or 'plain' |
||
local title = args['title'] or 'Links to related articles' |
local title = args['title'] or 'Links to related articles' |
||
⚫ | |||
local titlestyle = 'background:' .. (args['bg'] or '#e8e8ff') .. ';' |
local titlestyle = 'background:' .. (args['bg'] or '#e8e8ff') .. ';' |
||
.. (isnotempty(args['fg']) and ('color:' .. args['fg'] .. ';') or '') |
.. (isnotempty(args['fg']) and ('color:' .. args['fg'] .. ';') or '') |
||
.. (isnotempty(args['bordercolor']) and ('border: 1px solid ' .. args['bordercolor'] .. ';') or '') |
.. (isnotempty(args['bordercolor']) and ('border: 1px solid ' .. args['bordercolor'] .. ';') or '') |
||
.. (args['titlestyle'] or '') |
.. (args['titlestyle'] or '') |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
navbar = navbar, title = title, |
navbar = navbar, title = title, |
||
list1 = |
list1 = list, |
||
state = args['state'] or 'collapsed', |
state = args['state'] or 'collapsed', |
||
titlestyle = titlestyle, |
titlestyle = titlestyle, |
||
Line 31: | Line 23: | ||
listpadding = '0px', |
listpadding = '0px', |
||
tracking = 'no' |
tracking = 'no' |
||
}) |
|||
⚫ | |||
end |
|||
function p.top(frame) |
|||
⚫ | |||
local parts = mw.ustring.split(navboxes(args, '<ADD LIST HERE>'), '<ADD LIST HERE>') |
|||
return parts[1] |
|||
end |
|||
function p.bottom(frame) |
|||
local args = {} |
|||
local parts = mw.ustring.split(navboxes(args, '<ADD LIST HERE>'), '<ADD LIST HERE>') |
|||
return parts[2] |
|||
end |
|||
function p.navbox(frame) |
|||
local args = frame:getParent().args |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
end |
end |
||
Revision as of 15:12, 11 October 2018
![]() | This Lua module is used on approximately 63,000 pages and changes may be widely noticed. Test changes in the module's /sandbox or /testcases subpages, or in your own module sandbox. Consider discussing changes on the talk page before implementing them. |
![]() | This module depends on the following other modules: |
Implements most of {{Navboxes}}.
-- This implements Template:navboxes
local p = {}
local Navbox = require('Module:Navbox')
local function isnotempty(s)
return s and s:match( '^%s*(.-)%s*$' ) ~= ''
end
local function navboxes(args, list)
local navbar = (args['state'] and args['state'] == 'off') and 'off' or 'plain'
local title = args['title'] or 'Links to related articles'
local titlestyle = 'background:' .. (args['bg'] or '#e8e8ff') .. ';'
.. (isnotempty(args['fg']) and ('color:' .. args['fg'] .. ';') or '')
.. (isnotempty(args['bordercolor']) and ('border: 1px solid ' .. args['bordercolor'] .. ';') or '')
.. (args['titlestyle'] or '')
return Navbox._navbox({
navbar = navbar, title = title,
list1 = list,
state = args['state'] or 'collapsed',
titlestyle = titlestyle,
liststyle = 'font-size:114%',
listpadding = '0px',
tracking = 'no'
})
end
function p.top(frame)
local args = frame:getParent().args
local parts = mw.ustring.split(navboxes(args, '<ADD LIST HERE>'), '<ADD LIST HERE>')
return parts[1]
end
function p.bottom(frame)
local args = {}
local parts = mw.ustring.split(navboxes(args, '<ADD LIST HERE>'), '<ADD LIST HERE>')
return parts[2]
end
function p.navbox(frame)
local args = frame:getParent().args
local list = args['list1'] or args['list'] or ''
local track_cats = ''
if list == '' then
if mw.title.getCurrentTitle().namespace == 0 then
track_cats = '[[Category:Navboxes template with no content]]'
end
end
return navboxes(args, list) .. track_cats
end
return p