Module:Infobox: Difference between revisions

support finding plainlist in infobox class fields
Decat tweaks per request on talk
 
(One intermediate revision by one other user not shown)
Line 6: Line 6:
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local has_rows = false
local has_rows = false
local yesno = require("Module:Yesno")
local lists = {
local lists = {
plainlist_t = {
plainlist_t = {
Line 16: Line 17:
found = false,
found = false,
styles = 'Plainlist/styles.css'
styles = 'Plainlist/styles.css'
},
hlist_t = {
patterns = {
'^hlist$',
'%shlist$',
'^hlist%s',
'%shlist%s'
},
found = false,
styles = 'Hlist/styles.css'
}
}
-- TODO: hlist_t goes here when ready to be TStyled, plus relevant
-- implementations below
}
}


Line 157: Line 166:
:cssText(rowArgs.rowcellstyle)
:cssText(rowArgs.rowcellstyle)
:wikitext(fixChildBoxes(rowArgs.header, 'th'))
:wikitext(fixChildBoxes(rowArgs.header, 'th'))
if rowArgs.data then
if rowArgs.data and not yesno(args.decat) then
root:wikitext(
root:wikitext(
'[[Category:Pages using infobox templates with ignored data cells]]'
'[[Category:Pages using infobox templates with ignored data cells]]'
Line 422: Line 431:
-- Render tracking categories. args.decat == turns off tracking categories.
-- Render tracking categories. args.decat == turns off tracking categories.
local function renderTrackingCategories()
local function renderTrackingCategories()
if args.decat == 'yes' then return end
if yesno(args.decat) then return end
if args.child == 'yes' then
if args.child == 'yes' then
if args.title then
if args.title then
Line 446: Line 455:
local function loadTemplateStyles()
local function loadTemplateStyles()
local frame = mw.getCurrentFrame()
local frame = mw.getCurrentFrame()
local hlist_templatestyles = ''
if lists.hlist_t.found then
hlist_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = lists.hlist_t.styles }
}
end
local plainlist_templatestyles = ''
if lists.plainlist_t.found then
plainlist_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = lists.plainlist_t.styles }
}
end
-- See function description
-- See function description
Line 470: Line 493:
grandchild_templatestyles = frame:extensionTag{
grandchild_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
}
end
local plainlist_templatestyles = ''
if lists.plainlist_t.found then
plainlist_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = lists.plainlist_t.styles }
}
}
end
end
return table.concat({
return table.concat({
base_templatestyles, -- see function description
-- hlist -> plainlist -> base is best-effort to preserve old Common.css ordering.
-- this ordering is not a guarantee because the rows of interest invoking
-- each class may not be on a specific page
hlist_templatestyles,
plainlist_templatestyles,
base_templatestyles,
templatestyles,
templatestyles,
child_templatestyles,
child_templatestyles,
grandchild_templatestyles,
grandchild_templatestyles
plainlist_templatestyles
})
})
end
end