Line 13: |
Line 13: |
| local marker = '<span class=special_infobox_marker>' | | local marker = '<span class=special_infobox_marker>' |
| local s = sval | | 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, '(<%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 119: |
Line 127: |
| if rowArgs.data then | | if rowArgs.data then |
| root:wikitext( | | root:wikitext( |
− | '[[Category:Pages which use infobox templates with ignored data cells]]' | + | '[[Category:Pages using infobox templates with ignored data cells]]' |
| ) | | ) |
| end | | end |
| elseif rowArgs.data and rowArgs.data:gsub( | | elseif rowArgs.data and rowArgs.data:gsub( |
− | category_in_empty_row_pattern, ''
| + | category_in_empty_row_pattern, '' |
| ):match('^%S') then | | ):match('^%S') then |
| has_rows = true | | has_rows = true |
Line 375: |
Line 383: |
| if args.title then | | if args.title then |
| root:wikitext( | | root:wikitext( |
− | '[[Category:Pages which use embedded infobox templates with the title parameter]]' | + | '[[Category:Pages using 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 which use infobox templates with no data rows]]') | + | root:wikitext('[[Category:Articles using infobox templates with no data rows]]') |
| end | | end |
| end | | end |
Line 386: |
Line 394: |
| Loads the templatestyles for the infobox. | | Loads the templatestyles for the infobox. |
| | | |
− | TODO: load base templatestyles here rather than in MediaWiki:Common.css | + | TODO: FINISH loading base templatestyles here rather than in |
− | We aren't doing it here yet because there are 4-5000 pages with 'raw' infobox
| + | MediaWiki:Common.css. There are 4-5000 pages with 'raw' infobox tables. |
− | tables. See [[Mediawiki_talk:Common.css/to_do#Infobox]] and/or come help :). | + | 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 | + | -- See function description |
− | -- local base_templatestyles = frame:extensionTag{
| + | local base_templatestyles = frame:extensionTag{ |
− | -- name = 'templatestyles', args = { src = cfg.i18n.templatestyles }
| + | name = 'templatestyles', args = { src = 'Module:Infobox/styles.css' } |
− | -- }
| + | } |
− |
| + | |
| local templatestyles = '' | | local templatestyles = '' |
| if args['templatestyles'] then templatestyles = frame:extensionTag{ | | if args['templatestyles'] then templatestyles = frame:extensionTag{ |
Line 420: |
Line 428: |
| | | |
| return table.concat({ | | return table.concat({ |
− | -- base_templatestyles, -- see function description
| + | base_templatestyles, -- see function description |
| templatestyles, | | templatestyles, |
| child_templatestyles, | | child_templatestyles, |
| grandchild_templatestyles | | grandchild_templatestyles |
− | }) | + | }) |
− | | + | end |
| + | |
| + | -- common functions between the child and non child cases |
| + | local function structure_infobox_common() |
| + | renderSubheaders() |
| + | renderImages() |
| + | preprocessRows() |
| + | renderRows() |
| + | renderBelowRow() |
| + | renderNavBar() |
| + | renderItalicTitle() |
| + | renderEmptyRowCategories() |
| + | renderTrackingCategories() |
| + | cleanInfobox() |
| end | | end |
| | | |
Line 448: |
Line 469: |
| :wikitext(args.title) | | :wikitext(args.title) |
| end | | end |
− | | + | structure_infobox_common() |
− | renderSubheaders()
| + | |
− | renderImages()
| |
− | preprocessRows()
| |
− | renderRows()
| |
− | renderBelowRow()
| |
− | renderNavBar()
| |
− | renderItalicTitle()
| |
− | renderEmptyRowCategories() | |
− | renderTrackingCategories() | |
− | cleanInfobox()
| |
− | | |
| return loadTemplateStyles() .. root | | return loadTemplateStyles() .. root |
| end | | end |