Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 2: | Zeile 2: | ||
local getArgs = require('Module:Arguments').getArgs | local getArgs = require('Module:Arguments').getArgs | ||
local | local buch = {} | ||
function | -- Funktion zur Extraktion der Gesamtbände aus der Serien-ID | ||
- | function buch.getCompleteVolumes(seriesID) | ||
if not mw.smw then | |||
return "Semantic MediaWiki-Erweiterung nicht gefunden." | |||
end | |||
if not seriesID or seriesID == "" then | if not seriesID or seriesID == "" then | ||
return " | return "Keine Serien-ID angegeben." | ||
end | end | ||
-- | -- Abfrage vorbereiten | ||
local | local query = { ["[[SerienID::" .. seriesID .. "]]"] = "?Complete volumes" } | ||
if not | local queryResult = mw.smw.getQueryResult(query) | ||
return "Keine | |||
if not queryResult or not queryResult.results then | |||
return "Keine Ergebnisse gefunden." | |||
end | end | ||
-- | -- Ergebnisse analysieren | ||
local | for _, result in pairs(queryResult.results) do | ||
local printouts = result.printouts | |||
if printouts and printouts["Complete volumes"] then | |||
return printouts["Complete volumes"][1] -- Gibt den ersten gefundenen Wert zurück | |||
end | end | ||
end | end | ||
-- | return "Keine Gesamtbände gefunden." | ||
local | end | ||
local | |||
-- Hauptfunktion für die Buchdarstellung | |||
function buch.render(args, helper) | |||
local title = args["Titel"] or "Unbekannt" | |||
local author = args["Autor"] or "Unbekannt" | |||
local band = args["Band"] or "" | |||
local seriesID = args["Hat Serie"] or "" | |||
local cover = args["Coverbild"] or "" | |||
local genre = args["Genre"] or "" | |||
local language = args["Sprache"] or "" | |||
local location = args["Standort"] or "" | |||
local summary = args["Inhaltszusammenfassung"] or "" | |||
local price = args["Preis"] or "" | |||
local originalTitle = args["Original Titel"] or "" | |||
local publisher = args["Verlag"] or "" | |||
local year = args["Erscheinungsjahr"] or "" | |||
local isbn10 = helper.getIsbnLink(args["ISBN-10"], "ISBN-10") | |||
local isbn13 = helper.getIsbnLink(args["ISBN-13"], "ISBN-13") | |||
local dnbID = args["Datensatz ID"] or "" | |||
-- | -- Gesamtbände extrahieren | ||
local | local completeVolumes = buch.getCompleteVolumes(seriesID) | ||
-- Ausgabe für Band | |||
local bandOutput = "Band " .. band | |||
if completeVolumes and completeVolumes ~= "" then | |||
bandOutput = bandOutput .. " von " .. completeVolumes | |||
end | end | ||
return | -- Titelzeile | ||
local result = "'''Titel:''' " .. title .. "\n" | |||
result = result .. "'''Autor(en):''' " .. author .. "\n" | |||
result = result .. "'''Band:''' " .. bandOutput .. "\n" | |||
-- Zusätzliche Felder | |||
result = result .. (publisher ~= "" and "'''Verlag:''' " .. publisher .. "\n" or "") | |||
result = result .. (year ~= "" and "'''Erscheinungsjahr:''' " .. year .. "\n" or "") | |||
result = result .. (isbn10 ~= "" and "'''ISBN-10:''' " .. isbn10 .. "\n" or "") | |||
result = result .. (isbn13 ~= "" and "'''ISBN-13:''' " .. isbn13 .. "\n" or "") | |||
result = result .. (genre ~= "" and "'''Genre:''' " .. genre .. "\n" or "") | |||
result = result .. (language ~= "" and "'''Sprache:''' " .. language .. "\n" or "") | |||
result = result .. (location ~= "" and "'''Standort:''' " .. location .. "\n" or "") | |||
result = result .. (price ~= "" and "'''Preis:''' " .. price .. "\n" or "") | |||
result = result .. (dnbID ~= "" and "'''DNB-ID:''' [[https://d-nb.info/" .. dnbID .. "]]\n" or "") | |||
result = result .. (summary ~= "" and "'''Inhaltszusammenfassung:''' " .. summary .. "\n" or "") | |||
-- Coverbild | |||
local defaultCover = "Library:Cover:BuchDefault.webp" | |||
local coverImage = helper.getCoverImage(cover, defaultCover) | |||
result = result .. "\n" .. coverImage | |||
return result | |||
end | end | ||
return | return buch |
Version vom 21. November 2024, 14:43 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Publikation/Buch/Doku erstellt werden
local smw = require('Module:SMW')
local getArgs = require('Module:Arguments').getArgs
local buch = {}
-- Funktion zur Extraktion der Gesamtbände aus der Serien-ID
function buch.getCompleteVolumes(seriesID)
if not mw.smw then
return "Semantic MediaWiki-Erweiterung nicht gefunden."
end
if not seriesID or seriesID == "" then
return "Keine Serien-ID angegeben."
end
-- Abfrage vorbereiten
local query = { ["[[SerienID::" .. seriesID .. "]]"] = "?Complete volumes" }
local queryResult = mw.smw.getQueryResult(query)
if not queryResult or not queryResult.results then
return "Keine Ergebnisse gefunden."
end
-- Ergebnisse analysieren
for _, result in pairs(queryResult.results) do
local printouts = result.printouts
if printouts and printouts["Complete volumes"] then
return printouts["Complete volumes"][1] -- Gibt den ersten gefundenen Wert zurück
end
end
return "Keine Gesamtbände gefunden."
end
-- Hauptfunktion für die Buchdarstellung
function buch.render(args, helper)
local title = args["Titel"] or "Unbekannt"
local author = args["Autor"] or "Unbekannt"
local band = args["Band"] or ""
local seriesID = args["Hat Serie"] or ""
local cover = args["Coverbild"] or ""
local genre = args["Genre"] or ""
local language = args["Sprache"] or ""
local location = args["Standort"] or ""
local summary = args["Inhaltszusammenfassung"] or ""
local price = args["Preis"] or ""
local originalTitle = args["Original Titel"] or ""
local publisher = args["Verlag"] or ""
local year = args["Erscheinungsjahr"] or ""
local isbn10 = helper.getIsbnLink(args["ISBN-10"], "ISBN-10")
local isbn13 = helper.getIsbnLink(args["ISBN-13"], "ISBN-13")
local dnbID = args["Datensatz ID"] or ""
-- Gesamtbände extrahieren
local completeVolumes = buch.getCompleteVolumes(seriesID)
-- Ausgabe für Band
local bandOutput = "Band " .. band
if completeVolumes and completeVolumes ~= "" then
bandOutput = bandOutput .. " von " .. completeVolumes
end
-- Titelzeile
local result = "'''Titel:''' " .. title .. "\n"
result = result .. "'''Autor(en):''' " .. author .. "\n"
result = result .. "'''Band:''' " .. bandOutput .. "\n"
-- Zusätzliche Felder
result = result .. (publisher ~= "" and "'''Verlag:''' " .. publisher .. "\n" or "")
result = result .. (year ~= "" and "'''Erscheinungsjahr:''' " .. year .. "\n" or "")
result = result .. (isbn10 ~= "" and "'''ISBN-10:''' " .. isbn10 .. "\n" or "")
result = result .. (isbn13 ~= "" and "'''ISBN-13:''' " .. isbn13 .. "\n" or "")
result = result .. (genre ~= "" and "'''Genre:''' " .. genre .. "\n" or "")
result = result .. (language ~= "" and "'''Sprache:''' " .. language .. "\n" or "")
result = result .. (location ~= "" and "'''Standort:''' " .. location .. "\n" or "")
result = result .. (price ~= "" and "'''Preis:''' " .. price .. "\n" or "")
result = result .. (dnbID ~= "" and "'''DNB-ID:''' [[https://d-nb.info/" .. dnbID .. "]]\n" or "")
result = result .. (summary ~= "" and "'''Inhaltszusammenfassung:''' " .. summary .. "\n" or "")
-- Coverbild
local defaultCover = "Library:Cover:BuchDefault.webp"
local coverImage = helper.getCoverImage(cover, defaultCover)
result = result .. "\n" .. coverImage
return result
end
return buch