Editing Module:Infobox
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 5: | Line 5: | ||
local empty_row_categories = {} | local empty_row_categories = {} | ||
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 function fixChildBoxes(sval, tt) | local function fixChildBoxes(sval, tt) | ||
Line 51: | Line 12: | ||
local marker = '<span class=special_infobox_marker>' | local marker = '<span class=special_infobox_marker>' | ||
local s = sval | local s = sval | ||
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1') | s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1') | ||
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker) | s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker) | ||
Line 103: | Line 56: | ||
else | else | ||
return sval | return sval | ||
end | end | ||
end | end | ||
Line 149: | Line 94: | ||
if rowArgs.header and rowArgs.header ~= '_BLANK_' then | if rowArgs.header and rowArgs.header ~= '_BLANK_' then | ||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 167: | Line 109: | ||
if rowArgs.data then | if rowArgs.data then | ||
root:wikitext( | root:wikitext( | ||
'[[Category:Pages | '[[Category:Pages which use infobox templates with ignored data cells]]' | ||
) | ) | ||
end | end | ||
elseif rowArgs.data and rowArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then | elseif rowArgs.data and rowArgs.data:gsub( | ||
category_in_empty_row_pattern, '' | |||
):match('^%S') then | |||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:addClass(rowArgs.rowclass) | row:addClass(rowArgs.rowclass) | ||
Line 206: | Line 147: | ||
if not args.title then return end | if not args.title then return end | ||
root | root | ||
:tag('caption') | :tag('caption') | ||
Line 216: | Line 154: | ||
:cssText(args.titlestyle) | :cssText(args.titlestyle) | ||
:wikitext(args.title) | :wikitext(args.title) | ||
end | end | ||
Line 222: | Line 159: | ||
if not args.above then return end | if not args.above then return end | ||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 239: | Line 173: | ||
if not args.below then return end | if not args.below then return end | ||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 256: | Line 187: | ||
if subheaderArgs.data and | if subheaderArgs.data and | ||
subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then | subheaderArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then | ||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:addClass(subheaderArgs.rowclass) | row:addClass(subheaderArgs.rowclass) | ||
Line 299: | Line 227: | ||
if imageArgs.data and | if imageArgs.data and | ||
imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then | imageArgs.data:gsub(category_in_empty_row_pattern, ''):match('^%S') then | ||
local row = root:tag('tr') | local row = root:tag('tr') | ||
Line 399: | Line 324: | ||
if not args.name then return end | if not args.name then return end | ||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 414: | Line 338: | ||
local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title']) | local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title']) | ||
if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then | if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then | ||
root:wikitext( | root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'})) | ||
end | end | ||
end | end | ||
Line 434: | Line 358: | ||
if args.title then | if args.title then | ||
root:wikitext( | root:wikitext( | ||
'[[Category:Pages | '[[Category:Pages which use embedded infobox templates with the title parameter]]' | ||
) | ) | ||
end | end | ||
elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then | elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then | ||
root:wikitext('[[Category:Articles | root:wikitext('[[Category:Articles which use infobox templates with no data rows]]') | ||
end | end | ||
end | end | ||
Line 445: | Line 369: | ||
Loads the templatestyles for the infobox. | Loads the templatestyles for the infobox. | ||
TODO: | TODO: load base templatestyles here rather than in MediaWiki:Common.css | ||
MediaWiki:Common.css | We aren't doing it here yet because there are 4-5000 pages with 'raw' infobox | ||
See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :). | 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. | When we do this we should clean up the inline CSS below too. | ||
Will have to do some bizarre conversion category like with sidebar. | Will have to do some bizarre conversion category like with sidebar. | ||
]=] | ]=] | ||
local function loadTemplateStyles() | local function loadTemplateStyles() | ||
local frame = mw.getCurrentFrame() | local frame = mw.getCurrentFrame() | ||
-- See function description | |||
-- local base_templatestyles = frame:extensionTag{ | |||
-- name = 'templatestyles', args = { src = cfg.i18n.templatestyles } | |||
-- } | |||
local templatestyles = '' | local templatestyles = '' | ||
if args['templatestyles'] then | if args['templatestyles'] then templatestyles = frame:extensionTag{ | ||
name = 'templatestyles', args = { src = args['templatestyles'] } | name = 'templatestyles', args = { src = args['templatestyles'] } | ||
} | } | ||
Line 482: | Line 391: | ||
local child_templatestyles = '' | local child_templatestyles = '' | ||
if args['child templatestyles'] then | if args['child templatestyles'] then child_templatestyles = frame:extensionTag{ | ||
name = 'templatestyles', args = { src = args['child templatestyles'] } | name = 'templatestyles', args = { src = args['child templatestyles'] } | ||
} | } | ||
Line 489: | Line 397: | ||
local grandchild_templatestyles = '' | local grandchild_templatestyles = '' | ||
if args['grandchild templatestyles'] then | if args['grandchild templatestyles'] then grandchild_templatestyles = frame:extensionTag{ | ||
name = 'templatestyles', args = { src = args['grandchild templatestyles'] } | name = 'templatestyles', args = { src = args['grandchild templatestyles'] } | ||
} | } | ||
end | end | ||
return table.concat({ | return table.concat({ | ||
-- base_templatestyles, -- see function description | |||
templatestyles, | templatestyles, | ||
child_templatestyles, | child_templatestyles, | ||
grandchild_templatestyles | grandchild_templatestyles | ||
} | }) | ||
end | end | ||
Line 533: | Line 422: | ||
-- @deprecated next; target .infobox-<name> | -- @deprecated next; target .infobox-<name> | ||
:cssText(args.bodystyle) | :cssText(args.bodystyle) | ||
renderTitle() | renderTitle() | ||
Line 544: | Line 431: | ||
:wikitext(args.title) | :wikitext(args.title) | ||
end | end | ||
renderSubheaders() | |||
return loadTemplateStyles() .. root | renderImages() | ||
preprocessRows() | |||
renderRows() | |||
renderBelowRow() | |||
renderNavBar() | |||
renderItalicTitle() | |||
renderEmptyRowCategories() | |||
renderTrackingCategories() | |||
return loadTemplateStyles() .. tostring(root) | |||
end | end | ||