Modul:WikibaseP
Erscheinungsbild
Die Dokumentation für dieses Modul kann unter Modul:WikibaseP/Doku erstellt werden
local util = require('Module:WikibaseUtil')
local p = {}
local function computeSubtitle(args, entityId)
local s = args.subtitle
if s and s ~= '' then
s = tostring(s)
local low = s:lower()
if low == 'nein' or low == '0' then return nil end
if low ~= 'ja' and low ~= 'auto' then
return util.trim(s) -- eigener Untertitel
end
end
return util.getDescription(entityId)
end
local function shouldSetShortdesc(args)
local set = args.set
if not set or set == '' then return true end
set = tostring(set):lower()
if set == 'nein' or set == '0' then return false end
return true
end
function p.link(frame)
local args = util.getArgs(frame)
local entityId = util.detectEntityId(args)
if not entityId then return '' end
local label = args.label or util.getEntityLabelOrLemma(entityId) or entityId
local line1 = string.format('%s %s', entityId, label)
return util.buildEntityLink(entityId, line1, args.target)
end
function p.render(frame)
local args = util.getArgs(frame)
local entityId = util.detectEntityId(args)
if not entityId then return '' end
local label = args.label or util.getEntityLabelOrLemma(entityId) or entityId
local line1text = string.format('%s %s', entityId, label)
local link = util.buildEntityLink(entityId, line1text, args.target)
local sub = computeSubtitle(args, entityId)
if sub and sub ~= '' then
if shouldSetShortdesc(args) then
util.setShortdesc(frame, sub)
end
return link .. '<br />' .. util.trim(sub)
end
return link
end
function p.shortdesc(frame)
local args = util.getArgs(frame)
local entityId = util.detectEntityId(args)
if not entityId then return '' end
local sub = computeSubtitle(args, entityId)
if not sub or sub == '' then return '' end
return util.setShortdesc(frame, sub)
end
return p