17,230
edits
(implement table with groups) |
(couple bugfixes with table) |
||
Line 50: | Line 50: | ||
for _, page in ipairs( pages ) do | for _, page in ipairs( pages ) do | ||
-- parse extra | -- parse extra | ||
local extra = page.extra | local extra = page.extra | ||
page.extra = {} | page.extra = {} | ||
for prop in mw.text.gsplit( extra, ',' ) do | |||
if extra then | |||
for prop in mw.text.gsplit( extra, ',' ) do | |||
if prop then | |||
local propvalue = mw.text.split( prop, ':' ) | |||
page.extra[propvalue[1]] = propvalue[2] or true -- for valueless flags use true | |||
end | |||
end | end | ||
-- remove extra from sortkey | |||
page.sortkey = string.sub( page.sortkey, 1, -string.len( extra ) - 2 ) | |||
end | end | ||
Line 70: | Line 76: | ||
local defaultcell = content:tag( 'tr' ) | local defaultcell = content:tag( 'tr' ) | ||
:tag( 'td' ) | :tag( 'td' ) | ||
:addClass( 'odd' ) | |||
:attr( 'colspan', '2' ) | |||
:css( 'text-align', 'center' ) | |||
renderHList( defaultcell, pagetree.default ) | renderHList( defaultcell, pagetree.default ) | ||
end | end | ||
Line 75: | Line 84: | ||
-- coerce it to a table for easier processing | -- coerce it to a table for easier processing | ||
local groups = type(catprops.groups) == 'table' and catprops.groups or { catprops.groups } | local groups = type(catprops.groups) == 'table' and catprops.groups or { catprops.groups } | ||
for | for index, group in ipairs(groups) do | ||
if( pagetree[group] ) then | if( pagetree[group] ) then | ||
local row = content:tag( 'tr' ) | local row = content:tag( 'tr' ) | ||
row:tag( 'th' ) | row:tag( 'th' ) | ||
:addClass( 'label' ) | |||
:wikitext( group ) | :wikitext( group ) | ||
local cell = row:tag( 'td' ) | local cell = row:tag( 'td' ) | ||
:addClass( (index + (#pagetree.default and 1 or 0)) % 2 == 0 and 'even' or 'odd' ) | |||
renderHList( cell, pagetree[group] ) | renderHList( cell, pagetree[group] ) | ||
end | end |