20.564
Bearbeitungen
(+ namespace check) |
(+ Wartungsmeldung Datei-Freiattribut-Fehler Straßen/Orts-Angabe) |
||
| (9 dazwischenliegende Versionen von 2 Benutzern werden nicht angezeigt) | |||
| Zeile 7: | Zeile 7: | ||
local lfd = require("Modul:LinkFormDatum") | local lfd = require("Modul:LinkFormDatum") | ||
local wob = require("Modul:Wörterbuch") | local wob = require("Modul:Wörterbuch") | ||
local kal = require("Modul:Kalender") | |||
local license_url = { | |||
-- Quelle: https://creativecommons.org/licenses/list.en | |||
["CC BY 3.0"] = "https://creativecommons.org/licenses/by/3.0/de/deed.de", | |||
["CC BY-NC 3.0"] = "https://creativecommons.org/licenses/by-nc/3.0/de/deed.de", | |||
["CC BY-NC-ND 3.0"] = "https://creativecommons.org/licenses/by-nc-nd/3.0/de/deed.de", | |||
["CC BY-NC-SA 3.0"] = "https://creativecommons.org/licenses/by-nc-sa/3.0/de/deed.de", | |||
["CC BY-ND 3.0"] = "https://creativecommons.org/licenses/by-nd/3.0/de/deed.de", | |||
["CC BY-SA 3.0"] = "https://creativecommons.org/licenses/by-sa/3.0/de/deed.de", | |||
["CC BY 4.0"] = "https://creativecommons.org/licenses/by/4.0/deed.de", | |||
["CC BY-NC 4.0"] = "https://creativecommons.org/licenses/by-nc/4.0/deed.de", | |||
["CC BY-NC-ND 4.0"] = "https://creativecommons.org/licenses/by-nc-nd/4.0/deed.de", | |||
["CC BY-NC-SA 4.0"] = "https://creativecommons.org/licenses/by-nc-sa/4.0/deed.de", | |||
["CC BY-ND 4.0"] = "https://creativecommons.org/licenses/by-nd/4.0/deed.de", | |||
["CC BY-SA 4.0"] = "https://creativecommons.org/licenses/by-sa/4.0/deed.de"} | |||
function p.Dateibox(frame) | function p.Dateibox(frame) | ||
| Zeile 20: | Zeile 36: | ||
local frame, pargs = dev.GetFrameAndParentArgs(frame) | local frame, pargs = dev.GetFrameAndParentArgs(frame) | ||
local title = pargs["fullpagename"] or wik.fullpagename() | local title = pargs["fullpagename"] or wik.fullpagename() -- pargs["fullpagename"] zum Testen/Debuggen | ||
local v = "" | local v = "" | ||
| Zeile 33: | Zeile 49: | ||
v = v .. ", " | v = v .. ", " | ||
end | end | ||
v = v .. "[[:Kategorie:" .. g .. "|" .. g .. "]]{{#set:Genre=" .. g .. "}}[[Kategorie:" .. g .. "]]" | v = v .. "[[:Kategorie:" .. g .. "|" .. g .. "]]" .. | ||
"{{#set:Genre=" .. g .. "}}[[Kategorie:" .. g .. "]]" | |||
end | end | ||
t = t .. p.attrZeile("Genre", v) | t = t .. p.attrZeile("Genre", v) | ||
| Zeile 44: | Zeile 61: | ||
local w = pargs["Wert" .. i] or "" | local w = pargs["Wert" .. i] or "" | ||
if a ~= "" and w ~= "" then | if a ~= "" and w ~= "" then | ||
aw[a] = (aw[a] or "") .. w .. ";" | aw[a] = (aw[a] or "") .. w .. ";" -- Werte zusammenführen | ||
elseif a ~= "" or w ~= "" then | elseif a ~= "" or w ~= "" then | ||
aw_fail = true | aw_fail = true | ||
| Zeile 50: | Zeile 67: | ||
end | end | ||
if aw_fail then | if aw_fail then | ||
mw.smw.set{["Wartungsmeldung"]="Datei-Freiattribut-Fehler"} | |||
end | end | ||
for a, w in pairs(aw) do | for a, w in pairs(aw) do | ||
if a == "Gebäude" then | if a == "Gebäude" then -- zusätzlich Gebäude nach StraßeHnr suchen und hinzufügen | ||
local gebaeude_wert = {} | local gebaeude_wert = {} | ||
for _, e in ipairs(str.splitAndStrip(w, ";")) do | for _, e in ipairs(str.splitAndStrip(w, ";")) do -- direkt über Wertx angegebene Gebäude | ||
gebaeude_wert[e] = true | gebaeude_wert[e] = true | ||
end | end | ||
local gebaeude_query = {} | local gebaeude_query = {} | ||
for g, _ in pairs(gebaeude_wert) do | for g, _ in pairs(gebaeude_wert) do -- über query ermittelte Gebäude | ||
local q = "[[:+]][[Kategorie:Gebäude]][[StraßeHnr::" .. g .. "]]|?#-" | local q = "[[:+]][[Kategorie:Gebäude]]" .. | ||
"[[StraßeHnr::" .. g .. "]]|?#-" | |||
q = mw.smw.ask(q) or {} | q = mw.smw.ask(q) or {} | ||
for _, qg in ipairs(q) do | for _, qg in ipairs(q) do | ||
qg = qg[1] | qg = qg[1] | ||
if gebaeude_wert[qg] ~= true then | if gebaeude_wert[qg] ~= true then -- nur, wenn nicht schon direkt angegeben (auch nil!) | ||
gebaeude_query[qg] = true | gebaeude_query[qg] = true | ||
end | end | ||
end | end | ||
end | end | ||
v = "" | v = "" -- jetzt den Anzeigetext zusammenbauen | ||
for g, _ in pairs(gebaeude_wert) do | for g, _ in pairs(gebaeude_wert) do -- erst die direkt angegebenen Gebäude | ||
if v ~= "" then | if v ~= "" then | ||
v = v .. ", " | v = v .. ", " | ||
| Zeile 76: | Zeile 94: | ||
v = v .. "[[" .. a .. "::" .. g .. "]]" | v = v .. "[[" .. a .. "::" .. g .. "]]" | ||
end | end | ||
local v_query = "" | local v_query = "" -- dann die via query ermittelten Gebäude | ||
for g, _ in pairs(gebaeude_query) do | for g, _ in pairs(gebaeude_query) do | ||
if v_query ~= "" then | if v_query ~= "" then | ||
| Zeile 84: | Zeile 102: | ||
end | end | ||
if v_query ~= "" then | if v_query ~= "" then | ||
v = v .. "<br>automatisch ermittelt über Straße/Hausnummer: " .. v_query | v = v .. "<br>automatisch ermittelt über Straße/Hausnummer: " .. | ||
v_query | |||
end | end | ||
elseif a == "Straße" then -- Straße als Freiattribute wird zu pargs["Straße"] verschoben | |||
mw.smw.set{["Wartungsmeldung"]="Datei-Freiattribut-Fehler Straßen-Angabe"} | |||
pargs["Straße"] = (pargs["Straße"] or "") .. ";" .. w | |||
v = "" | |||
elseif a == "Ort" then -- Ort als Freiattribute wird zu pargs["Ort"] verschoben | |||
mw.smw.set{["Wartungsmeldung"]="Datei-Freiattribut-Fehler Orts-Angabe"} | |||
pargs["Ort"] = (pargs["Ort"] or "") .. ";" .. w | |||
v = "" | |||
else | else | ||
v = p.attrValList(a, {[a] = w}) | v = p.attrValList(a, {[a] = w}) | ||
| Zeile 93: | Zeile 120: | ||
-- normale Zeilen | -- normale Zeilen | ||
t = t .. p.attrZeile("Urheber", p.attrValList("Urheber", pargs)) | t = t .. p.attrZeile("Urheber", p.attrValList("Urheber", pargs), | ||
nil, nil, "fileinfotpl_aut") -- mit Setzen der Medienbetracher-Tags | |||
t = t .. p.attrZeile("Quellangaben", p.attrVal("Quellangaben", pargs)) | t = t .. p.attrZeile("Quellangaben", p.attrVal("Quellangaben", pargs)) | ||
| Zeile 100: | Zeile 128: | ||
v = p.attrValList(a[1], pargs) | v = p.attrValList(a[1], pargs) | ||
if v ~= "" then | if v ~= "" then | ||
t = t .. p.zeile("[[Attribut:" .. a[1] .. "|" .. wob. | t = t .. p.zeile("[[Attribut:" .. a[1] .. "|" .. wob.attrText(a[1]) .. "]]", v, | ||
"ausgeblendet:", "[[" .. a[2] .. "::" .. (pargs[a[2]] or "Nein") .. "]]") | |||
end | end | ||
end | end | ||
| Zeile 112: | Zeile 140: | ||
-- Erstellungsdatum/ÜberDatum | -- Erstellungsdatum/ÜberDatum | ||
local erstellungsdatum = pargs["Erstellungsdatum"] or "" | |||
if erstellungsdatum ~= "" then | |||
t = t .. p.attrZeile("Erstellungsdatum", | |||
lfd.linkFormDate(erstellungsdatum, | |||
"Erstellungsdatum", "Erstellungstag", "Erstellungsjahr")) | |||
end | |||
ueberdatum = pargs["ÜberDatum"] or "" | |||
if ueberdatum ~= "" then | |||
t = t .. p.attrZeile("ÜberDatum", | |||
lfd.linkFormDate(ueberdatum, "ÜberDatum", "ÜberTag", "ÜberJahr")) | |||
end | end | ||
| Zeile 125: | Zeile 156: | ||
t = t .. p.attrZeile("Signatur", p.attrVal("Signatur", 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("Länge", p.attrVal("Länge", pargs)) | ||
-- Lizenz mit Setzen der Medienbetracher-Tags | |||
local lizenz, is_cc_license = | |||
p.ccLicenseCorrection(pargs["Lizenz"] or "") -- ggf. CC-Schreibeweise korrigieren | |||
if not is_cc_license then | |||
lizenz = p.nocNcLicenseCorrection(lizenz) -- ggf. NoC-NC 1.0 Schreibweise korrigieren | |||
end | |||
if not com.isEmpty(lizenz) then -- Spezial-Behandlung für Media Viewer | |||
t = t .. | |||
"<tr>" .. | |||
"<td class=\"fileinfo-paramfield\">'''[[Attribut:Lizenz|Lizenz]]'''</td>" .. | |||
"<td colspan = \"3\">" .. | |||
"<span class=\"licensetpl\">" .. | |||
"<span class=\"licensetpl_short\">" .. | |||
lizenz .. | |||
"</span>" .. | |||
"</span>" .. | |||
"</td>" .. | |||
"</tr>" .. | |||
"{{#set:Lizenz=" .. lizenz .. "}}" | |||
end | |||
-- normale Zeilen | |||
t = t .. p.attrZeile("UploadCommons", p.attrVal("UploadCommons", pargs)) | t = t .. p.attrZeile("UploadCommons", p.attrVal("UploadCommons", pargs)) | ||
t = t .. p.attrZeile("Beschreibung", p.attrVal("Beschreibung", pargs)) | t = t .. p.attrZeile("Beschreibung", p.attrVal("Beschreibung", pargs), | ||
nil, nil, "fileinfotpl_desc") -- mit Setzen der Medienbetracher-Tags | |||
-- Dateiinfo erstellen | -- Dateiinfo erstellen | ||
local dateiinfo, infotext = "", "" | local dateiinfo, infotext = "", "" | ||
if not com.isEmpty(pargs["Beschreibung"]) then | if not com.isEmpty(pargs["Beschreibung"]) then -- Beschreibung | ||
dateiinfo = dateiinfo .. wik.wikiTextLimit(pargs["Beschreibung"], 100) -- max. Zeichenanzahl Bild-Unterschrift | dateiinfo = dateiinfo .. | ||
if mw.ustring.len(dateiinfo) ~= mw.ustring.len(pargs["Beschreibung"]) then | wik.wikiTextLimit(pargs["Beschreibung"], 100) -- max. Zeichenanzahl Bild-Unterschrift | ||
if mw.ustring.len(dateiinfo) ~= | |||
mw.ustring.len(pargs["Beschreibung"]) then | |||
dateiinfo = dateiinfo .. " ..." | dateiinfo = dateiinfo .. " ..." | ||
infotext = infotext .. pargs["Beschreibung"] | infotext = infotext .. pargs["Beschreibung"] | ||
end | end | ||
end | end | ||
local urheber = str.splitAndStrip(pargs["Urheber"] or "", ";") | local urheber = str.splitAndStrip(pargs["Urheber"] or "", ";") -- Urheber | ||
if #urheber > 0 then | if #urheber > 0 then | ||
for u = 1, #urheber do | for u = 1, #urheber do | ||
| Zeile 148: | Zeile 204: | ||
infotext = infotext .. "<br>" | infotext = infotext .. "<br>" | ||
end | end | ||
infotext = infotext .. wob. | infotext = infotext .. wob.attrText("Urheber") .. ": " .. | ||
table.concat(urheber, ", ") | |||
end | end | ||
for _, d in ipairs{"Erstellungsdatum", "ÜberDatum"} do | for _, d in ipairs{"Erstellungsdatum", "ÜberDatum"} do -- Erstellungsdatum, ÜberDatum | ||
date = pargs[d] or "" | date = pargs[d] or "" | ||
if date ~= "" then | if date ~= "" then | ||
| Zeile 156: | Zeile 213: | ||
infotext = infotext .. "<br>" | infotext = infotext .. "<br>" | ||
end | end | ||
end | end | ||
end | end | ||
if not com.isEmpty( | if not com.isEmpty(lizenz) then -- Lizenz | ||
if infotext ~= "" then | if infotext ~= "" then | ||
infotext = infotext .. "<br>" | infotext = infotext .. "<br>" | ||
end | end | ||
infotext = infotext .. wob. | infotext = infotext .. wob.attrText("Lizenz") .. ": " .. lizenz | ||
end | end | ||
if infotext ~= "" then | if infotext ~= "" then | ||
| Zeile 172: | Zeile 228: | ||
end | end | ||
if dateiinfo ~= "" then | if dateiinfo ~= "" then | ||
t = t .. p.zeile("[[Attribut:Dateiinfo|Dateiinfo]] '''<br>(Bild-Unterschrift und Info-Box,<br>automatisch erstellt)''' ", "[[Dateiinfo::" .. dateiinfo .. "]]") | t = t .. p.zeile("[[Attribut:Dateiinfo|Dateiinfo]] '''<br>" .. | ||
"(Bild-Unterschrift und Info-Box,<br>automatisch erstellt)''' ", | |||
"[[Dateiinfo::" .. dateiinfo .. "]]") | |||
end | end | ||
-- Tabellenende mit sem. Browsen | -- Quellangaben plus Hinweis als Medienbetrachter-Zeile | ||
t = t .. p.zeile("[[Bild:IconSearch.svg|16px| | t = t .. p.zeile("Medienbetrachter-Zeile'''<br>(automatisch erstellt)''' ", | ||
"[[Spezial:Durchsuchen/{{FULLPAGENAME}}| | (pargs["Quellangaben"] or "") .. | ||
" ▽ mehr Infos ▽", nil, nil, "fileinfotpl_src") | |||
--[[ funktioniert nicht | |||
if is_cc_license then | |||
t = t .. | |||
"<tr>" .. | |||
"<td class=\"fileinfo-paramfield\">'''Lizenz-URL'''<br>(automatisch erstellt)</td>" .. | |||
"<td colspan = \"3\">" .. | |||
"<span class=\"licensetpl\">" .. | |||
"<span class=\"licensetpl_link\">" .. | |||
license_url[lizenz] .. | |||
"</span>" .. | |||
"</span>" .. | |||
"</td>" .. | |||
"</tr>" | |||
end ]] | |||
-- Erstellungsdatum ISO-Notation für Media Viewer | |||
if erstellungsdatum ~= "" then | |||
t = t .. p.zeile("Erstellungsdatum,<br>'''(ISO-Notation automatisch erstellt)''' ", | |||
kal.date2ISO(erstellungsdatum), nil, nil, "fileinfotpl_date") | |||
end | |||
-- Tabellenende mit sem. Browsen und Bilder-Suche | |||
t = t .. p.zeile("[[Bild:IconSearch.svg|16px|Semantisches Browsen|link=Spezial:Durchsuchen/{{FULLPAGENAME}}]]", | |||
"[[Spezial:Durchsuchen/{{FULLPAGENAME}}|Semantisches Browsen]] / " .. | |||
"{{#queryformlink:form=Abfrage Bilder|link text=Bilder-Suche}}") | |||
t = t .. "</table>" | t = t .. "</table>" | ||
| Zeile 237: | Zeile 322: | ||
end | end | ||
function p.attrZeile(a1, v1, a2, v2) | function p.attrZeile(a1, v1, a2, v2, id1) -- Tabellenzeile mit max. 2 Attributen | ||
local t = "" | local t = "" | ||
if v1 ~= "" then | if v1 ~= "" then | ||
a1 = "[[Attribut:" .. a1 .. "|" .. wob. | a1 = "[[Attribut:" .. a1 .. "|" .. wob.attrText(a1) .. "]]" | ||
if a2 ~= nil and v2 ~= nil and v2 ~= "" then | if a2 ~= nil and v2 ~= nil and v2 ~= "" then | ||
a2 = "[[Attribut:" .. a2 .. "|" .. wob. | a2 = "[[Attribut:" .. a2 .. "|" .. wob.attrText(a2) .. "]]" | ||
end | end | ||
t = t .. p.zeile(a1, v1, a2, v2) | t = t .. p.zeile(a1, v1, a2, v2, id1) | ||
end | end | ||
return t | return t | ||
end | end | ||
function p.zeile(a1, v1, a2, v2) | function p.zeile(a1, v1, a2, v2, id1) -- Tabellenzeile mit max. 2x2 Einträgen | ||
local t = "" | local t = "" | ||
if v1 ~= "" then | if v1 ~= "" then | ||
t = t .. "<tr>" | t = t .. "<tr>" | ||
t = t .. "<td>'''" .. a1 .. "'''</td>" | if id1 == nil then | ||
t = t .. "<td>'''" .. a1 .. "'''</td>" | |||
else | |||
t = t .. "<td id=\"" .. id1 .. "\" class=\"fileinfo-paramfield\">'''" .. a1 .. "'''</td>" | |||
end | |||
if a2 == nil or v2 == nil or v2 == "" then | if a2 == nil or v2 == nil or v2 == "" then | ||
t = t .. "<td colspan = \"3\">" .. v1 .. "</td>" | t = t .. "<td colspan = \"3\">" .. v1 .. "</td>" | ||
| Zeile 264: | Zeile 353: | ||
end | end | ||
return t | return t | ||
end | |||
function p.ccLicenseCorrection(lic_text) -- Schreibweise CC-Lizenzen korrigieren | |||
local lic_text_fixed = string.upper(lic_text) | |||
local is_cc_license = false | |||
if string.sub(lic_text_fixed, 1, 3) == "CC " or -- Beginn mit "CC " or "CC-"? | |||
string.sub(lic_text_fixed, 1, 3) == "CC-" then | |||
is_cc_license = true | |||
if string.sub(lic_text_fixed, 3, 3) == "-" then -- Bindestrich hinter "CC" entfernen | |||
lic_text_fixed = "CC " .. string.sub(lic_text_fixed, 4) | |||
end | |||
local version_hyphen_start, version_hyphen_end = -- Bindestrich vor Version entfernen | |||
string.find(lic_text_fixed,"-%d") | |||
if version_hyphen_start ~= nil then | |||
lic_text_fixed = | |||
string.sub(lic_text_fixed, 1, version_hyphen_start - 1) .. | |||
" " .. string.sub(lic_text_fixed, version_hyphen_start + 1) | |||
end | |||
else | |||
lic_text_fixed = lic_text | |||
end | |||
return lic_text_fixed, is_cc_license | |||
end | |||
function p.nocNcLicenseCorrection(lic_text) -- Schreibweise NoC-NC 1.0 Lizenz korrigieren | |||
local lic_text_fixed = lic_text | |||
if string.upper(lic_text) == "NOC-NC-1.0" or | |||
string.upper(lic_text) == "NOC-NC 1.0" then | |||
lic_text_fixed = "NoC-NC 1.0" | |||
end | |||
return lic_text_fixed | |||
end | |||
function p.LicenseCorrection(frame) -- Schreibweise CC- und NoC-NC 1.0 Lizenz korrigieren | |||
local lizenz = frame.args["Lizenz"] or "" | |||
lizenz = p.ccLicenseCorrection(lizenz) | |||
lizenz = p.nocNcLicenseCorrection(lizenz) | |||
return lizenz | |||
end | end | ||
return p | return p | ||