Module:Infobox:修订间差异
无编辑摘要 |
小 导入1个版本 |
||
| (未显示3个用户的3个中间版本) | |||
| 第1行: | 第1行: | ||
-- 中文的此模块对比英文维基多解析了overimage, overcaption, | -- 中文的此模块对比英文维基多解析了overimage, overcaption, | ||
-- overimagerowclass以及header/labal/data*style参数。 | -- overimagerowclass以及header/labal/data*style参数。 | ||
local p = {} | local p = {} | ||
local args = {} | local args = {} | ||
local origArgs = {} | local origArgs = {} | ||
local root | local root | ||
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 has_rows = false | local has_rows = false | ||
local yesno = require("Module:Yesno") | |||
local lists = { | local lists = { | ||
plainlist_t = { | plainlist_t = { | ||
| 第49行: | 第47行: | ||
end | end | ||
end | end | ||
end | |||
local function isUntitledChildBox(sval) | |||
return sval and ( sval:match( '^%s*<%s*[Tt][Rr]' ) or sval:match( '^%s*\127[^\127]*UNIQ%-%-templatestyles%-%x+%-QINU[^\127]*\127%s*<%s*[Tt][Rr]' ) ) | |||
end | end | ||
| 第161行: | 第163行: | ||
:tag('tr') | :tag('tr') | ||
:addClass(rowArgs.rowclass) | :addClass(rowArgs.rowclass) | ||
:addClass( isUntitledChildBox( rowArgs.header ) and 'infobox-hiddenrow' or nil ) | |||
:cssText(rowArgs.rowstyle) | :cssText(rowArgs.rowstyle) | ||
:tag('th') | :tag('th') | ||
| 第172行: | 第175行: | ||
:cssText(rowArgs.rowcellstyle) | :cssText(rowArgs.rowcellstyle) | ||
:wikitext(fixChildBoxes(rowArgs.header, 'th')) | :wikitext(fixChildBoxes(rowArgs.header, 'th')) | ||
if rowArgs.data then | if rowArgs.data and not yesno(args.decat) then | ||
root:wikitext( | root:wikitext( | ||
'[[Category:使用已忽略数据行信息框模板的条目]]' | '[[Category:使用已忽略数据行信息框模板的条目]]' | ||
| 第195行: | 第198行: | ||
:wikitext(rowArgs.label) | :wikitext(rowArgs.label) | ||
:done() | :done() | ||
else | |||
row:addClass( isUntitledChildBox( rowArgs.data ) and 'infobox-hiddenrow' or nil ) | |||
end | end | ||
| 第236行: | 第241行: | ||
root | root | ||
:tag('tr') | :tag('tr') | ||
:addClass( isUntitledChildBox( args.above ) and 'infobox-hiddenrow' or nil ) | |||
:tag('th') | :tag('th') | ||
:attr('colspan', '2') | :attr('colspan', '2') | ||
| 第253行: | 第259行: | ||
root | root | ||
:tag('tr') | :tag('tr') | ||
:addClass( isUntitledChildBox( args.below ) and 'infobox-hiddenrow' or nil ) | |||
:tag('td') | :tag('td') | ||
:attr('colspan', '2') | :attr('colspan', '2') | ||
| 第270行: | 第277行: | ||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:addClass(subheaderArgs.rowclass) | row:addClass(subheaderArgs.rowclass) | ||
row:addClass( isUntitledChildBox( subheaderArgs.data ) and 'infobox-hiddenrow' or nil ) | |||
local dataCell = row:tag('td') | local dataCell = row:tag('td') | ||
| 第314行: | 第322行: | ||
local row = root:tag('tr') | local row = root:tag('tr') | ||
row:addClass(imageArgs.rowclass) | row:addClass(imageArgs.rowclass) | ||
row:addClass( isUntitledChildBox( imageArgs.data ) and 'infobox-hiddenrow' or nil ) | |||
local dataCell = row:tag('td') | local dataCell = row:tag('td') | ||
| 第461行: | 第470行: | ||
-- Render tracking categories. args.decat == turns off tracking categories. | -- Render tracking categories. args.decat == turns off tracking categories. | ||
local function renderTrackingCategories() | local function renderTrackingCategories() | ||
if args.decat | if yesno(args.decat) then return end | ||
if args.child == 'yes' then | if args.child == 'yes' then | ||
if args.title then | if args.title then | ||
| 第500行: | 第509行: | ||
end | end | ||
-- See function description | |||
local base_templatestyles = frame:extensionTag{ | local base_templatestyles = frame:extensionTag{ | ||
name = 'templatestyles', args = { src = 'Module:Infobox/styles.css' } | name = 'templatestyles', args = { src = 'Module:Infobox/styles.css' } | ||
} | } | ||
| 第512行: | 第517行: | ||
if args['templatestyles'] then | if args['templatestyles'] then | ||
templatestyles = frame:extensionTag{ | templatestyles = frame:extensionTag{ | ||
name = 'templatestyles', | name = 'templatestyles', args = { src = args['templatestyles'] } | ||
} | } | ||
end | end | ||
| 第540行: | 第536行: | ||
return table.concat({ | return table.concat({ | ||
-- hlist -> plainlist -> base is best-effort to preserve old Common.css ordering. | |||
-- this ordering is not a guarantee because the rows of interest invoking | |||
-- each class may not be on a specific page | |||
hlist_templatestyles, | hlist_templatestyles, | ||
plainlist_templatestyles, | plainlist_templatestyles, | ||
base_templatestyles, | base_templatestyles, | ||
templatestyles, | templatestyles, | ||
child_templatestyles, | child_templatestyles, | ||
| 第569行: | 第567行: | ||
if args.child ~= 'yes' then | if args.child ~= 'yes' then | ||
root = mw.html.create('table') | root = mw.html.create('table') | ||
root | root | ||
:addClass(args.subbox == 'yes' and 'infobox-subbox' or 'infobox') | :addClass(args.subbox == 'yes' and 'infobox-subbox' or 'infobox') | ||
| 第751行: | 第748行: | ||
origArgs = frame | origArgs = frame | ||
end | end | ||
parseDataParameters() | parseDataParameters() | ||
return | return _infobox() | ||
end | end | ||
-- For calling via #invoke within a template | |||
function p.infoboxTemplate(frame) | function p.infoboxTemplate(frame) | ||
origArgs = {} | origArgs = {} | ||
for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end | for k,v in pairs(frame.args) do origArgs[k] = mw.text.trim(v) end | ||
parseDataParameters() | parseDataParameters() | ||
return | return _infobox() | ||
end | end | ||
return p | return p | ||