Module:Places

From Nguhcraft Wiki
Revision as of 23:24, 18 November 2025 by Annwan (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Places/doc

local _m = {}

local data = mw.loadJsonData([[Data:Places]])

_m.countries = function(frame)
	local out = [==[
<table class="wikitable sortable">
<tr>
	<th>Common name</td>
	<th>Full name</td>
	<th>Ruler</td>
	<th>Ruler title</td>
	<th>Date founded</td>
	<th>Capital</td>
	<th>Code-2</td>
	<th>Code-3</td>
	<th>UŊ Member</td>
</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>" .. c.date_founded[1] .. "-" .. c.date_founded[2] .. "-" .. c.date_founded[3] .. "</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>"
			out = out .. "</tr>"
		end
	end
	out = out .. [[</table>]]
	return out
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