Zum Inhalt springen

„Modul:Flaggen“ – Versionsunterschied

aus Wikipedia, der freien Enzyklopädie
[gesichtete Version][gesichtete Version]
Inhalt gelöscht Inhalt hinzugefügt
Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
 
(2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 6: Zeile 6:
local a = full.info[code] or code
local a = full.info[code] or code
local flag = mw.loadData('Modul:Flaggen/'..string.sub(a, 1, 1)).info[a]
local flag = mw.loadData('Modul:Flaggen/'..string.sub(a, 1, 1)).info[a]
if flag == nil then return 'Flag of None.svg' else
if flag == nil then return 'Datei:Flag of None.svg' else
return flag[1]
return 'Datei:'..flag[1]
end
end
end
end
Zeile 17: Zeile 17:
return land[2]
return land[2]
end
end
end

local function artikel(code)
local a = full.info[code] or code
local artikel = mw.loadData('Modul:Flaggen/'..string.sub(a, 1, 1)).info[a]
if artikel == nil then return flag(a) else
if artikel[3] == nil then return flag(a) else
return 'Flagge '..artikel[3]
end end
end
end


Zeile 33: Zeile 42:
local w = args['w'] or '30'
local w = args['w'] or '30'
if b then
if b then
if b == 'n' then return '[[Datei:' ..flag(args[1]).. '|' ..w..'px]] [['..land(args[1])..']]' else
if b == 'f' then return '[['..flag(a).. '|' ..w..'px|link='..artikel(a)..']]' else
if c then
if c then
if c == 'n' then return '[[Datei:' ..flag(args[1]).. '|' ..w..'px]] [['..land(args[1])..'|'..b..']]' else
if c == 'n' then return '[['..flag(a).. '|' ..w..'px]] [['..land(a)..'|'..b..']]' else
return '[[Datei:' ..flag(args[1]).. '|' ..w..'px]] [['..c..'|'..b..']]' end else
return '[['..flag(a).. '|' ..w..'px]] [['..c..'|'..b..']]' end else
return '[[Datei:' ..flag(args[1]).. '|' ..w..'px]] [['..b..']]' end end
return '[[' ..flag(a).. '|' ..w..'px]] [['..b..']]' end end
else
else
if n then return '[[Datei:' ..flag(args[1]).. '|' ..w..'px]] [['..n..'|'..land(args[1])..']]' end end
if n then return '[[' ..flag(a).. '|' ..w..'px]] [['..n..'|'..land(a)..']]' end end
if f then
if f then
if f == 'n' then return '[[Datei:' ..flag(args[1]).. '|' ..w..'px|link='..land(args[1])..']]' else
if f == 'n' then return '[[' ..flag(a).. '|' ..w..'px|link='..land(a)..']]' else
return '[[Datei:' ..flag(args[1]).. '|' ..w..'px|link='..f..']]' end end
return '[[' ..flag(a).. '|' ..w..'px|link='..f..']]' end end
return '[[Datei:' ..flag(args[1]).. '|' ..w..'px]]'
return '[[' ..flag(a).. '|' ..w..'px]] [['..land(a)..']]'
end
end


Zeile 81: Zeile 90:
return root
return root
end
end



return p
return p

Aktuelle Version vom 4. Oktober 2023, 18:18 Uhr

Die Dokumentation für dieses Modul kann unter Modul:Flaggen/Doku erstellt werden

local p = {}
local full = mw.loadData('Modul:Flaggen/Alias');
local getArgs = require('Modul:Arguments').getArgs

local function flag(code)
	local a = full.info[code] or code
	local flag = mw.loadData('Modul:Flaggen/'..string.sub(a, 1, 1)).info[a]
	if flag == nil then return 'Datei:Flag of None.svg' else
	return 'Datei:'..flag[1]
	end
end

local function land(code)
	local a = full.info[code] or code
	local land = mw.loadData('Modul:Flaggen/'..string.sub(a, 1, 1)).info[a]
	if land == nil then return a else
	return land[2]
	end
end

local function artikel(code)
	local a = full.info[code] or code
	local artikel = mw.loadData('Modul:Flaggen/'..string.sub(a, 1, 1)).info[a]
	if artikel == nil then return flag(a) else
	if artikel[3] == nil then return flag(a) else
	return 'Flagge '..artikel[3]
	end end
end

function p.staat(frame) -- SUPPORT Modul:Partei/Liste
	local args = getArgs(frame)
	return land(args[1])
end

function p.flagge(frame)
	local args = getArgs(frame)
	local a = args[1]
	local b = args[2]
	local c = args[3]
	local f = args['f']
	local n = args['n']
	local w = args['w'] or '30'
	if b then
		if b == 'f' then return '[['..flag(a).. '|' ..w..'px|link='..artikel(a)..']]' else
		if c then
			if c == 'n' then return '[['..flag(a).. '|' ..w..'px]] [['..land(a)..'|'..b..']]' else
			return '[['..flag(a).. '|' ..w..'px]] [['..c..'|'..b..']]' end else
		return '[[' ..flag(a).. '|' ..w..'px]] [['..b..']]' end end
	else
	if n then return '[[' ..flag(a).. '|' ..w..'px]] [['..n..'|'..land(a)..']]' end end
	if f then
		if f == 'n' then return '[[' ..flag(a).. '|' ..w..'px|link='..land(a)..']]' else
		return '[[' ..flag(a).. '|' ..w..'px|link='..f..']]' end end
	return '[[' ..flag(a).. '|' ..w..'px]] [['..land(a)..']]'
end

function p.tabelle(frame)
	local args = getArgs(frame)
	local buchstabe = args['buchstabe']
	local cfg = mw.loadData('Modul:Flaggen/'..buchstabe)
	local root = mw.html.create('table'):addClass('wikitable sortable')
	root:tag('tr')
		:tag('th'):wikitext('Code'):done()
		:tag('th'):wikitext('Flag'):done()
		:tag('th'):wikitext('Land'):done()
	for code, value in pairs(cfg.info) do
	root:tag('tr')
		:tag('td'):wikitext('' .. code .. ''):done()
		:tag('td'):wikitext('[[Datei:' .. value[1] .. '|30px]]'):done()
		:tag('td'):wikitext('[[' .. value[2] ..']]'):done()
	end
	return root
end

function p.alias(frame)
	local root = mw.html.create('table'):addClass('wikitable sortable')
	root:tag('tr')
		:tag('th'):wikitext('Staat-Land'):done()
		:tag('th'):wikitext('Code'):done()
	local alln = {}
	for k, v in pairs(full.info) do
		alln[#alln+1] = k
	end
	table.sort(alln)
	for _, code in ipairs(alln) do
	root:tag('tr')
		:tag('td'):wikitext('[[' .. code .. ']]'):done()
		:tag('td'):wikitext(full.info[code]):done()
	end
	return root
end

return p