Modul:Datei: Unterschied zwischen den Versionen
Aus FürthWiki
(Optimierungen Dateiinfo) |
(fix ...) |
||
| Zeile 171: | Zeile 171: | ||
infotext = infotext .. args.Beschreibung | infotext = infotext .. args.Beschreibung | ||
dateiinfo = dateiinfo .. wik.wikiTextLimit(args.Beschreibung, 75) | dateiinfo = dateiinfo .. wik.wikiTextLimit(args.Beschreibung, 75) | ||
if mw.ustring.len(dateiinfo) ~= mw.ustring.len(args.Beschreibung) then | |||
dateiinfo = dateiinfo .. " ..." | |||
end | |||
end | end | ||
if not com.isEmpty(args.Urheber) then | if not com.isEmpty(args.Urheber) then | ||
| Zeile 184: | Zeile 187: | ||
infotext = infotext .. "'''Erstellungsdatum:''' " .. | infotext = infotext .. "'''Erstellungsdatum:''' " .. | ||
lfd.linkFormDate(args.Erstellungsdatum) | lfd.linkFormDate(args.Erstellungsdatum) | ||
end | end | ||
if infotext ~= "" then | if infotext ~= "" then | ||
Version vom 24. November 2025, 13:45 Uhr
Seiten-Übersicht
| Hauptseite | Unterseiten | ||
|---|---|---|---|
| Allgemein | |||
| Faktenbox | Vorlagen | ||
| Formulare |
|
||
| Module | |||
| Abfrage | Vorlagen |
| |
| Formulare |
| ||
| Sonstige | |||
Siehe auch
local p = {}
local com = require("Module:Common")
local str = require("Module:String")
local wik = require("Module:Wiki")
local lfd = require("Module:LinkFormDatum")
function p.daten(frame, args)
local title = mw.title.getCurrentTitle().text
local extension = p.getExtension(title)
local filekind = p.getFilekind(extension)
local a, w, z
local t = '<table class="wikitable">' ..
'<th colspan="4">' .. title .. '</th>'
if not com.isEmpty(args.Genre) then
t = t .. '<tr>'..
'<td>[[Attribut:Genre|Genre]]</td>' ..
'<td colspan="3">'..frame:callParserFunction(
'#arraymap', args.Genre, ';', 'x', '[[:Kategorie:x|x]] [[Kategorie:x]]') .. '</td>' ..
'</tr>'
end
-- Liste Freiattribute und Werte auf
for i = 1, 6 do
a = 'Attribut'..i
w = 'Wert'..i
if not com.isEmpty(args[a]) then
if not com.isEmpty(args[w]) then
t=t..'<tr>'..
'<td>[[Attribut:'..args[a]..'|'..args[a]..']]</td>'..
'<td colspan="3">'
if args[a] == 'Gebäude' then
t=t..p.gebaeude(frame, args[w])
else
t=t..frame:callParserFunction(
'#arraymap', args[w], ';', 'x', '[['..args[a]..'::x]]')
end
t=t..'</td>'..
'</tr>'
else
t=t..frame:preprocess('[[Kategorie:Freiattribut-Fehler]]')
end
end
end
if not com.isEmpty(args.Urheber) then
t = t .. '<tr>'..
'<td>[[Attribut:Urheber|Urheber]]</td>' ..
'<td colspan="3">'..frame:callParserFunction(
'#arraymap', args['Urheber'], ';', 'x', '[[Urheber::x]]')..
'</td>'..
'</tr>'
end
if not com.isEmpty(args.Quellangaben) then
t = t .. '<tr>'..
'<td>[[Attribut:Quellangaben|Quellangaben]]</td>'..
'<td colspan="3">[[Quellangaben::'..args.Quellangaben..']]</td>'..
'</tr>'
end
if not com.isEmpty(args.Ort) then
t = t .. '<tr>'..
'<td>[[Attribut:Ort|Ort]]</td>'..
'<td>' .. frame:callParserFunction(
'#arraymap', args.Ort, ';', 'x', '[[Ort::x]]') ..'</td>'..
'<td><b>ausblenden:</b></td>'
z = '<td>[[ZeigeNichtInOrt::Nein]]</td>'
if not com.isEmpty(args.ZeigeNichtInOrt) then
z = '<td>[[ZeigeNichtInOrt::'..args.ZeigeNichtInOrt..']]</td>'
end
t = t .. z ..'</tr>'
end
if not com.isEmpty(args['Straße']) then
t = t .. '<tr>' ..
'<td>[[Attribut:Straße|Straße]]</td>' ..
'<td>' .. frame:callParserFunction(
'#arraymap', args['Straße'], ';', 'x', '[[Straße::x]]')
t = t .. '</td>' ..
'<td><b>ausblenden:</b></td>'
z = '<td>[[ZeigeNichtInStraße::Nein]]</td>'
if not com.isEmpty(args['ZeigeNichtInStraße']) then
z = '<td>[[ZeigeNichtInStraße::'..args['ZeigeNichtInStraße']..']]</td>'
end
t = t .. z .. '</tr>'
end
if not com.isEmpty(extension) then
t=t..'<tr>'..
'<td>[[Attribut:Dateiart|Dateiart]]</td>'..
'<td>[[Dateiart::' .. filekind .. ']]</td>'..
'<td>[[Attribut:Dateityp|Dateityp]]</td>'..
'<td>[[Dateityp::' .. extension .. ']]</td>'..
'</tr>'
end
if not com.isEmpty(args.Erstellungsdatum) then
t = t .. '<tr>' ..
'<td>[[Attribut:Erstellungsdatum|Erstellungsdatum]]</td>' ..
'<td colspan="3">' .. frame:expandTemplate{title='LinkFormDatum', args={
args.Erstellungsdatum,
'Erstellungsdatum',
'Erstellungstag',
'Erstellungsjahr'}} .. '</td>' ..
'</tr>'
end
if not com.isEmpty(args['ÜberDatum']) then
t=t..'<tr>'..
'<td>[[Attribut:ÜberDatum|Über Datum]]</td>'..
'<td colspan="3">'..frame:expandTemplate{title='LinkFormDatum', args={
args['ÜberDatum'],
'ÜberDatum',
'ÜberTag',
'ÜberJahr'}}..'</td>'..
'</tr>'
end
if not com.isEmpty(args.Seitennummer) then
t=t..'<tr>'..
'<td>[[Attribut:Seitennummer|Seitennummer]]</td>'..
'<td colspan="3">'..frame:callParserFunction(
'#arraymap', args.Seitennummer, ';', 'x', '[[Seitennummer::x]]') ..'</td>'..
'</tr>'
end
if not com.isEmpty(args.Signatur) then
t=t..'<tr>'..
'<td>[[Attribut:Signatur|Signatur]]</td>'..
'<td colspan="3">[[Signatur::'..args.Signatur..']]</td>'..
'</tr>'
end
if not com.isEmpty(args['Länge']) then
t=t..'<tr>'..
'<td>[[Attribut:Länge|Länge]]</td>'..
'<td colspan="3">'..'[[Länge::'..args['Länge']..']]</td>'..
'</tr>'
end
if not com.isEmpty(args.Lizenz) then
t=t..'<tr>'..
'<td>[[Attribut:Lizenz|Lizenz]]</td>'..
'<td colspan="3">[[Lizenz::' .. args.Lizenz .. ']]</td>'..
'</tr>'
end
if not com.isEmpty(args.UploadCommons) then
t=t..'<tr>'..
'<td>[[Attribut:UploadCommons|Upload zu Commons]]</td>'..
'<td colspan="3">[[UploadCommons::' .. args.UploadCommons .. ']]</td>'..
'</tr>'
end
if not com.isEmpty(args.Beschreibung) then
t=t..'<tr>'..
'<td>[[Attribut:Beschreibung|Beschreibung]]</td>'..
'<td colspan="3">[[Beschreibung::' ..args.Beschreibung .. ']]</td>'..
'</tr>'
mw.smw.set{["Beschreibungslänge"] = string.len(args.Beschreibung)}
mw.smw.set{["BeschreibungsMaxWortlänge"] = str.maxWordLen(args.Beschreibung, " -()[]|;,.:\\\"'/!?")}
end
-- Dateiinfo erstellen
local infotext = ""
local dateiinfo = ""
if not com.isEmpty(args.Beschreibung) then
infotext = infotext .. args.Beschreibung
dateiinfo = dateiinfo .. wik.wikiTextLimit(args.Beschreibung, 75)
if mw.ustring.len(dateiinfo) ~= mw.ustring.len(args.Beschreibung) then
dateiinfo = dateiinfo .. " ..."
end
end
if not com.isEmpty(args.Urheber) then
if infotext ~= "" then
infotext = infotext .. "<br>"
end
infotext = infotext .. "'''Urheber:''' " .. args.Urheber
end
if not com.isEmpty(args.Erstellungsdatum) then
if infotext ~= "" then
infotext = infotext .. "<br>"
end
infotext = infotext .. "'''Erstellungsdatum:''' " ..
lfd.linkFormDate(args.Erstellungsdatum)
end
if infotext ~= "" then
if dateiinfo ~= "" then
dateiinfo = dateiinfo .. " "
end
dateiinfo = dateiinfo .. "{{#info:" .. infotext .. "}}"
end
if dateiinfo ~= "" then
t=t..'<tr>'..
'<td>[[Attribut:Dateiinfo|Dateiinfo]] (automatisch erstellt)</td>'..
'<td colspan="3">[[Dateiinfo::' .. dateiinfo .. ']]</td>'..
'</tr>'
end
t=t..'<tr>'..
'<td>[[Bild:IconSearch.svg|16px|semantisches Browsen|link=Spezial:Durchsuchen/{{NAMESPACE}}:{{PAGENAME}}]]</td>'..
'<td colspan="3">[[Spezial:Durchsuchen/{{NAMESPACE}}:{{PAGENAME}}|semantisches Browsen]]</td>'..
'</tr>'
t=t..'</table>'
return frame:preprocess(t)
end
function p.GetExtension(frame)
-- #invoke wrapper
return p.getExtension(frame.args[1])
end
function p.getExtension(filename)
local extension = filename:match("^.+%.([^%.]+)$")
return mw.ustring.lower(extension)
end
function p.GetFilekind(frame)
-- #invoke wrapper
return p.getFilekind(frame.args[1])
end
function p.getFilekind(filetype)
local t = {
["Bild"] = {"webp", "png", "gif", "jpg", "jpeg", "svg"},
["Dokument"] = {"pdf"},
["Audio"] = {"mp3", "ogg", "oga", "flac", "opus", "wav"},
["Midi"] = {"midi", "mid"},
["Video"] = {"webm", "mp4", "m4v", "ogv", "mpg", "mpeg"},
["3D-Modell"] = {"obj", "glb", "gltf"},
}
for key, values in pairs(t) do
for _, value in ipairs(values) do
if value == filetype then
return key -- Bricht beide Schleifen ab und gibt den Key zurück
end
end
end
return "" -- Gib leeren String zurück, wenn nichts gefunden wurde
end
function p.gebaeude(frame, wert)
return frame:expandTemplate{title='Datei/Gebäude', args = {wert=wert} }
end
return p