(Die Seite wurde neu angelegt: „local artikel = {} function artikel.render(args, main) local output = '<table class="publikation artikel">' -- Coverbild output = output .. '<tr><td colspan="2" style="text-align: center;">' .. main.getCoverImage(args["Coverbild"], "DefaultArtikelCover.jpg") .. '</td></tr>' -- Titel output = output .. '<tr><td><strong>Titel</strong></td><td>[[Hat Titel::' .. (args["Titel"] or "Unbekannt") .. ']]</td></tr>' -- Autoren (Mehrfachw…“) |
Keine Bearbeitungszusammenfassung |
||
Zeile 1: | Zeile 1: | ||
local getArgs = require("Module:Arguments").getArgs | |||
local helper = require("Modul:Publikation/Helper") | |||
local related = require("Modul:Publikation/Related") | |||
local artikel = {} | local artikel = {} | ||
function artikel.render(args | function artikel.render(frame) | ||
local args = getArgs(frame) | |||
local output = '<table class="publikation artikel">' | local output = '<table class="publikation artikel">' | ||
-- Coverbild | -- Coverbild | ||
output = output .. '<tr><td colspan="2" style="text-align: center;">' .. | output = output .. '<tr><td colspan="2" style="text-align: center;">' .. | ||
helper.getCoverImage({ cover = args["Coverbild"], defaultCover = "Library:Cover:DefaultArtikelCover.webp" }) .. | |||
'</td></tr>' | |||
-- Titel | -- Titel | ||
output = output .. '<tr><td><strong>Titel</strong></td><td>[[Hat Titel::' .. (args["Titel"] or "Unbekannt") .. ']]</td></tr>' | output = output .. '<tr><td><strong>Titel</strong></td><td>[[Hat Titel::' .. (args["Titel"] or "Unbekannt") .. ']]</td></tr>' | ||
-- | -- Autor(en) | ||
if args["Autor"] then | if args["Autor"] and args["Autor"] ~= "" then | ||
output = output .. '<tr><td><strong>Autor(en)</strong></td><td>' | output = output .. '<tr><td><strong>Autor(en)</strong></td><td>' | ||
for author in mw.text.gsplit(args["Autor"], ",") do | for author in mw.text.gsplit(args["Autor"], ",") do | ||
output = output .. '[[ | author = mw.text.trim(author) | ||
local authorPage = "Library:Autor:" .. author:gsub(" ", "_") | |||
helper.setProperty({ args = { ["Hat Autor"] = author } }) -- Semantischer Wert | |||
output = output .. '[[' .. authorPage .. '|' .. author .. ']], ' | |||
end | end | ||
output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma | output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma | ||
Zeile 20: | Zeile 29: | ||
-- Publikationswerk | -- Publikationswerk | ||
output = output .. (args[" | if args["Publikationswerk"] and args["Publikationswerk"] ~= "" then | ||
helper.setProperty({ args = { ["Publikationswerk"] = args["Publikationswerk"] } }) -- Semantischer Wert | |||
output = output .. '<tr><td><strong>Publikationswerk</strong></td><td>' .. args["Publikationswerk"] .. '</td></tr>' | |||
end | |||
-- Umfang | |||
output = output .. (args["Umfang"] and '<tr><td><strong>Umfang</strong></td><td>[[Umfang::' .. args["Umfang"] .. ']] Seiten</td></tr>' or "") | |||
-- Erscheinungsjahr | -- Erscheinungsjahr | ||
output = output .. (args["Erscheinungsjahr"] and '<tr><td><strong>Erscheinungsjahr</strong></td><td>[[Erscheinungsjahr::' .. args["Erscheinungsjahr"] .. ']]</td></tr>' or "") | output = output .. (args["Erscheinungsjahr"] and '<tr><td><strong>Erscheinungsjahr</strong></td><td>[[Erscheinungsjahr::' .. args["Erscheinungsjahr"] .. ']]</td></tr>' or "") | ||
-- Sprache | -- Sprache | ||
output = output .. (args["Sprache"] and '<tr><td><strong>Sprache</strong></td><td>[[Sprache::' .. args["Sprache"] .. ']]</td></tr>' or "") | output = output .. (args["Sprache"] and '<tr><td><strong>Sprache</strong></td><td>[[Sprache::' .. args["Sprache"] .. ']]</td></tr>' or "") | ||
-- | -- ISSN | ||
if args["ISSN"] and args["ISSN"] ~= "" then | |||
local issnLink = string.format('[https://portal.issn.org/resource/ISSN/%s %s]', args["ISSN"], args["ISSN"]) | |||
output = output .. '<tr><td><strong>ISSN</strong></td><td>[[ISSN::' .. args["ISSN"] .. ']] (' .. issnLink .. ')</td></tr>' | |||
end | |||
-- | -- Datensatz ID | ||
output = output .. (args[" | output = output .. (args["Datensatz ID"] and '<tr><td><strong>Datensatz ID</strong></td><td>[[Datensatz ID::' .. args["Datensatz ID"] .. ']]</td></tr>' or "") | ||
-- Zusammenfassung | |||
if args["Inhaltszusammenfassung"] and args["Inhaltszusammenfassung"] ~= "" then | |||
local rawSummary = mw.text.unstripNoWiki(args["Inhaltszusammenfassung"]):gsub("<.->", "") | |||
local truncatedSummary = mw.ustring.sub(rawSummary, 1, 80) .. (mw.ustring.len(rawSummary) > 80 and "..." or "") | |||
helper.setProperty({ args = { ["Inhaltszusammenfassung"] = rawSummary } }) -- Semantischer Wert | |||
output = output .. '<tr><td><strong>Zusammenfassung</strong></td><td>' .. args["Inhaltszusammenfassung"] .. '</td></tr>' | |||
end | |||
-- | -- Stichworte (Keywords) | ||
output = output .. | if args["Keyword"] then | ||
output = output .. '<tr><td><strong>Stichworte</strong></td><td>' | |||
for keyword in mw.text.gsplit(args["Keyword"], ",") do | |||
keyword = mw.text.trim(keyword) | |||
helper.setProperty({ args = { ["Keyword"] = keyword } }) -- Semantischer Wert | |||
output = output .. keyword .. ', ' | |||
end | |||
output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma | |||
end | |||
-- | -- Ähnliche Artikel basierend auf Stichwörtern | ||
if args["Keyword"] then | |||
local similarArticles = related.similarArticles({ Keyword = args["Keyword"], limit = 5 }) | |||
if similarArticles ~= "Keine ähnlichen Artikel gefunden." then | |||
output = output .. '<tr><td><strong>Ähnliche Artikel</strong></td><td>' .. similarArticles .. '</td></tr>' | |||
end | |||
end | |||
output = output .. '</table>' | output = output .. '</table>' |
Version vom 27. November 2024, 22:13 Uhr
Die Dokumentation für dieses Modul kann unter Modul:Publikation/Artikel/Doku erstellt werden
local getArgs = require("Module:Arguments").getArgs
local helper = require("Modul:Publikation/Helper")
local related = require("Modul:Publikation/Related")
local artikel = {}
function artikel.render(frame)
local args = getArgs(frame)
local output = '<table class="publikation artikel">'
-- Coverbild
output = output .. '<tr><td colspan="2" style="text-align: center;">' ..
helper.getCoverImage({ cover = args["Coverbild"], defaultCover = "Library:Cover:DefaultArtikelCover.webp" }) ..
'</td></tr>'
-- Titel
output = output .. '<tr><td><strong>Titel</strong></td><td>[[Hat Titel::' .. (args["Titel"] or "Unbekannt") .. ']]</td></tr>'
-- Autor(en)
if args["Autor"] and args["Autor"] ~= "" then
output = output .. '<tr><td><strong>Autor(en)</strong></td><td>'
for author in mw.text.gsplit(args["Autor"], ",") do
author = mw.text.trim(author)
local authorPage = "Library:Autor:" .. author:gsub(" ", "_")
helper.setProperty({ args = { ["Hat Autor"] = author } }) -- Semantischer Wert
output = output .. '[[' .. authorPage .. '|' .. author .. ']], '
end
output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
end
-- Publikationswerk
if args["Publikationswerk"] and args["Publikationswerk"] ~= "" then
helper.setProperty({ args = { ["Publikationswerk"] = args["Publikationswerk"] } }) -- Semantischer Wert
output = output .. '<tr><td><strong>Publikationswerk</strong></td><td>' .. args["Publikationswerk"] .. '</td></tr>'
end
-- Umfang
output = output .. (args["Umfang"] and '<tr><td><strong>Umfang</strong></td><td>[[Umfang::' .. args["Umfang"] .. ']] Seiten</td></tr>' or "")
-- Erscheinungsjahr
output = output .. (args["Erscheinungsjahr"] and '<tr><td><strong>Erscheinungsjahr</strong></td><td>[[Erscheinungsjahr::' .. args["Erscheinungsjahr"] .. ']]</td></tr>' or "")
-- Sprache
output = output .. (args["Sprache"] and '<tr><td><strong>Sprache</strong></td><td>[[Sprache::' .. args["Sprache"] .. ']]</td></tr>' or "")
-- ISSN
if args["ISSN"] and args["ISSN"] ~= "" then
local issnLink = string.format('[https://portal.issn.org/resource/ISSN/%s %s]', args["ISSN"], args["ISSN"])
output = output .. '<tr><td><strong>ISSN</strong></td><td>[[ISSN::' .. args["ISSN"] .. ']] (' .. issnLink .. ')</td></tr>'
end
-- Datensatz ID
output = output .. (args["Datensatz ID"] and '<tr><td><strong>Datensatz ID</strong></td><td>[[Datensatz ID::' .. args["Datensatz ID"] .. ']]</td></tr>' or "")
-- Zusammenfassung
if args["Inhaltszusammenfassung"] and args["Inhaltszusammenfassung"] ~= "" then
local rawSummary = mw.text.unstripNoWiki(args["Inhaltszusammenfassung"]):gsub("<.->", "")
local truncatedSummary = mw.ustring.sub(rawSummary, 1, 80) .. (mw.ustring.len(rawSummary) > 80 and "..." or "")
helper.setProperty({ args = { ["Inhaltszusammenfassung"] = rawSummary } }) -- Semantischer Wert
output = output .. '<tr><td><strong>Zusammenfassung</strong></td><td>' .. args["Inhaltszusammenfassung"] .. '</td></tr>'
end
-- Stichworte (Keywords)
if args["Keyword"] then
output = output .. '<tr><td><strong>Stichworte</strong></td><td>'
for keyword in mw.text.gsplit(args["Keyword"], ",") do
keyword = mw.text.trim(keyword)
helper.setProperty({ args = { ["Keyword"] = keyword } }) -- Semantischer Wert
output = output .. keyword .. ', '
end
output = output:sub(1, -3) .. '</td></tr>' -- Entfernt das letzte Komma
end
-- Ähnliche Artikel basierend auf Stichwörtern
if args["Keyword"] then
local similarArticles = related.similarArticles({ Keyword = args["Keyword"], limit = 5 })
if similarArticles ~= "Keine ähnlichen Artikel gefunden." then
output = output .. '<tr><td><strong>Ähnliche Artikel</strong></td><td>' .. similarArticles .. '</td></tr>'
end
end
output = output .. '</table>'
return output
end
return artikel