Zuletzt bearbeitet vor 5 Stunden
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
 
(3 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
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


     -- Info-Boxen
     -- Headergrafik aus MediaWiki-Datei (oder Default)
     output = output .. '<div class="lpnon-player-info-boxes">'
    local headerImage = args["Headerbild"] or "LPON:DefaultHeaderPlayer.webp"
     output = output .. string.format(
        '<div class="lpon-player-header">[[File:%s|class=lpon-player-header-img|alt=Headerbild]]</div>\n',
        headerImage
    )


     -- Box 1: Allgemeine Infos
     -- Container für alle Boxen
     output = output .. '<div class="lpnon-player-box">'
     output = output .. '<div class="lpon-player-container">'
    output = output .. '<h3>Allgemein</h3>'
    output = output .. '<p><b>Status:</b> ' .. (args["Status"] or "Unbekannt") .. '</p>'
    output = output .. '<p><b>Beitritt:</b> ' .. (args["Beitrittsdatum"] or "Unbekannt") .. '</p>'
    output = output .. '<p><b>Rolle:</b> ' .. (args["Rolle"] or "Unbekannt") .. '</p>'
    output = output .. '</div>'


     -- Box 2: Social Links
     -- Über mich
     output = output .. '<div class="lpnon-player-box">'
     output = output .. '<div class="lpon-player-box">\n'
     output = output .. '<h3>Social Links</h3>'
     output = output .. '   <h2>Über mich</h2>\n'
    local linkPage = "LetsPlayOrNot:" .. playerName .. "/Links"
     output = output .. '   <p>' .. (args["Über"] or "Keine Beschreibung vorhanden.") .. '</p>\n'
    local rawContent = transcluder.get(linkPage)
     output = output .. '</div>\n'
     output = output .. '<div class="lpnon-player-links">' .. frame:preprocess(rawContent) .. '</div>'
     output = output .. '</div>'


     -- Box 3: Statistiken (Projekte / Episoden)
     -- Allgemein + Statistiken
     output = output .. '<div class="lpnon-player-box">'
    local projectQuery = string.format("[[LPON:Spieler::%s]][[LPON:Typ::Projekt]]|?LPON:Status", name)
     output = output .. '<h3>Statistiken</h3>'
     local projectResult = mw.smw.getQueryResult(projectQuery)
     local projekteCount = projectResult and #projectResult.results or 0


    -- Episoden zählen
     local episodeQuery = string.format("[[LPON:Spieler::%s]][[LPON:Typ::Episode]]", name)
     local episodeQuery = string.format("[[LPON:Typ::Episode]][[LPON:Spieler::%s]]", playerName)
     local episodeResult = mw.smw.getQueryResult(episodeQuery)
     local episodeResult = mw.smw.getQueryResult(episodeQuery)
     local episodeCount = (episodeResult and episodeResult.results) and #episodeResult.results or 0
     local episoden = episodeResult and #episodeResult.results or 0


     -- Projekte zählen
     output = output .. '<div class="lpon-player-box">\n'
     local projectQuery = string.format("[[LPON:Typ::Projekt]][[LPON:Spieler::%s]]", playerName)
    output = output .. '    <h2>Allgemein</h2>\n'
     local projectResult = mw.smw.getQueryResult(projectQuery)
    output = output .. '    <ul>\n'
     local projectCount = (projectResult and projectResult.results) and #projectResult.results or 0
     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> ' .. projekteCount .. '</li>\n'
    output = output .. '        <li><b>Episoden:</b> ' .. episoden .. '</li>\n'
    output = output .. '    </ul>\n'
    output = output .. '</div>\n'


     output = output .. string.format('<p><b>Episoden:</b> %d</p>', episodeCount)
    -- Projekte (max. 8 anzeigen + Status in Klammern)
     output = output .. string.format('<p><b>Projekte:</b> %d</p>', projectCount)
     output = output .. '<div class="lpon-player-box">\n'
     output = output .. '   <h2>Projekte</h2>\n'
    output = output .. '    <ul>'
    local maxProjects = 8
    local projectCount = 0
    local hasMoreProjects = false


     output = output .. '</div>' -- Ende Box 3
     if projectResult and projectResult.results then
        for _, result in ipairs(projectResult.results) do
            projectCount = projectCount + 1
            if projectCount > maxProjects then
                hasMoreProjects = true
                break
            end


    output = output .. '</div>' -- Ende der Boxen
            local projTitle = result.fulltext or "Unbekannt"
 
            local status = result.printouts["LPON:Status"] and result.printouts["LPON:Status"][1] or ""
    -- Über mich Text (optional)
            local display = projTitle
    if args["Über"] and args["Über"] ~= "" then
            if status and status ~= "" then
        output = output .. '<div class="lpnon-player-about">'
                display = string.format("%s (%s)", projTitle, status)
         output = output .. '<h2>Über mich</h2>'
            end
        output = output .. args["Über"]
            output = output .. string.format('<li>[[%s|%s]]</li>', projTitle, display)
         output = output .. '</div>'
        end
    else
         output = output .. '<li>Keine Projekte hinterlegt.</li>'
    end
    output = output .. '</ul>\n'
    if hasMoreProjects then
         output = output .. string.format('<p>[[LetsPlayOrNot:%s/Projekte|Alle Projekte anzeigen]]</p>', name)
     end
     end
    output = output .. '</div>\n'


     -- Aktive Projekte auflisten
     output = output .. '</div>' -- Ende von .lpon-player-container
    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">'
     -- Links (falls aktiviert)
    output = output .. '<h2>Projekte</h2>'
    if args["Links"] == "true" then
    if projectListResult and projectListResult.results and #projectListResult.results > 0 then
        output = output .. '<div class="lpon-player-links">\n'
         output = output .. '<ul>'
        output = output .. '   <h2>Links</h2>'
        for _, result in ipairs(projectListResult.results) do
         local linkPage = 'LetsPlayOrNot:' .. name .. '/Links'
            local title = result.printouts["LPON:Title"] and result.printouts["LPON:Title"][1] or "Unbekannt"
        local rawContent = transcluder.get(linkPage)
            local status = result.printouts["LPON:Status"] and result.printouts["LPON:Status"][1] or "Unbekannt"
         output = output .. frame:preprocess(rawContent)
            local projectPage = result.fulltext or title
         output = output .. '</div>'
            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
     end
    output = output .. '</div>'


     return output
     return output

Aktuelle Version vom 7. Mai 2025, 00:03 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

    -- Headergrafik aus MediaWiki-Datei (oder Default)
    local headerImage = args["Headerbild"] or "LPON:DefaultHeaderPlayer.webp"
    output = output .. string.format(
        '<div class="lpon-player-header">[[File:%s|class=lpon-player-header-img|alt=Headerbild]]</div>\n',
        headerImage
    )

    -- 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 projectQuery = string.format("[[LPON:Spieler::%s]][[LPON:Typ::Projekt]]|?LPON:Status", name)
    local projectResult = mw.smw.getQueryResult(projectQuery)
    local projekteCount = projectResult and #projectResult.results or 0

    local episodeQuery = string.format("[[LPON:Spieler::%s]][[LPON:Typ::Episode]]", name)
    local episodeResult = mw.smw.getQueryResult(episodeQuery)
    local episoden = episodeResult and #episodeResult.results or 0

    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> ' .. projekteCount .. '</li>\n'
    output = output .. '        <li><b>Episoden:</b> ' .. episoden .. '</li>\n'
    output = output .. '    </ul>\n'
    output = output .. '</div>\n'

    -- Projekte (max. 8 anzeigen + Status in Klammern)
    output = output .. '<div class="lpon-player-box">\n'
    output = output .. '    <h2>Projekte</h2>\n'
    output = output .. '    <ul>'
    local maxProjects = 8
    local projectCount = 0
    local hasMoreProjects = false

    if projectResult and projectResult.results then
        for _, result in ipairs(projectResult.results) do
            projectCount = projectCount + 1
            if projectCount > maxProjects then
                hasMoreProjects = true
                break
            end

            local projTitle = result.fulltext or "Unbekannt"
            local status = result.printouts["LPON:Status"] and result.printouts["LPON:Status"][1] or ""
            local display = projTitle
            if status and status ~= "" then
                display = string.format("%s (%s)", projTitle, status)
            end
            output = output .. string.format('<li>[[%s|%s]]</li>', projTitle, display)
        end
    else
        output = output .. '<li>Keine Projekte hinterlegt.</li>'
    end
    output = output .. '</ul>\n'
    if hasMoreProjects then
        output = output .. string.format('<p>[[LetsPlayOrNot:%s/Projekte|Alle Projekte anzeigen]]</p>', name)
    end
    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