Zuletzt bearbeitet vor 2 Monaten
von Xineohp1506

Modul:Publikation/Buch: Unterschied zwischen den Versionen

Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 3: Zeile 3:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs


function buch.render(frame)
function buch.render(frame, main)
     -- Argumente aus dem Frame extrahieren
     local args = frame.args -- Argumente aus dem Frame extrahieren
     local args = frame.args
     local output = '<table class="publikation buch">'
    local seriesID = args["SerienID"]
    local band = args["Band"] or "Unbekannt"
    local seriesName = args["Hat Serie"] or "Unbekannte Serie"


     -- Überprüfen, ob eine Serien-ID angegeben ist
     -- Coverbild
     if not seriesID then
    output = output .. '<tr><td colspan="2" style="text-align: center;">' .. main.getCoverImage(args["Coverbild"], "Library:Cover:DefaultBuchCover.webp") .. '</td></tr>'
         return "Fehler: Serien-ID nicht angegeben."
 
    -- Titel
    output = output .. '<tr><td><strong>Titel</strong></td><td>[[Hat Titel::' .. (args["Titel"] or "Unbekannt") .. ']]</td></tr>'
 
    -- Autoren (Mehrfachwerte als Liste)
     if args["Autor"] then
         output = output .. '<tr><td><strong>Autor(en)</strong></td><td>'
        for author in mw.text.gsplit(args["Autor"], ",") do
            output = output .. '[[Hat Autor::' .. mw.text.trim(author) .. ']], '
        end
        output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
     end
     end


     -- Serien-Seite abrufen
     -- Verlag
     local seriesQuery = "[[SerienID::" .. seriesID .. "]]"
     output = output .. (args["Verlag"] and '<tr><td><strong>Verlag</strong></td><td>[[Verlag::' .. args["Verlag"] .. ']]</td></tr>' or "")
    local seriesPageTitle = helper.getSeriesPageTitle({ args = { seriesQuery } })
 
    if seriesPageTitle == "Keine Ergebnisse gefunden." then
    -- Band und Serie
        return "Fehler: Serien-Seite konnte nicht abgerufen werden."
    if args["Band"] then
        local seriesID = args["SerienID"]
        local bandText = args["Band"]
 
        if seriesID then
            local seriesPageTitle = helper.getSeriesPageTitle({ args = { "[[SerienID::" .. seriesID .. "]]" } })
            local completeVolumes = "Keine Ergebnisse gefunden."
 
            if seriesPageTitle ~= "Keine Ergebnisse gefunden." then
                completeVolumes = helper.getCompleteVolumesByTitle({ args = { seriesPageTitle, "Complete volumes" } })
            end
 
            bandText = bandText .. " von " .. (completeVolumes or "?") .. ' ([[Library:Serie:' .. mw.uri.anchorEncode(seriesPageTitle) .. '|' .. (args["Hat Serie"] or "Serie") .. "]])"
        end
 
        output = output .. '<tr><td><strong>Band</strong></td><td>' .. bandText .. '</td></tr>'
     end
     end


     -- Gesamtbände abrufen
     -- Erscheinungsjahr
     local completeVolumes = helper.getCompleteVolumesByTitle({ args = { seriesPageTitle, "Complete volumes" } })
     output = output .. (args["Erscheinungsjahr"] and '<tr><td><strong>Erscheinungsjahr</strong></td><td>[[Erscheinungsjahr::' .. args["Erscheinungsjahr"] .. ']]</td></tr>' or "")
     if completeVolumes == "Keine Ergebnisse gefunden." then
 
         completeVolumes = "Unbekannt"
    -- ISBN
     if args["ISBN-10"] or args["ISBN-13"] then
        local isbn10 = main.getIsbnLink(args["ISBN-10"], "ISBN-10")
        local isbn13 = main.getIsbnLink(args["ISBN-13"], "ISBN-13")
         output = output .. '<tr><td><strong>ISBN</strong></td><td>' .. isbn10 .. (isbn10 ~= "" and isbn13 ~= "" and " / " or "") .. isbn13 .. '</td></tr>'
     end
     end


     -- Serien-Link erstellen
     -- Sprache
     local seriesLink = '[[' .. seriesPageTitle .. '|' .. seriesName .. ']]'
    output = output .. (args["Sprache"] and '<tr><td><strong>Sprache</strong></td><td>[[Sprache::' .. args["Sprache"] .. ']]</td></tr>' or "")
 
    -- Standort
     output = output .. (args["Standort"] and '<tr><td><strong>Standort</strong></td><td>[[Standort::' .. args["Standort"] .. ']]</td></tr>' or "")
 
    -- Umfang (Seitenanzahl)
    output = output .. (args["Umfang"] and '<tr><td><strong>Umfang</strong></td><td>[[Umfang::' .. args["Umfang"] .. ']] Seiten</td></tr>' or "")
 
    -- Preis
    output = output .. (args["Preis"] and '<tr><td><strong>Preis</strong></td><td>[[Preis::' .. args["Preis"] .. ']]</td></tr>' or "")
 
    -- Inhaltszusammenfassung
    output = output .. (args["Inhaltszusammenfassung"] and '<tr><td><strong>Inhaltszusammenfassung</strong></td><td>' .. args["Inhaltszusammenfassung"] .. '</td></tr>' or "")
 
    output = output .. '</table>'


    -- Ausgabeformat
     return output
     return string.format(
        "Band %s von %s (%s)",
        band,
        completeVolumes,
        seriesLink
    )
