Modul:Briefspielnews: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| Zeile 5: | Zeile 5: | ||
--Hole die 500 neuesten Kapitel | --Hole die 500 neuesten Kapitel | ||
function holeKapitel() | function holeKapitel(anzahl) | ||
local kapitel=mw.smw.ask("{{#ask: [[-has subobject::+]]" | local kapitel=mw.smw.ask("{{#ask: [[-has subobject::+]]" | ||
.."|?#-=" | .."|?#-=" | ||
| Zeile 12: | Zeile 12: | ||
.."|?Reihe ist" | .."|?Reihe ist" | ||
.."|?Kapiteldatum" | .."|?Kapiteldatum" | ||
.."|limit= | .."|limit="..anzahl | ||
.."|order=desc" | .."|order=desc" | ||
.."|sort=Kapiteldatum" | .."|sort=Kapiteldatum" | ||
| Zeile 44: | Zeile 44: | ||
--Aufzurufende Funktion | --Aufzurufende Funktion | ||
function p.news(frame) | function p.news(frame) | ||
local kapitel=holeKapitel() | local anzahl=robusttrim(frame.args[1]) | ||
if(anzahl=='') then anzahl='10' end | |||
local kapitel=holeKapitel(anzahl) | |||
return ausgabe(kapitel) | return ausgabe(kapitel) | ||
end | end | ||
return p | return p | ||
Version vom 5. Oktober 2024, 05:53 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Briefspielnews/Doku erstellt werden
require("Modul:Hilfsfunktionen")
require("Modul:Text")
local p = {}
--Hole die 500 neuesten Kapitel
function holeKapitel(anzahl)
local kapitel=mw.smw.ask("{{#ask: [[-has subobject::+]]"
.."|?#-="
.."|?Kurzbeschreibung#="
.."|?Kapitelname ist"
.."|?Reihe ist"
.."|?Kapiteldatum"
.."|limit="..anzahl
.."|order=desc"
.."|sort=Kapiteldatum"
.."|offset=0"
.."|searchlabel=")
if kapitel==nil then
return {}
end
return kapitel
end
--Formatierung der Ausgabe
function ausgabe(kapitel)
local result=""
local reihe={}
local tkeys=getSortKeys(kapitel)
for _,k in ipairs(tkeys) do
local r=kapitel[k]["Reihe ist"]
if reihe[r]==nil then
reihe[r]={}
end
table.insert(reihe[r],kapitel[k])
end
result=result..dump(reihe,"")
return result
end
--Aufzurufende Funktion
function p.news(frame)
local anzahl=robusttrim(frame.args[1])
if(anzahl=='') then anzahl='10' end
local kapitel=holeKapitel(anzahl)
return ausgabe(kapitel)
end
return p