Navigation menu

Module:Infobox: Difference between revisions

From The Kodiak Republic Wiki

no edit summary
(nix)
No edit summary
Tag: Manual revert
 
(18 intermediate revisions by 7 users not shown)
Line 6:
local category_in_empty_row_pattern = '%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*]]'
local has_rows = false
local lists = {
plainlist_t = {
patterns = {
'^plainlist$',
'%splainlist$',
'^plainlist%s',
'%splainlist%s'
},
found = false,
styles = 'Plainlist/styles.css'
},
hlist_t = {
patterns = {
'^hlist$',
'%shlist$',
'^hlist%s',
'%shlist%s'
},
found = false,
styles = 'Hlist/styles.css'
}
}
 
local function has_list_class(args_to_check)
for _, list in pairs(lists) do
if not list.found then
for _, arg in pairs(args_to_check) do
for _, pattern in ipairs(list.patterns) do
if mw.ustring.find(arg or '', pattern) then
list.found = true
break
end
end
if list.found then break end
end
end
end
end
 
local function fixChildBoxes(sval, tt)
Line 13 ⟶ 51:
local marker = '<span class=special_infobox_marker>'
local s = sval
-- start moving templatestyles and categories inside of table rows
local slast = ''
while slast ~= s do
slast = s
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(%[%[%s*[Cc][Aa][Tt][Ee][Gg][Oo][Rr][Yy]%s*:[^]]*%]%])', '%2%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>%s*)(\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127)', '%2%1')
end
-- end moving templatestyles and categories inside of table rows
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)
Line 104 ⟶ 150:
if rowArgs.header and rowArgs.header ~= '_BLANK_' then
has_rows = true
has_list_class({ rowArgs.rowclass, rowArgs.class, args.headerclass })
root
:tag('tr')
Line 119 ⟶ 167:
if rowArgs.data then
root:wikitext(
'[[Category:Pages which useusing infobox templates with ignored data cells]]'
)
end
elseif rowArgs.data and rowArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
category_in_empty_row_pattern, ''
):match('^%S') then
has_rows = true
has_list_class({ rowArgs.rowclass, rowArgs.class })
local row = root:tag('tr')
row:addClass(rowArgs.rowclass)
Line 159 ⟶ 207:
 
has_rows = true
has_list_class({args.titleclass})
root
:tag('caption')
Line 166 ⟶ 216:
:cssText(args.titlestyle)
:wikitext(args.title)
end
 
Line 172 ⟶ 223:
 
has_rows = true
has_list_class({ args.aboveclass })
root
:tag('tr')
Line 187 ⟶ 240:
 
has_rows = true
has_list_class({ args.belowclass })
root
:tag('tr')
Line 202 ⟶ 257:
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then
has_rows = true
has_list_class({ subheaderArgs.rowclass, subheaderArgs.class })
local row = root:tag('tr')
row:addClass(subheaderArgs.rowclass)
Line 244 ⟶ 301:
 
has_rows = true
has_list_class({ imageArgs.rowclass, imageArgs.class })
local row = root:tag('tr')
row:addClass(imageArgs.rowclass)
Line 355 ⟶ 414:
local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])
if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then
root:wikitext(mw.getCurrentFramerequire()'Module:expandTemplate({title = 'italicItalic title')._main({}))
end
end
Line 375 ⟶ 434:
if args.title then
root:wikitext(
'[[Category:Pages which useusing embedded infobox templates with the title parameter]]'
)
end
elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then
root:wikitext('[[Category:Articles which useusing infobox templates with no data rows]]')
end
end
Line 386 ⟶ 445:
Loads the templatestyles for the infobox.
 
TODO: loadFINISH loading base templatestyles here rather than in MediaWiki:Common.css
WeMediaWiki:Common.css. aren't doing it here yet because thereThere are 4-5000 pages with 'raw' infobox tables.
tables. See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :).
When we do this we should clean up the inline CSS below too.
Will have to do some bizarre conversion category like with sidebar.
 
]=]
local function loadTemplateStyles()
local frame = mw.getCurrentFrame()
local hlist_templatestyles = ''
-- See function description
if lists.hlist_t.found then
-- local base_templatestyles = frame:extensionTag{
hlist_templatestyles = frame:extensionTag{
-- name = 'templatestyles', args = { src = cfg.i18n.templatestyles }
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
local base_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = 'Module:Infobox/styles.css' }
}
 
local templatestyles = ''
if args['templatestyles'] then templatestyles = frame:extensionTag{
templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['templatestyles'] }
}
Line 408 ⟶ 482:
local child_templatestyles = ''
if args['child templatestyles'] then child_templatestyles = frame:extensionTag{
child_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['child templatestyles'] }
}
Line 414 ⟶ 489:
local grandchild_templatestyles = ''
if args['grandchild templatestyles'] then grandchild_templatestyles = frame:extensionTag{
grandchild_templatestyles = frame:extensionTag{
name = 'templatestyles', args = { src = args['grandchild templatestyles'] }
}
end
 
return table.concat({
-- hlist -> plainlist -> base is best-effort to preserve old Common.css ordering.
-- base_templatestyles, -- see function description
-- 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,
child_templatestyles,
grandchild_templatestyles
})
end
 
Line 453 ⟶ 533:
-- @deprecated next; target .infobox-<name>
:cssText(args.bodystyle)
has_list_class({ args.bodyclass })
 
renderTitle()
renderAboveRow()
structure_infobox_common()
 
return loadTemplateStyles() .. root
else
root = mw.html.create()
Line 464 ⟶ 543:
root
:wikitext(args.title)
 
structure_infobox_common()
return root
end
structure_infobox_common()
return loadTemplateStyles() .. root
end
 
Cookies help us deliver our services. By using our services, you agree to our use of cookies.