Modul:NewsArtikel: Unterschied zwischen den Versionen
Neu: Umbenennung von Modul:News → Modul:NewsArtikel (fix Scribunto-Namensraum-Konflikt NS 3000) (via create-page on MediaWiki MCP Server) |
Keine Bearbeitungszusammenfassung |
||
| (7 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 9: | Zeile 9: | ||
-- ----------------------------------------------------------------------- | -- ----------------------------------------------------------------------- | ||
-- | -- Monatsnamen (DE) | ||
-- ----------------------------------------------------------------------- | -- ----------------------------------------------------------------------- | ||
local monate = { | local monate = { | ||
| Zeile 16: | Zeile 16: | ||
} | } | ||
-- ----------------------------------------------------------------------- | |||
-- Hilfsfunktion: Datum YYYY-MM-DD → lesbares deutsches Datum | |||
-- ----------------------------------------------------------------------- | |||
local function formatDatum(datum) | local function formatDatum(datum) | ||
if not datum or datum == '' then return '' end | if not datum or datum == '' then return '' end | ||
| Zeile 23: | Zeile 26: | ||
local mname = monate[mi] or m | local mname = monate[mi] or m | ||
return string.format('%d. %s %s', tonumber(d), mname, y) | return string.format('%d. %s %s', tonumber(d), mname, y) | ||
end | |||
-- ----------------------------------------------------------------------- | |||
-- Brotkrümelnavigation: News > YYYY > Monat YYYY > Artikelname | |||
-- ----------------------------------------------------------------------- | |||
local function breadcrumb(datum, pageName) | |||
if not datum or datum == '' then return '' end | |||
local y, m = datum:match('^(%d%d%d%d)%-(%d%d)') | |||
if not y then return '' end | |||
local mi = tonumber(m) | |||
local mname = monate[mi] or m | |||
local monatLabel = mname .. ' ' .. y | |||
local archivMonat = string.format('News:Archiv/%s/%s', y, m) | |||
local archivJahr = 'News:Archiv/' .. y | |||
local parts = { | |||
'<span class="isin-breadcrumb" style="font-size:85%;color:#555;display:block;margin-top:-1em;margin-bottom:0.4em;">', | |||
'[[News:Alle Artikel|News]]', | |||
' › ', | |||
'[[' .. archivJahr .. '|' .. y .. ']]', | |||
' › ', | |||
'[[' .. archivMonat .. '|' .. monatLabel .. ']]', | |||
' › ', | |||
pageName, | |||
'</span>', | |||
} | |||
return table.concat(parts, '') | |||
end | end | ||
| Zeile 84: | Zeile 115: | ||
local bild = trim(args['bild'] or '') | local bild = trim(args['bild'] or '') | ||
local schluesselliste = args['schlüssel'] or args['schluessel'] or '' | local schluesselliste = args['schlüssel'] or args['schluessel'] or '' | ||
local beschreibung | -- beschreibung fällt auf lead zurück | ||
local beschreibung = trim(args['beschreibung'] or '') | |||
if beschreibung == '' then beschreibung = lead end | |||
-- Seiteninfos | -- Seiteninfos | ||
| Zeile 91: | Zeile 124: | ||
local siteName = mw.site.siteName | local siteName = mw.site.siteName | ||
-- Revisionsdatum via preprocess | -- Revisionsdatum via preprocess | ||
local revDate = pframe:preprocess('{{REVISIONYEAR}}-{{REVISIONMONTH}}-{{REVISIONDAY2}}') | local revDate = pframe:preprocess('{{REVISIONYEAR}}-{{REVISIONMONTH}}-{{REVISIONDAY2}}') | ||
| Zeile 98: | Zeile 131: | ||
local out = {} | local out = {} | ||
-- 0. Brotkrümelnavigation (immer, wenn datum vorhanden) | |||
local bc = breadcrumb(datum, pageName) | |||
if bc ~= '' then | |||
table.insert(out, bc) | |||
end | |||
-- 1. Status-Banner + Kategorien | -- 1. Status-Banner + Kategorien | ||
| Zeile 105: | 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 117: | Zeile 163: | ||
end | end | ||
-- 3. Schlagwort-Kategorien | -- 3. Schlagwort-Kategorien (Trennzeichen: Komma) | ||
for keyword in schluesselliste:gmatch('[^ | for keyword in schluesselliste:gmatch('[^,]+') do | ||
keyword = trim(keyword) | keyword = trim(keyword) | ||
if keyword ~= '' then | if keyword ~= '' then | ||
| Zeile 128: | Zeile 174: | ||
if (status == 'veröffentlicht' or status == 'veroeffentlicht') and datum ~= '' then | if (status == 'veröffentlicht' or status == 'veroeffentlicht') and datum ~= '' then | ||
local kwList = {} | local kwList = {} | ||
for keyword in schluesselliste:gmatch('[^ | for keyword in schluesselliste:gmatch('[^,]+') do | ||
keyword = trim(keyword) | keyword = trim(keyword) | ||
if keyword ~= '' then table.insert(kwList, keyword) end | if keyword ~= '' then table.insert(kwList, keyword) end | ||
end | end | ||
local seoArgs = { [1] = '' } | local seoArgs = { [1] = '' } | ||
seoArgs['title'] = pageName .. ' - ' .. siteName | seoArgs['title'] = pageName .. ' - ' .. siteName | ||
| Zeile 152: | 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 | ||