Zuletzt bearbeitet vor 2 Monaten
von Xineohp1506

Modul:LPON/Projekt: Unterschied zwischen den Versionen

(Die Seite wurde neu angelegt: „local getArgs = require('Module:Arguments').getArgs local helper = require('Module:LPON/Helper') local projekt = {} function projekt.render(frame) local args = getArgs(frame) local output = "" -- DISPLAYTITLE setzen if args["Titel"] then helper.setDisplayTitle({title = args["Titel"]}) end -- Semantische Daten setzen if args["Status"] then helper.setProperty({args = {["LPON:Status"] = args["Status"]}}) end…“)
 
Keine Bearbeitungszusammenfassung
 
(56 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 1: Zeile 1:
local getArgs = require('Module:Arguments').getArgs
local getArgs = require('Module:Arguments').getArgs
local helper = require('Module:LPON/Helper')
local helper = require('Module:LPON/Helper')
local modOutput = require('Module:LPON/ModOutput')
local episodeOutput = require('Module:LPON/EpisodeOutput')
local transcluder = require('Module:Transcluder')
local projekt = {}
local projekt = {}


function projekt.render(frame)
function projekt.render(frame)
     local args = getArgs(frame)
     local args = getArgs(frame)
    local frame = mw.getCurrentFrame()
    local cleanProjektname = helper.cleanString(args["Titel"])
    local cleanGame = helper.cleanString(args["Game"])
     local output = ""
     local output = ""
   
    -- Setzen des Datensatztyp
helper.setProperty({args = {["LPON:Typ"] = "Projekt"}})


     -- DISPLAYTITLE setzen
     -- DISPLAYTITLE setzen
     if args["Titel"] then
     if args["Titel"] then
         helper.setDisplayTitle({title = args["Titel"]})
         helper.setDisplayTitle({title = args["Titel"]})
        helper.setProperty({args = {["LPON:Projekt"] = cleanProjektname}})
        helper.setProperty({args = {["LPON:Title"] = args["Titel"]}})
     end
     end


     -- Semantische Daten setzen
     -- Setze die Beschreibung als semantischen Wert
     if args["Status"] then
    if args["Beschreibung"] and args["Beschreibung"] ~= "" then
         helper.setProperty({args = {["LPON:Status"] = args["Status"]}})
    local truncatedSummary = helper.cleanAndTruncate(args["Beschreibung"], 200)
        helper.setProperty({args = {["LPON:Description"] = truncatedSummary}}) -- Setze den semantischen Wert
        mw.ext.seo.set{description = truncatedSummary} -- Setze die Beschreibung
    end
 
    -- Infobox Container
    output = output .. '<div class="infobox lpnon-infobox">\n'
 
    -- Coverbild in der Infobox
    local coverImage = args["Coverbild"] or "DefaultProjektCover.webp"
    output = output .. '<div class="infobox-image">\n'
    output = output .. '[[File:' .. coverImage .. '|240px|center|alt=Cover von ' .. (args["Titel"] or "Projekt") .. ']]\n'
    output = output .. '</div>\n'
 
    -- Titel in der Infobox
    output = output .. '<div class="infobox-title">' .. (args["Titel"] or "Unbekannt") .. '</div>\n'
 
    -- Tabelleninhalt der Infobox
    output = output .. '<table class="infobox-table">\n'
 
-- Game
    if args["Game"] and args["Game"] ~= "" then
        helper.setProperty({ args = { ["LPON:Game"] = cleanGame } })
        helper.setProperty({ args = {["LPON:GameTitle"] = args["Game"]}})
        output = output .. '<tr><th>Game</th><td>[[' .. cleanGame.. '|' .. args["Game"] .. ']]</td></tr>\n'
    end
   
    -- Status
     if args["Status"] and args["Status"] ~= "" then
         helper.setProperty({ args = { ["LPON:Status"] = args["Status"] } })
        output = output .. '<tr><th>Status</th><td>' .. args["Status"] .. '</td></tr>\n'
     end
     end


     if args["Spieler"] then
    -- Spieler
     if args["Spieler"] and args["Spieler"] ~= "" then
        local playerList = {}
         for player in mw.text.gsplit(args["Spieler"], ",") do
         for player in mw.text.gsplit(args["Spieler"], ",") do
             helper.setProperty({args = {["LPON:Spieler"] = mw.text.trim(player)}})
            player = mw.text.trim(player)
            local playerPage = helper.getPlayerLink(frame, player)
             helper.setProperty({ args = { ["LPON:Spieler"] = player } })
            table.insert(playerList, playerPage)
         end
         end
        output = output .. '<tr><th>Spieler</th><td>' .. table.concat(playerList, ", ") .. '</td></tr>\n'
     end
     end


     if args["Beschreibung"] then
    -- Startdatum
        local truncatedDesc = mw.ustring.sub(args["Beschreibung"], 1, 250)
     if args["Startdatum"] and args["Startdatum"] ~= "" then
         helper.setProperty({args = {["LPON:Beschreibung"] = truncatedDesc}})
         helper.setProperty({ args = { ["LPON:Startdatum"] = args["Startdatum"] } })
        output = output .. '<tr><th>Startdatum</th><td>' .. args["Startdatum"] .. '</td></tr>\n'
     end
     end


    -- Infobox
     output = output .. '</table>\n'  -- Ende der Tabelle
     output = output .. string.format([[
     output = output .. '</div>\n'  -- Ende der Infobox
<div class="lpnon-infobox">
      
    <strong>Projekt:</strong> %s<br />
     <strong>Status:</strong> %s<br />
    <strong>Spieler:</strong> %s<br />
</div>
     ]],
    args["Titel"] or mw.title.getCurrentTitle().text,
    args["Status"] or "Unbekannt",
    args["Spieler"] or "Keine Spieler angegeben")
 
     -- Beschreibung
     -- Beschreibung
     output = output .. string.format('<div class="lpnon-description">%s</div>', args["Beschreibung"] or "Keine Beschreibung verfügbar.")
     output = output .. '<div class="lpnon-description">'.. (args["Beschreibung"] or "Keine Beschreibung angegeben") ..'</div>'
   
-- Screenshots ausgeben
output = output .. '<h2>Screenshots</h2>\n'
if args["Bilder"] and args["Bilder"] ~= "" then
    output = output .. '<div class="lpon-gallery">\n'
    for imageData in mw.text.gsplit(args["Bilder"], ",") do
        local parts = mw.text.split(imageData, "|")
        local image = mw.text.trim(parts[1])
        local caption = parts[2] and mw.text.trim(parts[2]) or ""
        output = output .. string.format('[[File:%s|thumb|alt=%s|%s]]\n', image, caption, caption)
    end
    output = output .. '</div>\n'
else
    output = output .. '<p>Keine Bilder verfügbar.</p>\n'
end
   
-- Spieler Links
output = output .. '<h2>Links</h2>\n'
output = output .. '<div class="lpon-links">\n'
if args["Spieler"] and args["Spieler"] ~= "" then
    for player in mw.text.gsplit(args["Spieler"], ",") do
        player = mw.text.trim(player)
        local linkPage = "LetsPlayOrNot:" .. player .. "/Links"
        local rawContent = transcluder.get(linkPage)
        local parsedContent = frame:preprocess(rawContent)
        output = output .. '<div class="lpon-player-links"><h3>'  .. player ..  ':</h3>\n'
        output = output .. parsedContent .. '\n'
        output = output .. '</div>\n'
    end
else
    output = output .. '<p>Keine Links verfügbar.</p>\n'
end
output = output .. '</div>\n'
-- AddInfoPage
if args["AddInfo"] == "true" then
output = output .. '<div class="lpon-addinfo">\n'
    local AddInfoPage = "LetsPlayOrNot:" .. cleanProjektname .. "/AddInfo"
    local AddInfoRawContent = transcluder.get(AddInfoPage)
    local AddInfoParsedContent = frame:preprocess(AddInfoRawContent)
    output = output .. AddInfoParsedContent .. '\n'
    output = output .. '</div>\n'
end
    -- Cheats (falls aktiviert)
if args["useCheats"] == "true" then
    output = output .. '<h2>Cheats</h2>\n'
    output = output .. '<div class="lpon-cheats">\n'
    -- Cheats von der Unterseite /Cheats einbinden
    local cheatPage = "LetsPlayOrNot:" .. mw.title.getCurrentTitle().text .. "/Cheats"
    local rawContent = transcluder.get(cheatPage)
    local parsedContent = frame:preprocess(rawContent)
    -- Inhalte hinzufügen
    if parsedContent and parsedContent ~= "" then
        output = output .. parsedContent .. '\n'
    else
        output = output .. '<p>Keine Cheats eingetragen.</p>\n'
    end
    output = output .. '</div>\n'
end


    -- Mods (optional Subseite oder direkt)
-- Mods (optional Subseite oder direkt)
    if args["useSubpage"] == "true" then
if args["useModSubpage"] and args["useModSubpage"] ~= "" then
        output = output .. string.format('<div class="lpnon-mods"><a href="%s/Mods">Zur Modliste</a></div>', mw.title.getCurrentTitle().text)
    output = output .. '<h2>Mods</h2>\n'
    else
    if args["useModSubpage"] == "true" then
        output = output .. '<div class="lpnon-mods"><ul><li>Mod 1</li><li>Mod 2</li></ul></div>'
        local currentTitle = mw.title.getCurrentTitle().text
    end
        output = output .. string.format('<div class="lpnon-mods">[[LetsPlayOrNot:%s/Mods|Zur Modliste]]</div>', currentTitle)
    elseif args["useModSubpage"] == "false" then
        output = output .. modOutput.inside(cleanProjektname)
    end
else
    -- Keine Ausgabe
    output = output .. '<!-- Keine Mods angegeben -->\n'
end


     -- Folgen (optional Subseite oder direkt)
     -- Folgen (optional Subseite oder direkt)
    if args["useEpisodesSubpage"] == "true" then
-- Folgen (optional Subseite oder direkt)
        output = output .. string.format('<div class="lpnon-episodes"><a href="%s/Folgen">Zur Folgenübersicht</a></div>', mw.title.getCurrentTitle().text)
if args["useEpisodesSubpage"] and args["useEpisodesSubpage"] ~= "" then
    else
    output = output .. '<h2>Folgen</h2>\n'
        output = output .. '<div class="lpnon-episodes"><ul><li>Folge 1</li><li>Folge 2</li></ul></div>'
    if args["useEpisodesSubpage"] == "true" then
    end
        local currentTitle = mw.title.getCurrentTitle().text
        output = output .. string.format('<div class="lpnon-mods">[[LetsPlayOrNot:%s/Episoden|Zur Episodenliste]]</div>', currentTitle)
    elseif args["useEpisodesSubpage"] == "false" then
        output = output .. episodeOutput.inside(frame, cleanProjektname)
    end
else
    output = output .. '<!-- Keine Episoden angegeben -->\n'
end


     -- Kategorien setzen
     -- Kategorien setzen
     local categories = {"LPON Projekte"}
     local categories = {} -- Korrekte Initialisierung der Tabelle
   
     if args["Spieler"] then
     if args["Spieler"] then
         for player in mw.text.gsplit(args["Spieler"], ",") do
         for player in mw.text.gsplit(args["Spieler"], ",") do
             table.insert(categories, "Spieler:" .. mw.text.trim(player))
             table.insert(categories, "LPON:Spieler:" .. mw.text.trim(player))
         end
         end
     end
     end
     if args["Status"] then
     if args["Status"] then
         table.insert(categories, "Status:" .. args["Status"])
         table.insert(categories, "LPON:Status:" .. args["Status"])
     end
     end
   
    -- Hinzufügen allgemeiner Kategorien
    --table.insert(categories, "All LPON")


     output = output .. helper.addCategories({categories = categories, sortkey = args["Titel"]})
     output = output .. helper.addCategories({categories = categories, sortkey = args["Titel"]})
    output = output .. helper.addCategories({categories = "LPON:" .. helper.cleanString(args["Titel"]), sortkey = "!"})


     return output
     return output

Aktuelle Version vom 21. Dezember 2024, 01:44 Uhr

Die Dokumentation für dieses Modul kann unter Modul:LPON/Projekt/Doku erstellt werden

local getArgs = require('Module:Arguments').getArgs
local helper = require('Module:LPON/Helper')
local modOutput = require('Module:LPON/ModOutput')
local episodeOutput = require('Module:LPON/EpisodeOutput')
local transcluder = require('Module:Transcluder')
local projekt = {}

function projekt.render(frame)
    local args = getArgs(frame)
    local frame = mw.getCurrentFrame()
    local cleanProjektname = helper.cleanString(args["Titel"])
    local cleanGame = helper.cleanString(args["Game"])
    local output = ""
    
    -- Setzen des Datensatztyp
	helper.setProperty({args = {["LPON:Typ"] = "Projekt"}})

    -- DISPLAYTITLE setzen
    if args["Titel"] then
        helper.setDisplayTitle({title = args["Titel"]})
        helper.setProperty({args = {["LPON:Projekt"] = cleanProjektname}})
        helper.setProperty({args = {["LPON:Title"] = args["Titel"]}})
    end

    -- Setze die Beschreibung als semantischen Wert
    if args["Beschreibung"] and args["Beschreibung"] ~= "" then
    	local truncatedSummary = helper.cleanAndTruncate(args["Beschreibung"], 200)
        helper.setProperty({args = {["LPON:Description"] = truncatedSummary}}) -- Setze den semantischen Wert
        mw.ext.seo.set{description = truncatedSummary} -- Setze die Beschreibung
    end

    -- Infobox Container
    output = output .. '<div class="infobox lpnon-infobox">\n'

    -- Coverbild in der Infobox
    local coverImage = args["Coverbild"] or "DefaultProjektCover.webp"
    output = output .. '<div class="infobox-image">\n'
    output = output .. '[[File:' .. coverImage .. '|240px|center|alt=Cover von ' .. (args["Titel"] or "Projekt") .. ']]\n'
    output = output .. '</div>\n'

    -- Titel in der Infobox
    output = output .. '<div class="infobox-title">' .. (args["Titel"] or "Unbekannt") .. '</div>\n'

    -- Tabelleninhalt der Infobox
    output = output .. '<table class="infobox-table">\n'

	-- Game
    if args["Game"] and args["Game"] ~= "" then
        helper.setProperty({ args = { ["LPON:Game"] = cleanGame } })
        helper.setProperty({ args = {["LPON:GameTitle"] = args["Game"]}})
        output = output .. '<tr><th>Game</th><td>[[' .. cleanGame.. '|' .. args["Game"] .. ']]</td></tr>\n'
    end
    
    -- Status
    if args["Status"] and args["Status"] ~= "" then
        helper.setProperty({ args = { ["LPON:Status"] = args["Status"] } })
        output = output .. '<tr><th>Status</th><td>' .. args["Status"] .. '</td></tr>\n'
    end

    -- Spieler
    if args["Spieler"] and args["Spieler"] ~= "" then
        local playerList = {}
        for player in mw.text.gsplit(args["Spieler"], ",") do
            player = mw.text.trim(player)
            local playerPage = helper.getPlayerLink(frame, player)
            helper.setProperty({ args = { ["LPON:Spieler"] = player } })
            table.insert(playerList, playerPage)
        end
        output = output .. '<tr><th>Spieler</th><td>' .. table.concat(playerList, ", ") .. '</td></tr>\n'
    end

    -- Startdatum
    if args["Startdatum"] and args["Startdatum"] ~= "" then
        helper.setProperty({ args = { ["LPON:Startdatum"] = args["Startdatum"] } })
        output = output .. '<tr><th>Startdatum</th><td>' .. args["Startdatum"] .. '</td></tr>\n'
    end

    output = output .. '</table>\n'  -- Ende der Tabelle
    output = output .. '</div>\n'  -- Ende der Infobox
    
    -- Beschreibung
    output = output .. '<div class="lpnon-description">'.. (args["Beschreibung"] or "Keine Beschreibung angegeben") ..'</div>'
    
	-- Screenshots ausgeben
	output = output .. '<h2>Screenshots</h2>\n'
	if args["Bilder"] and args["Bilder"] ~= "" then
	    output = output .. '<div class="lpon-gallery">\n'
	    for imageData in mw.text.gsplit(args["Bilder"], ",") do
	        local parts = mw.text.split(imageData, "|")
	        local image = mw.text.trim(parts[1])
	        local caption = parts[2] and mw.text.trim(parts[2]) or ""
	        output = output .. string.format('[[File:%s|thumb|alt=%s|%s]]\n', image, caption, caption)
	    end
	    output = output .. '</div>\n'
	else
	    output = output .. '<p>Keine Bilder verfügbar.</p>\n'
	end
    
	-- Spieler Links
	output = output .. '<h2>Links</h2>\n'
	output = output .. '<div class="lpon-links">\n'
	if args["Spieler"] and args["Spieler"] ~= "" then
	    for player in mw.text.gsplit(args["Spieler"], ",") do
	        player = mw.text.trim(player)
	        local linkPage = "LetsPlayOrNot:" .. player .. "/Links"
	        local rawContent = transcluder.get(linkPage)
	        local parsedContent = frame:preprocess(rawContent)
	        output = output .. '<div class="lpon-player-links"><h3>'  .. player ..  ':</h3>\n'
	        output = output .. parsedContent .. '\n'
	        output = output .. '</div>\n'
	    end
	else
	    output = output .. '<p>Keine Links verfügbar.</p>\n'
	end
	output = output .. '</div>\n'
	
	-- AddInfoPage
	if args["AddInfo"] == "true" then
		output = output .. '<div class="lpon-addinfo">\n'
		    local AddInfoPage = "LetsPlayOrNot:" .. cleanProjektname .. "/AddInfo"
		    local AddInfoRawContent = transcluder.get(AddInfoPage)
		    local AddInfoParsedContent = frame:preprocess(AddInfoRawContent)
		    output = output .. AddInfoParsedContent .. '\n'
	    output = output .. '</div>\n'
	end
	
    -- Cheats (falls aktiviert)
	if args["useCheats"] == "true" then
	    output = output .. '<h2>Cheats</h2>\n'
	    output = output .. '<div class="lpon-cheats">\n'
	
	    -- Cheats von der Unterseite /Cheats einbinden
	    local cheatPage = "LetsPlayOrNot:" .. mw.title.getCurrentTitle().text .. "/Cheats"
	    local rawContent = transcluder.get(cheatPage)
	    local parsedContent = frame:preprocess(rawContent)
	
	    -- Inhalte hinzufügen
	    if parsedContent and parsedContent ~= "" then
	        output = output .. parsedContent .. '\n'
	    else
	        output = output .. '<p>Keine Cheats eingetragen.</p>\n'
	    end
	
	    output = output .. '</div>\n'
	end

	-- Mods (optional Subseite oder direkt)
	if args["useModSubpage"] and args["useModSubpage"] ~= "" then
	    output = output .. '<h2>Mods</h2>\n'
	    if args["useModSubpage"] == "true" then
	        local currentTitle = mw.title.getCurrentTitle().text
	        output = output .. string.format('<div class="lpnon-mods">[[LetsPlayOrNot:%s/Mods|Zur Modliste]]</div>', currentTitle)
	    elseif args["useModSubpage"] == "false" then
	        output = output .. modOutput.inside(cleanProjektname)
	    end
	else
	    -- Keine Ausgabe
	    output = output .. '<!-- Keine Mods angegeben -->\n'
	end

    -- Folgen (optional Subseite oder direkt)
	-- Folgen (optional Subseite oder direkt)
	if args["useEpisodesSubpage"] and args["useEpisodesSubpage"] ~= "" then
	    output = output .. '<h2>Folgen</h2>\n'
	    if args["useEpisodesSubpage"] == "true" then
	        local currentTitle = mw.title.getCurrentTitle().text
	        output = output .. string.format('<div class="lpnon-mods">[[LetsPlayOrNot:%s/Episoden|Zur Episodenliste]]</div>', currentTitle)
	    elseif args["useEpisodesSubpage"] == "false" then
	        output = output .. episodeOutput.inside(frame, cleanProjektname)
	    end
	else
	    output = output .. '<!-- Keine Episoden angegeben -->\n'
	end

    -- Kategorien setzen
    local categories = {} -- Korrekte Initialisierung der Tabelle
    
    if args["Spieler"] then
        for player in mw.text.gsplit(args["Spieler"], ",") do
            table.insert(categories, "LPON:Spieler:" .. mw.text.trim(player))
        end
    end
    if args["Status"] then
        table.insert(categories, "LPON:Status:" .. args["Status"])
    end
    
    -- Hinzufügen allgemeiner Kategorien
    --table.insert(categories, "All LPON")

    output = output .. helper.addCategories({categories = categories, sortkey = args["Titel"]})
    output = output .. helper.addCategories({categories = "LPON:" .. helper.cleanString(args["Titel"]), sortkey = "!"})

    return output
end

return projekt