Modul:WikibaseL
Erscheinungsbild
Die Dokumentation für dieses Modul kann unter Modul:WikibaseL/Doku erstellt werden
local util = require('Module:Wikibase')
local p = {}
local function getLexicalCategoryLabel(entityId)
local ok, entity = pcall(mw.wikibase.getEntity, entityId)
if not ok or type(entity) ~= 'table' then return nil end
local lc = entity.lexicalCategory
if type(lc) == 'table' then lc = lc.id or lc.value end
if type(lc) ~= 'string' or lc == '' then return nil end
local ok2, label = pcall(mw.wikibase.getLabel, lc)
if ok2 and type(label) == 'string' and label ~= '' then return label end
return lc
end
local function getSenseGloss(entityId, senseParam)
-- identisch zur Logik aus dem Alt-Modul, hier nur als Platzhalter: wird beim Übernehmen 1:1 portiert
return nil
end
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 == 'sense' then
local sp = args.S or '1'
return getSenseGloss(entityId, sp)
end
-- "S1" / "1" als Direktangabe
if low:match('^s%d+$') or low:match('^%d+$') then
return getSenseGloss(entityId, low)
end
if low ~= 'ja' and low ~= 'auto' then
return util.trim(s) -- eigener Untertitel
end
end
-- Default: Wortart
return getLexicalCategoryLabel(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 lemma = args.label or util.getEntityLabelOrLemma(entityId) or entityId
local line1 = string.format('%s %s', entityId, lemma)
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 lemma = args.label or util.getEntityLabelOrLemma(entityId) or entityId
local line1text = string.format('%s %s', entityId, lemma)
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