Module:Places: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 67: | Line 67: | ||
]=] | ]=] | ||
for _, c in ipairs(data.places) do | for _, c in ipairs(data.places) do | ||
if c.condominium then | if c.condominium and not c.reason_dissolved then | ||
out = out .. "<tr>" | out = out .. "<tr>" | ||
out = out .. "<td>" .. frame:expandTemplate{title = "Banner", args = {c.code2}} | out = out .. "<td>" .. frame:expandTemplate{title = "Banner", args = {c.code2}} | ||
Revision as of 10:46, 19 November 2025
Documentation for this module may be created at Module:Places/doc
local _m = {}
local u = require"Module:Utils"
local data = mw.loadJsonData([[Data:Places]])
_m.countries = function(frame)
local out = [==[
<table class="wikitable sortable">
<tr>
<th>Common name</th>
<th>Full name</th>
<th>Ruler</th>
<th>Ruler title</th>
<th data-sort-type="date">Date founded</th>
<th>Capital</th>
<th>Code-2</th>
<th>Code-3</th>
<th>UŊ Member</th>
<th>Notes</th>
</tr>
]==]
for _, c in ipairs(data.places) do
if not c.not_ngation and not c.condominium and not c.reason_dissolved and not c.reserved then
out = out .. "<tr>"
out = out .. "<td>" .. frame:expandTemplate{title = "Banner", args = {c.code2}}
.. " " .. (c.common_name and ("[[" .. c.common_name .. "]]") or "") .. "</td>"
out = out .. "<td>" .. (c.name or "") .. "</td>"
if not c.ruler then out = out .. "<td></td>"
elseif type(c.ruler) == "table" then
out = out .. "<td>"
for i, r in ipairs(c.ruler) do out = out .. (i ~= 1 and ", [[" or "[[") .. r .. "]]" end
out = out .. "</td>"
elseif c.ruler_link then
out = out .. "<td>[[" .. c.ruler_link .. "|" .. c.ruler .. "]]</td>"
else out = out .. "<td>[[" .. c.ruler .. "]]</td>"
end
out = out .. "<td>" .. (c.ruler_title or "") .. "</td>"
if not c.date_founded then out = out .. "<td></td>" else
out = out .. "<td>" .. u.date(c.date_founded[1], c.date_founded[2], c.date_founded[3], true) .. "</td>"
end
out = out .. "<td>" .. (c.capital or "") .. "</td>"
out = out .. "<td>" .. c.code2 .. "</td>"
out = out .. "<td>" .. c.code3 .. "</td>"
out = out .. "<td>" .. (c.ung == "member" and "yes" or "no") .. "</td>"
if not c.notes then out = out .. "<td></td>" else
out = out .. [[<td><div class="mw-collapsible mw-collapsed">]] .. c.notes .. "</div></td>"
end
out = out .. "</tr>"
end
end
out = out .. [[</table>]]
return out
end
_m.condominia = function(frame)
out = [=[
<table class="wikitable sortable">
<th>Common name</th>
<th>Full name</th>
<th data-sort-type="date">Date founded</th>
<th>Capital</th>
<th>Parent Ŋation(s)</th>
<th>Code-2</th>
<th>Code-3</th>
<th>Notes</th>
</tr>
]=]
for _, c in ipairs(data.places) do
if c.condominium and not c.reason_dissolved then
out = out .. "<tr>"
out = out .. "<td>" .. frame:expandTemplate{title = "Banner", args = {c.code2}}
.. " " .. (c.common_name and ("[[" .. c.common_name .. "]]") or "") .. "</td>"
out = out .. "<td>" .. (c.name or "") .. "</td>"
if not c.date_founded then out = out .. "<td></td>" else
out = out .. "<td>" .. u.date(c.date_founded[1], c.date_founded[2], c.date_founded[3], true) .. "</td>"
end
out = out .. "<td>" .. (c.capital or "") .. "</td>"
for i, p in ipairs(c.condominium) do
if i ~= 1 then out = out .. ", " end
out = out .. _m.get_style(frame, p)
end
out = out .. "<td>" .. c.code2 .. "</td>"
out = out .. "<td>" .. c.code3 .. "</td>"
if not c.notes then out = out .. "<td></td>" else
out = out .. [[<td><div class="mw-collapsible mw-collapsed">]] .. c.notes .. "</div></td>"
end
out = out .. "</tr>"
end
end
out = out .. [[</table>]]
return out
end
_m.non_countries = function(frame)
return ""
end
_m.former = function(frame)
return ""
end
_m.get = function(it) for _, v in ipairs(data.places) do if it == v.code2 then return v end end end
_m.get_style = function(frame, it)
if it == nil then it = u._a(frame) end
local c = _m.get(it)
return frame:expandTemplate{title = "Banner", args = {c.code2}} .. "[[" .. c.common_name .. "]]"
end
_m.get_banner = function(frame)
for _, c in ipairs(data.places) do
if c.code2 == frame.args[1] then return (c.banner or "???") end
end
end
return _m