15.082
Bearbeitungen
(- Beschreibungslänge, - BeschreibungMaxWortlänge, + ÜberDatum) |
(rework) |
||
| Zeile 1: | Zeile 1: | ||
local p = {} | local p = {} | ||
local com = require(" | local com = require("Modul:Common") | ||
local str = require(" | local dev = require("Modul:Development") | ||
local wik = require(" | local str = require("Modul:String") | ||
local lfd = require(" | local wik = require("Modul:Wiki") | ||
local lfd = require("Modul:LinkFormDatum") | |||
local wob = require("Modul:Wörterbuch") | |||
function p. | function p.Dateibox(frame) | ||
local | -- mw.log("Dateibox(frame)") | ||
-- mw.logObject(frame, "frame") | |||
-- Kommando-Zeile zum Debuggen: | |||
-- =p.Dateibox{pargs={["fullpagename"]="Datei:test.jpg",["Genre"]="g1;g2",["Attribut1"]="a1",["Wert1"]="w1;w2"}} | |||
-- =p.Dateibox{pargs={["fullpagename"]="Datei:test.jpg",["Beschreibung"]="Int. Tag gegen Gewalt an Frauen: Aktive vom ''Unabhängige Frauen Fürth e. V.'' an einem Infostand, Nov. 2019"}} | |||
local frame, pargs = dev.GetFrameAndParentArgs(frame) | |||
local title = pargs["fullpagename"] or wik.fullpagename() -- pargs["title"] zum Testen/Debuggen | |||
local extension = p.getExtension(title) | local extension = p.getExtension(title) | ||
local filekind = p.getFilekind(extension) | local filekind = p.getFilekind(extension) | ||
local | local t, v = "", "" | ||
-- Tabellenkopf | |||
t = t .. "<table class = \"wikitable\">" | |||
t = t .. "<th colspan = \"4\">" .. title .. "</th>" | |||
-- Genre-Kategorien | |||
v = "" | |||
for i, g in ipairs(str.splitAndStrip(pargs["Genre"], ";")) do | |||
if i > 1 then | |||
v = v .. ", " | |||
end | |||
v = v .. "[[:Kategorie:" .. g .. "|" .. g .. "]]{{#set:Genre=" .. g .. "}}[[Kategorie:" .. g .. "]]" | |||
end | end | ||
t = t .. p.attrZeile("Genre", v) | |||
-- | |||
-- Freiattribute | |||
for i = 1, 6 do | for i = 1, 6 do | ||
a = | local a = pargs["Attribut" .. i] or "" | ||
w = | local w = pargs["Wert" .. i] or "" | ||
if | if a ~= "" then | ||
if | if w ~= "" then | ||
v = "" | |||
if a == "Gebäude" then | |||
v = v .. p.gebaeude(frame, w) | |||
if | |||
else | else | ||
v = v .. p.attrValList(a, {[a] = w}) | |||
end | end | ||
t=t.. | t = t .. p.attrZeile(a, v) | ||
else | else | ||
t=t.. | t = t .. "[[Kategorie:Freiattribut-Fehler]]" | ||
end | end | ||
elseif w ~= "" then | |||
t = t .. "[[Kategorie:Freiattribut-Fehler]]" | |||
end | end | ||
end | end | ||
-- normale Zeilen | |||
t = t .. p.attrZeile("Urheber", p.attrValList("Urheber", pargs)) | |||
t = t .. p.attrZeile("Quellangaben", p.attrVal("Quellangaben", pargs)) | |||
-- Ort/Straße mit Ausblendung | |||
for _, a in ipairs{{"Straße", "ZeigeNichtInStraße"}, {"Ort", "ZeigeNichtInOrt"}} do | |||
v = p.attrValList(a[1], pargs) | |||
if v ~= "" then | |||
t = t .. p.zeile("[[Attribut:" .. a[1] .. "|" .. wob.attr_text(a[1]) .. "]]", v, "ausgeblendet:", | |||
"[[" .. a[2] .. "::" .. (pargs[a[2]] or "Nein") .. "]]") | |||
end | end | ||
end | end | ||
-- Dateiart/Dateityp | |||
t = t .. p.attrZeile("Dateiart", "[[Dateiart::" .. filekind .. "]]", | |||
"Dateityp", "[[Dateityp::" .. extension .. "]]") | |||
-- Erstellungsdatum/ÜberDatum | |||
for _, d in ipairs{ | |||
{"Erstellungsdatum", "Erstellungstag", "Erstellungsjahr"}, | |||
{"ÜberDatum", "ÜberTag", "ÜberJahr"}} do | |||
if | local date = pargs[d[1]] or "" | ||
if date ~= "" then | |||
t = t .. p.attrZeile(d[1], lfd.linkFormDate(date, d[1], d[2], d[3])) | |||
end | end | ||
end | end | ||
-- normale Zeilen | |||
t = t .. p.attrZeile("Seitennummer", p.attrValList("Seitennummer", pargs)) | |||
t = t .. p.attrZeile("Signatur", p.attrVal("Signatur", pargs)) | |||
t = t .. p.attrZeile("Länge", p.attrVal("Länge", pargs)) | |||
t = t .. p.attrZeile("Lizenz", p.attrVal("Lizenz", pargs)) | |||
t = t .. p.attrZeile("UploadCommons", p.attrVal("UploadCommons", pargs)) | |||
t = t .. p.attrZeile("Beschreibung", p.attrVal("Beschreibung", pargs)) | |||
-- Dateiinfo erstellen | -- Dateiinfo erstellen | ||
local infotext = "" | local dateiinfo, infotext = "", "" | ||
if not com.isEmpty(pargs["Beschreibung"]) then | |||
if not com.isEmpty( | dateiinfo = dateiinfo .. wik.wikiTextLimit(pargs["Beschreibung"], 100) -- max. Zeichenanzahl Bild-Unterschrift | ||
if mw.ustring.len(dateiinfo) ~= mw.ustring.len(pargs["Beschreibung"]) then | |||
dateiinfo = dateiinfo .. wik.wikiTextLimit( | |||
if mw.ustring.len(dateiinfo) ~= mw.ustring.len( | |||
dateiinfo = dateiinfo .. " ..." | dateiinfo = dateiinfo .. " ..." | ||
infotext = infotext .. pargs["Beschreibung"] | |||
end | end | ||
end | end | ||
if | local urheber = str.splitAndStrip(pargs["Urheber"] or "", ";") | ||
if #urheber > 0 then | |||
for u = 1, #urheber do | |||
if wik.pageExists(urheber[u]) then | |||
urheber[u] = "[[" .. urheber[u] .. "]]" | |||
end | |||
end | |||
if infotext ~= "" then | if infotext ~= "" then | ||
infotext = infotext .. "<br>" | infotext = infotext .. "<br>" | ||
end | end | ||
infotext = infotext .. "Urheber: " .. | infotext = infotext .. wob.attr_text("Urheber") .. ": " .. table.concat(urheber, ", ") | ||
end | end | ||
if | for _, d in ipairs{"Erstellungsdatum", "ÜberDatum"} do | ||
date = pargs[d] or "" | |||
if date ~= "" then | |||
if infotext ~= "" then | |||
infotext = infotext .. "<br>" | |||
end | |||
infotext = infotext .. wob.attr_text(d) .. ": " .. lfd.linkFormDate(date) | |||
end | end | ||
end | end | ||
if not com.isEmpty( | if not com.isEmpty(pargs["Lizenz"]) then | ||
if infotext ~= "" then | if infotext ~= "" then | ||
infotext = infotext .. "<br>" | infotext = infotext .. "<br>" | ||
end | end | ||
infotext = infotext .. " | infotext = infotext .. wob.attr_text("Lizenz") .. ": " .. pargs["Lizenz"] | ||
end | end | ||
if infotext ~= "" then | if infotext ~= "" then | ||
| Zeile 200: | Zeile 133: | ||
end | end | ||
if dateiinfo ~= "" then | if dateiinfo ~= "" then | ||
t=t.. | t = t .. p.attrZeile("Dateiinfo", "[[Dateiinfo::" .. dateiinfo .. "]]") | ||
end | end | ||
t=t.. | -- Tabellenende mit sem. Browsen | ||
t = t .. | |||
"<tr>" .. | |||
"<td>[[Bild:IconSearch.svg|16px|semantisches Browsen|link=Spezial:Durchsuchen/{{FULLPAGENAME}}]]</td>" .. | |||
t=t.. | "<td colspan = \"3\">[[Spezial:Durchsuchen/{{FULLPAGENAME}}|semantisches Browsen]]</td>" .. | ||
"</tr>" | |||
t = t .. "</table>" | |||
-- Seite setzen | |||
t = t .. "{{#set:Seite=" .. wik.fullpagename() .. "}}" | |||
-- mw.logObject(t, "t") | |||
t = frame:preprocess(t) | |||
-- mw.logObject(t, "t") | |||
return t | |||
return | |||
end | end | ||
| Zeile 223: | Zeile 156: | ||
local extension = filename:match("^.+%.([^%.]+)$") | local extension = filename:match("^.+%.([^%.]+)$") | ||
return mw.ustring.lower(extension) | return mw.ustring.lower(extension) | ||
end | end | ||
| Zeile 250: | Zeile 178: | ||
function p.gebaeude(frame, wert) | function p.gebaeude(frame, wert) | ||
return frame:expandTemplate{title= | return frame:expandTemplate{title = "Datei/Gebäude", args = {wert = wert} } | ||
end | |||
function p.attrVal(a, pargs) | |||
local t = "" | |||
local v = pargs[a] or "" | |||
if v ~= "" then | |||
t = t .. "[[" .. a .. "::" .. v .. "]]" | |||
end | |||
return t | |||
end | |||
function p.attrValList(a, pargs) | |||
local t = "" | |||
local l = str.splitAndStrip(pargs[a] or "", ";") | |||
for i, v in ipairs(l) do | |||
if i > 1 then | |||
t = t .. ", " | |||
end | |||
t = t .. "[[" .. a .. "::" .. v .. "]]" | |||
end | |||
return t | |||
end | |||
function p.attrZeile(a1, v1, a2, v2) | |||
local t = "" | |||
if v1 ~= "" then | |||
a1 = "[[Attribut:" .. a1 .. "|" .. wob.attr_text(a1) .. "]]" | |||
if a2 ~= nil and v2 ~= nil and v2 ~= "" then | |||
a2 = "[[Attribut:" .. a2 .. "|" .. wob.attr_text(a2) .. "]]" | |||
end | |||
t = t .. p.zeile(a1, v1, a2, v2) | |||
end | |||
return t | |||
end | |||
function p.zeile(a1, v1, a2, v2) | |||
local t = "" | |||
if v1 ~= "" then | |||
t = t .. "<tr>" | |||
t = t .. "<td>'''" .. a1 .. "'''</td>" | |||
if a2 == nil or v2 == nil or v2 == "" then | |||
t = t .. "<td colspan = \"3\">" .. v1 .. "</td>" | |||
else | |||
t = t .. "<td>" .. v1 .. "</td>" | |||
t = t .. "<td>'''" .. a2 .. "'''</td>" | |||
t = t .. "<td>" .. v2 .. "</td>" | |||
end | |||
t = t .. "</tr>" | |||
end | |||
return t | |||
end | end | ||
return p | return p | ||