Zum Inhalt springen

Modul:WikibaseP

aus AufEinWort, der freien Forschung
Dies ist eine alte Version dieser Seite, zuletzt bearbeitet am 16. Dezember 2025 um 12:17 Uhr durch Nikolaos (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „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 se…“). Sie kann sich erheblich von der aktuellen Version unterscheiden.
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)

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