Changes

Jump to navigation Jump to search
283 bytes added ,  18:10, 29 December 2025
Re-add optimizations for child=yes (avoid duplicated templatestyles and categories). Implement :attr('role', 'navigation') per edit request on talk page.
Line 45: Line 45:  
Finds whether a sidebar has a subgroup sidebar.
 
Finds whether a sidebar has a subgroup sidebar.
 
]]
 
]]
local function hasSubgroup(s)
+
local function detectChild(s)
 
if mw.ustring.find(s, cfg.i18n.pattern.subgroup) then
 
if mw.ustring.find(s, cfg.i18n.pattern.subgroup) then
 
return true
 
return true
Line 96: Line 96:  
end
 
end
 
 
local plainlist_styles = add_list_templatestyles('plainlist', 'Plainlist/styles.css')
+
local plainlist_styles = add_list_templatestyles('plainlist', cfg.i18n.templatestyles.plainlist)
local hlist_styles = add_list_templatestyles('hlist', 'Hlist/styles.css')
+
local hlist_styles = add_list_templatestyles('hlist', cfg.i18n.templatestyles.hlist)
 
 
 
-- a second workaround for [[phab:T303378]]
 
-- a second workaround for [[phab:T303378]]
Line 104: Line 104:  
if has_navbar(args.navbar, args.name) and hlist_styles == '' then
 
if has_navbar(args.navbar, args.name) and hlist_styles == '' then
 
hlist_styles = frame:extensionTag{
 
hlist_styles = frame:extensionTag{
name = 'templatestyles', args = { src = 'Hlist/styles.css' }
+
name = 'templatestyles', args = { src = cfg.i18n.templatestyles.hlist}
 
}
 
}
 
end
 
end
+
 
 
-- hlist -> plainlist is best-effort to preserve old Common.css ordering. [hlist_note]
 
-- hlist -> plainlist is best-effort to preserve old Common.css ordering. [hlist_note]
 
return hlist_styles .. plainlist_styles
 
return hlist_styles .. plainlist_styles
Line 116: Line 116:  
-- table. then remove all templatestyles markers from the arg
 
-- table. then remove all templatestyles markers from the arg
 
local function move_hiding_templatestyles(args)
 
local function move_hiding_templatestyles(args)
local gfind = string.gfind
+
local gmatch = string.gmatch
 
local gsub = string.gsub
 
local gsub = string.gsub
 
local templatestyles_markers = {}
 
local templatestyles_markers = {}
 
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
 
local strip_marker_pattern = '(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)'
 
for k, arg in pairs(args) do
 
for k, arg in pairs(args) do
for marker in gfind(arg, strip_marker_pattern) do
+
for marker in gmatch(arg, strip_marker_pattern) do
 
table.insert(templatestyles_markers, marker)
 
table.insert(templatestyles_markers, marker)
 
end
 
end
Line 144: Line 144:  
root = root:tag('table')
 
root = root:tag('table')
 
if not child then
 
if not child then
root  
+
root
 
:addClass(cfg.i18n.class.sidebar)
 
:addClass(cfg.i18n.class.sidebar)
-- 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('nomobile')
 
:addClass('nomobile')
Line 153: Line 153:  
:addClass(args.wraplinks ~= cfg.i18n.wrap_true and cfg.i18n.class.wraplinks or nil)
 
: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)
 +
:attr('role', 'navigation')
 
:css('width', args.width or nil)
 
:css('width', args.width or nil)
 
:cssText(args.bodystyle or args.style)
 
:cssText(args.bodystyle or args.style)
Line 262: Line 263:  
end
 
end
    +
local hasChild = false
 
for i, num in ipairs(rowNums) do
 
for i, num in ipairs(rowNums) do
 
local heading = args['heading' .. num]
 
local heading = args['heading' .. num]
Line 280: Line 282:  
local content = args['content' .. num]
 
local content = args['content' .. num]
 
if content then
 
if content then
 +
local baseContentClass = cfg.i18n.class.content
 +
if detectChild(content) then
 +
baseContentClass = cfg.i18n.class.content_with_subgroup
 +
hasChild = true
 +
end
 
root
 
root
 
:tag('tr')
 
:tag('tr')
 
:tag('td')
 
:tag('td')
:addClass(hasSubgroup(content) and cfg.i18n.class.content_with_subgroup
+
:addClass(baseContentClass)
or cfg.i18n.class.content)
   
:addClass(args.contentclass)
 
:addClass(args.contentclass)
 
:addClass(args['content' .. num .. 'class'])
 
:addClass(args['content' .. num .. 'class'])
Line 322: Line 328:  
end
 
end
 
 
local base_templatestyles = frame:extensionTag{
+
local base_templatestyles = ''
name = 'templatestyles', args = { src = cfg.i18n.templatestyles }
+
if not child then
}
+
base_templatestyles = frame:extensionTag{
 +
name = 'templatestyles', args = { src = cfg.i18n.templatestyles.sidebar }
 +
}
 +
end
 
 
 
local templatestyles = ''
 
local templatestyles = ''
Line 355: Line 364:  
hiding_templatestyles,
 
hiding_templatestyles,
 
tostring(root),
 
tostring(root),
(child and cfg.i18n.category.child or ''),
+
(hasChild and cfg.i18n.category.child or ''),
 
categorizeTemplatesWithInlineStyles(args)
 
categorizeTemplatesWithInlineStyles(args)
 
})
 
})
Line 383: Line 392:  
:cssText(args.basestyle)
 
:cssText(args.basestyle)
 
:cssText(args.listtitlestyle)
 
:cssText(args.listtitlestyle)
 +
:cssText('color: var(--color-base)')
 
:cssText(args['list' .. num .. 'titlestyle'])
 
:cssText(args['list' .. num .. 'titlestyle'])
 
:node(title)
 
:node(title)
Anonymous user

Navigation menu