Zuletzt bearbeitet vor 5 Tagen
von Xineohp1506

Modul:LPON/Player: Unterschied zwischen den Versionen

(Die Seite wurde neu angelegt: „local player = {} local helper = require('Module:LPON/Helper') local getArgs = require('Module:Arguments').getArgs local transcluder = require('Module:Transcluder') function player.render(frame) local args = getArgs(frame) local output = "" local playerName = args["Name"] or mw.title.getCurrentTitle().subpageText local cleanPlayerName = helper.cleanString(playerName) -- DISPLAYTITLE setzen helper.setDisplayTitle({title = playerN…“)
 
Keine Bearbeitungszusammenfassung
 
Zeile 1: Zeile 1:
local player = {}
local player = {}
local helper = require('Module:LPON/Helper')
local helper = require("Module:LPON/Helper")
local getArgs = require('Module:Arguments').getArgs
local transcluder = require("Module:Transcluder")
local transcluder = require('Module:Transcluder')
local getArgs = require("Module:Arguments").getArgs


function player.render(frame)
function player.render(frame)
     local args = getArgs(frame)
     local args = getArgs(frame)
     local output = ""
     local output = ''
 
     local name = args["Name"] or mw.title.getCurrentTitle().text
     local playerName = args["Name"] or mw.title.getCurrentTitle().subpageText
     local cleanName = helper.cleanString(name)
     local cleanPlayerName = helper.cleanString(playerName)


     -- DISPLAYTITLE setzen
     -- DISPLAYTITLE setzen
     helper.setDisplayTitle({title = playerName})
     helper.setDisplayTitle({ title = name })


     -- Headergrafik
     -- Semantische Eigenschaften
     local headerImage = args["Headerbild"] or "DefaultPlayerHeader.jpg"
     helper.setProperty({ args = { ["LPON:Spieler"] = name } })
     output = output .. '<div class="lpnon-player-header">'
    if args["Status"] then helper.setProperty({ args = { ["LPON:Status"] = args["Status"] } }) end
     output = output .. '[[File:' .. headerImage .. '|center|100%]]'
    if args["Beitritt"] then helper.setProperty({ args = { ["LPON:Beitritt"] = args["Beitritt"] } }) end
     output = output .. '</div>'
     if args["Rolle"] then helper.setProperty({ args = { ["LPON:Rolle"] = args["Rolle"] } }) end
     if args["Projekte"] then
        for projekt in mw.text.gsplit(args["Projekte"], ",") do
            helper.setProperty({ args = { ["LPON:Projekt"] = mw.text.trim(projekt) } })
        end
     end


     -- Info-Boxen
     -- Container für alle Boxen
     output = output .. '<div class="lpnon-player-info-boxes">'
     output = output .. '<div class="lpon-player-container">'


     -- Box 1: Allgemeine Infos
     -- Über mich
     output = output .. '<div class="lpnon-player-box">'
     output = output .. '<div class="lpon-player-box">\n'
     output = output .. '<h3>Allgemein</h3>'
     output = output .. '   <h2>Über mich</h2>\n'
     output = output .. '<p><b>Status:</b> ' .. (args["Status"] or "Unbekannt") .. '</p>'
     output = output .. '   <p>' .. (args["Über"] or "Keine Beschreibung vorhanden.") .. '</p>\n'
    output = output .. '<p><b>Beitritt:</b> ' .. (args["Beitrittsdatum"] or "Unbekannt") .. '</p>'
     output = output .. '</div>\n'
    output = output .. '<p><b>Rolle:</b> ' .. (args["Rolle"] or "Unbekannt") .. '</p>'
     output = output .. '</div>'


     -- Box 2: Social Links
     -- Allgemein + Statistiken
     output = output .. '<div class="lpnon-player-box">'
    local episoden = args["Episoden"] or "-"
     output = output .. '<h3>Social Links</h3>'
    local projekte = args["Projekte"] and select(2, string.gsub(args["Projekte"], ",", "")) + 1 or "-"
     local linkPage = "LetsPlayOrNot:" .. playerName .. "/Links"
     output = output .. '<div class="lpon-player-box">\n'
     local rawContent = transcluder.get(linkPage)
     output = output .. '   <h2>Allgemein</h2>\n'
     output = output .. '<div class="lpnon-player-links">' .. frame:preprocess(rawContent) .. '</div>'
    output = output .. '    <ul>\n'
     output = output .. '</div>'
     output = output .. '        <li><b>Status:</b> ' .. (args["Status"] or "Unbekannt") .. '</li>\n'
    output = output .. '        <li><b>Beitritt:</b> ' .. (args["Beitritt"] or "Unbekannt") .. '</li>\n'
     output = output .. '        <li><b>Rolle:</b> ' .. (args["Rolle"] or "Unbekannt") .. '</li>\n'
     output = output .. '   </ul>\n'
    output = output .. '    <h2>Statistiken</h2>\n'
    output = output .. '    <ul>\n'
    output = output .. '        <li><b>Projekte:</b> ' .. projekte .. '</li>\n'
    output = output .. '        <li><b>Episoden:</b> ' .. episoden .. '</li>\n'
    output = output .. '   </ul>\n'
     output = output .. '</div>\n'


     -- Box 3: Statistiken (Projekte / Episoden)
     -- Projekte
     output = output .. '<div class="lpnon-player-box">'
     output = output .. '<div class="lpon-player-box">\n'
     output = output .. '<h3>Statistiken</h3>'
     output = output .. '   <h2>Projekte</h2>\n'
 
    output = output .. '    <ul>'
     -- Episoden zählen
     if args["Projekte"] then
    local episodeQuery = string.format("[[LPON:Typ::Episode]][[LPON:Spieler::%s]]", playerName)
        for projekt in mw.text.gsplit(args["Projekte"], ",") do
    local episodeResult = mw.smw.getQueryResult(episodeQuery)
            projekt = mw.text.trim(projekt)
    local episodeCount = (episodeResult and episodeResult.results) and #episodeResult.results or 0
            output = output .. '<li>[[LetsPlayOrNot:' .. projekt .. '|' .. projekt .. ']]</li>'
 
        end
    -- Projekte zählen
     else
    local projectQuery = string.format("[[LPON:Typ::Projekt]][[LPON:Spieler::%s]]", playerName)
        output = output .. '<li>Keine Projekte hinterlegt.</li>'
    local projectResult = mw.smw.getQueryResult(projectQuery)
    end
    local projectCount = (projectResult and projectResult.results) and #projectResult.results or 0
     output = output .. '</ul>\n'
 
     output = output .. '</div>\n'
     output = output .. string.format('<p><b>Episoden:</b> %d</p>', episodeCount)
     output = output .. '</div>' -- Ende von .lpon-player-container
     output = output .. string.format('<p><b>Projekte:</b> %d</p>', projectCount)
 
     output = output .. '</div>' -- Ende Box 3
 
     output = output .. '</div>' -- Ende der Boxen


     -- Über mich Text (optional)
     -- Links (falls aktiviert)
     if args["Über"] and args["Über"] ~= "" then
     if args["Links"] == "true" then
         output = output .. '<div class="lpnon-player-about">'
         output = output .. '<div class="lpon-player-links">\n'
         output = output .. '<h2>Über mich</h2>'
         output = output .. '   <h2>Links</h2>'
         output = output .. args["Über"]
        local linkPage = 'LetsPlayOrNot:' .. name .. '/Links'
        local rawContent = transcluder.get(linkPage)
         output = output .. frame:preprocess(rawContent)
         output = output .. '</div>'
         output = output .. '</div>'
     end
     end
    -- Aktive Projekte auflisten
    local projectListQuery = string.format("[[LPON:Typ::Projekt]][[LPON:Spieler::%s]]|?LPON:Title|?LPON:Status", playerName)
    local projectListResult = mw.smw.getQueryResult(projectListQuery)
    output = output .. '<div class="lpnon-player-projects">'
    output = output .. '<h2>Projekte</h2>'
    if projectListResult and projectListResult.results and #projectListResult.results > 0 then
        output = output .. '<ul>'
        for _, result in ipairs(projectListResult.results) do
            local title = result.printouts["LPON:Title"] and result.printouts["LPON:Title"][1] or "Unbekannt"
            local status = result.printouts["LPON:Status"] and result.printouts["LPON:Status"][1] or "Unbekannt"
            local projectPage = result.fulltext or title
            output = output .. string.format('<li>[[%s|%s]] (%s)</li>', projectPage, title, status)
        end
        output = output .. '</ul>'
    else
        output = output .. '<p>Keine Projekte gefunden.</p>'
    end
    output = output .. '</div>'


     return output
     return output

Aktuelle Version vom 30. April 2025, 00:40 Uhr

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

local player = {}
local helper = require("Module:LPON/Helper")
local transcluder = require("Module:Transcluder")
local getArgs = require("Module:Arguments").getArgs

function player.render(frame)
    local args = getArgs(frame)
    local output = ''
    local name = args["Name"] or mw.title.getCurrentTitle().text
    local cleanName = helper.cleanString(name)

    -- DISPLAYTITLE setzen
    helper.setDisplayTitle({ title = name })

    -- Semantische Eigenschaften
    helper.setProperty({ args = { ["LPON:Spieler"] = name } })
    if args["Status"] then helper.setProperty({ args = { ["LPON:Status"] = args["Status"] } }) end
    if args["Beitritt"] then helper.setProperty({ args = { ["LPON:Beitritt"] = args["Beitritt"] } }) end
    if args["Rolle"] then helper.setProperty({ args = { ["LPON:Rolle"] = args["Rolle"] } }) end
    if args["Projekte"] then
        for projekt in mw.text.gsplit(args["Projekte"], ",") do
            helper.setProperty({ args = { ["LPON:Projekt"] = mw.text.trim(projekt) } })
        end
    end

    -- Container für alle Boxen
    output = output .. '<div class="lpon-player-container">'

    -- Über mich
    output = output .. '<div class="lpon-player-box">\n'
    output = output .. '    <h2>Über mich</h2>\n'
    output = output .. '    <p>' .. (args["Über"] or "Keine Beschreibung vorhanden.") .. '</p>\n'
    output = output .. '</div>\n'

    -- Allgemein + Statistiken
    local episoden = args["Episoden"] or "-"
    local projekte = args["Projekte"] and select(2, string.gsub(args["Projekte"], ",", "")) + 1 or "-"
    output = output .. '<div class="lpon-player-box">\n'
    output = output .. '    <h2>Allgemein</h2>\n'
    output = output .. '    <ul>\n'
    output = output .. '        <li><b>Status:</b> ' .. (args["Status"] or "Unbekannt") .. '</li>\n'
    output = output .. '        <li><b>Beitritt:</b> ' .. (args["Beitritt"] or "Unbekannt") .. '</li>\n'
    output = output .. '        <li><b>Rolle:</b> ' .. (args["Rolle"] or "Unbekannt") .. '</li>\n'
    output = output .. '    </ul>\n'
    output = output .. '    <h2>Statistiken</h2>\n'
    output = output .. '    <ul>\n'
    output = output .. '        <li><b>Projekte:</b> ' .. projekte .. '</li>\n'
    output = output .. '        <li><b>Episoden:</b> ' .. episoden .. '</li>\n'
    output = output .. '    </ul>\n'
    output = output .. '</div>\n'

    -- Projekte
    output = output .. '<div class="lpon-player-box">\n'
    output = output .. '    <h2>Projekte</h2>\n'
    output = output .. '    <ul>'
    if args["Projekte"] then
        for projekt in mw.text.gsplit(args["Projekte"], ",") do
            projekt = mw.text.trim(projekt)
            output = output .. '<li>[[LetsPlayOrNot:' .. projekt .. '|' .. projekt .. ']]</li>'
        end
    else
        output = output .. '<li>Keine Projekte hinterlegt.</li>'
    end
    output = output .. '</ul>\n'
    output = output .. '</div>\n'
    output = output .. '</div>' -- Ende von .lpon-player-container

    -- Links (falls aktiviert)
    if args["Links"] == "true" then
        output = output .. '<div class="lpon-player-links">\n'
        output = output .. '    <h2>Links</h2>'
        local linkPage = 'LetsPlayOrNot:' .. name .. '/Links'
        local rawContent = transcluder.get(linkPage)
        output = output .. frame:preprocess(rawContent)
        output = output .. '</div>'
    end

    return output
end

return player