Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 116: | Zeile 116: | ||
-- AddInfoPage | -- AddInfoPage | ||
if args["AddInfo"] | if args["AddInfo"] == "true" then | ||
output = output .. '<div class="lpon-addinfo">\n' | output = output .. '<div class="lpon-addinfo">\n' | ||
local AddInfoPage = "LetsPlayOrNot:" .. cleanProjektname .. "/AddInfo" | local AddInfoPage = "LetsPlayOrNot:" .. cleanProjektname .. "/AddInfo" |
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