Modul:NewsArtikel: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| (2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 144: | Zeile 144: | ||
table.insert(out, '[[Kategorie:News:Veröffentlicht]]') | table.insert(out, '[[Kategorie:News:Veröffentlicht]]') | ||
if monat then | if monat then | ||
local sy, sm, sd = datum:match('^(%d%d%d%d)%-(%d%d)%-(%d%d)') | |||
if sy then | |||
local smname = monate[tonumber(sm)] or sm | |||
local sortKey = string.format('%s. %s %s', sd, smname, sy) | |||
table.insert(out, '[[Kategorie:Archiv-News/' .. monat .. '|' .. sortKey .. ']]') | |||
else | |||
table.insert(out, '[[Kategorie:Archiv-News/' .. monat .. ']]') | |||
end | |||
end | end | ||
else | else | ||
| Zeile 192: | Zeile 197: | ||
return table.concat(out, '\n') | return table.concat(out, '\n') | ||
end | |||
function p.archivListe(frame) | |||
local year = trim(frame.args[1] or '') | |||
local month = trim(frame.args[2] or '') | |||
if year == '' or month == '' then return '' end | |||
local catName = 'Archiv-News/' .. year .. '-' .. month | |||
local dplResult = frame:callParserFunction('#dpl', { | |||
'', -- leerer erster param (entspricht {{#dpl:|...}}) | |||
category = catName, | |||
format = ',\n%PAGE%,,', | |||
ordermethod = 'title', | |||
order = 'ascending', | |||
count = '200', | |||
suppresserrors = 'true', | |||
allowcachedresults = 'true', | |||
}) | |||
local items = {} | |||
for page in dplResult:gmatch('[^\n]+') do | |||
page = page:match('^%s*(.-)%s*$') | |||
if page ~= '' then | |||
local titleObj = mw.title.new(page) | |||
if titleObj then | |||
local content = titleObj:getContent() or '' | |||
local datum = content:match('|%s*datum%s*=%s*([%d%-]+)') or '' | |||
local dateStr = formatDatum(datum) | |||
local label = titleObj.text | |||
local line | |||
if dateStr ~= '' then | |||
line = '* ' .. dateStr .. ': [[' .. page .. '|' .. label .. ']]' | |||
else | |||
line = '* [[' .. page .. '|' .. label .. ']]' | |||
end | |||
table.insert(items, {datum = datum, display = line}) | |||
end | |||
end | |||
end | |||
table.sort(items, function(a, b) return a.datum < b.datum end) | |||
local lines = {} | |||
for _, item in ipairs(items) do table.insert(lines, item.display) end | |||
return table.concat(lines, '\n') | |||
end | end | ||
return p | return p | ||