Zuletzt bearbeitet vor 3 Monaten
von Xineohp1506

Modul:Publikation/Manga: Unterschied zwischen den Versionen

Keine Bearbeitungszusammenfassung
Keine Bearbeitungszusammenfassung
Zeile 111: Zeile 111:


     -- ISBN
     -- ISBN
    if args["ISBN-10"] or args["ISBN-13"] then
if args["ISBN-10"] or args["ISBN-13"] then
        local isbn10 = helper.getIsbnLink({isbn = args["ISBN-10"], version = "ISBN-10"})
    local isbn10 = args["ISBN-10"] and helper.getIsbnLink({isbn = args["ISBN-10"], version = "ISBN-10"}) or ""
        local isbn13 = helper.getIsbnLink({isbn = args["ISBN-13"], version = "ISBN-13"})
    local isbn13 = args["ISBN-13"] and helper.getIsbnLink({isbn = args["ISBN-13"], version = "ISBN-13"}) or ""
        output = output .. '<tr><td><strong>ISBN</strong></td><td>' .. isbn10 .. (isbn10 ~= "" and isbn13 ~= "" and " / " or "") .. isbn13 .. '</td></tr>'
    end
    -- Semantische Werte setzen
    if args["ISBN-10"] and args["ISBN-10"] ~= "" then
        helper.setProperty({args = {["Hat ISBN-10"] = args["ISBN-10"]}})
    end
    if args["ISBN-13"] and args["ISBN-13"] ~= "" then
        helper.setProperty({args = {["Hat ISBN-13"] = args["ISBN-13"]}})
    end
    -- Anzeige der ISBN
    output = output .. '<tr><td><strong>ISBN</strong></td><td>' .. isbn10 .. (isbn10 ~= "" and isbn13 ~= "" and " / " or "") .. isbn13 .. '</td></tr>'
end
 
      
      
-- Genre (Mehrfachwerte als Liste)
-- Genre (Mehrfachwerte als Liste)

Version vom 26. November 2024, 23:41 Uhr

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

local getArgs = require('Module:Arguments').getArgs
local helper = require("Modul:Publikation/Helper")
local related = require("Modul:Publikation/Related")
local manga = {}

