182
个编辑
更改
无编辑摘要
--
-- This module implements {{Infobox}}
-- 中文的此模块对比英文维基多解析了overimage, overcaption,
-- overimagerowclass以及header/labal/data*style参数。
--
local p = {}
local origArgs
local root
local function union(t1, t2)
:addClass(args.headerclass)
:css('text-align', 'center')
:cssText(argsrowArgs.headerstyle) :cssText(rowArgs.rowcellstyle) :wikitext(fixChildBoxes(rowArgs.header, 'th'))
elseif rowArgs.data then
local row = root:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('text-align', 'left')
:attr('id', rowArgs.labelid)
:cssText(argsrowArgs.labelstyle) :cssText(rowArgs.rowcellstyle)
:wikitext(rowArgs.label)
:done()
:addClass(rowArgs.class)
:cssText(rowArgs.datastyle)
:cssTextnewline(rowArgs.rowcellstyle) :wikitext(fixChildBoxes(rowArgs.data, 'td'))
end
end
local function renderOverImage()
if not args.overimage then return end
local row = root:tag('tr')
row:addClass(args.overimagerowclass)
local topImage = row:tag('td')
topImage:attr('colspan', 2)
topImage:addClass(args.imageclass)
topImage:cssText(args.imagestyle)
topImage:css('text-align', 'center')
if args.overcaption and args.captionstyle then
topImage:wikitext(args.overimage .. '<br /><span style=\"' .. args.captionstyle .. '\">' .. args.overcaption .. '</span>')
else
if args.overcaption then
topImage:wikitext(args.overimage .. '<br />' .. args.overcaption)
else
topImage:wikitext(args.overimage)
end
end
end
:addClass(args.titleclass)
:cssText(args.titlestyle)
:wikitext('\'\'\'' .. args.title.. '\'\'\'')
end
:css('font-weight', 'bold')
:cssText(args.abovestyle)
:wikitext(fixChildBoxes(args.above,'th'))
end
:css('text-align', 'center')
:cssText(args.belowstyle)
:newline() :wikitext(fixChildBoxes(args.below,'td'))
end
addRow({
data = args['subheader' .. tostring(num)],
datastyle = args.subheaderstyle, rowcellstyle = or args['subheaderstyle' .. tostring(num)],
class = args.subheaderclass,
rowclass = args['subheaderrowclass' .. tostring(num)]
addRow({
header = args['header' .. tostring(num)],
headerstyle = (args.headerstyle or '') .. (args.headerstyle and ';' or '') .. (args['header' .. tostring(num) .. 'style'] or ''),
label = args['label' .. tostring(num)],
labelstyle = (args.labelstyle or '') .. (args.labelstyle and ';' or '') .. (args['label' .. tostring(num) .. 'style'] or ''),
data = args['data' .. tostring(num)],
datastyle = (args.datastyleor '') .. (args.datastyle and ';' or '') .. (args['data' .. tostring(num) .. 'style'] or ''),
class = args['class' .. tostring(num)],
rowclass = args['rowclass' .. tostring(num)],
rowstyle = args['rowstyle' .. tostring(num)],
dataid = args['dataid' .. tostring(num)],
labelid = args['labelid' .. tostring(num)],
local function renderTrackingCategories()
if args.decat ~= 'yes' then
end
end
root
:addClass((args.subbox ~= 'yes') and 'infobox' or nil)
:addClass(args.bodyclass)
:attr('cellspacing', 3)
:css('border-spacing', '3px')
if args.subbox == 'yes' then
:css('width', 'auto')
:css('min-width', '100%')
:css('font-size', '100%small')
:css('clear', 'none')
:css('float', 'none')
root
:css('width', '22em')
:css('text-align', 'left')
:css('font-size', 'small')
:css('line-height', '1.5em')
end
root
end
renderOverImage()
renderSubheaders()
renderImages()
preprocessSingleArg(dependArgName)
end
end
end
end
a = a + step
end
end
function preprocessSpecificStyle(styleTable, step)
-- Assign the parameters *style to the args table
local a = 1 -- Counter variable.
local moreArgumentsExist = true
while moreArgumentsExist == true do
moreArgumentsExist = false
for i = a,a + step - 1 do
for j,v in ipairs(styleTable) do
local styleArgName = v.arg .. tostring(i) .. 'style'
if origArgs[styleArgName] then
moreArgumentsExist = true -- Do another loop if any arguments are found, even blank ones.
preprocessSingleArg(styleArgName)
end
end
preprocessSingleArg('subbox')
preprocessSingleArg('bodystyle')
preprocessSingleArg('overimage')
preprocessSingleArg('overcaption')
preprocessSingleArg('overimagerowclass')
preprocessSingleArg('title')
preprocessSingleArg('titleclass')
{prefix = 'rowclass'},
{prefix = 'rowstyle'},
{prefix = 'class'},
{prefix = 'dataid'},
{prefix = 'headerid'},
{prefix = 'rowid'}
}, 5080) preprocessSpecificStyle({ {arg = 'header'}, {arg = 'label'}, {arg = 'data'} }, 80)
preprocessSingleArg('headerclass')
preprocessSingleArg('headerstyle')