Editing Module:Sidebar
Appearance
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
require(' | -- | ||
-- This module implements {{Sidebar}} | |||
-- | |||
require('Module:No globals') | |||
local cfg = mw.loadData('Module:Sidebar/configuration') | local cfg = mw.loadData('Module:Sidebar/configuration') | ||
Line 44: | Line 47: | ||
--[[ | --[[ | ||
Finds whether a sidebar has a subgroup sidebar. | Finds whether a sidebar has a subgroup sidebar. | ||
TODO: Remove support for legacy class name | |||
]] | ]] | ||
local function hasSubgroup(s) | local function hasSubgroup(s) | ||
if mw.ustring.find(s, cfg.i18n.pattern.subgroup) then | if mw.ustring.find(s, cfg.i18n.pattern.subgroup) or | ||
mw.ustring.find(s, 'vertical%-navbox%-subgroup') then | |||
return true | return true | ||
else | else | ||
return false | return false | ||
end | end | ||
end | end | ||
Line 138: | Line 68: | ||
args = getArgs(frame) | args = getArgs(frame) | ||
end | end | ||
local root = mw.html.create() | local root = mw.html.create() | ||
local child = args.child and mw.text.trim(args.child) == cfg.i18n.child_yes | local child = args.child and mw.text.trim(args.child) == cfg.i18n.child_yes | ||
Line 148: | Line 77: | ||
-- force collapsibleclass to be sidebar-collapse otherwise output nothing | -- force collapsibleclass to be sidebar-collapse otherwise output nothing | ||
:addClass(collapsibleClass == cfg.i18n.class.collapse and cfg.i18n.class.collapse or nil) | :addClass(collapsibleClass == cfg.i18n.class.collapse and cfg.i18n.class.collapse or nil) | ||
:addClass('vertical-navbox') -- legacy class, TODO: Remove after migrating users | |||
:addClass('nomobile') | :addClass('nomobile') | ||
:addClass(args.float == cfg.i18n.float_none and cfg.i18n.class.float_none or nil) | :addClass(args.float == cfg.i18n.float_none and cfg.i18n.class.float_none or nil) | ||
:addClass(args.float == cfg.i18n.float_left and cfg.i18n.class.float_left or nil) | :addClass(args.float == cfg.i18n.float_left and cfg.i18n.class.float_left or nil) | ||
:addClass(args.wraplinks | :addClass(args.wraplinks == cfg.i18n.wrap_true and cfg.i18n.class.wraplinks or nil) | ||
:addClass(args.bodyclass or args.class) | :addClass(args.bodyclass or args.class) | ||
:css('width', args.width or nil) | :css('width', args.width or nil) | ||
Line 309: | Line 239: | ||
end | end | ||
if not child and | if not child then | ||
if args.navbar ~= cfg.i18n.navbar_none and args.navbar ~= cfg.i18n.navbar_off and | |||
(args.name or frame:getParent():getTitle():gsub(cfg.i18n.pattern.sandbox, '') ~= | |||
cfg.i18n.title_not_to_add_navbar) then | |||
root | |||
:tag('tr') | |||
:tag('td') | |||
:addClass(cfg.i18n.class.navbar) | |||
:cssText(args.navbarstyle) | |||
:wikitext(require('Module:Navbar')._navbar{ | |||
args.name, | |||
mini = 1, | |||
fontstyle = args.navbarfontstyle | |||
}) | |||
end | |||
end | end | ||
local | local sidebar_templatestyles = mw.getCurrentFrame():extensionTag{ | ||
name = 'templatestyles', args = { src = cfg.i18n.templatestyles } | name = 'templatestyles', args = { src = cfg.i18n.templatestyles } | ||
} | } | ||
Line 328: | Line 262: | ||
local templatestyles = '' | local templatestyles = '' | ||
if args['templatestyles'] and args['templatestyles'] ~= '' then | if args['templatestyles'] and args['templatestyles'] ~= '' then | ||
templatestyles = | templatestyles = mw.getCurrentFrame():extensionTag{ | ||
name = 'templatestyles', args = { src = args['templatestyles'] } | name = 'templatestyles', args = { src = args['templatestyles'] } | ||
} | } | ||
Line 335: | Line 269: | ||
local child_templatestyles = '' | local child_templatestyles = '' | ||
if args['child templatestyles'] and args['child templatestyles'] ~= '' then | if args['child templatestyles'] and args['child templatestyles'] ~= '' then | ||
child_templatestyles = | child_templatestyles = mw.getCurrentFrame():extensionTag{ | ||
name = 'templatestyles', args = { src = args['child templatestyles'] } | name = 'templatestyles', args = { src = args['child templatestyles'] } | ||
} | } | ||
Line 342: | Line 276: | ||
local grandchild_templatestyles = '' | local grandchild_templatestyles = '' | ||
if args['grandchild templatestyles'] and args['grandchild templatestyles'] ~= '' then | if args['grandchild templatestyles'] and args['grandchild templatestyles'] ~= '' then | ||
grandchild_templatestyles = | grandchild_templatestyles = mw.getCurrentFrame():extensionTag{ | ||
name = 'templatestyles', args = { src = args['grandchild templatestyles'] } | name = 'templatestyles', args = { src = args['grandchild templatestyles'] } | ||
} | } | ||
Line 348: | Line 282: | ||
return table.concat({ | return table.concat({ | ||
sidebar_templatestyles, | |||
templatestyles, | templatestyles, | ||
child_templatestyles, | child_templatestyles, | ||
grandchild_templatestyles, | grandchild_templatestyles, | ||
tostring(root), | tostring(root), | ||
(child and cfg.i18n.category.child or ''), | (child and cfg.i18n.category.child or ''), | ||
categorizeTemplatesWithInlineStyles(args) | categorizeTemplatesWithInlineStyles(args) | ||
}) | }) | ||
end | end | ||
Line 405: | Line 306: | ||
local contentArgs = {} | local contentArgs = {} | ||
for k, v in pairs(args) do | for k, v in pairs(args) do | ||
Line 424: | Line 320: | ||
:cssText(args.listframestyle) | :cssText(args.listframestyle) | ||
:cssText(args['list' .. num .. 'framestyle']) | :cssText(args['list' .. num .. 'framestyle']) | ||
: | :tag('div') | ||
:addClass(cfg.i18n.class.list_title) | |||
-- don't /need/ a listnumtitleclass because you can do | |||
-- .templateclass .listnumclass .sidebar-list-title | |||
:addClass(args.listtitleclass) | |||
:cssText(args.basestyle) | |||
:cssText(args.listtitlestyle) | |||
:cssText(args['list' .. num .. 'titlestyle']) | |||
:wikitext(trimAndAddAutomaticNewline(args['list' .. num .. 'title'] | |||
or cfg.i18n.default_list_title)) | |||
:done() | |||
:tag('div') | :tag('div') | ||
:addClass(cfg.i18n.class.list_content) | :addClass(cfg.i18n.class.list_content) |