function manga.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 das semantische Attribut "Hat Serie", falls es definiert ist
    if args["Hat Serie"] and args["Hat Serie"] ~= "" then
        helper.setProperty({ args = { ["Hat Serie"] = args["Hat Serie"] } })
    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 manga table">'

    -- Coverbild
    output = output .. '<tr><td colspan="2" style="text-align: center;">' .. helper.getCoverImage({cover = args["Coverbild"], defaultCover = "Library:Cover:DefaultMangaCover.webp"}) .. '</td></tr>'

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

    -- Original Titel
    if args["Original Titel"] and args["Original Titel"] ~= "" then
        output = output .. '<tr><td><strong>Original Titel</strong></td><td>[[Original Titel::' .. args["Original Titel"] .. ']]</td></tr>'
    end
    
	-- Autoren mit separater semantischer Speicherung und Links
    if args["Autor"] and 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 .. ']], ' -- Link erstellen
        end
        output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
    end
    
    -- Mangaka mit separater semantischer Speicherung und Links
	if args["Mangaka"] and args["Mangaka"] ~= "" then
    	output = output .. '<tr><td><strong>Mangaka</strong></td><td>'
    	for mangaka in mw.text.gsplit(args["Mangaka"], ",") do
        	mangaka = mw.text.trim(mangaka)
        	local mangakaPage = "Library:Mangaka:" .. mangaka:gsub(" ", "_")
        	helper.setProperty({ args = { ["Mangaka"] = mangaka } }) -- Semantischen Wert setzen
        	output = output .. '[[' .. mangakaPage .. '|' .. mangaka .. ']], ' -- Link erstellen
    	end
    	output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
	end


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

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

    -- Band und Serie
    if args["Band"] then
        local seriesID = args["SerienID"]
        local bandText = args["Band"]
        helper.setProperty({ args = { ["Band"] = args["Band"] } }) -- Semantischen Wert setzen

        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 "?") .. ' ([[' .. mw.uri.anchorEncode(seriesPageTitle) .. '|' .. (args["Hat Serie"] or "Serie") .. "]])"
        end
        output = output .. '<tr><td><strong>Band</strong></td><td>' .. bandText .. '</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 "")

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

    -- 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 = 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 setzen
	    if args["ISBN-10"] and args["ISBN-10"] ~= "" then
	        helper.setProperty({args = {["Hat ISBN-10"] = args["ISBN-10"]}})
	    end
	    if args["ISBN-13"] and args["ISBN-13"] ~= "" then
	        helper.setProperty({args = {["Hat ISBN-13"] = args["ISBN-13"]}})
	    end
	
	    -- Anzeige der ISBN
	    output = output .. '<tr><td><strong>ISBN</strong></td><td>' .. isbn10 .. (isbn10 ~= "" and isbn13 ~= "" and " / " or "") .. isbn13 .. '</td></tr>'
	end

    
	-- Genre (Mehrfachwerte als Liste)
    if args["Genre"] and args["Genre"] ~= "" then
        output = output .. '<tr><td><strong>Genre</strong></td><td>'
        for genre in mw.text.gsplit(args["Genre"], ",") do
            genre = mw.text.trim(genre) -- Entfernt führende/trailing Whitespaces
            output = output .. '[[Genre::' .. genre .. ']], '
        end
        output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
    end   
    
    -- Preis
    output = output .. (args["Preis"] and '<tr><td><strong>Preis</strong></td><td>[[Preis::' .. args["Preis"] .. ']]</td></tr>' or "")

    -- Umfang
    output = output .. (args["Umfang"] and '<tr><td><strong>Umfang</strong></td><td>[[Umfang::' .. args["Umfang"] .. ']] Seiten</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
    
    -- Inhaltszusammenfassung
    if args["Inhaltszusammenfassung"] then
        output = output .. '<tr><td><strong>Inhaltszusammenfassung</strong></td><td>' .. args["Inhaltszusammenfassung"] .. '</td></tr>'
    end
    
    output = output .. '</table>'

	-- Weitere Bücher in der Serie (unterhalb der Tabelle)
    if args["Hat Serie"] then
        local relatedBooks = related.buchRelated({ 
    		series = args["Hat Serie"], 
    		limit = 5 ,
    		defaultCover = "DefaultMangaCover.webp" -- Default-Cover
		})
        output = output .. '<div class="related-books">' ..
                 '<h2>Weitere Bücher in der Serie:</h2>' ..
                  (relatedBooks or "<p>Keine weiteren Bände verfügbar.</p>") ..
                  '</div>'
    end
    
    -- Kategorien setzen
    local categories = {} -- Korrekte Initialisierung der Tabelle

    -- Kategorien basierend auf Argumenten hinzufügen
    if args["Genre"] then
        for genre in mw.text.gsplit(args["Genre"], ",") do
            table.insert(categories, mw.text.trim(genre))
        end
    end
    if args["Standort"] then
        table.insert(categories, "Standort:" .. args["Standort"])
    end
    
    if args["Mangaka"] and args["Mangaka"] ~= "" then
        for mangaka in mw.text.gsplit(args["Mangaka"], ",") do
            table.insert(categories,  "Mangaka:" .. mw.text.trim(mangaka))
        end
    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["Hat Serie"] and args["Hat Serie"] ~= "" then
        table.insert(categories, "Serie:" .. args["Hat Serie"])
    end
    
    if args["Verlag"] and args["Verlag"] ~= "" then
        table.insert(categories, args["Verlag"])
    end
    
    -- Hinzufügen allgemeiner Kategorien
    table.insert(categories, "Mangas")
    table.insert(categories, "Alle Publikationen")

    -- Kategorien hinzufügen
    output = output .. helper.addCategories({categories = categories, sortkey = args["Titel"]})
    
    return output
end

return manga