https://wiki.abidanarchive.com/index.php?title=Module:Infobox&feed=atom&action=history
Module:Infobox - Revision history
2024-03-29T15:51:29Z
Revision history for this page on the wiki
MediaWiki 1.34.2
https://wiki.abidanarchive.com/index.php?title=Module:Infobox&diff=630&oldid=prev
TransEmo: 1 revision imported
2019-10-13T19:23:38Z
<p>1 revision imported</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">Revision as of 19:23, 13 October 2019</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
TransEmo
https://wiki.abidanarchive.com/index.php?title=Module:Infobox&diff=189&oldid=prev
TransEmo: 1 revision imported
2019-10-13T19:08:15Z
<p>1 revision imported</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">Revision as of 19:08, 13 October 2019</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
TransEmo
https://wiki.abidanarchive.com/index.php?title=Module:Infobox&diff=629&oldid=prev
o>TransEmo: 1 revision imported
2019-10-11T11:39:03Z
<p>1 revision imported</p>
<table class="diff diff-contentalign-left" data-mw="interface">
<tr class="diff-title" lang="en">
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">← Older revision</td>
<td colspan="1" style="background-color: #fff; color: #222; text-align: center;">Revision as of 11:39, 11 October 2019</td>
</tr><tr><td colspan="2" class="diff-notice" lang="en"><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>
o>TransEmo
https://wiki.abidanarchive.com/index.php?title=Module:Infobox&diff=188&oldid=prev
w>Gonnym: Undid revision 906073835 by Gonnym (talk) errors in code were reported
2019-07-13T13:05:36Z
<p>Undid revision 906073835 by <a href="/index.php/Special:Contributions/Gonnym" title="Special:Contributions/Gonnym">Gonnym</a> (<a href="/index.php?title=User_talk:Gonnym&action=edit&redlink=1" class="new" title="User talk:Gonnym (page does not exist)">talk</a>) errors in code were reported</p>
<p><b>New page</b></p><div>--<br />
-- This module implements {{Infobox}}<br />
--<br />
<br />
local p = {}<br />
<br />
local navbar = require('Module:Navbar')._navbar<br />
<br />
local args = {}<br />
local origArgs<br />
local root<br />
<br />
local function notempty( s ) return s and s:match( '%S' ) end<br />
<br />
local function fixChildBoxes(sval, tt)<br />
if notempty(sval) then<br />
local marker = '<span class=special_infobox_marker>'<br />
local s = sval<br />
s = mw.ustring.gsub(s, '(<%s*[Tt][Rr])', marker .. '%1')<br />
s = mw.ustring.gsub(s, '(</[Tt][Rr]%s*>)', '%1' .. marker)<br />
if s:match(marker) then<br />
s = mw.ustring.gsub(s, marker .. '%s*' .. marker, '')<br />
s = mw.ustring.gsub(s, '([\r\n]|-[^\r\n]*[\r\n])%s*' .. marker, '%1')<br />
s = mw.ustring.gsub(s, marker .. '%s*([\r\n]|-)', '%1')<br />
s = mw.ustring.gsub(s, '(</[Cc][Aa][Pp][Tt][Ii][Oo][Nn]%s*>%s*)' .. marker, '%1')<br />
s = mw.ustring.gsub(s, '(<%s*[Tt][Aa][Bb][Ll][Ee][^<>]*>%s*)' .. marker, '%1')<br />
s = mw.ustring.gsub(s, '^(%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')<br />
s = mw.ustring.gsub(s, '([\r\n]%{|[^\r\n]*[\r\n]%s*)' .. marker, '%1')<br />
s = mw.ustring.gsub(s, marker .. '(%s*</[Tt][Aa][Bb][Ll][Ee]%s*>)', '%1')<br />
s = mw.ustring.gsub(s, marker .. '(%s*\n|%})', '%1')<br />
end<br />
if s:match(marker) then<br />
local subcells = mw.text.split(s, marker)<br />
s = ''<br />
for k = 1, #subcells do<br />
if k == 1 then<br />
s = s .. subcells[k] .. '</' .. tt .. '></tr>'<br />
elseif k == #subcells then<br />
local rowstyle = ' style="display:none"'<br />
if notempty(subcells[k]) then rowstyle = '' end<br />
s = s .. '<tr' .. rowstyle ..'><' .. tt .. ' colspan=2>\n' .. subcells[k]<br />
elseif notempty(subcells[k]) then<br />
if (k % 2) == 0 then<br />
s = s .. subcells[k]<br />
else<br />
s = s .. '<tr><' .. tt .. ' colspan=2>\n' .. subcells[k] .. '</' .. tt .. '></tr>'<br />
end<br />
end<br />
end<br />
end<br />
-- the next two lines add a newline at the end of lists for the PHP parser<br />
-- https://en.wikipedia.org/w/index.php?title=Template_talk:Infobox_musical_artist&oldid=849054481<br />
-- remove when [[:phab:T191516]] is fixed or OBE<br />
s = mw.ustring.gsub(s, '([\r\n][%*#;:][^\r\n]*)$', '%1\n')<br />
s = mw.ustring.gsub(s, '^([%*#;:][^\r\n]*)$', '%1\n')<br />
s = mw.ustring.gsub(s, '^([%*#;:])', '\n%1')<br />
s = mw.ustring.gsub(s, '^(%{%|)', '\n%1')<br />
return s<br />
else<br />
return sval<br />
end<br />
end<br />
<br />
local function union(t1, t2)<br />
-- Returns the union of the values of two tables, as a sequence.<br />
local vals = {}<br />
for k, v in pairs(t1) do<br />
vals[v] = true<br />
end<br />
for k, v in pairs(t2) do<br />
vals[v] = true<br />
end<br />
local ret = {}<br />
for k, v in pairs(vals) do<br />
table.insert(ret, k)<br />
end<br />
return ret<br />
end<br />
<br />
local function getArgNums(prefix)<br />
-- Returns a table containing the numbers of the arguments that exist<br />
-- for the specified prefix. For example, if the prefix was 'data', and<br />
-- 'data1', 'data2', and 'data5' exist, it would return {1, 2, 5}.<br />
local nums = {}<br />
for k, v in pairs(args) do<br />
local num = tostring(k):match('^' .. prefix .. '([1-9]%d*)$')<br />
if num then table.insert(nums, tonumber(num)) end<br />
end<br />
table.sort(nums)<br />
return nums<br />
end<br />
<br />
local function addRow(rowArgs)<br />
-- Adds a row to the infobox, with either a header cell<br />
-- or a label/data cell combination.<br />
if rowArgs.header then<br />
root<br />
:tag('tr')<br />
:addClass(rowArgs.rowclass)<br />
:cssText(rowArgs.rowstyle)<br />
:attr('id', rowArgs.rowid)<br />
:tag('th')<br />
:attr('colspan', 2)<br />
:attr('id', rowArgs.headerid)<br />
:addClass(rowArgs.class)<br />
:addClass(args.headerclass)<br />
:css('text-align', 'center')<br />
:cssText(args.headerstyle)<br />
:cssText(rowArgs.rowcellstyle)<br />
:wikitext(fixChildBoxes(rowArgs.header, 'th'))<br />
elseif rowArgs.data then<br />
local row = root:tag('tr')<br />
row:addClass(rowArgs.rowclass)<br />
row:cssText(rowArgs.rowstyle)<br />
row:attr('id', rowArgs.rowid)<br />
if rowArgs.label then<br />
row<br />
:tag('th')<br />
:attr('scope', 'row')<br />
:attr('id', rowArgs.labelid)<br />
:cssText(args.labelstyle)<br />
:cssText(rowArgs.rowcellstyle)<br />
:wikitext(rowArgs.label)<br />
:done()<br />
end<br />
<br />
local dataCell = row:tag('td')<br />
if not rowArgs.label then <br />
dataCell<br />
:attr('colspan', 2)<br />
:css('text-align', 'center') <br />
end<br />
dataCell<br />
:attr('id', rowArgs.dataid)<br />
:addClass(rowArgs.class)<br />
:cssText(rowArgs.datastyle)<br />
:cssText(rowArgs.rowcellstyle)<br />
:wikitext(fixChildBoxes(rowArgs.data, 'td'))<br />
end<br />
end<br />
<br />
local function renderTitle()<br />
if not args.title then return end<br />
<br />
root<br />
:tag('caption')<br />
:addClass(args.titleclass)<br />
:cssText(args.titlestyle)<br />
:wikitext(args.title)<br />
end<br />
<br />
local function renderAboveRow()<br />
if not args.above then return end<br />
<br />
root<br />
:tag('tr')<br />
:tag('th')<br />
:attr('colspan', 2)<br />
:addClass(args.aboveclass)<br />
:css('text-align', 'center')<br />
:css('font-size', '125%')<br />
:css('font-weight', 'bold')<br />
:cssText(args.abovestyle)<br />
:wikitext(fixChildBoxes(args.above,'th'))<br />
end<br />
<br />
local function renderBelowRow()<br />
if not args.below then return end<br />
<br />
root<br />
:tag('tr')<br />
:tag('td')<br />
:attr('colspan', '2')<br />
:addClass(args.belowclass)<br />
:css('text-align', 'center')<br />
:cssText(args.belowstyle)<br />
:wikitext(fixChildBoxes(args.below,'td'))<br />
end<br />
<br />
local function renderSubheaders()<br />
if args.subheader then<br />
args.subheader1 = args.subheader<br />
end<br />
if args.subheaderrowclass then<br />
args.subheaderrowclass1 = args.subheaderrowclass<br />
end<br />
local subheadernums = getArgNums('subheader')<br />
for k, num in ipairs(subheadernums) do<br />
addRow({<br />
data = args['subheader' .. tostring(num)],<br />
datastyle = args.subheaderstyle,<br />
rowcellstyle = args['subheaderstyle' .. tostring(num)],<br />
class = args.subheaderclass,<br />
rowclass = args['subheaderrowclass' .. tostring(num)]<br />
})<br />
end<br />
end<br />
<br />
local function renderImages()<br />
if args.image then<br />
args.image1 = args.image<br />
end<br />
if args.caption then<br />
args.caption1 = args.caption<br />
end<br />
local imagenums = getArgNums('image')<br />
for k, num in ipairs(imagenums) do<br />
local caption = args['caption' .. tostring(num)]<br />
local data = mw.html.create():wikitext(args['image' .. tostring(num)])<br />
if caption then<br />
data<br />
:tag('div')<br />
:cssText(args.captionstyle)<br />
:wikitext(caption)<br />
end<br />
addRow({<br />
data = tostring(data),<br />
datastyle = args.imagestyle,<br />
class = args.imageclass,<br />
rowclass = args['imagerowclass' .. tostring(num)]<br />
})<br />
end<br />
end<br />
<br />
local function renderRows()<br />
-- Gets the union of the header and data argument numbers,<br />
-- and renders them all in order using addRow.<br />
local rownums = union(getArgNums('header'), getArgNums('data'))<br />
table.sort(rownums)<br />
for k, num in ipairs(rownums) do<br />
addRow({<br />
header = args['header' .. tostring(num)],<br />
label = args['label' .. tostring(num)],<br />
data = args['data' .. tostring(num)],<br />
datastyle = args.datastyle,<br />
class = args['class' .. tostring(num)],<br />
rowclass = args['rowclass' .. tostring(num)],<br />
rowstyle = args['rowstyle' .. tostring(num)],<br />
rowcellstyle = args['rowcellstyle' .. tostring(num)],<br />
dataid = args['dataid' .. tostring(num)],<br />
labelid = args['labelid' .. tostring(num)],<br />
headerid = args['headerid' .. tostring(num)],<br />
rowid = args['rowid' .. tostring(num)]<br />
})<br />
end<br />
end<br />
<br />
local function renderNavBar()<br />
if not args.name then return end<br />
<br />
root<br />
:tag('tr')<br />
:tag('td')<br />
:attr('colspan', '2')<br />
:css('text-align', 'right')<br />
:wikitext(navbar{<br />
args.name,<br />
mini = 1,<br />
})<br />
end<br />
<br />
local function renderItalicTitle()<br />
local italicTitle = args['italic title'] and mw.ustring.lower(args['italic title'])<br />
if italicTitle == '' or italicTitle == 'force' or italicTitle == 'yes' then<br />
root:wikitext(mw.getCurrentFrame():expandTemplate({title = 'italic title'}))<br />
end<br />
end<br />
<br />
local function renderTrackingCategories()<br />
if args.decat ~= 'yes' then<br />
if args.child == 'yes' then<br />
if args.title then<br />
root:wikitext('[[Category:Pages which use embedded infobox templates with the title parameter]]')<br />
end<br />
elseif #(getArgNums('data')) == 0 and mw.title.getCurrentTitle().namespace == 0 then<br />
root:wikitext('[[Category:Articles which use infobox templates with no data rows]]')<br />
end<br />
end<br />
end<br />
<br />
local function _infobox()<br />
-- Specify the overall layout of the infobox, with special settings<br />
-- if the infobox is used as a 'child' inside another infobox.<br />
if args.child ~= 'yes' then<br />
root = mw.html.create('table')<br />
<br />
root<br />
:addClass((args.subbox ~= 'yes') and 'infobox' or nil)<br />
:addClass(args.bodyclass)<br />
<br />
if args.subbox == 'yes' then<br />
root<br />
:css('padding', '0')<br />
:css('border', 'none')<br />
:css('margin', '-3px')<br />
:css('width', 'auto')<br />
:css('min-width', '100%')<br />
:css('font-size', '100%')<br />
:css('clear', 'none')<br />
:css('float', 'none')<br />
:css('background-color', 'transparent')<br />
else<br />
root<br />
:css('width', '22em')<br />
end<br />
root<br />
:cssText(args.bodystyle)<br />
<br />
renderTitle()<br />
renderAboveRow()<br />
else<br />
root = mw.html.create()<br />
<br />
root<br />
:wikitext(args.title)<br />
end<br />
<br />
renderSubheaders()<br />
renderImages() <br />
renderRows() <br />
renderBelowRow() <br />
renderNavBar()<br />
renderItalicTitle()<br />
renderTrackingCategories()<br />
<br />
return tostring(root)<br />
end<br />
<br />
local function preprocessSingleArg(argName)<br />
-- If the argument exists and isn't blank, add it to the argument table.<br />
-- Blank arguments are treated as nil to match the behaviour of ParserFunctions.<br />
if origArgs[argName] and origArgs[argName] ~= '' then<br />
args[argName] = origArgs[argName]<br />
end<br />
end<br />
<br />
local function preprocessArgs(prefixTable, step)<br />
-- Assign the parameters with the given prefixes to the args table, in order, in batches<br />
-- of the step size specified. This is to prevent references etc. from appearing in the<br />
-- wrong order. The prefixTable should be an array containing tables, each of which has<br />
-- two possible fields, a "prefix" string and a "depend" table. The function always parses<br />
-- parameters containing the "prefix" string, but only parses parameters in the "depend"<br />
-- table if the prefix parameter is present and non-blank.<br />
if type(prefixTable) ~= 'table' then<br />
error("Non-table value detected for the prefix table", 2)<br />
end<br />
if type(step) ~= 'number' then<br />
error("Invalid step value detected", 2)<br />
end<br />
<br />
-- Get arguments without a number suffix, and check for bad input.<br />
for i,v in ipairs(prefixTable) do<br />
if type(v) ~= 'table' or type(v.prefix) ~= "string" or (v.depend and type(v.depend) ~= 'table') then<br />
error('Invalid input detected to preprocessArgs prefix table', 2)<br />
end<br />
preprocessSingleArg(v.prefix)<br />
-- Only parse the depend parameter if the prefix parameter is present and not blank.<br />
if args[v.prefix] and v.depend then<br />
for j, dependValue in ipairs(v.depend) do<br />
if type(dependValue) ~= 'string' then<br />
error('Invalid "depend" parameter value detected in preprocessArgs')<br />
end<br />
preprocessSingleArg(dependValue)<br />
end<br />
end<br />
end<br />
<br />
-- Get arguments with number suffixes.<br />
local a = 1 -- Counter variable.<br />
local moreArgumentsExist = true<br />
while moreArgumentsExist == true do<br />
moreArgumentsExist = false<br />
for i = a, a + step - 1 do<br />
for j,v in ipairs(prefixTable) do<br />
local prefixArgName = v.prefix .. tostring(i)<br />
if origArgs[prefixArgName] then<br />
moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones.<br />
preprocessSingleArg(prefixArgName)<br />
end<br />
-- Process the depend table if the prefix argument is present and not blank, or<br />
-- we are processing "prefix1" and "prefix" is present and not blank, and<br />
-- if the depend table is present.<br />
if v.depend and (args[prefixArgName] or (i == 1 and args[v.prefix])) then<br />
for j,dependValue in ipairs(v.depend) do<br />
local dependArgName = dependValue .. tostring(i)<br />
preprocessSingleArg(dependArgName)<br />
end<br />
end<br />
end<br />
end<br />
a = a + step<br />
end<br />
end<br />
<br />
function p.infobox(frame)<br />
-- If called via #invoke, use the args passed into the invoking template.<br />
-- Otherwise, for testing purposes, assume args are being passed directly in.<br />
if frame == mw.getCurrentFrame() then<br />
origArgs = frame:getParent().args<br />
else<br />
origArgs = frame<br />
end<br />
<br />
-- Parse the data parameters in the same order that the old {{infobox}} did, so that<br />
-- references etc. will display in the expected places. Parameters that depend on<br />
-- another parameter are only processed if that parameter is present, to avoid<br />
-- phantom references appearing in article reference lists.<br />
preprocessSingleArg('child')<br />
preprocessSingleArg('bodyclass')<br />
preprocessSingleArg('subbox')<br />
preprocessSingleArg('bodystyle')<br />
preprocessSingleArg('title')<br />
preprocessSingleArg('titleclass')<br />
preprocessSingleArg('titlestyle')<br />
preprocessSingleArg('above')<br />
preprocessSingleArg('aboveclass')<br />
preprocessSingleArg('abovestyle')<br />
preprocessArgs({<br />
{prefix = 'subheader', depend = {'subheaderstyle', 'subheaderrowclass'}}<br />
}, 10)<br />
preprocessSingleArg('subheaderstyle')<br />
preprocessSingleArg('subheaderclass')<br />
preprocessArgs({<br />
{prefix = 'image', depend = {'caption', 'imagerowclass'}}<br />
}, 10)<br />
preprocessSingleArg('captionstyle')<br />
preprocessSingleArg('imagestyle')<br />
preprocessSingleArg('imageclass')<br />
preprocessArgs({<br />
{prefix = 'header'},<br />
{prefix = 'data', depend = {'label'}},<br />
{prefix = 'rowclass'},<br />
{prefix = 'rowstyle'},<br />
{prefix = 'rowcellstyle'},<br />
{prefix = 'class'},<br />
{prefix = 'dataid'},<br />
{prefix = 'labelid'},<br />
{prefix = 'headerid'},<br />
{prefix = 'rowid'}<br />
}, 50)<br />
preprocessSingleArg('headerclass')<br />
preprocessSingleArg('headerstyle')<br />
preprocessSingleArg('labelstyle')<br />
preprocessSingleArg('datastyle')<br />
preprocessSingleArg('below')<br />
preprocessSingleArg('belowclass')<br />
preprocessSingleArg('belowstyle')<br />
preprocessSingleArg('name')<br />
args['italic title'] = origArgs['italic title'] -- different behaviour if blank or absent<br />
preprocessSingleArg('decat')<br />
<br />
return _infobox()<br />
end<br />
<br />
return p</div>
w>Gonnym