Zuletzt bearbeitet vor 4 Monaten
von Xineohp1506

Modul:LPON/Mod: Unterschied zwischen den Versionen

(Die Seite wurde neu angelegt: „local getArgs = require('Module:Arguments').getArgs local helper = require('Module:LPON/Helper') local mod = {} function mod.render(frame) local args = getArgs(frame) local output = "" -- DISPLAYTITLE setzen if args["Titel"] then helper.setDisplayTitle({title = args["Titel"]}) end -- Semantische Eigenschaften setzen if args["Projekt"] then helper.setProperty({args = {["LPON:Projekt"] = args["Projekt"]}})…“)
 
Keine Bearbeitungszusammenfassung
 
(21 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 6: Zeile 6:
     local args = getArgs(frame)
     local args = getArgs(frame)
     local output = ""
     local output = ""
 
    local cleanGame = helper.cleanString(args["Game"])
   
    -- Setzen des Datensatztyp
helper.setProperty({args = {["LPON:Typ"] = "Mod"}})
     -- DISPLAYTITLE setzen
     -- DISPLAYTITLE setzen
     if args["Titel"] then
     if args["Titel"] then
         helper.setDisplayTitle({title = args["Titel"]})
         helper.setDisplayTitle({title = args["Titel"]})
    end
         helper.setProperty({args = {["LPON:Modname"] = args["Titel"]}})
 
    -- Semantische Eigenschaften setzen
    if args["Projekt"] then
        helper.setProperty({args = {["LPON:Projekt"] = args["Projekt"]}})
    end
    if args["Game"] then
        helper.setProperty({args = {["LPON:Game"] = args["Game"]}})
    end
    if args["Kategorie"] then
         helper.setProperty({args = {["LPON:Mod-Kategorie"] = args["Kategorie"]}})
     end
     end


Zeile 29: Zeile 23:
     output = output .. '<tr><th>Mod-Name</th><td>' .. (args["Titel"] or "Unbekannt") .. '</td></tr>\n'
     output = output .. '<tr><th>Mod-Name</th><td>' .. (args["Titel"] or "Unbekannt") .. '</td></tr>\n'


     -- Projekt
     -- Projekte
     if args["Projekt"] then
     if args["Projekt"] then
        output = output .. '<tr><th>Projekt</th><td>' .. args["Projekt"] .. '</td></tr>\n'
    local projectList = {}
    end
    for projekt in mw.text.gsplit(args["Projekt"], ",") do
        projekt = mw.text.trim(projekt)
        helper.setProperty({args = {["LPON:Projekt"] = helper.cleanString(projekt)}})
        table.insert(projectList, projekt)
    end
    output = output .. '<tr><th>Projekte</th><td>' .. table.concat(projectList, ", ") .. '</td></tr>\n'
end


   
     -- Spiel
     -- Spiel
     if args["Game"] then
     if args["Game"] then
        helper.setProperty({args = {["LPON:Game"] = cleanGame}})
         output = output .. '<tr><th>Spiel</th><td>' .. args["Game"] .. '</td></tr>\n'
         output = output .. '<tr><th>Spiel</th><td>' .. args["Game"] .. '</td></tr>\n'
     end
     end
Zeile 42: Zeile 44:
     if args["Kategorie"] then
     if args["Kategorie"] then
         output = output .. '<tr><th>Kategorie</th><td>' .. args["Kategorie"] .. '</td></tr>\n'
         output = output .. '<tr><th>Kategorie</th><td>' .. args["Kategorie"] .. '</td></tr>\n'
        helper.setProperty({args = {["LPON:Mod-Kategorie"] = args["Kategorie"]}})
     end
     end


Zeile 47: Zeile 50:
     if args["Version"] then
     if args["Version"] then
         output = output .. '<tr><th>Version</th><td>' .. args["Version"] .. '</td></tr>\n'
         output = output .. '<tr><th>Version</th><td>' .. args["Version"] .. '</td></tr>\n'
        helper.setProperty({args = {["LPON:Mod-Version"] = args["Version"]}})
    end
    -- Modautor
    if args["Modautor"] then
        output = output .. '<tr><th>Modautor</th><td>' .. args["Modautor"] .. '</td></tr>\n'
        helper.setProperty({args = {["LPON:Modautor"] = args["Modautor"]}})
     end
     end


     -- Download
     -- Download
     if args["Download"] then
     if args["Download"] and args["Download"] ~= "" then
        local source = args["Quelle"] or "Unbekannt"
    local source = args["Quelle"] or "Unbekannt"
        output = output .. string.format('<tr><th>Download</th><td><a href="%s">%s</a></td></tr>\n', args["Download"], source)
-- Semantische Speicherung der URL und Quelle
    else
    helper.setProperty({args = {["LPON:Download-URL"] = args["Download"]}})
        output = output .. '<tr><th>Download</th><td>PRIVAT</td></tr>\n'
    helper.setProperty({args = {["LPON:Download-Quelle"] = source}})
    end
    output = output .. '<tr><th>Download</th><td>[' .. args["Download"] .. ' ' .. source .. ']</td></tr>\n'
else
    output = output .. '<tr><th>Download</th><td>PRIVAT</td></tr>\n'
end


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


     output = output .. '</table>\n' -- Ende der Tabelle
     output = output .. '</table>\n' -- Ende der Tabelle
   
    -- Kategorien setzen
    local categories = {} -- Korrekte Initialisierung der Tabelle
    -- Kategorien basierend auf Argumenten hinzufügen
    if args["Projekt"] and args["Projekt"] ~= "" then
        for projekt in mw.text.gsplit(args["Projekt"], ",") do
        local cleanProjekt = helper.cleanString(projekt)
            table.insert(categories, "LPON:" .. cleanProjekt)
        end
    end
    if args["Game"] then
        table.insert(categories, cleanGame .. ":Mods")
    end


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


return mod
return mod

Aktuelle Version vom 17. Dezember 2024, 12:46 Uhr

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

local getArgs = require('Module:Arguments').getArgs
local helper = require('Module:LPON/Helper')
local mod = {}

function mod.render(frame)
    local args = getArgs(frame)
    local output = ""
    local cleanGame = helper.cleanString(args["Game"])
    
    -- Setzen des Datensatztyp
	helper.setProperty({args = {["LPON:Typ"] = "Mod"}})
	
    -- DISPLAYTITLE setzen
    if args["Titel"] then
        helper.setDisplayTitle({title = args["Titel"]})
        helper.setProperty({args = {["LPON:Modname"] = args["Titel"]}})
    end

    -- Tabelle erstellen
    output = output .. '<table class="lpnon-mod-table">\n'

    -- Titel
    output = output .. '<tr><th>Mod-Name</th><td>' .. (args["Titel"] or "Unbekannt") .. '</td></tr>\n'

    -- Projekte
    if args["Projekt"] then
	    local projectList = {}
	    for projekt in mw.text.gsplit(args["Projekt"], ",") do
	        projekt = mw.text.trim(projekt)
	        helper.setProperty({args = {["LPON:Projekt"] = helper.cleanString(projekt)}})
	        table.insert(projectList, projekt)
	    end
	    output = output .. '<tr><th>Projekte</th><td>' .. table.concat(projectList, ", ") .. '</td></tr>\n'
	end

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

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

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

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

    -- Download
    if args["Download"] and args["Download"] ~= "" then
	    local source = args["Quelle"] or "Unbekannt"
		-- Semantische Speicherung der URL und Quelle
    	helper.setProperty({args = {["LPON:Download-URL"] = args["Download"]}})
    	helper.setProperty({args = {["LPON:Download-Quelle"] = source}})
	    output = output .. '<tr><th>Download</th><td>[' .. args["Download"] .. ' ' .. source .. ']</td></tr>\n'
	else
	    output = output .. '<tr><th>Download</th><td>PRIVAT</td></tr>\n'
	end

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

    output = output .. '</table>\n' -- Ende der Tabelle
    
    -- Kategorien setzen
    local categories = {} -- Korrekte Initialisierung der Tabelle

    -- Kategorien basierend auf Argumenten hinzufügen
    if args["Projekt"] and args["Projekt"] ~= "" then
        for projekt in mw.text.gsplit(args["Projekt"], ",") do
        	local cleanProjekt = helper.cleanString(projekt)
            table.insert(categories, "LPON:" .. cleanProjekt)
        end
    end
    if args["Game"] then
        table.insert(categories, cleanGame .. ":Mods")
    end

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

return mod