|
|
Line 1: |
Line 1: |
| <div class="infobox">
| | require('Module:No globals') |
| {| width="315" align="right" cellpadding="3" cellspacing="0" style="border-radius:13px;margin-bottom: 0;
| | |
| {{#if: {{{image|}}}| | | local p = {} |
| {{!}} colspan="2" bgcolor={{{bgcolor_value|#222222; style="border-top-right-radius: 13px; border-top-left-radius: 13px; background: #f3f3f3 !important; color: #cccccc; font-size:smaller; text-align: center;padding: 10px;"}}} {{!}} {{{image}}} }}
| | |
| |-
| | local cells = mw.loadData('Module:Tree chart/data') |
| | colspan="2" style="text-align: center; color: #e5e5ed; font-size:larger; background-color:#2862a8 !important; text-align:center;padding: .3rem 1.25rem;" | '''{{{name}}}'''
| | |
| |-
| | function p._main(cell_args) |
| | colspan="2" style="text-align: center; color: #e5e5ed; background-color:#4979b5; text-align:center; font-size:8pt; padding: 6px" | '''Basic information'''
| | local ret = mw.html.create() |
| |-
| | local top = ret:tag('tr') |
| {{#if: {{{species|}}}|
| | :css{ height = '1px', |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Major Species
| | ['text-align'] = 'center' } |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | local bottom = ret:tag('tr') |
| {{{species}}}}}
| | :css{ height = '1px', |
| |-
| | ['text-align'] = 'center' } |
| {{#if: {{{homeworld|}}}|
| | for _, v in ipairs(cell_args) do |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Homeworld(s)
| | if type(v) == 'string' then |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | top:wikitext(cells[v].t) |
| {{{homeworld}}}}}
| | bottom:wikitext(cells[v].b) |
| |-
| | else |
| {{#if: {{{founded|}}}|
| | top:tag('td') |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Founded
| | :attr{ colspan = v.colspan or cell_args.colspan or 6, |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}} | | rowspan = v.rowspan or cell_args.rowspan or 2 } |
| {{{founded}}}}}
| | :css{ padding = '0.2em', |
| |-
| | border = (v.border or cell_args.border or '2') .. 'px solid black' } |
| {{#if: {{{warp|}}}|
| | :cssText(v.boxstyle or cell_args.boxstyle) |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Warp Capable
| | :wikitext(v.text) |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | end |
| {{{warp}}}}}
| | end |
| |-
| | return tostring(ret) |
| {{#if: {{{language|}}}|
| | end |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Official Language
| | |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | function p.main(frame) |
| {{{language}}}}} | | local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Tree chart', trim = false, removeBlanks = false}) |
| |-
| | local cell_args = { |
| {{#if: {{{currency|}}}|
| | colspan = args.colspan, |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Official Currency
| | rowspan = args.rowspan, |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | border = args.border, |
| {{{currency}}}}}
| | boxstyle = args.boxstyle |
| |-
| | } |
| | colspan="2" style="text-align: center; color: #e5e5ed; background-color:#4979b5; text-align:center; font-size:8pt; padding: 6px" | '''Political Information'''
| | for _, val in ipairs(args) do |
| |-
| | local trimmedVal = val:match('^%s*(.-)%s*$') |
| {{#if: {{{government|}}}|
| | if trimmedVal == '' then |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Government
| | trimmedVal = '$' |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | end |
| {{{government}}}}}
| | if cells[trimmedVal] then |
| |-
| | table.insert(cell_args, trimmedVal) |
| {{#if: {{{leader|}}}|
| | else |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Leader
| | -- Unnamed params behave weirdly |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | -- white space at the front counts for param_{{{1}}}, but not whitespace at the end, so remove it |
| {{{leader}}}}}
| | local rightTrimmedVal = val:gsub('%s+$','') |
| |-
| | table.insert(cell_args, { |
| {{#if: {{{advancement|}}}|
| | text = args[trimmedVal] or ('{{{'..trimmedVal..'}}}'), |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Degree of Advancement
| | colspan = args['colspan_'..rightTrimmedVal], |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | rowspan = args['rowspan_'..rightTrimmedVal], |
| {{{advancement}}}}}
| | border = args['border_'..rightTrimmedVal], |
| |-
| | boxstyle = args['boxstyle_'..rightTrimmedVal] |
| {{#if: {{{military|}}}| | | }) |
| {{!}} bgcolor={{{bgcolor_value|#222222; style="background: #e0e0e0; padding:8px 10px; color: #696969; font-size:smaller; width:40%;"}}} {{!}} Military Branches
| | end |
| {{!}} bgcolor={{{bgcolor_value|#2B2B2B style="background: #ececec; padding:8px 10px; color: #696969; font-size:smaller; width:60%;"}}} {{!}}
| | end |
| {{{military}}}}}
| | |
| |- class="infobox-link" style="border-radius-bottom-right: 13px; border-radius-bottom-left: 13px;"
| | return p._main(cell_args) |
| |colspan="2" style="border-bottom-right-radius: 13px; border-bottom-left-radius: 13px; text-align: center; color: #F67F00; font-size: 8pt; background-color:#4979b5; text-align:center;padding: 6px 0;" | [[Template:Government]]
| | end |
| |}</div>
| | |
| <includeonly>[[Category:Governments]]
| | return p |
| {{DEFAULTSORT:{{PAGENAME}}}}</includeonly><noinclude>
| |
| <br clear=all>
| |
| <pre>
| |
| {{Government
| |
| |name=
| |
| |image=
| |
| |species=
| |
| |homeworld=
| |
| |founded=
| |
| |warp=
| |
| |language=
| |
| |currency=
| |
| |government=
| |
| |leader=
| |
| |advancement=
| |
| |military=
| |
| }}</pre>
| |
| [[Category:Infobox Templates|{{PAGENAME}}]]
| |
| </noinclude>
| |
Documentation for this module may be created at Module:Tree chart/doc
require('Module:No globals')
local p = {}
local cells = mw.loadData('Module:Tree chart/data')
function p._main(cell_args)
local ret = mw.html.create()
local top = ret:tag('tr')
:css{ height = '1px',
['text-align'] = 'center' }
local bottom = ret:tag('tr')
:css{ height = '1px',
['text-align'] = 'center' }
for _, v in ipairs(cell_args) do
if type(v) == 'string' then
top:wikitext(cells[v].t)
bottom:wikitext(cells[v].b)
else
top:tag('td')
:attr{ colspan = v.colspan or cell_args.colspan or 6,
rowspan = v.rowspan or cell_args.rowspan or 2 }
:css{ padding = '0.2em',
border = (v.border or cell_args.border or '2') .. 'px solid black' }
:cssText(v.boxstyle or cell_args.boxstyle)
:wikitext(v.text)
end
end
return tostring(ret)
end
function p.main(frame)
local args = require('Module:Arguments').getArgs(frame, {wrappers = 'Template:Tree chart', trim = false, removeBlanks = false})
local cell_args = {
colspan = args.colspan,
rowspan = args.rowspan,
border = args.border,
boxstyle = args.boxstyle
}
for _, val in ipairs(args) do
local trimmedVal = val:match('^%s*(.-)%s*$')
if trimmedVal == '' then
trimmedVal = '$'
end
if cells[trimmedVal] then
table.insert(cell_args, trimmedVal)
else
-- Unnamed params behave weirdly
-- white space at the front counts for param_{{{1}}}, but not whitespace at the end, so remove it
local rightTrimmedVal = val:gsub('%s+$','')
table.insert(cell_args, {
text = args[trimmedVal] or ('{{{'..trimmedVal..'}}}'),
colspan = args['colspan_'..rightTrimmedVal],
rowspan = args['rowspan_'..rightTrimmedVal],
border = args['border_'..rightTrimmedVal],
boxstyle = args['boxstyle_'..rightTrimmedVal]
})
end
end
return p._main(cell_args)
end
return p