Die Dokumentation für dieses Modul kann unter Modul:Publikation/Zeitschrift/Doku erstellt werden
local getArgs = require('Module:Arguments').getArgs
local helper = require("Modul:Publikation/Helper")
local related = require("Modul:Publikation/Related")
local zeitschrift = {}
function zeitschrift.render(frame)
local args = frame.args
local output = "" -- Initialisierung von output
-- Setze den DISPLAYTITLE basierend auf dem Titel des Buches
if args["Titel"] then
helper.setDisplayTitle({title = args["Titel"]})
end
-- Setze die Inhaltszusammenfassung als semantischen Wert
if args["Inhaltszusammenfassung"] and args["Inhaltszusammenfassung"] ~= "" then
local rawSummary = mw.text.unstripNoWiki(args["Inhaltszusammenfassung"]):gsub("<.->", ""):gsub("%[%[.-%]%]", ""):gsub("%{.-%}", "") -- Entferne HTML-Tags und MediaWiki-Markierungen, bewahre geschützte Bereiche wie <nowiki>
local truncatedSummary = mw.ustring.sub(rawSummary, 1, 250) -- Begrenze auf 250 Zeichen
helper.setProperty({ args = { ["Inhaltszusammenfassung"] = truncatedSummary } }) -- Setze den semantischen Wert
mw.ext.seo.set{description = truncatedSummary} -- Setze die Beschreibung
end
-- OpenGraph-Bild für SEO
local coverImage = args["Coverbild"] or "DefaultBuchCover.webp"
mw.ext.seo.set{["og:image"] = mw.uri.fullUrl("File:Library:" .. coverImage)}
-- Coverbild semantisch setzen
if args["Coverbild"] and args["Coverbild"] ~= "" then
helper.setProperty({ args = { ["Hat Cover"] = args["Coverbild"] } })
end
local output = '<table class="publikation zeitschrift table">'
-- Coverbild
output = output .. '<tr><td colspan="2" style="text-align: center;">' ..
helper.getCoverImage({cover = args["Coverbild"], defaultCover = "DefaultZeitschriftCover.webp"}) ..
'</td></tr>'
-- Titel
output = output .. '<tr><td><strong>Titel</strong></td><td>[[Hat Titel::' .. (args["Titel"] or "Unbekannt") .. ']]</td></tr>'
-- Autoren
if args["Autor"] then
output = output .. '<tr><td><strong>Autor(en)</strong></td><td>'
for author in mw.text.gsplit(args["Autor"], ",") do
author = mw.text.trim(author)
local authorPage = "Library:Autor:" .. author:gsub(" ", "_")
helper.setProperty({ args = { ["Hat Autor"] = author } }) -- Semantischen Wert setzen
output = output .. '[[' .. authorPage .. '|' .. author .. ']], '
end
output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
end
-- Stichworte
if args["Stichworte"] then
output = output .. '<tr><td><strong>Stichworte</strong></td><td>'
for keyword in mw.text.gsplit(args["Stichworte"], ",") do
keyword = mw.text.trim(keyword)
helper.setProperty({ args = { ["Keyword"] = keyword } }) -- Semantischen Wert setzen
output = output .. keyword .. ', '
end
output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
end
-- Verlag
output = output .. (args["Verlag"] and '<tr><td><strong>Verlag</strong></td><td>[[Verlag::' .. args["Verlag"] .. ']]</td></tr>' or "")
-- ISBN und ISSN
if args["ISBN-10"] or args["ISBN-13"] or args["ISSN"] then
-- ISBN-10 und ISBN-13 Verarbeitung
local isbn10 = args["ISBN-10"] and helper.getIsbnLink({isbn = args["ISBN-10"], version = "ISBN-10"}) or ""
local isbn13 = args["ISBN-13"] and helper.getIsbnLink({isbn = args["ISBN-13"], version = "ISBN-13"}) or ""
-- Semantische Werte für ISBN setzen
if args["ISBN-10"] and args["ISBN-10"] ~= "" then
helper.setProperty({args = {["ISBN-10"] = args["ISBN-10"]}})
end
if args["ISBN-13"] and args["ISBN-13"] ~= "" then
helper.setProperty({args = {["ISBN-13"] = args["ISBN-13"]}})
end
-- ISSN Verarbeitung
local issn = args["ISSN"] and args["ISSN"] or ""
if issn ~= "" then
-- Semantischen Wert für ISSN setzen
helper.setProperty({args = {["ISSN"] = issn}})
-- ISSN-Link erstellen
issn = issn .. ' ([https://portal.issn.org/resource/ISSN/' .. issn .. ' The ISSN Portal])'
end
-- Anzeige der ISBN und ISSN
local identifiers = {}
if isbn10 ~= "" then table.insert(identifiers, isbn10) end
if isbn13 ~= "" then table.insert(identifiers, isbn13) end
if issn ~= "" then table.insert(identifiers, issn) end
-- Tabelle hinzufügen
output = output .. '<tr><td><strong>Identifikatoren</strong></td><td>' .. table.concat(identifiers, " / ") .. '</td></tr>'
end
-- Erscheinungsjahr
output = output .. (args["Erscheinungsjahr"] and '<tr><td><strong>Erscheinungsjahr</strong></td><td>[[Erscheinungsjahr::' .. args["Erscheinungsjahr"] .. ']]</td></tr>' or "")
-- Jahrgang
output = output .. (args["Jahrgang"] and '<tr><td><strong>Jahrgang</strong></td><td>[[Jahrgang::' .. args["Jahrgang"] .. ']]</td></tr>' or "")
-- Ausgabe
output = output .. (args["Ausgabe"] and '<tr><td><strong>Ausgabe</strong></td><td>[[Ausgabe::' .. args["Ausgabe"] .. ']]</td></tr>' or "")
-- Standort
output = output .. (args["Standort"] and '<tr><td><strong>Standort</strong></td><td>[[Standort::' .. args["Standort"] .. ']]</td></tr>' or "")
-- Datensatz ID (z. B. DNB-ID)
if args["Datensatz ID"] then
local dnbLink = "https://d-nb.info/" .. args["Datensatz ID"]
output = output .. '<tr><td><strong>Datensatz ID</strong></td><td>' .. args["Datensatz ID"] .. ' ([' .. dnbLink .. ' DNB])</td></tr>'
helper.setProperty({args = {["Datensatz ID"] = args["Datensatz ID"]}})
end
-- Wichtige Artikel
if args["Wichtige Artikel"] and args["Wichtige Artikel"] ~= "" then
output = output .. '<tr><td><strong>Wichtige Artikel</strong></td><td>'
for article in mw.text.gsplit(args["Wichtige Artikel"], ",") do
article = mw.text.trim(article)
output = output .. article .. ', '
end
output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
end
-- Inhaltszusammenfassung
output = output .. (args["Inhaltszusammenfassung"] and '<tr><td><strong>Inhaltszusammenfassung</strong></td><td>' .. args["Inhaltszusammenfassung"] .. '</td></tr>' or "")
-- Ähnliche Artikel
if args["Stichworte"] then
local similarArticles = related.similarArticles({ Keyword = args["Stichworte"], limit = 5 })
if similarArticles ~= "Keine ähnlichen Artikel gefunden." then
output = output .. '<tr><td><strong>Ähnliche Artikel</strong></td><td>' .. similarArticles .. '</td></tr>'
end
end
output = output .. '</table>'
-- Kategorien setzen
local categories = {} -- Korrekte Initialisierung der Tabelle
-- Kategorien basierend auf Argumenten hinzufügen
if args["Stichworte"] then
for keyword in mw.text.gsplit(args["Stichworte"], ",") do
table.insert(categories, mw.text.trim(keyword))
end
end
if args["Standort"] then
table.insert(categories, "Standort:" .. args["Standort"])
end
if args["Autor"] and args["Autor"] ~= "" then
for autor in mw.text.gsplit(args["Autor"], ",") do
table.insert(categories, "Autor:" .. mw.text.trim(autor))
end
end
if args["Verlag"] and args["Verlag"] ~= "" then
table.insert(categories, args["Verlag"])
end
-- Hinzufügen allgemeiner Kategorien
table.insert(categories, "Zeitschriften")
table.insert(categories, "Alle Publikationen")
output = output .. helper.addCategories({categories = categories, sortkey = args["Titel"]})
return output
end
return zeitschrift