end
end


return buch
return buch

Version vom 23. November 2024, 00:32 Uhr

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

local buch = {}
local helper = require("Modul:Publikation/SerieHelper")
local getArgs = require('Module:Arguments').getArgs

function buch.render(frame, main)
    local args = frame.args -- Argumente aus dem Frame extrahieren
    local output = '<table class="publikation buch">'

    -- Coverbild
    output = output .. '<tr><td colspan="2" style="text-align: center;">' .. main.getCoverImage(args["Coverbild"], "Library:Cover:DefaultBuchCover.webp") .. '</td></tr>'

    -- Titel
    output = output .. '<tr><td><strong>Titel</strong></td><td>[[Hat Titel::' .. (args["Titel"] or "Unbekannt") .. ']]</td></tr>'

    -- Autoren (Mehrfachwerte als Liste)
    if args["Autor"] then
        output = output .. '<tr><td><strong>Autor(en)</strong></td><td>'
        for author in mw.text.gsplit(args["Autor"], ",") do
            output = output .. '[[Hat Autor::' .. mw.text.trim(author) .. ']], '
        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 "")

    -- Band und Serie
    if args["Band"] then
        local seriesID = args["SerienID"]
        local bandText = args["Band"]

        if seriesID then
            local seriesPageTitle = helper.getSeriesPageTitle({ args = { "[[SerienID::" .. seriesID .. "]]" } })
            local completeVolumes = "Keine Ergebnisse gefunden."

            if seriesPageTitle ~= "Keine Ergebnisse gefunden." then
                completeVolumes = helper.getCompleteVolumesByTitle({ args = { seriesPageTitle, "Complete volumes" } })
            end

            bandText = bandText .. " von " .. (completeVolumes or "?") .. ' ([[Library:Serie:' .. mw.uri.anchorEncode(seriesPageTitle) .. '|' .. (args["Hat Serie"] or "Serie") .. "]])"
        end

        output = output .. '<tr><td><strong>Band</strong></td><td>' .. bandText .. '</td></tr>'
    end

    -- Erscheinungsjahr
    output = output .. (args["Erscheinungsjahr"] and '<tr><td><strong>Erscheinungsjahr</strong></td><td>[[Erscheinungsjahr::' .. args["Erscheinungsjahr"] .. ']]</td></tr>' or "")

    -- ISBN
    if args["ISBN-10"] or args["ISBN-13"] then
        local isbn10 = main.getIsbnLink(args["ISBN-10"], "ISBN-10")
        local isbn13 = main.getIsbnLink(args["ISBN-13"], "ISBN-13")
        output = output .. '<tr><td><strong>ISBN</strong></td><td>' .. isbn10 .. (isbn10 ~= "" and isbn13 ~= "" and " / " or "") .. isbn13 .. '</td></tr>'
    end

    -- Sprache
    output = output .. (args["Sprache"] and '<tr><td><strong>Sprache</strong></td><td>[[Sprache::' .. args["Sprache"] .. ']]</td></tr>' or "")

    -- Standort
    output = output .. (args["Standort"] and '<tr><td><strong>Standort</strong></td><td>[[Standort::' .. args["Standort"] .. ']]</td></tr>' or "")

    -- Umfang (Seitenanzahl)
    output = output .. (args["Umfang"] and '<tr><td><strong>Umfang</strong></td><td>[[Umfang::' .. args["Umfang"] .. ']] Seiten</td></tr>' or "")

    -- Preis
    output = output .. (args["Preis"] and '<tr><td><strong>Preis</strong></td><td>[[Preis::' .. args["Preis"] .. ']]</td></tr>' or "")

    -- Inhaltszusammenfassung
    output = output .. (args["Inhaltszusammenfassung"] and '<tr><td><strong>Inhaltszusammenfassung</strong></td><td>' .. args["Inhaltszusammenfassung"] .. '</td></tr>' or "")

    output = output .. '</table>'

    return output
end

return buch