@DeletedUser41170185 (talk | contribs) mNo edit summary |
Lemoncream (talk | contribs) No edit summary |
||
(17 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
⚫ | |||
⚫ | |||
local p = {} |
local p = {} |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
+ | } |
||
+ | |||
− | function p.main( |
+ | function p.main(frame) |
− | + | local args = getArgs(frame, { |
|
⚫ | |||
+ | wrappers = { 'Template:Infobox' }, |
||
+ | trim = false |
||
+ | }) |
||
⚫ | |||
end |
end |
||
− | function p._main( |
+ | function p._main(args) |
+ | local infobox = mw.html.create('table') |
||
⚫ | |||
+ | :addClass('infobox') |
||
⚫ | |||
+ | :newline() |
||
⚫ | |||
+ | -- Add the infobox title. |
||
⚫ | |||
+ | :tag('tr') |
||
− | |||
+ | :tag('th') |
||
− | local infobox = '{| class="infobox"\n| colspan="2" style="text-align:center; color:' .. title_textcolor .. '; background-color:' .. title_background .. ';" | <span style="font-weight:bold;">' .. args["title"] .. '</span>\n|-\n| colspan="2" style="text-align:center;"|\n|-\n' |
||
+ | :attr('colspan', 2) |
||
− | |||
+ | :css('background', args['title-bgcolor'] or default['title-bgcolor']) |
||
⚫ | |||
+ | :css('text-align', 'center') |
||
⚫ | |||
+ | :css('color', args['title-textcolor'] or default['title-textcolor']) |
||
− | infobox = infobox .. '| colspan="2" | [[File:' .. args["image"] .. '|center|' .. image_size .. ']]\n|-\n' |
||
+ | :css('font-weight', 'bold') |
||
⚫ | |||
+ | :wikitext(args['title']) |
||
− | |||
+ | :done() |
||
⚫ | |||
+ | :done() |
||
⚫ | |||
+ | :newline() |
||
⚫ | |||
− | infobox = infobox .. '| colspan="2" style="text-align:center; color:' .. heading_textcolor .. '; background-color:' .. heading_background .. '" | <span style="font-weight:bold;">' .. args["heading" .. n] .. '</span>\n|-\n' |
||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | infobox = infobox .. '| colspan="2" style="' .. style .. '" | ' .. args["value" .. n] .. '\n|-\n' |
||
⚫ | |||
− | else |
||
− | if args["value" .. n] then |
||
− | infobox = infobox .. '!' .. args['trait' .. n] .. ':\n| ' .. args["value" .. n] .. '\n|-\n' |
||
⚫ | |||
− | end |
||
− | |||
⚫ | |||
− | end |
||
⚫ | |||
− | infobox = infobox .. '|}' |
||
⚫ | |||
− | |||
+ | :tag('tr') |
||
⚫ | |||
+ | :tag('td') |
||
+ | :attr('colspan', 2) |
||
+ | :wikitext(string.format('[[File:%s|%s]]', args['image'], args['image-size'] or default['image-size'])) |
||
+ | :done() |
||
+ | :done() |
||
+ | :newline() |
||
⚫ | |||
+ | |||
+ | local i = 1 |
||
⚫ | |||
+ | -- Insert headings if necessary. |
||
⚫ | |||
+ | infobox |
||
+ | :tag('tr') |
||
+ | :tag('td') |
||
+ | :attr('colspan', 2) |
||
+ | :css('background', args['heading-bgcolor'] or default['heading-bgcolor']) |
||
+ | :css('text-align', 'center') |
||
+ | :css('color', args['heading-textcolor'] or default['heading-textcolor']) |
||
+ | :css('font-weight', 'bold') |
||
+ | :wikitext(args['heading' .. i]) |
||
+ | :done() |
||
+ | :done() |
||
+ | :newline() |
||
⚫ | |||
+ | |||
⚫ | |||
+ | infobox |
||
+ | :tag('tr') |
||
+ | :tag('td') |
||
+ | :attr('colspan', 2) |
||
⚫ | |||
+ | :wikitext(args['value' .. i]) |
||
+ | :done() |
||
+ | :done() |
||
+ | :newline() |
||
⚫ | |||
+ | infobox |
||
+ | :tag('tr') |
||
+ | :tag('th') |
||
+ | :css('text-align', 'right') |
||
+ | :wikitext(args['trait' .. i] .. ':') |
||
+ | :done() |
||
+ | :tag('td') |
||
+ | :wikitext(args['value' .. i]) |
||
+ | :done() |
||
+ | :done() |
||
+ | :newline() |
||
⚫ | |||
+ | |||
⚫ | |||
⚫ | |||
+ | |||
+ | return infobox |
||
end |
end |
||
+ | |||
return p |
return p |
Revision as of 01:38, 1 December 2018
▶️
Planeshift.
The documentation for this module can be found at Template:Infobox.
You may be forwarded to another wiki language, in case a translation is not available.
Dependencies
local p = {}
local color = require('Module:Color')._main
local getArgs = require('Module:Arguments').getArgs
local default = {
['title-textcolor'] = 'white',
['title-bgcolor'] = color({'wiki1'}),
['heading-textcolor'] = 'black',
['heading-bgcolor'] = '#EADCDA',
['image-size'] = '256px',
}
function p.main(frame)
local args = getArgs(frame, {
wrappers = { 'Template:Infobox' },
trim = false
})
return p._main(args)
end
function p._main(args)
local infobox = mw.html.create('table')
:addClass('infobox')
:newline()
-- Add the infobox title.
:tag('tr')
:tag('th')
:attr('colspan', 2)
:css('background', args['title-bgcolor'] or default['title-bgcolor'])
:css('text-align', 'center')
:css('color', args['title-textcolor'] or default['title-textcolor'])
:css('font-weight', 'bold')
:wikitext(args['title'])
:done()
:done()
:newline()
if args['image'] then
infobox
:tag('tr')
:tag('td')
:attr('colspan', 2)
:wikitext(string.format('[[File:%s|%s]]', args['image'], args['image-size'] or default['image-size']))
:done()
:done()
:newline()
end
local i = 1
while args['trait' .. i] do
-- Insert headings if necessary.
if args['heading' .. i] then
infobox
:tag('tr')
:tag('td')
:attr('colspan', 2)
:css('background', args['heading-bgcolor'] or default['heading-bgcolor'])
:css('text-align', 'center')
:css('color', args['heading-textcolor'] or default['heading-textcolor'])
:css('font-weight', 'bold')
:wikitext(args['heading' .. i])
:done()
:done()
:newline()
end
if mw.text.trim(args["trait" .. i]) == 'fullwidth' and args['value' .. i] then
infobox
:tag('tr')
:tag('td')
:attr('colspan', 2)
:cssText(args['stylevalue' .. i] or 'text-align: center;')
:wikitext(args['value' .. i])
:done()
:done()
:newline()
elseif args['value' .. i] then
infobox
:tag('tr')
:tag('th')
:css('text-align', 'right')
:wikitext(args['trait' .. i] .. ':')
:done()
:tag('td')
:wikitext(args['value' .. i])
:done()
:done()
:newline()
end
i = i + 1
end
return infobox
end
return p