Module:Infobox: Difference between revisions
CaptainChris (talk | contribs) No edit summary Tag: Reverted |
CaptainChris (talk | contribs) No edit summary Tag: Reverted |
||
| Line 3: | Line 3: | ||
function p.infobox(f) | function p.infobox(f) | ||
local args = require('Module:Arguments').getArgs(f) | local args = require('Module:Arguments').getArgs(f) | ||
local titleObject = mw.title.getCurrentTitle() | local titleObject = mw.title.getCurrentTitle() | ||
local title = args.title or titleObject.baseText | local title = args.title or titleObject.baseText | ||
local template = f:getParent():getTitle():lower():gsub('template:', '') | local template = f:getParent():getTitle():lower():gsub('template:', '') | ||
local json = { | local json = { | ||
| Line 17: | Line 17: | ||
if not imageArea and imageArea ~= 'none' then | if not imageArea and imageArea ~= 'none' then | ||
local images = {} | local images = {} | ||
local defaultImageSize = args.defaultimagesize or '150px' | local defaultImageSize = args.defaultimagesize or '150px' | ||
local defaultImageClass = args.defaultimageclass | local defaultImageClass = args.defaultimageclass | ||
| Line 76: | Line 77: | ||
local groupSize = args['group' .. v .. 'size'] or defaultImageSize | local groupSize = args['group' .. v .. 'size'] or defaultImageSize | ||
local groupClass = args['group' .. v .. 'class'] or defaultImageClass | local groupClass = args['group' .. v .. 'class'] or defaultImageClass | ||
local groupImages = {} | local groupImages = {} | ||
| Line 103: | Line 105: | ||
json.images[#json.images + 1] = image | json.images[#json.images + 1] = image | ||
local altText = image .. ': Infobox image for ' .. title .. ' the ' .. template .. '.' | local altText = | ||
image .. | |||
': Infobox image for ' .. | |||
title .. | |||
' the ' .. | |||
template .. | |||
'.' | |||
image = | image = | ||
| Line 227: | Line 235: | ||
if extraText and extraText ~= 'none' then | if extraText and extraText ~= 'none' then | ||
json.extratext = extraText | json.extratext = extraText | ||
extraText = | extraText = | ||
'<div class="infobox-extratext">' .. | '<div class="infobox-extratext">' .. | ||
| Line 234: | Line 243: | ||
extraText = '' | extraText = '' | ||
end | end | ||
local footer = args.footer | local footer = args.footer | ||
| Line 241: | Line 248: | ||
if footer then | if footer then | ||
json.footer = footer | json.footer = footer | ||
footer = '| class="infobox-footer" colspan="2" | ' .. footer | footer = '|-\n| class="infobox-footer" colspan="2" | ' .. footer | ||
else | |||
footer = '' | |||
end | end | ||
json.title = title | json.title = title | ||
local rows = mw.getCurrentFrame():preprocess(args.rows or '') | |||
local html = { | local html = { | ||
'<div class="infobox">', | '<div class="infobox">', | ||
'<div class="infobox-title">' .. title .. '</div>', | '<div class="infobox-title">' .. title .. '</div>', | ||
imageArea .. extraText, | |||
'{| class="infobox-rows" cellspacing="1" cellpadding="4"', | '{| class="infobox-rows" cellspacing="1" cellpadding="4"', | ||
rows, | |||
footer, | |||
footer | |||
'|}', | '|}', | ||
'</div>' | '</div>' | ||