Vorlage:Personendaten: Unterschied zwischen den Versionen
Aus NordhausenWiki
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung Markierung: Zurückgesetzt |
||
| Zeile 1: | Zeile 1: | ||
local p = {} | |||
-- Hilfsfunktion: Prüft ob Parameter leer ist | |||
local function isEmpty(s) | |||
return s == nil or s == '' or s == false | |||
end | |||
-- Hilfsfunktion: Holt Parameter mit Fallback auf GROSSBUCHSTABEN | |||
local function getParam(args, name, nameAlt) | |||
local value = args[name] | |||
if isEmpty(value) and nameAlt then | |||
value = args[nameAlt] | |||
end | |||
return value | |||
end | |||
= | -- Hauptfunktion für Infobox | ||
function p.infobox(frame) | |||
local args = frame:getParent().args | |||
-- Parameter auslesen | |||
local vornamen = getParam(args, 'vornamen', 'VORNAMEN') or '' | |||
local nachname = getParam(args, 'nachname', 'NACHNAME') or '' | |||
local bild = getParam(args, 'bild', 'BILD') | |||
local bildalt = getParam(args, 'bildalt', 'BILDALT') or (vornamen .. ' ' .. nachname) | |||
local bildbeschreibung = getParam(args, 'bildbeschreibung', 'BILDBESCHREIBUNG') | |||
local alternativnamen = getParam(args, 'alternativnamen', 'ALTERNATIVNAMEN') | |||
local geburtsdatum = getParam(args, 'geburtsdatum', 'GEBURTSDATUM') | |||
local geburtsort = getParam(args, 'geburtsort', 'GEBURTSORT') | |||
local sterbedatum = getParam(args, 'sterbedatum', 'STERBEDATUM') | |||
local sterbeort = getParam(args, 'sterbeort', 'STERBEORT') | |||
local kurzbeschreibung = getParam(args, 'kurzbeschreibung', 'KURZBESCHREIBUNG') | |||
local sonstiges = getParam(args, 'sonstiges', 'SONSTIGES') | |||
local commons = getParam(args, 'commons', 'COMMONS') | |||
local dbndh = getParam(args, 'dbndh', 'DbNDH') | |||
local wikidata = getParam(args, 'wikidata', 'WIKIDATA') | |||
local pnd = getParam(args, 'pnd', 'PND') | |||
local sortierung = getParam(args, 'sortierung', 'SORTIERUNG') | |||
local person = getParam(args, 'person', 'PERSON') | |||
-- HTML-Builder erstellen | |||
local html = mw.html.create('div'):addClass('person-infobox') | |||
-- Header (Name) | |||
html:tag('div') | |||
:addClass('person-header') | |||
:wikitext(vornamen .. ' ' .. nachname) | |||
-- Bild | |||
local kategorien = {} | |||
if not isEmpty(bild) then | |||
local bildContainer = html:tag('div'):addClass('person-bild-container') | |||
local bildLower = string.lower(bild) | |||
local isExtern = string.match(bildLower, '^https?://') | |||
if isExtern then | |||
bildContainer:wikitext('[' .. bild .. ' <img src="' .. bild .. '" width="220" alt="' .. bildalt .. '" class="person-bild-extern" />]') | |||
table.insert(kategorien, '[[Kategorie:Personen mit externem Bild]]') | |||
else | |||
bildContainer:wikitext('[[Datei:' .. bild .. '|220px|' .. bildalt .. '|class=person-bild]]') | |||
end | |||
if not isEmpty(bildbeschreibung) then | |||
bildContainer:tag('div') | |||
:addClass('person-bildtext') | |||
:wikitext(bildbeschreibung) | |||
end | |||
else | |||
table.insert(kategorien, '[[Kategorie:Ohne Bild|' .. nachname .. ']]') | |||
end | |||
-- Alternativnamen | |||
if not isEmpty(alternativnamen) then | |||
html:tag('div') | |||
:addClass('person-alternativnamen') | |||
:wikitext(alternativnamen) | |||
end | |||
-- Daten-Tabelle | |||
local hasSterbedaten = not isEmpty(sterbedatum) or not isEmpty(sterbeort) | |||
if not isEmpty(geburtsdatum) or not isEmpty(geburtsort) or hasSterbedaten then | |||
local tabelle = html:tag('table'):addClass('person-daten') | |||
-- Geburt | |||
local geburtszeile = tabelle:tag('tr') | |||
geburtszeile:tag('th'):wikitext('Geboren') | |||
local geburtText = isEmpty(geburtsdatum) and 'unbekannt' or geburtsdatum | |||
if not isEmpty(geburtsort) then | |||
geburtText = geburtText .. ' in ' .. geburtsort | |||
end | |||
geburtszeile:tag('td'):wikitext(geburtText) | |||
-- Tod | |||
if hasSterbedaten then | |||
local todzeile = tabelle:tag('tr') | |||
todzeile:tag('th'):wikitext('Gestorben') | |||
local todText = sterbedatum or '' | |||
if not isEmpty(sterbeort) then | |||
if not isEmpty(sterbedatum) then | |||
todText = todText .. ' in ' | |||
end | |||
todText = todText .. sterbeort | |||
end | |||
todzeile:tag('td'):wikitext(todText) | |||
end | |||
end | |||
-- Kurzbeschreibung | |||
if not isEmpty(kurzbeschreibung) then | |||
html:tag('div') | |||
:addClass('person-kurzbeschreibung') | |||
:wikitext(kurzbeschreibung) | |||
end | |||
-- Sonstiges | |||
if not isEmpty(sonstiges) then | |||
html:tag('div') | |||
:addClass('person-sonstiges') | |||
:wikitext(sonstiges) | |||
end | |||
-- Externe Links | |||
local links = {} | |||
if not isEmpty(commons) then | |||
table.insert(links, '[[Datei:Commons-logo.svg|12px|link=]] [https://commons.wikimedia.org/wiki/Category:' .. commons .. ' Commons]') | |||
end | |||
if not isEmpty(dbndh) then | |||
table.insert(links, 'DbNDH: [https://datenbank.nordhausen.org/wiki/Item:' .. dbndh .. ' ' .. dbndh .. ']') | |||
end | |||
if not isEmpty(wikidata) then | |||
table.insert(links, '[https://www.wikidata.org/wiki/' .. wikidata .. ' Wikidata]') | |||
end | |||
if not isEmpty(pnd) then | |||
table.insert(links, 'GND: [http://d-nb.info/gnd/' .. pnd .. ' ' .. pnd .. ']') | |||
end | |||
if #links > 0 then | |||
html:tag('div') | |||
:addClass('person-links') | |||
:wikitext(table.concat(links, ' • ')) | |||
end | |||
-- Kategorisierung | |||
table.insert(kategorien, '[[Kategorie:Person]]') | |||
-- Sortierung | |||
local sortKey = sortierung | |||
if isEmpty(sortKey) then | |||
sortKey = nachname | |||
if not isEmpty(vornamen) then | |||
sortKey = sortKey .. ', ' .. vornamen | |||
end | |||
end | |||
-- DEFAULTSORT Magic Word (war vorher falsch als SORTIERUNG) | |||
local sortierungText = '{{DEFAULTSORT:' .. sortKey .. '}}' | |||
-- Person vs. Autor Kategorie | |||
if isEmpty(person) or person == '1' or person == 'ja' or person == 'true' then | |||
table.insert(kategorien, '[[Kategorie:Person|' .. sortKey .. ']]') | |||
else | |||
table.insert(kategorien, '[[Kategorie:Autor|' .. sortKey .. ']]') | |||
end | |||
return tostring(html) .. sortierungText .. table.concat(kategorien, '') | |||
end | |||
return p | |||
Version vom 21. Januar 2026, 10:17 Uhr
local p = {}
-- Hilfsfunktion: Prüft ob Parameter leer ist local function isEmpty(s)
return s == nil or s == or s == false
end
-- Hilfsfunktion: Holt Parameter mit Fallback auf GROSSBUCHSTABEN local function getParam(args, name, nameAlt)
local value = args[name]
if isEmpty(value) and nameAlt then
value = args[nameAlt]
end
return value
end
-- Hauptfunktion für Infobox function p.infobox(frame)
local args = frame:getParent().args
-- Parameter auslesen
local vornamen = getParam(args, 'vornamen', 'VORNAMEN') or
local nachname = getParam(args, 'nachname', 'NACHNAME') or
local bild = getParam(args, 'bild', 'BILD')
local bildalt = getParam(args, 'bildalt', 'BILDALT') or (vornamen .. ' ' .. nachname)
local bildbeschreibung = getParam(args, 'bildbeschreibung', 'BILDBESCHREIBUNG')
local alternativnamen = getParam(args, 'alternativnamen', 'ALTERNATIVNAMEN')
local geburtsdatum = getParam(args, 'geburtsdatum', 'GEBURTSDATUM')
local geburtsort = getParam(args, 'geburtsort', 'GEBURTSORT')
local sterbedatum = getParam(args, 'sterbedatum', 'STERBEDATUM')
local sterbeort = getParam(args, 'sterbeort', 'STERBEORT')
local kurzbeschreibung = getParam(args, 'kurzbeschreibung', 'KURZBESCHREIBUNG')
local sonstiges = getParam(args, 'sonstiges', 'SONSTIGES')
local commons = getParam(args, 'commons', 'COMMONS')
local dbndh = getParam(args, 'dbndh', 'DbNDH')
local wikidata = getParam(args, 'wikidata', 'WIKIDATA')
local pnd = getParam(args, 'pnd', 'PND')
local sortierung = getParam(args, 'sortierung', 'SORTIERUNG')
local person = getParam(args, 'person', 'PERSON')
-- HTML-Builder erstellen
local html = mw.html.create('div'):addClass('person-infobox')
-- Header (Name)
html:tag('div')
:addClass('person-header')
:wikitext(vornamen .. ' ' .. nachname)
-- Bild
local kategorien = {}
if not isEmpty(bild) then
local bildContainer = html:tag('div'):addClass('person-bild-container')
local bildLower = string.lower(bild)
local isExtern = string.match(bildLower, '^https?://')
if isExtern then
bildContainer:wikitext('[' .. bild .. ' <img src="' .. bild .. '" width="220" alt="' .. bildalt .. '" class="person-bild-extern" />]')
table.insert(kategorien, )
else
bildContainer:wikitext('' .. bildalt .. '')
end
if not isEmpty(bildbeschreibung) then
bildContainer:tag('div')
:addClass('person-bildtext')
:wikitext(bildbeschreibung)
end
else
table.insert(kategorien, )
end
-- Alternativnamen
if not isEmpty(alternativnamen) then
html:tag('div')
:addClass('person-alternativnamen')
:wikitext(alternativnamen)
end
-- Daten-Tabelle
local hasSterbedaten = not isEmpty(sterbedatum) or not isEmpty(sterbeort)
if not isEmpty(geburtsdatum) or not isEmpty(geburtsort) or hasSterbedaten then
local tabelle = html:tag('table'):addClass('person-daten')
-- Geburt
local geburtszeile = tabelle:tag('tr')
geburtszeile:tag('th'):wikitext('Geboren')
local geburtText = isEmpty(geburtsdatum) and 'unbekannt' or geburtsdatum
if not isEmpty(geburtsort) then
geburtText = geburtText .. ' in ' .. geburtsort
end
geburtszeile:tag('td'):wikitext(geburtText)
-- Tod
if hasSterbedaten then
local todzeile = tabelle:tag('tr')
todzeile:tag('th'):wikitext('Gestorben')
local todText = sterbedatum or
if not isEmpty(sterbeort) then
if not isEmpty(sterbedatum) then
todText = todText .. ' in '
end
todText = todText .. sterbeort
end
todzeile:tag('td'):wikitext(todText)
end
end
-- Kurzbeschreibung
if not isEmpty(kurzbeschreibung) then
html:tag('div')
:addClass('person-kurzbeschreibung')
:wikitext(kurzbeschreibung)
end
-- Sonstiges
if not isEmpty(sonstiges) then
html:tag('div')
:addClass('person-sonstiges')
:wikitext(sonstiges)
end
-- Externe Links
local links = {}
if not isEmpty(commons) then
table.insert(links, '
.. commons .. ' Commons')
end
if not isEmpty(dbndh) then
table.insert(links, 'DbNDH: .. dbndh .. ' ' .. dbndh .. '')
end
if not isEmpty(wikidata) then
table.insert(links, '.. wikidata .. ' Wikidata')
end
if not isEmpty(pnd) then
table.insert(links, 'GND: .. pnd .. ' ' .. pnd .. '')
end
if #links > 0 then
html:tag('div')
:addClass('person-links')
:wikitext(table.concat(links, ' • '))
end
-- Kategorisierung
table.insert(kategorien, )
-- Sortierung
local sortKey = sortierung
if isEmpty(sortKey) then
sortKey = nachname
if not isEmpty(vornamen) then
sortKey = sortKey .. ', ' .. vornamen
end
end
-- DEFAULTSORT Magic Word (war vorher falsch als SORTIERUNG)
local sortierungText =
-- Person vs. Autor Kategorie
if isEmpty(person) or person == '1' or person == 'ja' or person == 'true' then
table.insert(kategorien, )
else
table.insert(kategorien, )
end
return tostring(html) .. sortierungText .. table.concat(kategorien, )
end
return p