Module:Places: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 79: | Line 79: | ||
if i ~= 1 then out = out .. ", " end | if i ~= 1 then out = out .. ", " end | ||
local pc = _m.get(p) | local pc = _m.get(p) | ||
out = out .. frame:expandTemplate{title = "Banner", args = {p}} .. "[[" .. | out = out .. frame:expandTemplate{title = "Banner", args = {p}} .. "[[" .. pc.common_name .. "]]" | ||
end | end | ||
out = out .. "<td>" .. c.code2 .. "</td>" | out = out .. "<td>" .. c.code2 .. "</td>" | ||
Revision as of 10:51, 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
local pc = _m.get(p)
out = out .. frame:expandTemplate{title = "Banner", args = {p}} .. "[[" .. pc.common_name .. "]]"
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)
local c = _m.get(u._a(frame))
return frame:expandTemplate{title = "Banner", args = {c.code2}} .. "[[" .. c.common_name .. "]]"
end
_m.get_banner = function(it)
for _, c in ipairs(data.places) do
if c.code2 == u._a(it) then return (c.banner or "???") end
end
end
return _m