Modul:Vorlage:Löschkandidatenarchiv
Erstellt eine Tabelle mit den LD-Seiten eines Jahres.
-- Modul zur Automatisierung des Archivs der LD-Seiten
function getMonthLen(m,y)
if m == 1 or m == 3 or m==5 or m==7 or m==8 or m==10 or m==12 then
return 31;
elseif m == 4 or m== 6 or m== 9 or m == 11 then
return 30;
end
-- m == 2
if y % 4 == 0 then
return 29
else
return 28
end
end
function Createatable(y)
local Preface = '[[Wikipedia:Löschkandidaten/SUBNAME|XX]]'
local shortname = {'Jan.','Feb.','März','Apr.','Mai','Juni', 'Juli','Aug.','Sep.','Okt.','Nov.','Dez.'}
local longname = {'Januar','Februar','März','April','Mai','Juni', 'Juli','August','September','Oktober','November','Dezember'}
local monthlen = 0;
year = tonumber(y) or 0
syear = tostring(year);
local currentyear = tonumber(os.date('%Y'));
local currentmonth = tonumber(os.date('%m'));
local currentday = tonumber(os.date('%d'));
local Output = '<table style="width:100%;box-sizing:border-box; font-size:100%; text-align:center; line-height:130%;" class="plainlinks">\n'
Output = Output .. '<tr><th style="text-align:right; width:10ex;">Monat </th><th colspan="31">T a g</th></tr>\n'
local Zeile = '';
local subname ='';
local pagelink = '';
if year > currentyear or year < 2004 then
return "\n";
end
if year == 2004 then
for month = 12,3,-1 do
Zeile ='<th style="text-align:right">' .. shortname[month] .. ' ' .. syear ..'</th>'
monthlen = getMonthLen(month,year);
for i = 1,31 do
if i > monthlen or (month == 3 and i < 25) then
Zeile = Zeile ..'<td style="width:4ex;"></td>'
else
subname=tostring(i) .. '._' .. longname[month] ..'_' .. syear;
pagelink=mw.ustring.gsub(Preface,"SUBNAME",subname);
pagelink=mw.ustring.gsub(pagelink,"XX",tostring(i));
Zeile = Zeile ..'<td style="width:4ex;">' .. pagelink ..'</td>';
end
end
Zeile = Zeile ..'</tr>\n';
Output = Output .. Zeile;
end
Output = Output .. '</table>\n';
return Output
elseif year == currentyear then
for month = currentmonth,1,-1 do
Zeile ='<th style="text-align:right">' .. shortname[month] .. ' ' .. syear ..'</th>'
if month == currentmonth then
monthlen = currentday;
else
monthlen = getMonthLen(month,year);
end
for i = 1,31 do
if i > monthlen then
Zeile = Zeile ..'<td style="width:4ex;"></td>'
else
subname=tostring(i) .. '._' .. longname[month] ..'_' .. syear;
pagelink=mw.ustring.gsub(Preface,"SUBNAME",subname);
pagelink=mw.ustring.gsub(pagelink,"XX",tostring(i));
Zeile = Zeile ..'<td style="width:4ex;">' .. pagelink ..'</td>';
end
end
Zeile = Zeile ..'</tr>\n';
Output = Output .. Zeile;
end
Output = Output .. '</table>\n';
return Output
elseif year < currentyear then
for month = 12,1,-1 do
Zeile ='<th style="text-align:right">' .. shortname[month] .. ' ' .. syear ..'</th>'
monthlen = getMonthLen(month,year);
for i = 1,31 do
if i > monthlen then
Zeile = Zeile ..'<td style="width:4ex;"></td>'
else
subname=tostring(i) .. '._' .. longname[month] ..'_' .. syear;
pagelink=mw.ustring.gsub(Preface,"SUBNAME",subname);
pagelink=mw.ustring.gsub(pagelink,"XX",tostring(i));
Zeile = Zeile ..'<td style="width:4ex;">' .. pagelink ..'</td>';
end
end
Zeile = Zeile ..'</tr>\n';
Output = Output .. Zeile;
end
Output = Output .. '</table>\n';
return Output
end
Output = '<span class="error">Kein Jahresname angegeben!</span>\n'
return Output
end
local p = {};
function p.Createalltables(frame)
local year = 0;
local Text = '';
local header = ''
local tableyear='';
for year = 2024, 2004,-1 do
header = '\n\n=== Jahr ' .. tostring(year) .. ' ===\n'
Text = Text .. header;
tableyear = Createatable(year)
Text = Text .. tableyear
end
return Text;
end
function p.GetOneTable(frame)
local year = tonumber(frame.args[1]) or 2024;
local Text = Createatable(year);
return Text;
end
return p