<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Maintenance+script</id>
	<title>Amateur Theatre Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Maintenance+script"/>
	<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php/Special:Contributions/Maintenance_script"/>
	<updated>2026-11-29T06:57:12Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.46.3</generator>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=3232</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=3232"/>
		<updated>2026-10-27T04:19:11Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- TemplateStyles stylesheet holding the infobox&#039;s look (pc-infobox classes).&lt;br /&gt;
local STYLESHEET = &#039;Template:DynamicInfobox/styles.css&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages whose infobox could not be rendered, e.g. because the&lt;br /&gt;
-- entity is not (yet) in UnlinkedWikibase&#039;s cache.&lt;br /&gt;
local ERROR_CATEGORY = &#039;Pages with Infobox Errors&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages showing a bare Q-ID instead of a label, because the&lt;br /&gt;
-- entity is not (yet) cached or has no English/&amp;quot;mul&amp;quot; label on Wikidata.&lt;br /&gt;
local MISSING_LABEL_CATEGORY = &#039;Pages with Missing Wikidata Labels&#039;&lt;br /&gt;
&lt;br /&gt;
-- Error message plus the error tracking category.&lt;br /&gt;
local function errorOutput(message)&lt;br /&gt;
    return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: &#039; .. message .. &#039;&amp;lt;/span&amp;gt;&#039; ..&lt;br /&gt;
        &#039;[[Category:&#039; .. ERROR_CATEGORY .. &#039;]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return errorOutput(&#039;No Wikidata QID provided&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return errorOutput(&#039;Entity &#039; .. qid .. &#039; not found&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local lang = mw.language.getContentLanguage()&lt;br /&gt;
&lt;br /&gt;
    -- Label of an entity: English, then the language-independent default&lt;br /&gt;
    -- label (&amp;quot;mul&amp;quot;), otherwise nil.&lt;br /&gt;
    local function getLabel(ent)&lt;br /&gt;
        if not ent or not ent.labels then return nil end&lt;br /&gt;
        for _, l in ipairs({ &#039;en&#039;, &#039;mul&#039; }) do&lt;br /&gt;
            local label = ent.labels[l]&lt;br /&gt;
            if label and label.value and label.value ~= &#039;&#039; then&lt;br /&gt;
                return label.value&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikipedia article of an entity, from its Wikidata sitelinks: English&lt;br /&gt;
    -- first, German as fallback. Returns the URL and a link label, or nil.&lt;br /&gt;
    -- Entities cached by the UpdateEntities maintenance script&lt;br /&gt;
    -- (wbgetentities) carry sitelink titles but no URLs, so the URL is built&lt;br /&gt;
    -- from the title.&lt;br /&gt;
    local wikipediaSites = {&lt;br /&gt;
        { site = &#039;enwiki&#039;, lang = &#039;en&#039;, label = &#039;Wikipedia&#039; },&lt;br /&gt;
        { site = &#039;dewiki&#039;, lang = &#039;de&#039;, label = &#039;Wikipedia (de)&#039; }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    local function getWikipediaUrl(ent)&lt;br /&gt;
        if not ent or not ent.sitelinks then return nil end&lt;br /&gt;
        for _, w in ipairs(wikipediaSites) do&lt;br /&gt;
            local link = ent.sitelinks[w.site]&lt;br /&gt;
            if link and link.title and link.title ~= &#039;&#039; then&lt;br /&gt;
                -- WIKI encoding also turns spaces into underscores&lt;br /&gt;
                return &#039;https://&#039; .. w.lang .. &#039;.wikipedia.org/wiki/&#039; ..&lt;br /&gt;
                    mw.uri.encode(link.title, &#039;WIKI&#039;), w.label&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Categories collected while the infobox is built and appended to the&lt;br /&gt;
    -- output at the end, e.g. &amp;quot;Pages with Image&amp;quot; or the country.&lt;br /&gt;
    local categories = {}&lt;br /&gt;
    local function addCategory(name)&lt;br /&gt;
        if not categories[name] then&lt;br /&gt;
            categories[name] = true&lt;br /&gt;
            table.insert(categories, name)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikidata country items mapped to the wiki&#039;s country categories. Add an&lt;br /&gt;
    -- entry here to categorise pages by another country.&lt;br /&gt;
    local countryCategories = {&lt;br /&gt;
        Q183 = &#039;Germany&#039;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Add the country categories for every non-deprecated value of pid&lt;br /&gt;
    -- (P17 country for organisations, P27 citizenship for people).&lt;br /&gt;
    local function addCountryCategories(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return end&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.id and&lt;br /&gt;
                countryCategories[v.id] then&lt;br /&gt;
                addCategory(countryCategories[v.id])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a &amp;quot;Member of &amp;lt;label&amp;gt;&amp;quot; category for every non-deprecated umbrella&lt;br /&gt;
    -- organisation (P463). Values whose entity or label is not cached yet are&lt;br /&gt;
    -- skipped; formatValue already flags those as missing labels.&lt;br /&gt;
    local function addMemberOfCategories()&lt;br /&gt;
        if not entity.claims or not entity.claims.P463 then return end&lt;br /&gt;
        for _, claim in ipairs(entity.claims.P463) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.id then&lt;br /&gt;
                local label = getLabel(mw.ext.UnlinkedWikibase.getEntity(v.id))&lt;br /&gt;
                -- Drop characters that are not allowed in page titles&lt;br /&gt;
                label = label and mw.text.trim((label:gsub(&#039;[%[%]{}|#&amp;lt;&amp;gt;]&#039;, &#039;&#039;)))&lt;br /&gt;
                if label and label ~= &#039;&#039; then&lt;br /&gt;
                    addCategory(&#039;Member of &#039; .. label)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Render the stylesheet and infobox followed by its base category and all&lt;br /&gt;
    -- collected categories.&lt;br /&gt;
    local function render(box, baseCategory)&lt;br /&gt;
        local out = {&lt;br /&gt;
            frame:extensionTag(&#039;templatestyles&#039;, &#039;&#039;, { src = STYLESHEET }) ..&lt;br /&gt;
            tostring(box),&lt;br /&gt;
            &#039;[[Category:&#039; .. baseCategory .. &#039;]]&#039;&lt;br /&gt;
        }&lt;br /&gt;
        for _, name in ipairs(categories) do&lt;br /&gt;
            table.insert(out, &#039;[[Category:&#039; .. name .. &#039;]]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        return table.concat(out, &#039;\n&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Format a Wikidata time value according to its precision, e.g.&lt;br /&gt;
    -- &amp;quot;15 January 2023&amp;quot;, &amp;quot;January 2023&amp;quot; or &amp;quot;2023&amp;quot;.&lt;br /&gt;
    local function formatTime(value)&lt;br /&gt;
        local sign, year, month, day =&lt;br /&gt;
            value.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
        if not year then return value.time end&lt;br /&gt;
        local y, m, d = tonumber(year), tonumber(month), tonumber(day)&lt;br /&gt;
        local precision = value.precision or 11&lt;br /&gt;
        if sign == &#039;-&#039; then return tostring(y) .. &#039; BC&#039; end&lt;br /&gt;
        local format, date&lt;br /&gt;
        if precision &amp;gt;= 11 and m &amp;gt; 0 and d &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;j F Y&#039;, string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
        elseif precision == 10 and m &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;F Y&#039;, string.format(&#039;%04d-%02d-01&#039;, y, m)&lt;br /&gt;
        else&lt;br /&gt;
            return tostring(y)&lt;br /&gt;
        end&lt;br /&gt;
        local ok, text = pcall(lang.formatDate, lang, format, date)&lt;br /&gt;
        if ok then return text end&lt;br /&gt;
        return date&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                return formatTime(value)&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                local label = getLabel(linkedEntity)&lt;br /&gt;
                if not label then addCategory(MISSING_LABEL_CATEGORY) end&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    -- Then prefer a Wikipedia article (external link)&lt;br /&gt;
                    local url = getWikipediaUrl(linkedEntity)&lt;br /&gt;
                    if url then&lt;br /&gt;
                        return &#039;[&#039; .. url .. &#039; &#039; .. (label or value.id) .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the plain label if available&lt;br /&gt;
                    if label then return label end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Formatted value of a property, or nil.&lt;br /&gt;
    local function getFormatted(pid)&lt;br /&gt;
        return formatValue(getPropertyValue(pid))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- All non-deprecated values of a property, formatted and separated by&lt;br /&gt;
    -- line breaks, or nil. Used for properties with several values, e.g.&lt;br /&gt;
    -- several umbrella associations (P463).&lt;br /&gt;
    local function getAllFormatted(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local values = {}&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and snak and snak.datavalue then&lt;br /&gt;
                local text = formatValue(snak.datavalue.value)&lt;br /&gt;
                if text then table.insert(values, text) end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if #values == 0 then return nil end&lt;br /&gt;
        return table.concat(values, &#039;&amp;lt;br&amp;gt;&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for _, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the main image (P18) with its media legend (P2096) as caption.&lt;br /&gt;
    -- Capiunto always renders images directly below the title.&lt;br /&gt;
    local function addMainImage(box)&lt;br /&gt;
        local claim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        local v = claim and claim.mainsnak and claim.mainsnak.datavalue and&lt;br /&gt;
            claim.mainsnak.datavalue.value&lt;br /&gt;
        if not v then return end&lt;br /&gt;
        addCategory(&#039;Pages with Image&#039;)&lt;br /&gt;
        local caption = getQualifierValue(claim, &#039;P2096&#039;)&lt;br /&gt;
        if caption == &#039;&#039; then caption = nil end&lt;br /&gt;
        box:addImage(&#039;[[File:&#039; .. tostring(v) .. &#039;|280px]]&#039;, caption)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Leaflet/OpenStreetMap map for this entity, as HTML, or nil.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function. A module&#039;s&lt;br /&gt;
    -- return value goes through the main parse pass but NOT the preprocessor, so&lt;br /&gt;
    -- parser-function syntax would otherwise be emitted literally. We expand it&lt;br /&gt;
    -- here with frame:preprocess().&lt;br /&gt;
    local function getMap()&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                    mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Map&#039;)&lt;br /&gt;
        return frame:preprocess(string.format(&lt;br /&gt;
            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Social media accounts, in display order. Each entry lists one or more&lt;br /&gt;
    -- Wikidata properties (first one with a value wins) and a function that&lt;br /&gt;
    -- turns the stored identifier into a profile URL.&lt;br /&gt;
    ---@type {label: string, pids: string[], url: fun(v: string, pid: string): string?}[]&lt;br /&gt;
    local socialMedia = {&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Facebook&#039;,&lt;br /&gt;
            pids = { &#039;P2013&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.facebook.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Instagram&#039;,&lt;br /&gt;
            pids = { &#039;P2003&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.instagram.com/&#039; .. v .. &#039;/&#039;&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;YouTube&#039;,&lt;br /&gt;
            pids = { &#039;P2397&#039;, &#039;P11245&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P11245&#039; then&lt;br /&gt;
                    return &#039;https://www.youtube.com/@&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.youtube.com/channel/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;TikTok&#039;,&lt;br /&gt;
            pids = { &#039;P7085&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.tiktok.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;X&#039;,&lt;br /&gt;
            pids = { &#039;P2002&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://x.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Threads&#039;,&lt;br /&gt;
            pids = { &#039;P11892&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.threads.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Bluesky&#039;,&lt;br /&gt;
            pids = { &#039;P12361&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://bsky.app/profile/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Mastodon&#039;,&lt;br /&gt;
            pids = { &#039;P4033&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                -- Stored as user@server.domain&lt;br /&gt;
                local user, server = v:match(&#039;^@?([^@]+)@(.+)$&#039;)&lt;br /&gt;
                if not user then return nil end&lt;br /&gt;
                return &#039;https://&#039; .. server .. &#039;/@&#039; .. user&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;LinkedIn&#039;,&lt;br /&gt;
            pids = { &#039;P4264&#039;, &#039;P6634&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P6634&#039; then&lt;br /&gt;
                    return &#039;https://www.linkedin.com/in/&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.linkedin.com/company/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Get the best string value for a property: preferred rank first, then&lt;br /&gt;
    -- the first normal-rank claim. Deprecated claims (e.g. abandoned&lt;br /&gt;
    -- accounts) are skipped.&lt;br /&gt;
    local function getBestStringValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local fallback&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if type(v) == &#039;string&#039; and v ~= &#039;&#039; then&lt;br /&gt;
                if claim.rank == &#039;preferred&#039; then return v end&lt;br /&gt;
                if claim.rank ~= &#039;deprecated&#039; and not fallback then&lt;br /&gt;
                    fallback = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return fallback&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Links to the entity&#039;s social media profiles, e.g.&lt;br /&gt;
    -- &amp;quot;Facebook · Instagram · YouTube&amp;quot;, or nil.&lt;br /&gt;
    local function getSocialMedia()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        for _, site in ipairs(socialMedia) do&lt;br /&gt;
            for _, pid in ipairs(site.pids) do&lt;br /&gt;
                local v = getBestStringValue(pid)&lt;br /&gt;
                local url = v and site.url(mw.text.trim(v), pid)&lt;br /&gt;
                if url then&lt;br /&gt;
                    -- Spaces would end the external link target early&lt;br /&gt;
                    url = url:gsub(&#039; &#039;, &#039;%%20&#039;)&lt;br /&gt;
                    table.insert(links, &#039;[&#039; .. url .. &#039; &#039; .. site.label .. &#039;]&#039;)&lt;br /&gt;
                    break&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if #links == 0 then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Social Media&#039;)&lt;br /&gt;
        return table.concat(links, &#039; · &#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Official website (P856) as a link showing just the host and path.&lt;br /&gt;
    local function getWebsite()&lt;br /&gt;
        local url = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
        if type(url) ~= &#039;string&#039; or url == &#039;&#039; then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Official Website&#039;)&lt;br /&gt;
        local display = url:gsub(&#039;^https?://&#039;, &#039;&#039;):gsub(&#039;^www%.&#039;, &#039;&#039;)&lt;br /&gt;
            :gsub(&#039;/$&#039;, &#039;&#039;)&lt;br /&gt;
        return &#039;[&#039; .. url .. &#039; &#039; .. display .. &#039;]&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Footer line with links to the entity&#039;s Wikipedia article (if any) and&lt;br /&gt;
    -- its Wikidata item.&lt;br /&gt;
    local function getFooter()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        local wikipediaUrl, wikipediaLabel = getWikipediaUrl(entity)&lt;br /&gt;
        if wikipediaUrl then&lt;br /&gt;
            addCategory(&#039;Pages with Wikipedia Article&#039;)&lt;br /&gt;
            table.insert(links,&lt;br /&gt;
                &#039;[&#039; .. wikipediaUrl .. &#039; &#039; .. wikipediaLabel .. &#039;]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        table.insert(links,&lt;br /&gt;
            &#039;[https://www.wikidata.org/wiki/&#039; .. qid .. &#039; View on Wikidata]&#039;)&lt;br /&gt;
        return &#039;&amp;lt;div class=&amp;quot;pc-infobox-footer&amp;quot;&amp;gt;&#039; ..&lt;br /&gt;
            table.concat(links, &#039; · &#039;) .. &#039;&amp;lt;/div&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a section: an optional header followed by its rows. Each row is&lt;br /&gt;
    -- either { label, data } or { wikitext = ... }; rows without data are&lt;br /&gt;
    -- dropped, and the header is only shown if at least one row remains.&lt;br /&gt;
    local function addSection(box, header, rows)&lt;br /&gt;
        local present = {}&lt;br /&gt;
        for _, row in ipairs(rows) do&lt;br /&gt;
            if row.wikitext or row[2] then table.insert(present, row) end&lt;br /&gt;
        end&lt;br /&gt;
        if #present == 0 then return end&lt;br /&gt;
        if header then box:addHeader(header) end&lt;br /&gt;
        for _, row in ipairs(present) do&lt;br /&gt;
            if row.wikitext then&lt;br /&gt;
                box:addWikitext(row.wikitext)&lt;br /&gt;
            else&lt;br /&gt;
                box:addRow(row[1], row[2])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Date and place combined into one cell, e.g. &amp;quot;1 May 1950&amp;lt;br&amp;gt;Munich&amp;quot;.&lt;br /&gt;
    local function datePlace(datePid, placePid)&lt;br /&gt;
        local date, place = getFormatted(datePid), getFormatted(placePid)&lt;br /&gt;
        if date and place then return date .. &#039;&amp;lt;br&amp;gt;&#039; .. place end&lt;br /&gt;
        return date or place&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the links section shared by both infobox types.&lt;br /&gt;
    local function addLinks(box)&lt;br /&gt;
        addSection(box, &#039;Links&#039;, {&lt;br /&gt;
            { &#039;Website&#039;,      getWebsite() },&lt;br /&gt;
            { &#039;Social media&#039;, getSocialMedia() }&lt;br /&gt;
        })&lt;br /&gt;
        box:addWikitext(getFooter())&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local title = getLabel(entity)&lt;br /&gt;
    if not title then&lt;br /&gt;
        title = qid&lt;br /&gt;
        addCategory(MISSING_LABEL_CATEGORY)&lt;br /&gt;
    end&lt;br /&gt;
    local infobox = capiunto.create({&lt;br /&gt;
        title = title,&lt;br /&gt;
        bodyClass = &#039;infobox vcard pc-infobox&#039;&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    if getClaimEntityId(&#039;P31&#039;) == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
        addSection(infobox, nil, {&lt;br /&gt;
            { &#039;Born&#039;,       datePlace(&#039;P569&#039;, &#039;P19&#039;) },&lt;br /&gt;
            { &#039;Died&#039;,       datePlace(&#039;P570&#039;, &#039;P20&#039;) },&lt;br /&gt;
            { &#039;Occupation&#039;, getFormatted(&#039;P106&#039;) }&lt;br /&gt;
        })&lt;br /&gt;
        addCountryCategories(&#039;P27&#039;)&lt;br /&gt;
&lt;br /&gt;
        local map = getMap()&lt;br /&gt;
        if map then infobox:addWikitext(map) end&lt;br /&gt;
&lt;br /&gt;
        addLinks(infobox)&lt;br /&gt;
        return render(infobox, &#039;People&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Default: organisation/troupe infobox&lt;br /&gt;
&lt;br /&gt;
    -- Official name (P1448) as a subtitle, unless it just repeats the title&lt;br /&gt;
    local officialName = getFormatted(&#039;P1448&#039;)&lt;br /&gt;
    if officialName and officialName ~= title then&lt;br /&gt;
        infobox:addSubHeader(officialName, &#039;pc-infobox-subtitle&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Logo (P154), then the main image&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if type(logo) == &#039;string&#039; and logo ~= &#039;&#039; then&lt;br /&gt;
        addCategory(&#039;Pages with Logo&#039;)&lt;br /&gt;
        -- Row class gives transparent logos a light backing in dark mode&lt;br /&gt;
        infobox:addImage(&#039;[[File:&#039; .. logo .. &#039;|150px]]&#039;, nil,&lt;br /&gt;
            &#039;pc-infobox-logo&#039;)&lt;br /&gt;
    end&lt;br /&gt;
    addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
    -- Member count (P2124): the most recent value by its point in time&lt;br /&gt;
    -- (P585) qualifier, shown as e.g. &amp;quot;120 (as of 1 May 2023)&amp;quot;. Undated&lt;br /&gt;
    -- values are only used when no dated one exists, preferring preferred&lt;br /&gt;
    -- rank.&lt;br /&gt;
    local function getMemberCount()&lt;br /&gt;
        if not entity.claims or not entity.claims.P2124 then return nil end&lt;br /&gt;
        local best, bestKey, bestTime, undated&lt;br /&gt;
        for _, claim in ipairs(entity.claims.P2124) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.amount then&lt;br /&gt;
                local q = claim.qualifiers and claim.qualifiers.P585 and&lt;br /&gt;
                    claim.qualifiers.P585[1]&lt;br /&gt;
                local t = q and q.datavalue and q.datavalue.value&lt;br /&gt;
                local sign, y, m, d&lt;br /&gt;
                if type(t) == &#039;table&#039; and t.time then&lt;br /&gt;
                    sign, y, m, d = t.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                end&lt;br /&gt;
                if y then&lt;br /&gt;
                    local key = (tonumber(y) * 10000 + tonumber(m) * 100 +&lt;br /&gt;
                        tonumber(d)) * (sign == &#039;-&#039; and -1 or 1)&lt;br /&gt;
                    if not bestKey or key &amp;gt; bestKey then&lt;br /&gt;
                        best, bestKey, bestTime = v, key, t&lt;br /&gt;
                    end&lt;br /&gt;
                elseif not undated or claim.rank == &#039;preferred&#039; then&lt;br /&gt;
                    undated = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        local value = best or undated&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
        local amount = tonumber((value.amount:gsub(&#039;^%+&#039;, &#039;&#039;)))&lt;br /&gt;
        if not amount then return nil end&lt;br /&gt;
        local text = lang:formatNum(amount)&lt;br /&gt;
        if bestTime and best == value then&lt;br /&gt;
            text = text .. &#039; &amp;lt;span class=&amp;quot;pc-infobox-note&amp;quot;&amp;gt;(as of &#039; ..&lt;br /&gt;
                formatTime(bestTime) .. &#039;)&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
        end&lt;br /&gt;
        return text&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Registered address: the street address (P6375) qualifier of the&lt;br /&gt;
    -- headquarters (P159) statement, otherwise a P6375 statement on the&lt;br /&gt;
    -- entity itself. Addresses are monolingual text in any language.&lt;br /&gt;
    local function getAddress()&lt;br /&gt;
        local claim = getFirstClaimObject(&#039;P159&#039;)&lt;br /&gt;
        local qsnaks = claim and claim.qualifiers and claim.qualifiers.P6375&lt;br /&gt;
        for _, q in ipairs(qsnaks or {}) do&lt;br /&gt;
            local v = q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value&lt;br /&gt;
            if type(v) == &#039;table&#039; and v.text and v.text ~= &#039;&#039; then&lt;br /&gt;
                return v.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        local v = getPropertyValue(&#039;P6375&#039;)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.text and v.text ~= &#039;&#039; then return v.text end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local dissolved = getFormatted(&#039;P576&#039;)&lt;br /&gt;
    if dissolved then addCategory(&#039;Dissolved&#039;) end&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, nil, {&lt;br /&gt;
        { &#039;Founded&#039;,             getFormatted(&#039;P571&#039;) },&lt;br /&gt;
        { &#039;Dissolved&#039;,           dissolved },&lt;br /&gt;
        { &#039;Members&#039;,             getMemberCount() },&lt;br /&gt;
        { &#039;Legal form&#039;,          getFormatted(&#039;P1454&#039;) },&lt;br /&gt;
        { &#039;Parent organization&#039;, getFormatted(&#039;P749&#039;) },&lt;br /&gt;
        { &#039;Member of&#039;,           getAllFormatted(&#039;P463&#039;) }&lt;br /&gt;
    })&lt;br /&gt;
    addMemberOfCategories()&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, &#039;Location&#039;, {&lt;br /&gt;
        { &#039;Headquarters&#039;,     getFormatted(&#039;P159&#039;) },&lt;br /&gt;
        { &#039;Address&#039;,          getAddress() },&lt;br /&gt;
        { &#039;Country&#039;,          getFormatted(&#039;P17&#039;) },&lt;br /&gt;
        { wikitext = getMap() }&lt;br /&gt;
    })&lt;br /&gt;
    addCountryCategories(&#039;P17&#039;)&lt;br /&gt;
&lt;br /&gt;
    addLinks(infobox)&lt;br /&gt;
    return render(infobox, &#039;Clubs, Societies and Institutions&#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Template:DynamicInfobox&amp;diff=3088</id>
		<title>Template:DynamicInfobox</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Template:DynamicInfobox&amp;diff=3088"/>
		<updated>2026-10-22T20:28:02Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;onlyinclude&amp;gt;{{#invoke:DynamicCapiunto|main|qid={{{qid}}}}}{{#if:{{{qid|{{{1|}}}}}}|[[Category:Pages Linked to Wikidata]]}}&amp;lt;/onlyinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
Pages using this template with a QID are added to the maintenance category [[:Category:Pages Linked to Wikidata]].&lt;br /&gt;
&lt;br /&gt;
The infobox is styled by [[Template:DynamicInfobox/styles.css]].&lt;br /&gt;
&lt;br /&gt;
The infobox also adds categories based on the Wikidata values it shows:&lt;br /&gt;
* [[:Category:People]] (instance of human) or [[:Category:Clubs, Societies and Institutions]] (everything else)&lt;br /&gt;
* [[:Category:Pages with Wikipedia Article]], [[:Category:Pages with Image]], [[:Category:Pages with Logo]], [[:Category:Pages with Map]], [[:Category:Pages with Official Website]], [[:Category:Pages with Social Media]]&lt;br /&gt;
* [[:Category:Dissolved]] for organisations with a dissolution date (P576)&lt;br /&gt;
* A country category, e.g. [[:Category:Germany]], from country (P17) for organisations or country of citizenship (P27) for people. Only countries listed in &amp;lt;code&amp;gt;countryCategories&amp;lt;/code&amp;gt; in [[Module:DynamicCapiunto]] are used.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Below is an example usage of this template with a sample Wikidata QID.&lt;br /&gt;
&lt;br /&gt;
{{DynamicInfobox|qid=Q120730912}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;templatedata&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;params&amp;quot;: {&lt;br /&gt;
    &amp;quot;qid&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Wikidata QID&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Mandatory Wikidata QID to fetch all parameters dynamically from Wikidata.&amp;quot;,&lt;br /&gt;
      &amp;quot;required&amp;quot;: true&lt;br /&gt;
    },&amp;quot;official_name&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Official Name (P1448)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Official name&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;logo&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Logo (P154)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Logo image.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;image&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Image (P18)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Image.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;headquarters&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Headquarters (P159)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Headquarters.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;founding_date&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Founding Date (P571)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Founding date.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;dissolution_date&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Dissolution Date (P576)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Dissolution date.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;official_website&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Official Website (P856)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Official website.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;country&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Country (P17)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Country.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;legal_form&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Legal Form (P1454)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Legal form, e.g. registered association (e. V.).&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;address&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Address (P6375)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Registered address: the street address (P6375) qualifier on the headquarters (P159) statement, otherwise a P6375 statement on the item.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;member_of&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Member Of (P463)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;All non-deprecated memberships, e.g. umbrella associations, one per line.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent_organization&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Parent Organization (P749)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Parent organization.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;member_count&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Member Count (P2124)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Most recent member count, by its point in time (P585) qualifier, with that date shown in brackets.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;social_media&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Social media (P2013, P2003, P2397/P11245, P7085, P2002, P11892, P12361, P4033, P4264/P6634)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Links to Facebook, Instagram, YouTube, TikTok, X, Threads, Bluesky, Mastodon and LinkedIn profiles. Fetched from Wikidata; deprecated-rank accounts are skipped.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;place_of_death&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Place of Death (P20)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Place of death, shown together with the date of death for people.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;coordinates&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Coordinate Location (P625)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Coordinate location. Fetched from Wikidata and rendered as an OpenStreetMap (Leaflet) map via the Maps extension.&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Infobox for an organization. Fetches all parameters dynamically from Wikidata based on the mandatory QID.&amp;quot;,&lt;br /&gt;
  &amp;quot;format&amp;quot;: &amp;quot;inline&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/templatedata&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=3087</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=3087"/>
		<updated>2026-10-22T20:28:00Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- TemplateStyles stylesheet holding the infobox&#039;s look (pc-infobox classes).&lt;br /&gt;
local STYLESHEET = &#039;Template:DynamicInfobox/styles.css&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages whose infobox could not be rendered, e.g. because the&lt;br /&gt;
-- entity is not (yet) in UnlinkedWikibase&#039;s cache.&lt;br /&gt;
local ERROR_CATEGORY = &#039;Pages with Infobox Errors&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages showing a bare Q-ID instead of a label, because the&lt;br /&gt;
-- entity is not (yet) cached or has no English/&amp;quot;mul&amp;quot; label on Wikidata.&lt;br /&gt;
local MISSING_LABEL_CATEGORY = &#039;Pages with Missing Wikidata Labels&#039;&lt;br /&gt;
&lt;br /&gt;
-- Error message plus the error tracking category.&lt;br /&gt;
local function errorOutput(message)&lt;br /&gt;
    return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: &#039; .. message .. &#039;&amp;lt;/span&amp;gt;&#039; ..&lt;br /&gt;
        &#039;[[Category:&#039; .. ERROR_CATEGORY .. &#039;]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return errorOutput(&#039;No Wikidata QID provided&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return errorOutput(&#039;Entity &#039; .. qid .. &#039; not found&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local lang = mw.language.getContentLanguage()&lt;br /&gt;
&lt;br /&gt;
    -- Label of an entity: English, then the language-independent default&lt;br /&gt;
    -- label (&amp;quot;mul&amp;quot;), otherwise nil.&lt;br /&gt;
    local function getLabel(ent)&lt;br /&gt;
        if not ent or not ent.labels then return nil end&lt;br /&gt;
        for _, l in ipairs({ &#039;en&#039;, &#039;mul&#039; }) do&lt;br /&gt;
            local label = ent.labels[l]&lt;br /&gt;
            if label and label.value and label.value ~= &#039;&#039; then&lt;br /&gt;
                return label.value&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikipedia article of an entity, from its Wikidata sitelinks: English&lt;br /&gt;
    -- first, German as fallback. Returns the URL and a link label, or nil.&lt;br /&gt;
    -- Entities cached by the UpdateEntities maintenance script&lt;br /&gt;
    -- (wbgetentities) carry sitelink titles but no URLs, so the URL is built&lt;br /&gt;
    -- from the title.&lt;br /&gt;
    local wikipediaSites = {&lt;br /&gt;
        { site = &#039;enwiki&#039;, lang = &#039;en&#039;, label = &#039;Wikipedia&#039; },&lt;br /&gt;
        { site = &#039;dewiki&#039;, lang = &#039;de&#039;, label = &#039;Wikipedia (de)&#039; }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    local function getWikipediaUrl(ent)&lt;br /&gt;
        if not ent or not ent.sitelinks then return nil end&lt;br /&gt;
        for _, w in ipairs(wikipediaSites) do&lt;br /&gt;
            local link = ent.sitelinks[w.site]&lt;br /&gt;
            if link and link.title and link.title ~= &#039;&#039; then&lt;br /&gt;
                -- WIKI encoding also turns spaces into underscores&lt;br /&gt;
                return &#039;https://&#039; .. w.lang .. &#039;.wikipedia.org/wiki/&#039; ..&lt;br /&gt;
                    mw.uri.encode(link.title, &#039;WIKI&#039;), w.label&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Categories collected while the infobox is built and appended to the&lt;br /&gt;
    -- output at the end, e.g. &amp;quot;Pages with Image&amp;quot; or the country.&lt;br /&gt;
    local categories = {}&lt;br /&gt;
    local function addCategory(name)&lt;br /&gt;
        if not categories[name] then&lt;br /&gt;
            categories[name] = true&lt;br /&gt;
            table.insert(categories, name)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikidata country items mapped to the wiki&#039;s country categories. Add an&lt;br /&gt;
    -- entry here to categorise pages by another country.&lt;br /&gt;
    local countryCategories = {&lt;br /&gt;
        Q183 = &#039;Germany&#039;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Add the country categories for every non-deprecated value of pid&lt;br /&gt;
    -- (P17 country for organisations, P27 citizenship for people).&lt;br /&gt;
    local function addCountryCategories(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return end&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.id and&lt;br /&gt;
                countryCategories[v.id] then&lt;br /&gt;
                addCategory(countryCategories[v.id])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Render the stylesheet and infobox followed by its base category and all&lt;br /&gt;
    -- collected categories.&lt;br /&gt;
    local function render(box, baseCategory)&lt;br /&gt;
        local out = {&lt;br /&gt;
            frame:extensionTag(&#039;templatestyles&#039;, &#039;&#039;, { src = STYLESHEET }) ..&lt;br /&gt;
            tostring(box),&lt;br /&gt;
            &#039;[[Category:&#039; .. baseCategory .. &#039;]]&#039;&lt;br /&gt;
        }&lt;br /&gt;
        for _, name in ipairs(categories) do&lt;br /&gt;
            table.insert(out, &#039;[[Category:&#039; .. name .. &#039;]]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        return table.concat(out, &#039;\n&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Format a Wikidata time value according to its precision, e.g.&lt;br /&gt;
    -- &amp;quot;15 January 2023&amp;quot;, &amp;quot;January 2023&amp;quot; or &amp;quot;2023&amp;quot;.&lt;br /&gt;
    local function formatTime(value)&lt;br /&gt;
        local sign, year, month, day =&lt;br /&gt;
            value.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
        if not year then return value.time end&lt;br /&gt;
        local y, m, d = tonumber(year), tonumber(month), tonumber(day)&lt;br /&gt;
        local precision = value.precision or 11&lt;br /&gt;
        if sign == &#039;-&#039; then return tostring(y) .. &#039; BC&#039; end&lt;br /&gt;
        local format, date&lt;br /&gt;
        if precision &amp;gt;= 11 and m &amp;gt; 0 and d &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;j F Y&#039;, string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
        elseif precision == 10 and m &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;F Y&#039;, string.format(&#039;%04d-%02d-01&#039;, y, m)&lt;br /&gt;
        else&lt;br /&gt;
            return tostring(y)&lt;br /&gt;
        end&lt;br /&gt;
        local ok, text = pcall(lang.formatDate, lang, format, date)&lt;br /&gt;
        if ok then return text end&lt;br /&gt;
        return date&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                return formatTime(value)&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                local label = getLabel(linkedEntity)&lt;br /&gt;
                if not label then addCategory(MISSING_LABEL_CATEGORY) end&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    -- Then prefer a Wikipedia article (external link)&lt;br /&gt;
                    local url = getWikipediaUrl(linkedEntity)&lt;br /&gt;
                    if url then&lt;br /&gt;
                        return &#039;[&#039; .. url .. &#039; &#039; .. (label or value.id) .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the plain label if available&lt;br /&gt;
                    if label then return label end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Formatted value of a property, or nil.&lt;br /&gt;
    local function getFormatted(pid)&lt;br /&gt;
        return formatValue(getPropertyValue(pid))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- All non-deprecated values of a property, formatted and separated by&lt;br /&gt;
    -- line breaks, or nil. Used for properties with several values, e.g.&lt;br /&gt;
    -- several umbrella associations (P463).&lt;br /&gt;
    local function getAllFormatted(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local values = {}&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and snak and snak.datavalue then&lt;br /&gt;
                local text = formatValue(snak.datavalue.value)&lt;br /&gt;
                if text then table.insert(values, text) end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if #values == 0 then return nil end&lt;br /&gt;
        return table.concat(values, &#039;&amp;lt;br&amp;gt;&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for _, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the main image (P18) with its media legend (P2096) as caption.&lt;br /&gt;
    -- Capiunto always renders images directly below the title.&lt;br /&gt;
    local function addMainImage(box)&lt;br /&gt;
        local claim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        local v = claim and claim.mainsnak and claim.mainsnak.datavalue and&lt;br /&gt;
            claim.mainsnak.datavalue.value&lt;br /&gt;
        if not v then return end&lt;br /&gt;
        addCategory(&#039;Pages with Image&#039;)&lt;br /&gt;
        local caption = getQualifierValue(claim, &#039;P2096&#039;)&lt;br /&gt;
        if caption == &#039;&#039; then caption = nil end&lt;br /&gt;
        box:addImage(&#039;[[File:&#039; .. tostring(v) .. &#039;|280px]]&#039;, caption)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Leaflet/OpenStreetMap map for this entity, as HTML, or nil.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function. A module&#039;s&lt;br /&gt;
    -- return value goes through the main parse pass but NOT the preprocessor, so&lt;br /&gt;
    -- parser-function syntax would otherwise be emitted literally. We expand it&lt;br /&gt;
    -- here with frame:preprocess().&lt;br /&gt;
    local function getMap()&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                    mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Map&#039;)&lt;br /&gt;
        return frame:preprocess(string.format(&lt;br /&gt;
            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Social media accounts, in display order. Each entry lists one or more&lt;br /&gt;
    -- Wikidata properties (first one with a value wins) and a function that&lt;br /&gt;
    -- turns the stored identifier into a profile URL.&lt;br /&gt;
    ---@type {label: string, pids: string[], url: fun(v: string, pid: string): string?}[]&lt;br /&gt;
    local socialMedia = {&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Facebook&#039;,&lt;br /&gt;
            pids = { &#039;P2013&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.facebook.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Instagram&#039;,&lt;br /&gt;
            pids = { &#039;P2003&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.instagram.com/&#039; .. v .. &#039;/&#039;&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;YouTube&#039;,&lt;br /&gt;
            pids = { &#039;P2397&#039;, &#039;P11245&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P11245&#039; then&lt;br /&gt;
                    return &#039;https://www.youtube.com/@&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.youtube.com/channel/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;TikTok&#039;,&lt;br /&gt;
            pids = { &#039;P7085&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.tiktok.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;X&#039;,&lt;br /&gt;
            pids = { &#039;P2002&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://x.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Threads&#039;,&lt;br /&gt;
            pids = { &#039;P11892&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.threads.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Bluesky&#039;,&lt;br /&gt;
            pids = { &#039;P12361&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://bsky.app/profile/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Mastodon&#039;,&lt;br /&gt;
            pids = { &#039;P4033&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                -- Stored as user@server.domain&lt;br /&gt;
                local user, server = v:match(&#039;^@?([^@]+)@(.+)$&#039;)&lt;br /&gt;
                if not user then return nil end&lt;br /&gt;
                return &#039;https://&#039; .. server .. &#039;/@&#039; .. user&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;LinkedIn&#039;,&lt;br /&gt;
            pids = { &#039;P4264&#039;, &#039;P6634&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P6634&#039; then&lt;br /&gt;
                    return &#039;https://www.linkedin.com/in/&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.linkedin.com/company/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Get the best string value for a property: preferred rank first, then&lt;br /&gt;
    -- the first normal-rank claim. Deprecated claims (e.g. abandoned&lt;br /&gt;
    -- accounts) are skipped.&lt;br /&gt;
    local function getBestStringValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local fallback&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if type(v) == &#039;string&#039; and v ~= &#039;&#039; then&lt;br /&gt;
                if claim.rank == &#039;preferred&#039; then return v end&lt;br /&gt;
                if claim.rank ~= &#039;deprecated&#039; and not fallback then&lt;br /&gt;
                    fallback = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return fallback&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Links to the entity&#039;s social media profiles, e.g.&lt;br /&gt;
    -- &amp;quot;Facebook · Instagram · YouTube&amp;quot;, or nil.&lt;br /&gt;
    local function getSocialMedia()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        for _, site in ipairs(socialMedia) do&lt;br /&gt;
            for _, pid in ipairs(site.pids) do&lt;br /&gt;
                local v = getBestStringValue(pid)&lt;br /&gt;
                local url = v and site.url(mw.text.trim(v), pid)&lt;br /&gt;
                if url then&lt;br /&gt;
                    -- Spaces would end the external link target early&lt;br /&gt;
                    url = url:gsub(&#039; &#039;, &#039;%%20&#039;)&lt;br /&gt;
                    table.insert(links, &#039;[&#039; .. url .. &#039; &#039; .. site.label .. &#039;]&#039;)&lt;br /&gt;
                    break&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if #links == 0 then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Social Media&#039;)&lt;br /&gt;
        return table.concat(links, &#039; · &#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Official website (P856) as a link showing just the host and path.&lt;br /&gt;
    local function getWebsite()&lt;br /&gt;
        local url = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
        if type(url) ~= &#039;string&#039; or url == &#039;&#039; then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Official Website&#039;)&lt;br /&gt;
        local display = url:gsub(&#039;^https?://&#039;, &#039;&#039;):gsub(&#039;^www%.&#039;, &#039;&#039;)&lt;br /&gt;
            :gsub(&#039;/$&#039;, &#039;&#039;)&lt;br /&gt;
        return &#039;[&#039; .. url .. &#039; &#039; .. display .. &#039;]&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Footer line with links to the entity&#039;s Wikipedia article (if any) and&lt;br /&gt;
    -- its Wikidata item.&lt;br /&gt;
    local function getFooter()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        local wikipediaUrl, wikipediaLabel = getWikipediaUrl(entity)&lt;br /&gt;
        if wikipediaUrl then&lt;br /&gt;
            addCategory(&#039;Pages with Wikipedia Article&#039;)&lt;br /&gt;
            table.insert(links,&lt;br /&gt;
                &#039;[&#039; .. wikipediaUrl .. &#039; &#039; .. wikipediaLabel .. &#039;]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        table.insert(links,&lt;br /&gt;
            &#039;[https://www.wikidata.org/wiki/&#039; .. qid .. &#039; View on Wikidata]&#039;)&lt;br /&gt;
        return &#039;&amp;lt;div class=&amp;quot;pc-infobox-footer&amp;quot;&amp;gt;&#039; ..&lt;br /&gt;
            table.concat(links, &#039; · &#039;) .. &#039;&amp;lt;/div&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a section: an optional header followed by its rows. Each row is&lt;br /&gt;
    -- either { label, data } or { wikitext = ... }; rows without data are&lt;br /&gt;
    -- dropped, and the header is only shown if at least one row remains.&lt;br /&gt;
    local function addSection(box, header, rows)&lt;br /&gt;
        local present = {}&lt;br /&gt;
        for _, row in ipairs(rows) do&lt;br /&gt;
            if row.wikitext or row[2] then table.insert(present, row) end&lt;br /&gt;
        end&lt;br /&gt;
        if #present == 0 then return end&lt;br /&gt;
        if header then box:addHeader(header) end&lt;br /&gt;
        for _, row in ipairs(present) do&lt;br /&gt;
            if row.wikitext then&lt;br /&gt;
                box:addWikitext(row.wikitext)&lt;br /&gt;
            else&lt;br /&gt;
                box:addRow(row[1], row[2])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Date and place combined into one cell, e.g. &amp;quot;1 May 1950&amp;lt;br&amp;gt;Munich&amp;quot;.&lt;br /&gt;
    local function datePlace(datePid, placePid)&lt;br /&gt;
        local date, place = getFormatted(datePid), getFormatted(placePid)&lt;br /&gt;
        if date and place then return date .. &#039;&amp;lt;br&amp;gt;&#039; .. place end&lt;br /&gt;
        return date or place&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the links section shared by both infobox types.&lt;br /&gt;
    local function addLinks(box)&lt;br /&gt;
        addSection(box, &#039;Links&#039;, {&lt;br /&gt;
            { &#039;Website&#039;,      getWebsite() },&lt;br /&gt;
            { &#039;Social media&#039;, getSocialMedia() }&lt;br /&gt;
        })&lt;br /&gt;
        box:addWikitext(getFooter())&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local title = getLabel(entity)&lt;br /&gt;
    if not title then&lt;br /&gt;
        title = qid&lt;br /&gt;
        addCategory(MISSING_LABEL_CATEGORY)&lt;br /&gt;
    end&lt;br /&gt;
    local infobox = capiunto.create({&lt;br /&gt;
        title = title,&lt;br /&gt;
        bodyClass = &#039;infobox vcard pc-infobox&#039;&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    if getClaimEntityId(&#039;P31&#039;) == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
        addSection(infobox, nil, {&lt;br /&gt;
            { &#039;Born&#039;,       datePlace(&#039;P569&#039;, &#039;P19&#039;) },&lt;br /&gt;
            { &#039;Died&#039;,       datePlace(&#039;P570&#039;, &#039;P20&#039;) },&lt;br /&gt;
            { &#039;Occupation&#039;, getFormatted(&#039;P106&#039;) }&lt;br /&gt;
        })&lt;br /&gt;
        addCountryCategories(&#039;P27&#039;)&lt;br /&gt;
&lt;br /&gt;
        local map = getMap()&lt;br /&gt;
        if map then infobox:addWikitext(map) end&lt;br /&gt;
&lt;br /&gt;
        addLinks(infobox)&lt;br /&gt;
        return render(infobox, &#039;People&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Default: organisation/troupe infobox&lt;br /&gt;
&lt;br /&gt;
    -- Official name (P1448) as a subtitle, unless it just repeats the title&lt;br /&gt;
    local officialName = getFormatted(&#039;P1448&#039;)&lt;br /&gt;
    if officialName and officialName ~= title then&lt;br /&gt;
        infobox:addSubHeader(officialName, &#039;pc-infobox-subtitle&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Logo (P154), then the main image&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if type(logo) == &#039;string&#039; and logo ~= &#039;&#039; then&lt;br /&gt;
        addCategory(&#039;Pages with Logo&#039;)&lt;br /&gt;
        -- Row class gives transparent logos a light backing in dark mode&lt;br /&gt;
        infobox:addImage(&#039;[[File:&#039; .. logo .. &#039;|150px]]&#039;, nil,&lt;br /&gt;
            &#039;pc-infobox-logo&#039;)&lt;br /&gt;
    end&lt;br /&gt;
    addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
    -- Member count (P2124): the most recent value by its point in time&lt;br /&gt;
    -- (P585) qualifier, shown as e.g. &amp;quot;120 (as of 1 May 2023)&amp;quot;. Undated&lt;br /&gt;
    -- values are only used when no dated one exists, preferring preferred&lt;br /&gt;
    -- rank.&lt;br /&gt;
    local function getMemberCount()&lt;br /&gt;
        if not entity.claims or not entity.claims.P2124 then return nil end&lt;br /&gt;
        local best, bestKey, bestTime, undated&lt;br /&gt;
        for _, claim in ipairs(entity.claims.P2124) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.amount then&lt;br /&gt;
                local q = claim.qualifiers and claim.qualifiers.P585 and&lt;br /&gt;
                    claim.qualifiers.P585[1]&lt;br /&gt;
                local t = q and q.datavalue and q.datavalue.value&lt;br /&gt;
                local sign, y, m, d&lt;br /&gt;
                if type(t) == &#039;table&#039; and t.time then&lt;br /&gt;
                    sign, y, m, d = t.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                end&lt;br /&gt;
                if y then&lt;br /&gt;
                    local key = (tonumber(y) * 10000 + tonumber(m) * 100 +&lt;br /&gt;
                        tonumber(d)) * (sign == &#039;-&#039; and -1 or 1)&lt;br /&gt;
                    if not bestKey or key &amp;gt; bestKey then&lt;br /&gt;
                        best, bestKey, bestTime = v, key, t&lt;br /&gt;
                    end&lt;br /&gt;
                elseif not undated or claim.rank == &#039;preferred&#039; then&lt;br /&gt;
                    undated = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        local value = best or undated&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
        local amount = tonumber((value.amount:gsub(&#039;^%+&#039;, &#039;&#039;)))&lt;br /&gt;
        if not amount then return nil end&lt;br /&gt;
        local text = lang:formatNum(amount)&lt;br /&gt;
        if bestTime and best == value then&lt;br /&gt;
            text = text .. &#039; &amp;lt;span class=&amp;quot;pc-infobox-note&amp;quot;&amp;gt;(as of &#039; ..&lt;br /&gt;
                formatTime(bestTime) .. &#039;)&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
        end&lt;br /&gt;
        return text&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Registered address: the street address (P6375) qualifier of the&lt;br /&gt;
    -- headquarters (P159) statement, otherwise a P6375 statement on the&lt;br /&gt;
    -- entity itself. Addresses are monolingual text in any language.&lt;br /&gt;
    local function getAddress()&lt;br /&gt;
        local claim = getFirstClaimObject(&#039;P159&#039;)&lt;br /&gt;
        local qsnaks = claim and claim.qualifiers and claim.qualifiers.P6375&lt;br /&gt;
        for _, q in ipairs(qsnaks or {}) do&lt;br /&gt;
            local v = q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value&lt;br /&gt;
            if type(v) == &#039;table&#039; and v.text and v.text ~= &#039;&#039; then&lt;br /&gt;
                return v.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        local v = getPropertyValue(&#039;P6375&#039;)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.text and v.text ~= &#039;&#039; then return v.text end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local dissolved = getFormatted(&#039;P576&#039;)&lt;br /&gt;
    if dissolved then addCategory(&#039;Dissolved&#039;) end&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, nil, {&lt;br /&gt;
        { &#039;Founded&#039;,             getFormatted(&#039;P571&#039;) },&lt;br /&gt;
        { &#039;Dissolved&#039;,           dissolved },&lt;br /&gt;
        { &#039;Members&#039;,             getMemberCount() },&lt;br /&gt;
        { &#039;Legal form&#039;,          getFormatted(&#039;P1454&#039;) },&lt;br /&gt;
        { &#039;Parent organization&#039;, getFormatted(&#039;P749&#039;) },&lt;br /&gt;
        { &#039;Member of&#039;,           getAllFormatted(&#039;P463&#039;) }&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, &#039;Location&#039;, {&lt;br /&gt;
        { &#039;Headquarters&#039;,     getFormatted(&#039;P159&#039;) },&lt;br /&gt;
        { &#039;Address&#039;,          getAddress() },&lt;br /&gt;
        { &#039;Country&#039;,          getFormatted(&#039;P17&#039;) },&lt;br /&gt;
        { wikitext = getMap() }&lt;br /&gt;
    })&lt;br /&gt;
    addCountryCategories(&#039;P17&#039;)&lt;br /&gt;
&lt;br /&gt;
    addLinks(infobox)&lt;br /&gt;
    return render(infobox, &#039;Clubs, Societies and Institutions&#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Template:DynamicInfobox&amp;diff=2093</id>
		<title>Template:DynamicInfobox</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Template:DynamicInfobox&amp;diff=2093"/>
		<updated>2026-10-22T10:04:53Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;onlyinclude&amp;gt;{{#invoke:DynamicCapiunto|main|qid={{{qid}}}}}{{#if:{{{qid|{{{1|}}}}}}|[[Category:Pages Linked to Wikidata]]}}&amp;lt;/onlyinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
Pages using this template with a QID are added to the maintenance category [[:Category:Pages Linked to Wikidata]].&lt;br /&gt;
&lt;br /&gt;
The infobox is styled by [[Template:DynamicInfobox/styles.css]].&lt;br /&gt;
&lt;br /&gt;
The infobox also adds categories based on the Wikidata values it shows:&lt;br /&gt;
* [[:Category:People]] (instance of human) or [[:Category:Clubs, Societies and Institutions]] (everything else)&lt;br /&gt;
* [[:Category:Pages with Wikipedia Article]], [[:Category:Pages with Image]], [[:Category:Pages with Logo]], [[:Category:Pages with Map]], [[:Category:Pages with Official Website]], [[:Category:Pages with Social Media]]&lt;br /&gt;
* [[:Category:Dissolved]] for organisations with a dissolution date (P576)&lt;br /&gt;
* A country category, e.g. [[:Category:Germany]], from country (P17) for organisations or country of citizenship (P27) for people. Only countries listed in &amp;lt;code&amp;gt;countryCategories&amp;lt;/code&amp;gt; in [[Module:DynamicCapiunto]] are used.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Below is an example usage of this template with a sample Wikidata QID.&lt;br /&gt;
&lt;br /&gt;
{{DynamicInfobox|qid=Q120730912}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;templatedata&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;params&amp;quot;: {&lt;br /&gt;
    &amp;quot;qid&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Wikidata QID&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Mandatory Wikidata QID to fetch all parameters dynamically from Wikidata.&amp;quot;,&lt;br /&gt;
      &amp;quot;required&amp;quot;: true&lt;br /&gt;
    },&amp;quot;official_name&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Official Name (P1448)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Official name&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;logo&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Logo (P154)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Logo image.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;image&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Image (P18)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Image.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;headquarters&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Headquarters (P159)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Headquarters.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;founding_date&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Founding Date (P571)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Founding date.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;dissolution_date&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Dissolution Date (P576)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Dissolution date.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;official_website&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Official Website (P856)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Official website.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;country&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Country (P17)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Country.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent_organization&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Parent Organization (P749)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Parent organization.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;member_count&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Member Count (P2124)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Most recent member count, by its point in time (P585) qualifier, with that date shown in brackets.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;social_media&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Social media (P2013, P2003, P2397/P11245, P7085, P2002, P11892, P12361, P4033, P4264/P6634)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Links to Facebook, Instagram, YouTube, TikTok, X, Threads, Bluesky, Mastodon and LinkedIn profiles. Fetched from Wikidata; deprecated-rank accounts are skipped.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;place_of_death&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Place of Death (P20)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Place of death, shown together with the date of death for people.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;coordinates&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Coordinate Location (P625)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Coordinate location. Fetched from Wikidata and rendered as an OpenStreetMap (Leaflet) map via the Maps extension.&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Infobox for an organization. Fetches all parameters dynamically from Wikidata based on the mandatory QID.&amp;quot;,&lt;br /&gt;
  &amp;quot;format&amp;quot;: &amp;quot;inline&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/templatedata&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2092</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2092"/>
		<updated>2026-10-22T10:04:51Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- TemplateStyles stylesheet holding the infobox&#039;s look (pc-infobox classes).&lt;br /&gt;
local STYLESHEET = &#039;Template:DynamicInfobox/styles.css&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages whose infobox could not be rendered, e.g. because the&lt;br /&gt;
-- entity is not (yet) in UnlinkedWikibase&#039;s cache.&lt;br /&gt;
local ERROR_CATEGORY = &#039;Pages with Infobox Errors&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages showing a bare Q-ID instead of a label, because the&lt;br /&gt;
-- entity is not (yet) cached or has no English/&amp;quot;mul&amp;quot; label on Wikidata.&lt;br /&gt;
local MISSING_LABEL_CATEGORY = &#039;Pages with Missing Wikidata Labels&#039;&lt;br /&gt;
&lt;br /&gt;
-- Error message plus the error tracking category.&lt;br /&gt;
local function errorOutput(message)&lt;br /&gt;
    return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: &#039; .. message .. &#039;&amp;lt;/span&amp;gt;&#039; ..&lt;br /&gt;
        &#039;[[Category:&#039; .. ERROR_CATEGORY .. &#039;]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return errorOutput(&#039;No Wikidata QID provided&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return errorOutput(&#039;Entity &#039; .. qid .. &#039; not found&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local lang = mw.language.getContentLanguage()&lt;br /&gt;
&lt;br /&gt;
    -- Label of an entity: English, then the language-independent default&lt;br /&gt;
    -- label (&amp;quot;mul&amp;quot;), otherwise nil.&lt;br /&gt;
    local function getLabel(ent)&lt;br /&gt;
        if not ent or not ent.labels then return nil end&lt;br /&gt;
        for _, l in ipairs({ &#039;en&#039;, &#039;mul&#039; }) do&lt;br /&gt;
            local label = ent.labels[l]&lt;br /&gt;
            if label and label.value and label.value ~= &#039;&#039; then&lt;br /&gt;
                return label.value&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikipedia article of an entity, from its Wikidata sitelinks: English&lt;br /&gt;
    -- first, German as fallback. Returns the URL and a link label, or nil.&lt;br /&gt;
    -- Entities cached by the UpdateEntities maintenance script&lt;br /&gt;
    -- (wbgetentities) carry sitelink titles but no URLs, so the URL is built&lt;br /&gt;
    -- from the title.&lt;br /&gt;
    local wikipediaSites = {&lt;br /&gt;
        { site = &#039;enwiki&#039;, lang = &#039;en&#039;, label = &#039;Wikipedia&#039; },&lt;br /&gt;
        { site = &#039;dewiki&#039;, lang = &#039;de&#039;, label = &#039;Wikipedia (de)&#039; }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    local function getWikipediaUrl(ent)&lt;br /&gt;
        if not ent or not ent.sitelinks then return nil end&lt;br /&gt;
        for _, w in ipairs(wikipediaSites) do&lt;br /&gt;
            local link = ent.sitelinks[w.site]&lt;br /&gt;
            if link and link.title and link.title ~= &#039;&#039; then&lt;br /&gt;
                -- WIKI encoding also turns spaces into underscores&lt;br /&gt;
                return &#039;https://&#039; .. w.lang .. &#039;.wikipedia.org/wiki/&#039; ..&lt;br /&gt;
                    mw.uri.encode(link.title, &#039;WIKI&#039;), w.label&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Categories collected while the infobox is built and appended to the&lt;br /&gt;
    -- output at the end, e.g. &amp;quot;Pages with Image&amp;quot; or the country.&lt;br /&gt;
    local categories = {}&lt;br /&gt;
    local function addCategory(name)&lt;br /&gt;
        if not categories[name] then&lt;br /&gt;
            categories[name] = true&lt;br /&gt;
            table.insert(categories, name)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikidata country items mapped to the wiki&#039;s country categories. Add an&lt;br /&gt;
    -- entry here to categorise pages by another country.&lt;br /&gt;
    local countryCategories = {&lt;br /&gt;
        Q183 = &#039;Germany&#039;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Add the country categories for every non-deprecated value of pid&lt;br /&gt;
    -- (P17 country for organisations, P27 citizenship for people).&lt;br /&gt;
    local function addCountryCategories(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return end&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.id and&lt;br /&gt;
                countryCategories[v.id] then&lt;br /&gt;
                addCategory(countryCategories[v.id])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Render the stylesheet and infobox followed by its base category and all&lt;br /&gt;
    -- collected categories.&lt;br /&gt;
    local function render(box, baseCategory)&lt;br /&gt;
        local out = {&lt;br /&gt;
            frame:extensionTag(&#039;templatestyles&#039;, &#039;&#039;, { src = STYLESHEET }) ..&lt;br /&gt;
            tostring(box),&lt;br /&gt;
            &#039;[[Category:&#039; .. baseCategory .. &#039;]]&#039;&lt;br /&gt;
        }&lt;br /&gt;
        for _, name in ipairs(categories) do&lt;br /&gt;
            table.insert(out, &#039;[[Category:&#039; .. name .. &#039;]]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        return table.concat(out, &#039;\n&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Format a Wikidata time value according to its precision, e.g.&lt;br /&gt;
    -- &amp;quot;15 January 2023&amp;quot;, &amp;quot;January 2023&amp;quot; or &amp;quot;2023&amp;quot;.&lt;br /&gt;
    local function formatTime(value)&lt;br /&gt;
        local sign, year, month, day =&lt;br /&gt;
            value.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
        if not year then return value.time end&lt;br /&gt;
        local y, m, d = tonumber(year), tonumber(month), tonumber(day)&lt;br /&gt;
        local precision = value.precision or 11&lt;br /&gt;
        if sign == &#039;-&#039; then return tostring(y) .. &#039; BC&#039; end&lt;br /&gt;
        local format, date&lt;br /&gt;
        if precision &amp;gt;= 11 and m &amp;gt; 0 and d &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;j F Y&#039;, string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
        elseif precision == 10 and m &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;F Y&#039;, string.format(&#039;%04d-%02d-01&#039;, y, m)&lt;br /&gt;
        else&lt;br /&gt;
            return tostring(y)&lt;br /&gt;
        end&lt;br /&gt;
        local ok, text = pcall(lang.formatDate, lang, format, date)&lt;br /&gt;
        if ok then return text end&lt;br /&gt;
        return date&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                return formatTime(value)&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                local label = getLabel(linkedEntity)&lt;br /&gt;
                if not label then addCategory(MISSING_LABEL_CATEGORY) end&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    -- Then prefer a Wikipedia article (external link)&lt;br /&gt;
                    local url = getWikipediaUrl(linkedEntity)&lt;br /&gt;
                    if url then&lt;br /&gt;
                        return &#039;[&#039; .. url .. &#039; &#039; .. (label or value.id) .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the plain label if available&lt;br /&gt;
                    if label then return label end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Formatted value of a property, or nil.&lt;br /&gt;
    local function getFormatted(pid)&lt;br /&gt;
        return formatValue(getPropertyValue(pid))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for _, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the main image (P18) with its media legend (P2096) as caption.&lt;br /&gt;
    -- Capiunto always renders images directly below the title.&lt;br /&gt;
    local function addMainImage(box)&lt;br /&gt;
        local claim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        local v = claim and claim.mainsnak and claim.mainsnak.datavalue and&lt;br /&gt;
            claim.mainsnak.datavalue.value&lt;br /&gt;
        if not v then return end&lt;br /&gt;
        addCategory(&#039;Pages with Image&#039;)&lt;br /&gt;
        local caption = getQualifierValue(claim, &#039;P2096&#039;)&lt;br /&gt;
        if caption == &#039;&#039; then caption = nil end&lt;br /&gt;
        box:addImage(&#039;[[File:&#039; .. tostring(v) .. &#039;|280px]]&#039;, caption)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Leaflet/OpenStreetMap map for this entity, as HTML, or nil.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function. A module&#039;s&lt;br /&gt;
    -- return value goes through the main parse pass but NOT the preprocessor, so&lt;br /&gt;
    -- parser-function syntax would otherwise be emitted literally. We expand it&lt;br /&gt;
    -- here with frame:preprocess().&lt;br /&gt;
    local function getMap()&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                    mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Map&#039;)&lt;br /&gt;
        return frame:preprocess(string.format(&lt;br /&gt;
            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Social media accounts, in display order. Each entry lists one or more&lt;br /&gt;
    -- Wikidata properties (first one with a value wins) and a function that&lt;br /&gt;
    -- turns the stored identifier into a profile URL.&lt;br /&gt;
    ---@type {label: string, pids: string[], url: fun(v: string, pid: string): string?}[]&lt;br /&gt;
    local socialMedia = {&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Facebook&#039;,&lt;br /&gt;
            pids = { &#039;P2013&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.facebook.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Instagram&#039;,&lt;br /&gt;
            pids = { &#039;P2003&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.instagram.com/&#039; .. v .. &#039;/&#039;&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;YouTube&#039;,&lt;br /&gt;
            pids = { &#039;P2397&#039;, &#039;P11245&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P11245&#039; then&lt;br /&gt;
                    return &#039;https://www.youtube.com/@&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.youtube.com/channel/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;TikTok&#039;,&lt;br /&gt;
            pids = { &#039;P7085&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.tiktok.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;X&#039;,&lt;br /&gt;
            pids = { &#039;P2002&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://x.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Threads&#039;,&lt;br /&gt;
            pids = { &#039;P11892&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.threads.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Bluesky&#039;,&lt;br /&gt;
            pids = { &#039;P12361&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://bsky.app/profile/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Mastodon&#039;,&lt;br /&gt;
            pids = { &#039;P4033&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                -- Stored as user@server.domain&lt;br /&gt;
                local user, server = v:match(&#039;^@?([^@]+)@(.+)$&#039;)&lt;br /&gt;
                if not user then return nil end&lt;br /&gt;
                return &#039;https://&#039; .. server .. &#039;/@&#039; .. user&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;LinkedIn&#039;,&lt;br /&gt;
            pids = { &#039;P4264&#039;, &#039;P6634&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P6634&#039; then&lt;br /&gt;
                    return &#039;https://www.linkedin.com/in/&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.linkedin.com/company/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Get the best string value for a property: preferred rank first, then&lt;br /&gt;
    -- the first normal-rank claim. Deprecated claims (e.g. abandoned&lt;br /&gt;
    -- accounts) are skipped.&lt;br /&gt;
    local function getBestStringValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local fallback&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if type(v) == &#039;string&#039; and v ~= &#039;&#039; then&lt;br /&gt;
                if claim.rank == &#039;preferred&#039; then return v end&lt;br /&gt;
                if claim.rank ~= &#039;deprecated&#039; and not fallback then&lt;br /&gt;
                    fallback = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return fallback&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Links to the entity&#039;s social media profiles, e.g.&lt;br /&gt;
    -- &amp;quot;Facebook · Instagram · YouTube&amp;quot;, or nil.&lt;br /&gt;
    local function getSocialMedia()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        for _, site in ipairs(socialMedia) do&lt;br /&gt;
            for _, pid in ipairs(site.pids) do&lt;br /&gt;
                local v = getBestStringValue(pid)&lt;br /&gt;
                local url = v and site.url(mw.text.trim(v), pid)&lt;br /&gt;
                if url then&lt;br /&gt;
                    -- Spaces would end the external link target early&lt;br /&gt;
                    url = url:gsub(&#039; &#039;, &#039;%%20&#039;)&lt;br /&gt;
                    table.insert(links, &#039;[&#039; .. url .. &#039; &#039; .. site.label .. &#039;]&#039;)&lt;br /&gt;
                    break&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if #links == 0 then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Social Media&#039;)&lt;br /&gt;
        return table.concat(links, &#039; · &#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Official website (P856) as a link showing just the host and path.&lt;br /&gt;
    local function getWebsite()&lt;br /&gt;
        local url = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
        if type(url) ~= &#039;string&#039; or url == &#039;&#039; then return nil end&lt;br /&gt;
        addCategory(&#039;Pages with Official Website&#039;)&lt;br /&gt;
        local display = url:gsub(&#039;^https?://&#039;, &#039;&#039;):gsub(&#039;^www%.&#039;, &#039;&#039;)&lt;br /&gt;
            :gsub(&#039;/$&#039;, &#039;&#039;)&lt;br /&gt;
        return &#039;[&#039; .. url .. &#039; &#039; .. display .. &#039;]&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Footer line with links to the entity&#039;s Wikipedia article (if any) and&lt;br /&gt;
    -- its Wikidata item.&lt;br /&gt;
    local function getFooter()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        local wikipediaUrl, wikipediaLabel = getWikipediaUrl(entity)&lt;br /&gt;
        if wikipediaUrl then&lt;br /&gt;
            addCategory(&#039;Pages with Wikipedia Article&#039;)&lt;br /&gt;
            table.insert(links,&lt;br /&gt;
                &#039;[&#039; .. wikipediaUrl .. &#039; &#039; .. wikipediaLabel .. &#039;]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        table.insert(links,&lt;br /&gt;
            &#039;[https://www.wikidata.org/wiki/&#039; .. qid .. &#039; View on Wikidata]&#039;)&lt;br /&gt;
        return &#039;&amp;lt;div class=&amp;quot;pc-infobox-footer&amp;quot;&amp;gt;&#039; ..&lt;br /&gt;
            table.concat(links, &#039; · &#039;) .. &#039;&amp;lt;/div&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a section: an optional header followed by its rows. Each row is&lt;br /&gt;
    -- either { label, data } or { wikitext = ... }; rows without data are&lt;br /&gt;
    -- dropped, and the header is only shown if at least one row remains.&lt;br /&gt;
    local function addSection(box, header, rows)&lt;br /&gt;
        local present = {}&lt;br /&gt;
        for _, row in ipairs(rows) do&lt;br /&gt;
            if row.wikitext or row[2] then table.insert(present, row) end&lt;br /&gt;
        end&lt;br /&gt;
        if #present == 0 then return end&lt;br /&gt;
        if header then box:addHeader(header) end&lt;br /&gt;
        for _, row in ipairs(present) do&lt;br /&gt;
            if row.wikitext then&lt;br /&gt;
                box:addWikitext(row.wikitext)&lt;br /&gt;
            else&lt;br /&gt;
                box:addRow(row[1], row[2])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Date and place combined into one cell, e.g. &amp;quot;1 May 1950&amp;lt;br&amp;gt;Munich&amp;quot;.&lt;br /&gt;
    local function datePlace(datePid, placePid)&lt;br /&gt;
        local date, place = getFormatted(datePid), getFormatted(placePid)&lt;br /&gt;
        if date and place then return date .. &#039;&amp;lt;br&amp;gt;&#039; .. place end&lt;br /&gt;
        return date or place&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the links section shared by both infobox types.&lt;br /&gt;
    local function addLinks(box)&lt;br /&gt;
        addSection(box, &#039;Links&#039;, {&lt;br /&gt;
            { &#039;Website&#039;,      getWebsite() },&lt;br /&gt;
            { &#039;Social media&#039;, getSocialMedia() }&lt;br /&gt;
        })&lt;br /&gt;
        box:addWikitext(getFooter())&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local title = getLabel(entity)&lt;br /&gt;
    if not title then&lt;br /&gt;
        title = qid&lt;br /&gt;
        addCategory(MISSING_LABEL_CATEGORY)&lt;br /&gt;
    end&lt;br /&gt;
    local infobox = capiunto.create({&lt;br /&gt;
        title = title,&lt;br /&gt;
        bodyClass = &#039;infobox vcard pc-infobox&#039;&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    if getClaimEntityId(&#039;P31&#039;) == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
        addSection(infobox, nil, {&lt;br /&gt;
            { &#039;Born&#039;,       datePlace(&#039;P569&#039;, &#039;P19&#039;) },&lt;br /&gt;
            { &#039;Died&#039;,       datePlace(&#039;P570&#039;, &#039;P20&#039;) },&lt;br /&gt;
            { &#039;Occupation&#039;, getFormatted(&#039;P106&#039;) }&lt;br /&gt;
        })&lt;br /&gt;
        addCountryCategories(&#039;P27&#039;)&lt;br /&gt;
&lt;br /&gt;
        local map = getMap()&lt;br /&gt;
        if map then infobox:addWikitext(map) end&lt;br /&gt;
&lt;br /&gt;
        addLinks(infobox)&lt;br /&gt;
        return render(infobox, &#039;People&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Default: organisation/troupe infobox&lt;br /&gt;
&lt;br /&gt;
    -- Official name (P1448) as a subtitle, unless it just repeats the title&lt;br /&gt;
    local officialName = getFormatted(&#039;P1448&#039;)&lt;br /&gt;
    if officialName and officialName ~= title then&lt;br /&gt;
        infobox:addSubHeader(officialName, &#039;pc-infobox-subtitle&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Logo (P154), then the main image&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if type(logo) == &#039;string&#039; and logo ~= &#039;&#039; then&lt;br /&gt;
        addCategory(&#039;Pages with Logo&#039;)&lt;br /&gt;
        -- Row class gives transparent logos a light backing in dark mode&lt;br /&gt;
        infobox:addImage(&#039;[[File:&#039; .. logo .. &#039;|150px]]&#039;, nil,&lt;br /&gt;
            &#039;pc-infobox-logo&#039;)&lt;br /&gt;
    end&lt;br /&gt;
    addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
    -- Member count (P2124): the most recent value by its point in time&lt;br /&gt;
    -- (P585) qualifier, shown as e.g. &amp;quot;120 (as of 1 May 2023)&amp;quot;. Undated&lt;br /&gt;
    -- values are only used when no dated one exists, preferring preferred&lt;br /&gt;
    -- rank.&lt;br /&gt;
    local function getMemberCount()&lt;br /&gt;
        if not entity.claims or not entity.claims.P2124 then return nil end&lt;br /&gt;
        local best, bestKey, bestTime, undated&lt;br /&gt;
        for _, claim in ipairs(entity.claims.P2124) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.amount then&lt;br /&gt;
                local q = claim.qualifiers and claim.qualifiers.P585 and&lt;br /&gt;
                    claim.qualifiers.P585[1]&lt;br /&gt;
                local t = q and q.datavalue and q.datavalue.value&lt;br /&gt;
                local sign, y, m, d&lt;br /&gt;
                if type(t) == &#039;table&#039; and t.time then&lt;br /&gt;
                    sign, y, m, d = t.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                end&lt;br /&gt;
                if y then&lt;br /&gt;
                    local key = (tonumber(y) * 10000 + tonumber(m) * 100 +&lt;br /&gt;
                        tonumber(d)) * (sign == &#039;-&#039; and -1 or 1)&lt;br /&gt;
                    if not bestKey or key &amp;gt; bestKey then&lt;br /&gt;
                        best, bestKey, bestTime = v, key, t&lt;br /&gt;
                    end&lt;br /&gt;
                elseif not undated or claim.rank == &#039;preferred&#039; then&lt;br /&gt;
                    undated = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        local value = best or undated&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
        local amount = tonumber((value.amount:gsub(&#039;^%+&#039;, &#039;&#039;)))&lt;br /&gt;
        if not amount then return nil end&lt;br /&gt;
        local text = lang:formatNum(amount)&lt;br /&gt;
        if bestTime and best == value then&lt;br /&gt;
            text = text .. &#039; &amp;lt;span class=&amp;quot;pc-infobox-note&amp;quot;&amp;gt;(as of &#039; ..&lt;br /&gt;
                formatTime(bestTime) .. &#039;)&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
        end&lt;br /&gt;
        return text&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local dissolved = getFormatted(&#039;P576&#039;)&lt;br /&gt;
    if dissolved then addCategory(&#039;Dissolved&#039;) end&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, nil, {&lt;br /&gt;
        { &#039;Founded&#039;,             getFormatted(&#039;P571&#039;) },&lt;br /&gt;
        { &#039;Dissolved&#039;,           dissolved },&lt;br /&gt;
        { &#039;Members&#039;,             getMemberCount() },&lt;br /&gt;
        { &#039;Parent organization&#039;, getFormatted(&#039;P749&#039;) }&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, &#039;Location&#039;, {&lt;br /&gt;
        { &#039;Headquarters&#039;,     getFormatted(&#039;P159&#039;) },&lt;br /&gt;
        { &#039;Country&#039;,          getFormatted(&#039;P17&#039;) },&lt;br /&gt;
        { wikitext = getMap() }&lt;br /&gt;
    })&lt;br /&gt;
    addCountryCategories(&#039;P17&#039;)&lt;br /&gt;
&lt;br /&gt;
    addLinks(infobox)&lt;br /&gt;
    return render(infobox, &#039;Clubs, Societies and Institutions&#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2090</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2090"/>
		<updated>2026-10-22T09:58:00Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- TemplateStyles stylesheet holding the infobox&#039;s look (pc-infobox classes).&lt;br /&gt;
local STYLESHEET = &#039;Template:DynamicInfobox/styles.css&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages whose infobox could not be rendered, e.g. because the&lt;br /&gt;
-- entity is not (yet) in UnlinkedWikibase&#039;s cache.&lt;br /&gt;
local ERROR_CATEGORY = &#039;Pages with infobox errors&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages showing a bare Q-ID instead of a label, because the&lt;br /&gt;
-- entity is not (yet) cached or has no English/&amp;quot;mul&amp;quot; label on Wikidata.&lt;br /&gt;
local MISSING_LABEL_CATEGORY = &#039;Pages with missing Wikidata labels&#039;&lt;br /&gt;
&lt;br /&gt;
-- Error message plus the error tracking category.&lt;br /&gt;
local function errorOutput(message)&lt;br /&gt;
    return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: &#039; .. message .. &#039;&amp;lt;/span&amp;gt;&#039; ..&lt;br /&gt;
        &#039;[[Category:&#039; .. ERROR_CATEGORY .. &#039;]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return errorOutput(&#039;No Wikidata QID provided&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return errorOutput(&#039;Entity &#039; .. qid .. &#039; not found&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local lang = mw.language.getContentLanguage()&lt;br /&gt;
&lt;br /&gt;
    -- Label of an entity: English, then the language-independent default&lt;br /&gt;
    -- label (&amp;quot;mul&amp;quot;), otherwise nil.&lt;br /&gt;
    local function getLabel(ent)&lt;br /&gt;
        if not ent or not ent.labels then return nil end&lt;br /&gt;
        for _, l in ipairs({ &#039;en&#039;, &#039;mul&#039; }) do&lt;br /&gt;
            local label = ent.labels[l]&lt;br /&gt;
            if label and label.value and label.value ~= &#039;&#039; then&lt;br /&gt;
                return label.value&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikipedia article of an entity, from its Wikidata sitelinks: English&lt;br /&gt;
    -- first, German as fallback. Returns the URL and a link label, or nil.&lt;br /&gt;
    -- Entities cached by the UpdateEntities maintenance script&lt;br /&gt;
    -- (wbgetentities) carry sitelink titles but no URLs, so the URL is built&lt;br /&gt;
    -- from the title.&lt;br /&gt;
    local wikipediaSites = {&lt;br /&gt;
        { site = &#039;enwiki&#039;, lang = &#039;en&#039;, label = &#039;Wikipedia&#039; },&lt;br /&gt;
        { site = &#039;dewiki&#039;, lang = &#039;de&#039;, label = &#039;Wikipedia (de)&#039; }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    local function getWikipediaUrl(ent)&lt;br /&gt;
        if not ent or not ent.sitelinks then return nil end&lt;br /&gt;
        for _, w in ipairs(wikipediaSites) do&lt;br /&gt;
            local link = ent.sitelinks[w.site]&lt;br /&gt;
            if link and link.title and link.title ~= &#039;&#039; then&lt;br /&gt;
                -- WIKI encoding also turns spaces into underscores&lt;br /&gt;
                return &#039;https://&#039; .. w.lang .. &#039;.wikipedia.org/wiki/&#039; ..&lt;br /&gt;
                    mw.uri.encode(link.title, &#039;WIKI&#039;), w.label&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Categories collected while the infobox is built and appended to the&lt;br /&gt;
    -- output at the end, e.g. &amp;quot;Has image&amp;quot; or the country.&lt;br /&gt;
    local categories = {}&lt;br /&gt;
    local function addCategory(name)&lt;br /&gt;
        if not categories[name] then&lt;br /&gt;
            categories[name] = true&lt;br /&gt;
            table.insert(categories, name)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikidata country items mapped to the wiki&#039;s country categories. Add an&lt;br /&gt;
    -- entry here to categorise pages by another country.&lt;br /&gt;
    local countryCategories = {&lt;br /&gt;
        Q183 = &#039;Germany&#039;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Add the country categories for every non-deprecated value of pid&lt;br /&gt;
    -- (P17 country for organisations, P27 citizenship for people).&lt;br /&gt;
    local function addCountryCategories(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return end&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.id and&lt;br /&gt;
                countryCategories[v.id] then&lt;br /&gt;
                addCategory(countryCategories[v.id])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Render the stylesheet and infobox followed by its base category and all&lt;br /&gt;
    -- collected categories.&lt;br /&gt;
    local function render(box, baseCategory)&lt;br /&gt;
        local out = {&lt;br /&gt;
            frame:extensionTag(&#039;templatestyles&#039;, &#039;&#039;, { src = STYLESHEET }) ..&lt;br /&gt;
            tostring(box),&lt;br /&gt;
            &#039;[[Category:&#039; .. baseCategory .. &#039;]]&#039;&lt;br /&gt;
        }&lt;br /&gt;
        for _, name in ipairs(categories) do&lt;br /&gt;
            table.insert(out, &#039;[[Category:&#039; .. name .. &#039;]]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        return table.concat(out, &#039;\n&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Format a Wikidata time value according to its precision, e.g.&lt;br /&gt;
    -- &amp;quot;15 January 2023&amp;quot;, &amp;quot;January 2023&amp;quot; or &amp;quot;2023&amp;quot;.&lt;br /&gt;
    local function formatTime(value)&lt;br /&gt;
        local sign, year, month, day =&lt;br /&gt;
            value.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
        if not year then return value.time end&lt;br /&gt;
        local y, m, d = tonumber(year), tonumber(month), tonumber(day)&lt;br /&gt;
        local precision = value.precision or 11&lt;br /&gt;
        if sign == &#039;-&#039; then return tostring(y) .. &#039; BC&#039; end&lt;br /&gt;
        local format, date&lt;br /&gt;
        if precision &amp;gt;= 11 and m &amp;gt; 0 and d &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;j F Y&#039;, string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
        elseif precision == 10 and m &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;F Y&#039;, string.format(&#039;%04d-%02d-01&#039;, y, m)&lt;br /&gt;
        else&lt;br /&gt;
            return tostring(y)&lt;br /&gt;
        end&lt;br /&gt;
        local ok, text = pcall(lang.formatDate, lang, format, date)&lt;br /&gt;
        if ok then return text end&lt;br /&gt;
        return date&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                return formatTime(value)&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                local label = getLabel(linkedEntity)&lt;br /&gt;
                if not label then addCategory(MISSING_LABEL_CATEGORY) end&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    -- Then prefer a Wikipedia article (external link)&lt;br /&gt;
                    local url = getWikipediaUrl(linkedEntity)&lt;br /&gt;
                    if url then&lt;br /&gt;
                        return &#039;[&#039; .. url .. &#039; &#039; .. (label or value.id) .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the plain label if available&lt;br /&gt;
                    if label then return label end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Formatted value of a property, or nil.&lt;br /&gt;
    local function getFormatted(pid)&lt;br /&gt;
        return formatValue(getPropertyValue(pid))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for _, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the main image (P18) with its media legend (P2096) as caption.&lt;br /&gt;
    -- Capiunto always renders images directly below the title.&lt;br /&gt;
    local function addMainImage(box)&lt;br /&gt;
        local claim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        local v = claim and claim.mainsnak and claim.mainsnak.datavalue and&lt;br /&gt;
            claim.mainsnak.datavalue.value&lt;br /&gt;
        if not v then return end&lt;br /&gt;
        addCategory(&#039;Has image&#039;)&lt;br /&gt;
        local caption = getQualifierValue(claim, &#039;P2096&#039;)&lt;br /&gt;
        if caption == &#039;&#039; then caption = nil end&lt;br /&gt;
        box:addImage(&#039;[[File:&#039; .. tostring(v) .. &#039;|280px]]&#039;, caption)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Leaflet/OpenStreetMap map for this entity, as HTML, or nil.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function. A module&#039;s&lt;br /&gt;
    -- return value goes through the main parse pass but NOT the preprocessor, so&lt;br /&gt;
    -- parser-function syntax would otherwise be emitted literally. We expand it&lt;br /&gt;
    -- here with frame:preprocess().&lt;br /&gt;
    local function getMap()&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                    mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return nil end&lt;br /&gt;
        addCategory(&#039;Has map&#039;)&lt;br /&gt;
        return frame:preprocess(string.format(&lt;br /&gt;
            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Social media accounts, in display order. Each entry lists one or more&lt;br /&gt;
    -- Wikidata properties (first one with a value wins) and a function that&lt;br /&gt;
    -- turns the stored identifier into a profile URL.&lt;br /&gt;
    ---@type {label: string, pids: string[], url: fun(v: string, pid: string): string?}[]&lt;br /&gt;
    local socialMedia = {&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Facebook&#039;,&lt;br /&gt;
            pids = { &#039;P2013&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.facebook.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Instagram&#039;,&lt;br /&gt;
            pids = { &#039;P2003&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.instagram.com/&#039; .. v .. &#039;/&#039;&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;YouTube&#039;,&lt;br /&gt;
            pids = { &#039;P2397&#039;, &#039;P11245&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P11245&#039; then&lt;br /&gt;
                    return &#039;https://www.youtube.com/@&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.youtube.com/channel/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;TikTok&#039;,&lt;br /&gt;
            pids = { &#039;P7085&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.tiktok.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;X&#039;,&lt;br /&gt;
            pids = { &#039;P2002&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://x.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Threads&#039;,&lt;br /&gt;
            pids = { &#039;P11892&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.threads.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Bluesky&#039;,&lt;br /&gt;
            pids = { &#039;P12361&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://bsky.app/profile/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Mastodon&#039;,&lt;br /&gt;
            pids = { &#039;P4033&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                -- Stored as user@server.domain&lt;br /&gt;
                local user, server = v:match(&#039;^@?([^@]+)@(.+)$&#039;)&lt;br /&gt;
                if not user then return nil end&lt;br /&gt;
                return &#039;https://&#039; .. server .. &#039;/@&#039; .. user&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;LinkedIn&#039;,&lt;br /&gt;
            pids = { &#039;P4264&#039;, &#039;P6634&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P6634&#039; then&lt;br /&gt;
                    return &#039;https://www.linkedin.com/in/&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.linkedin.com/company/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Get the best string value for a property: preferred rank first, then&lt;br /&gt;
    -- the first normal-rank claim. Deprecated claims (e.g. abandoned&lt;br /&gt;
    -- accounts) are skipped.&lt;br /&gt;
    local function getBestStringValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local fallback&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if type(v) == &#039;string&#039; and v ~= &#039;&#039; then&lt;br /&gt;
                if claim.rank == &#039;preferred&#039; then return v end&lt;br /&gt;
                if claim.rank ~= &#039;deprecated&#039; and not fallback then&lt;br /&gt;
                    fallback = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return fallback&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Links to the entity&#039;s social media profiles, e.g.&lt;br /&gt;
    -- &amp;quot;Facebook · Instagram · YouTube&amp;quot;, or nil.&lt;br /&gt;
    local function getSocialMedia()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        for _, site in ipairs(socialMedia) do&lt;br /&gt;
            for _, pid in ipairs(site.pids) do&lt;br /&gt;
                local v = getBestStringValue(pid)&lt;br /&gt;
                local url = v and site.url(mw.text.trim(v), pid)&lt;br /&gt;
                if url then&lt;br /&gt;
                    -- Spaces would end the external link target early&lt;br /&gt;
                    url = url:gsub(&#039; &#039;, &#039;%%20&#039;)&lt;br /&gt;
                    table.insert(links, &#039;[&#039; .. url .. &#039; &#039; .. site.label .. &#039;]&#039;)&lt;br /&gt;
                    break&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if #links == 0 then return nil end&lt;br /&gt;
        addCategory(&#039;Has social media&#039;)&lt;br /&gt;
        return table.concat(links, &#039; · &#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Official website (P856) as a link showing just the host and path.&lt;br /&gt;
    local function getWebsite()&lt;br /&gt;
        local url = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
        if type(url) ~= &#039;string&#039; or url == &#039;&#039; then return nil end&lt;br /&gt;
        addCategory(&#039;Has official website&#039;)&lt;br /&gt;
        local display = url:gsub(&#039;^https?://&#039;, &#039;&#039;):gsub(&#039;^www%.&#039;, &#039;&#039;)&lt;br /&gt;
            :gsub(&#039;/$&#039;, &#039;&#039;)&lt;br /&gt;
        return &#039;[&#039; .. url .. &#039; &#039; .. display .. &#039;]&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Footer line with links to the entity&#039;s Wikipedia article (if any) and&lt;br /&gt;
    -- its Wikidata item.&lt;br /&gt;
    local function getFooter()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        local wikipediaUrl, wikipediaLabel = getWikipediaUrl(entity)&lt;br /&gt;
        if wikipediaUrl then&lt;br /&gt;
            addCategory(&#039;Has Wikipedia article&#039;)&lt;br /&gt;
            table.insert(links,&lt;br /&gt;
                &#039;[&#039; .. wikipediaUrl .. &#039; &#039; .. wikipediaLabel .. &#039;]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        table.insert(links,&lt;br /&gt;
            &#039;[https://www.wikidata.org/wiki/&#039; .. qid .. &#039; View on Wikidata]&#039;)&lt;br /&gt;
        return &#039;&amp;lt;div class=&amp;quot;pc-infobox-footer&amp;quot;&amp;gt;&#039; ..&lt;br /&gt;
            table.concat(links, &#039; · &#039;) .. &#039;&amp;lt;/div&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a section: an optional header followed by its rows. Each row is&lt;br /&gt;
    -- either { label, data } or { wikitext = ... }; rows without data are&lt;br /&gt;
    -- dropped, and the header is only shown if at least one row remains.&lt;br /&gt;
    local function addSection(box, header, rows)&lt;br /&gt;
        local present = {}&lt;br /&gt;
        for _, row in ipairs(rows) do&lt;br /&gt;
            if row.wikitext or row[2] then table.insert(present, row) end&lt;br /&gt;
        end&lt;br /&gt;
        if #present == 0 then return end&lt;br /&gt;
        if header then box:addHeader(header) end&lt;br /&gt;
        for _, row in ipairs(present) do&lt;br /&gt;
            if row.wikitext then&lt;br /&gt;
                box:addWikitext(row.wikitext)&lt;br /&gt;
            else&lt;br /&gt;
                box:addRow(row[1], row[2])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Date and place combined into one cell, e.g. &amp;quot;1 May 1950&amp;lt;br&amp;gt;Munich&amp;quot;.&lt;br /&gt;
    local function datePlace(datePid, placePid)&lt;br /&gt;
        local date, place = getFormatted(datePid), getFormatted(placePid)&lt;br /&gt;
        if date and place then return date .. &#039;&amp;lt;br&amp;gt;&#039; .. place end&lt;br /&gt;
        return date or place&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the links section shared by both infobox types.&lt;br /&gt;
    local function addLinks(box)&lt;br /&gt;
        addSection(box, &#039;Links&#039;, {&lt;br /&gt;
            { &#039;Website&#039;,      getWebsite() },&lt;br /&gt;
            { &#039;Social media&#039;, getSocialMedia() }&lt;br /&gt;
        })&lt;br /&gt;
        box:addWikitext(getFooter())&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local title = getLabel(entity)&lt;br /&gt;
    if not title then&lt;br /&gt;
        title = qid&lt;br /&gt;
        addCategory(MISSING_LABEL_CATEGORY)&lt;br /&gt;
    end&lt;br /&gt;
    local infobox = capiunto.create({&lt;br /&gt;
        title = title,&lt;br /&gt;
        bodyClass = &#039;infobox vcard pc-infobox&#039;&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    if getClaimEntityId(&#039;P31&#039;) == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
        addSection(infobox, nil, {&lt;br /&gt;
            { &#039;Born&#039;,       datePlace(&#039;P569&#039;, &#039;P19&#039;) },&lt;br /&gt;
            { &#039;Died&#039;,       datePlace(&#039;P570&#039;, &#039;P20&#039;) },&lt;br /&gt;
            { &#039;Occupation&#039;, getFormatted(&#039;P106&#039;) }&lt;br /&gt;
        })&lt;br /&gt;
        addCountryCategories(&#039;P27&#039;)&lt;br /&gt;
&lt;br /&gt;
        local map = getMap()&lt;br /&gt;
        if map then infobox:addWikitext(map) end&lt;br /&gt;
&lt;br /&gt;
        addLinks(infobox)&lt;br /&gt;
        return render(infobox, &#039;People&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Default: organisation/troupe infobox&lt;br /&gt;
&lt;br /&gt;
    -- Official name (P1448) as a subtitle, unless it just repeats the title&lt;br /&gt;
    local officialName = getFormatted(&#039;P1448&#039;)&lt;br /&gt;
    if officialName and officialName ~= title then&lt;br /&gt;
        infobox:addSubHeader(officialName, &#039;pc-infobox-subtitle&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Logo (P154), then the main image&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if type(logo) == &#039;string&#039; and logo ~= &#039;&#039; then&lt;br /&gt;
        addCategory(&#039;Has logo&#039;)&lt;br /&gt;
        -- Row class gives transparent logos a light backing in dark mode&lt;br /&gt;
        infobox:addImage(&#039;[[File:&#039; .. logo .. &#039;|150px]]&#039;, nil,&lt;br /&gt;
            &#039;pc-infobox-logo&#039;)&lt;br /&gt;
    end&lt;br /&gt;
    addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
    -- Member count (P2124): the most recent value by its point in time&lt;br /&gt;
    -- (P585) qualifier, shown as e.g. &amp;quot;120 (as of 1 May 2023)&amp;quot;. Undated&lt;br /&gt;
    -- values are only used when no dated one exists, preferring preferred&lt;br /&gt;
    -- rank.&lt;br /&gt;
    local function getMemberCount()&lt;br /&gt;
        if not entity.claims or not entity.claims.P2124 then return nil end&lt;br /&gt;
        local best, bestKey, bestTime, undated&lt;br /&gt;
        for _, claim in ipairs(entity.claims.P2124) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.amount then&lt;br /&gt;
                local q = claim.qualifiers and claim.qualifiers.P585 and&lt;br /&gt;
                    claim.qualifiers.P585[1]&lt;br /&gt;
                local t = q and q.datavalue and q.datavalue.value&lt;br /&gt;
                local sign, y, m, d&lt;br /&gt;
                if type(t) == &#039;table&#039; and t.time then&lt;br /&gt;
                    sign, y, m, d = t.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                end&lt;br /&gt;
                if y then&lt;br /&gt;
                    local key = (tonumber(y) * 10000 + tonumber(m) * 100 +&lt;br /&gt;
                        tonumber(d)) * (sign == &#039;-&#039; and -1 or 1)&lt;br /&gt;
                    if not bestKey or key &amp;gt; bestKey then&lt;br /&gt;
                        best, bestKey, bestTime = v, key, t&lt;br /&gt;
                    end&lt;br /&gt;
                elseif not undated or claim.rank == &#039;preferred&#039; then&lt;br /&gt;
                    undated = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        local value = best or undated&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
        local amount = tonumber((value.amount:gsub(&#039;^%+&#039;, &#039;&#039;)))&lt;br /&gt;
        if not amount then return nil end&lt;br /&gt;
        local text = lang:formatNum(amount)&lt;br /&gt;
        if bestTime and best == value then&lt;br /&gt;
            text = text .. &#039; &amp;lt;span class=&amp;quot;pc-infobox-note&amp;quot;&amp;gt;(as of &#039; ..&lt;br /&gt;
                formatTime(bestTime) .. &#039;)&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
        end&lt;br /&gt;
        return text&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local dissolved = getFormatted(&#039;P576&#039;)&lt;br /&gt;
    if dissolved then addCategory(&#039;Dissolved&#039;) end&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, nil, {&lt;br /&gt;
        { &#039;Founded&#039;,             getFormatted(&#039;P571&#039;) },&lt;br /&gt;
        { &#039;Dissolved&#039;,           dissolved },&lt;br /&gt;
        { &#039;Members&#039;,             getMemberCount() },&lt;br /&gt;
        { &#039;Parent organization&#039;, getFormatted(&#039;P749&#039;) }&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, &#039;Location&#039;, {&lt;br /&gt;
        { &#039;Headquarters&#039;,     getFormatted(&#039;P159&#039;) },&lt;br /&gt;
        { &#039;Country&#039;,          getFormatted(&#039;P17&#039;) },&lt;br /&gt;
        { wikitext = getMap() }&lt;br /&gt;
    })&lt;br /&gt;
    addCountryCategories(&#039;P17&#039;)&lt;br /&gt;
&lt;br /&gt;
    addLinks(infobox)&lt;br /&gt;
    return render(infobox, &#039;Clubs, Societies and Institutions&#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2088</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2088"/>
		<updated>2026-10-22T09:53:30Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
-- TemplateStyles stylesheet holding the infobox&#039;s look (pc-infobox classes).&lt;br /&gt;
local STYLESHEET = &#039;Template:DynamicInfobox/styles.css&#039;&lt;br /&gt;
&lt;br /&gt;
-- Category for pages whose infobox could not be rendered, e.g. because the&lt;br /&gt;
-- entity is not (yet) in UnlinkedWikibase&#039;s cache.&lt;br /&gt;
local ERROR_CATEGORY = &#039;Pages with infobox errors&#039;&lt;br /&gt;
&lt;br /&gt;
-- Error message plus the error tracking category.&lt;br /&gt;
local function errorOutput(message)&lt;br /&gt;
    return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: &#039; .. message .. &#039;&amp;lt;/span&amp;gt;&#039; ..&lt;br /&gt;
        &#039;[[Category:&#039; .. ERROR_CATEGORY .. &#039;]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return errorOutput(&#039;No Wikidata QID provided&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return errorOutput(&#039;Entity &#039; .. qid .. &#039; not found&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local lang = mw.language.getContentLanguage()&lt;br /&gt;
&lt;br /&gt;
    -- Label of an entity: English, then the language-independent default&lt;br /&gt;
    -- label (&amp;quot;mul&amp;quot;), otherwise nil.&lt;br /&gt;
    local function getLabel(ent)&lt;br /&gt;
        if not ent or not ent.labels then return nil end&lt;br /&gt;
        for _, l in ipairs({ &#039;en&#039;, &#039;mul&#039; }) do&lt;br /&gt;
            local label = ent.labels[l]&lt;br /&gt;
            if label and label.value and label.value ~= &#039;&#039; then&lt;br /&gt;
                return label.value&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikipedia article of an entity, from its Wikidata sitelinks: English&lt;br /&gt;
    -- first, German as fallback. Returns the URL and a link label, or nil.&lt;br /&gt;
    -- Entities cached by the UpdateEntities maintenance script&lt;br /&gt;
    -- (wbgetentities) carry sitelink titles but no URLs, so the URL is built&lt;br /&gt;
    -- from the title.&lt;br /&gt;
    local wikipediaSites = {&lt;br /&gt;
        { site = &#039;enwiki&#039;, lang = &#039;en&#039;, label = &#039;Wikipedia&#039; },&lt;br /&gt;
        { site = &#039;dewiki&#039;, lang = &#039;de&#039;, label = &#039;Wikipedia (de)&#039; }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    local function getWikipediaUrl(ent)&lt;br /&gt;
        if not ent or not ent.sitelinks then return nil end&lt;br /&gt;
        for _, w in ipairs(wikipediaSites) do&lt;br /&gt;
            local link = ent.sitelinks[w.site]&lt;br /&gt;
            if link and link.title and link.title ~= &#039;&#039; then&lt;br /&gt;
                -- WIKI encoding also turns spaces into underscores&lt;br /&gt;
                return &#039;https://&#039; .. w.lang .. &#039;.wikipedia.org/wiki/&#039; ..&lt;br /&gt;
                    mw.uri.encode(link.title, &#039;WIKI&#039;), w.label&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Categories collected while the infobox is built and appended to the&lt;br /&gt;
    -- output at the end, e.g. &amp;quot;Has image&amp;quot; or the country.&lt;br /&gt;
    local categories = {}&lt;br /&gt;
    local function addCategory(name)&lt;br /&gt;
        if not categories[name] then&lt;br /&gt;
            categories[name] = true&lt;br /&gt;
            table.insert(categories, name)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Wikidata country items mapped to the wiki&#039;s country categories. Add an&lt;br /&gt;
    -- entry here to categorise pages by another country.&lt;br /&gt;
    local countryCategories = {&lt;br /&gt;
        Q183 = &#039;Germany&#039;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Add the country categories for every non-deprecated value of pid&lt;br /&gt;
    -- (P17 country for organisations, P27 citizenship for people).&lt;br /&gt;
    local function addCountryCategories(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return end&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.id and&lt;br /&gt;
                countryCategories[v.id] then&lt;br /&gt;
                addCategory(countryCategories[v.id])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Render the stylesheet and infobox followed by its base category and all&lt;br /&gt;
    -- collected categories.&lt;br /&gt;
    local function render(box, baseCategory)&lt;br /&gt;
        local out = {&lt;br /&gt;
            frame:extensionTag(&#039;templatestyles&#039;, &#039;&#039;, { src = STYLESHEET }) ..&lt;br /&gt;
            tostring(box),&lt;br /&gt;
            &#039;[[Category:&#039; .. baseCategory .. &#039;]]&#039;&lt;br /&gt;
        }&lt;br /&gt;
        for _, name in ipairs(categories) do&lt;br /&gt;
            table.insert(out, &#039;[[Category:&#039; .. name .. &#039;]]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        return table.concat(out, &#039;\n&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Format a Wikidata time value according to its precision, e.g.&lt;br /&gt;
    -- &amp;quot;15 January 2023&amp;quot;, &amp;quot;January 2023&amp;quot; or &amp;quot;2023&amp;quot;.&lt;br /&gt;
    local function formatTime(value)&lt;br /&gt;
        local sign, year, month, day =&lt;br /&gt;
            value.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
        if not year then return value.time end&lt;br /&gt;
        local y, m, d = tonumber(year), tonumber(month), tonumber(day)&lt;br /&gt;
        local precision = value.precision or 11&lt;br /&gt;
        if sign == &#039;-&#039; then return tostring(y) .. &#039; BC&#039; end&lt;br /&gt;
        local format, date&lt;br /&gt;
        if precision &amp;gt;= 11 and m &amp;gt; 0 and d &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;j F Y&#039;, string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
        elseif precision == 10 and m &amp;gt; 0 then&lt;br /&gt;
            format, date = &#039;F Y&#039;, string.format(&#039;%04d-%02d-01&#039;, y, m)&lt;br /&gt;
        else&lt;br /&gt;
            return tostring(y)&lt;br /&gt;
        end&lt;br /&gt;
        local ok, text = pcall(lang.formatDate, lang, format, date)&lt;br /&gt;
        if ok then return text end&lt;br /&gt;
        return date&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                return formatTime(value)&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    local label = getLabel(linkedEntity)&lt;br /&gt;
                    -- Then prefer a Wikipedia article (external link)&lt;br /&gt;
                    local url = getWikipediaUrl(linkedEntity)&lt;br /&gt;
                    if url then&lt;br /&gt;
                        return &#039;[&#039; .. url .. &#039; &#039; .. (label or value.id) .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the plain label if available&lt;br /&gt;
                    if label then return label end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Formatted value of a property, or nil.&lt;br /&gt;
    local function getFormatted(pid)&lt;br /&gt;
        return formatValue(getPropertyValue(pid))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for _, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the main image (P18) with its media legend (P2096) as caption.&lt;br /&gt;
    -- Capiunto always renders images directly below the title.&lt;br /&gt;
    local function addMainImage(box)&lt;br /&gt;
        local claim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        local v = claim and claim.mainsnak and claim.mainsnak.datavalue and&lt;br /&gt;
            claim.mainsnak.datavalue.value&lt;br /&gt;
        if not v then return end&lt;br /&gt;
        addCategory(&#039;Has image&#039;)&lt;br /&gt;
        local caption = getQualifierValue(claim, &#039;P2096&#039;)&lt;br /&gt;
        if caption == &#039;&#039; then caption = nil end&lt;br /&gt;
        box:addImage(&#039;[[File:&#039; .. tostring(v) .. &#039;|280px]]&#039;, caption)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Leaflet/OpenStreetMap map for this entity, as HTML, or nil.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function. A module&#039;s&lt;br /&gt;
    -- return value goes through the main parse pass but NOT the preprocessor, so&lt;br /&gt;
    -- parser-function syntax would otherwise be emitted literally. We expand it&lt;br /&gt;
    -- here with frame:preprocess().&lt;br /&gt;
    local function getMap()&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                    mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return nil end&lt;br /&gt;
        addCategory(&#039;Has map&#039;)&lt;br /&gt;
        return frame:preprocess(string.format(&lt;br /&gt;
            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Social media accounts, in display order. Each entry lists one or more&lt;br /&gt;
    -- Wikidata properties (first one with a value wins) and a function that&lt;br /&gt;
    -- turns the stored identifier into a profile URL.&lt;br /&gt;
    ---@type {label: string, pids: string[], url: fun(v: string, pid: string): string?}[]&lt;br /&gt;
    local socialMedia = {&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Facebook&#039;,&lt;br /&gt;
            pids = { &#039;P2013&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.facebook.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Instagram&#039;,&lt;br /&gt;
            pids = { &#039;P2003&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.instagram.com/&#039; .. v .. &#039;/&#039;&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;YouTube&#039;,&lt;br /&gt;
            pids = { &#039;P2397&#039;, &#039;P11245&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P11245&#039; then&lt;br /&gt;
                    return &#039;https://www.youtube.com/@&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.youtube.com/channel/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;TikTok&#039;,&lt;br /&gt;
            pids = { &#039;P7085&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.tiktok.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;X&#039;,&lt;br /&gt;
            pids = { &#039;P2002&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://x.com/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Threads&#039;,&lt;br /&gt;
            pids = { &#039;P11892&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://www.threads.com/@&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Bluesky&#039;,&lt;br /&gt;
            pids = { &#039;P12361&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                return &#039;https://bsky.app/profile/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;Mastodon&#039;,&lt;br /&gt;
            pids = { &#039;P4033&#039; },&lt;br /&gt;
            url = function(v)&lt;br /&gt;
                -- Stored as user@server.domain&lt;br /&gt;
                local user, server = v:match(&#039;^@?([^@]+)@(.+)$&#039;)&lt;br /&gt;
                if not user then return nil end&lt;br /&gt;
                return &#039;https://&#039; .. server .. &#039;/@&#039; .. user&lt;br /&gt;
            end&lt;br /&gt;
        },&lt;br /&gt;
        {&lt;br /&gt;
            label = &#039;LinkedIn&#039;,&lt;br /&gt;
            pids = { &#039;P4264&#039;, &#039;P6634&#039; },&lt;br /&gt;
            url = function(v, pid)&lt;br /&gt;
                if pid == &#039;P6634&#039; then&lt;br /&gt;
                    return &#039;https://www.linkedin.com/in/&#039; .. v&lt;br /&gt;
                end&lt;br /&gt;
                return &#039;https://www.linkedin.com/company/&#039; .. v&lt;br /&gt;
            end&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    -- Get the best string value for a property: preferred rank first, then&lt;br /&gt;
    -- the first normal-rank claim. Deprecated claims (e.g. abandoned&lt;br /&gt;
    -- accounts) are skipped.&lt;br /&gt;
    local function getBestStringValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local fallback&lt;br /&gt;
        for _, claim in ipairs(entity.claims[pid]) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if type(v) == &#039;string&#039; and v ~= &#039;&#039; then&lt;br /&gt;
                if claim.rank == &#039;preferred&#039; then return v end&lt;br /&gt;
                if claim.rank ~= &#039;deprecated&#039; and not fallback then&lt;br /&gt;
                    fallback = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return fallback&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Links to the entity&#039;s social media profiles, e.g.&lt;br /&gt;
    -- &amp;quot;Facebook · Instagram · YouTube&amp;quot;, or nil.&lt;br /&gt;
    local function getSocialMedia()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        for _, site in ipairs(socialMedia) do&lt;br /&gt;
            for _, pid in ipairs(site.pids) do&lt;br /&gt;
                local v = getBestStringValue(pid)&lt;br /&gt;
                local url = v and site.url(mw.text.trim(v), pid)&lt;br /&gt;
                if url then&lt;br /&gt;
                    -- Spaces would end the external link target early&lt;br /&gt;
                    url = url:gsub(&#039; &#039;, &#039;%%20&#039;)&lt;br /&gt;
                    table.insert(links, &#039;[&#039; .. url .. &#039; &#039; .. site.label .. &#039;]&#039;)&lt;br /&gt;
                    break&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if #links == 0 then return nil end&lt;br /&gt;
        addCategory(&#039;Has social media&#039;)&lt;br /&gt;
        return table.concat(links, &#039; · &#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Official website (P856) as a link showing just the host and path.&lt;br /&gt;
    local function getWebsite()&lt;br /&gt;
        local url = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
        if type(url) ~= &#039;string&#039; or url == &#039;&#039; then return nil end&lt;br /&gt;
        addCategory(&#039;Has official website&#039;)&lt;br /&gt;
        local display = url:gsub(&#039;^https?://&#039;, &#039;&#039;):gsub(&#039;^www%.&#039;, &#039;&#039;)&lt;br /&gt;
            :gsub(&#039;/$&#039;, &#039;&#039;)&lt;br /&gt;
        return &#039;[&#039; .. url .. &#039; &#039; .. display .. &#039;]&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Footer line with links to the entity&#039;s Wikipedia article (if any) and&lt;br /&gt;
    -- its Wikidata item.&lt;br /&gt;
    local function getFooter()&lt;br /&gt;
        local links = {}&lt;br /&gt;
        local wikipediaUrl, wikipediaLabel = getWikipediaUrl(entity)&lt;br /&gt;
        if wikipediaUrl then&lt;br /&gt;
            addCategory(&#039;Has Wikipedia article&#039;)&lt;br /&gt;
            table.insert(links,&lt;br /&gt;
                &#039;[&#039; .. wikipediaUrl .. &#039; &#039; .. wikipediaLabel .. &#039;]&#039;)&lt;br /&gt;
        end&lt;br /&gt;
        table.insert(links,&lt;br /&gt;
            &#039;[https://www.wikidata.org/wiki/&#039; .. qid .. &#039; View on Wikidata]&#039;)&lt;br /&gt;
        return &#039;&amp;lt;div class=&amp;quot;pc-infobox-footer&amp;quot;&amp;gt;&#039; ..&lt;br /&gt;
            table.concat(links, &#039; · &#039;) .. &#039;&amp;lt;/div&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a section: an optional header followed by its rows. Each row is&lt;br /&gt;
    -- either { label, data } or { wikitext = ... }; rows without data are&lt;br /&gt;
    -- dropped, and the header is only shown if at least one row remains.&lt;br /&gt;
    local function addSection(box, header, rows)&lt;br /&gt;
        local present = {}&lt;br /&gt;
        for _, row in ipairs(rows) do&lt;br /&gt;
            if row.wikitext or row[2] then table.insert(present, row) end&lt;br /&gt;
        end&lt;br /&gt;
        if #present == 0 then return end&lt;br /&gt;
        if header then box:addHeader(header) end&lt;br /&gt;
        for _, row in ipairs(present) do&lt;br /&gt;
            if row.wikitext then&lt;br /&gt;
                box:addWikitext(row.wikitext)&lt;br /&gt;
            else&lt;br /&gt;
                box:addRow(row[1], row[2])&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Date and place combined into one cell, e.g. &amp;quot;1 May 1950&amp;lt;br&amp;gt;Munich&amp;quot;.&lt;br /&gt;
    local function datePlace(datePid, placePid)&lt;br /&gt;
        local date, place = getFormatted(datePid), getFormatted(placePid)&lt;br /&gt;
        if date and place then return date .. &#039;&amp;lt;br&amp;gt;&#039; .. place end&lt;br /&gt;
        return date or place&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add the links section shared by both infobox types.&lt;br /&gt;
    local function addLinks(box)&lt;br /&gt;
        addSection(box, &#039;Links&#039;, {&lt;br /&gt;
            { &#039;Website&#039;,      getWebsite() },&lt;br /&gt;
            { &#039;Social media&#039;, getSocialMedia() }&lt;br /&gt;
        })&lt;br /&gt;
        box:addWikitext(getFooter())&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local title = getLabel(entity) or qid&lt;br /&gt;
    local infobox = capiunto.create({&lt;br /&gt;
        title = title,&lt;br /&gt;
        bodyClass = &#039;infobox vcard pc-infobox&#039;&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    if getClaimEntityId(&#039;P31&#039;) == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
        addSection(infobox, nil, {&lt;br /&gt;
            { &#039;Born&#039;,       datePlace(&#039;P569&#039;, &#039;P19&#039;) },&lt;br /&gt;
            { &#039;Died&#039;,       datePlace(&#039;P570&#039;, &#039;P20&#039;) },&lt;br /&gt;
            { &#039;Occupation&#039;, getFormatted(&#039;P106&#039;) }&lt;br /&gt;
        })&lt;br /&gt;
        addCountryCategories(&#039;P27&#039;)&lt;br /&gt;
&lt;br /&gt;
        local map = getMap()&lt;br /&gt;
        if map then infobox:addWikitext(map) end&lt;br /&gt;
&lt;br /&gt;
        addLinks(infobox)&lt;br /&gt;
        return render(infobox, &#039;People&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Default: organisation/troupe infobox&lt;br /&gt;
&lt;br /&gt;
    -- Official name (P1448) as a subtitle, unless it just repeats the title&lt;br /&gt;
    local officialName = getFormatted(&#039;P1448&#039;)&lt;br /&gt;
    if officialName and officialName ~= title then&lt;br /&gt;
        infobox:addSubHeader(officialName, &#039;pc-infobox-subtitle&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Logo (P154), then the main image&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if type(logo) == &#039;string&#039; and logo ~= &#039;&#039; then&lt;br /&gt;
        addCategory(&#039;Has logo&#039;)&lt;br /&gt;
        -- Row class gives transparent logos a light backing in dark mode&lt;br /&gt;
        infobox:addImage(&#039;[[File:&#039; .. logo .. &#039;|150px]]&#039;, nil,&lt;br /&gt;
            &#039;pc-infobox-logo&#039;)&lt;br /&gt;
    end&lt;br /&gt;
    addMainImage(infobox)&lt;br /&gt;
&lt;br /&gt;
    -- Member count (P2124): the most recent value by its point in time&lt;br /&gt;
    -- (P585) qualifier, shown as e.g. &amp;quot;120 (as of 1 May 2023)&amp;quot;. Undated&lt;br /&gt;
    -- values are only used when no dated one exists, preferring preferred&lt;br /&gt;
    -- rank.&lt;br /&gt;
    local function getMemberCount()&lt;br /&gt;
        if not entity.claims or not entity.claims.P2124 then return nil end&lt;br /&gt;
        local best, bestKey, bestTime, undated&lt;br /&gt;
        for _, claim in ipairs(entity.claims.P2124) do&lt;br /&gt;
            local snak = claim.mainsnak&lt;br /&gt;
            local v = snak and snak.datavalue and snak.datavalue.value&lt;br /&gt;
            if claim.rank ~= &#039;deprecated&#039; and type(v) == &#039;table&#039; and v.amount then&lt;br /&gt;
                local q = claim.qualifiers and claim.qualifiers.P585 and&lt;br /&gt;
                    claim.qualifiers.P585[1]&lt;br /&gt;
                local t = q and q.datavalue and q.datavalue.value&lt;br /&gt;
                local sign, y, m, d&lt;br /&gt;
                if type(t) == &#039;table&#039; and t.time then&lt;br /&gt;
                    sign, y, m, d = t.time:match(&#039;^([+-]?)(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                end&lt;br /&gt;
                if y then&lt;br /&gt;
                    local key = (tonumber(y) * 10000 + tonumber(m) * 100 +&lt;br /&gt;
                        tonumber(d)) * (sign == &#039;-&#039; and -1 or 1)&lt;br /&gt;
                    if not bestKey or key &amp;gt; bestKey then&lt;br /&gt;
                        best, bestKey, bestTime = v, key, t&lt;br /&gt;
                    end&lt;br /&gt;
                elseif not undated or claim.rank == &#039;preferred&#039; then&lt;br /&gt;
                    undated = v&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        local value = best or undated&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
        local amount = tonumber((value.amount:gsub(&#039;^%+&#039;, &#039;&#039;)))&lt;br /&gt;
        if not amount then return nil end&lt;br /&gt;
        local text = lang:formatNum(amount)&lt;br /&gt;
        if bestTime and best == value then&lt;br /&gt;
            text = text .. &#039; &amp;lt;span class=&amp;quot;pc-infobox-note&amp;quot;&amp;gt;(as of &#039; ..&lt;br /&gt;
                formatTime(bestTime) .. &#039;)&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
        end&lt;br /&gt;
        return text&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local dissolved = getFormatted(&#039;P576&#039;)&lt;br /&gt;
    if dissolved then addCategory(&#039;Dissolved&#039;) end&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, nil, {&lt;br /&gt;
        { &#039;Founded&#039;,             getFormatted(&#039;P571&#039;) },&lt;br /&gt;
        { &#039;Dissolved&#039;,           dissolved },&lt;br /&gt;
        { &#039;Members&#039;,             getMemberCount() },&lt;br /&gt;
        { &#039;Parent organization&#039;, getFormatted(&#039;P749&#039;) }&lt;br /&gt;
    })&lt;br /&gt;
&lt;br /&gt;
    addSection(infobox, &#039;Location&#039;, {&lt;br /&gt;
        { &#039;Headquarters&#039;,     getFormatted(&#039;P159&#039;) },&lt;br /&gt;
        { &#039;Country&#039;,          getFormatted(&#039;P17&#039;) },&lt;br /&gt;
        { wikitext = getMap() }&lt;br /&gt;
    })&lt;br /&gt;
    addCountryCategories(&#039;P17&#039;)&lt;br /&gt;
&lt;br /&gt;
    addLinks(infobox)&lt;br /&gt;
    return render(infobox, &#039;Clubs, Societies and Institutions&#039;)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Template:DynamicInfobox&amp;diff=2087</id>
		<title>Template:DynamicInfobox</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Template:DynamicInfobox&amp;diff=2087"/>
		<updated>2026-10-21T08:45:16Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;onlyinclude&amp;gt;{{#invoke:DynamicCapiunto|main|qid={{{qid}}}}}{{#if:{{{qid|{{{1|}}}}}}|[[Category:Pages Linked to Wikidata]]}}&amp;lt;/onlyinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
Pages using this template with a QID are added to the maintenance category [[:Category:Pages Linked to Wikidata]].&lt;br /&gt;
&lt;br /&gt;
The infobox is styled by [[Template:DynamicInfobox/styles.css]].&lt;br /&gt;
&lt;br /&gt;
The infobox also adds categories based on the Wikidata values it shows:&lt;br /&gt;
* [[:Category:People]] (instance of human) or [[:Category:Clubs, Societies and Institutions]] (everything else)&lt;br /&gt;
* [[:Category:Has Wikipedia article]], [[:Category:Has image]], [[:Category:Has logo]], [[:Category:Has map]], [[:Category:Has official website]], [[:Category:Has social media]]&lt;br /&gt;
* [[:Category:Dissolved]] for organisations with a dissolution date (P576)&lt;br /&gt;
* A country category, e.g. [[:Category:Germany]], from country (P17) for organisations or country of citizenship (P27) for people. Only countries listed in &amp;lt;code&amp;gt;countryCategories&amp;lt;/code&amp;gt; in [[Module:DynamicCapiunto]] are used.&lt;br /&gt;
&lt;br /&gt;
== Example ==&lt;br /&gt;
Below is an example usage of this template with a sample Wikidata QID.&lt;br /&gt;
&lt;br /&gt;
{{DynamicInfobox|qid=Q120730912}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;templatedata&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;params&amp;quot;: {&lt;br /&gt;
    &amp;quot;qid&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Wikidata QID&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Mandatory Wikidata QID to fetch all parameters dynamically from Wikidata.&amp;quot;,&lt;br /&gt;
      &amp;quot;required&amp;quot;: true&lt;br /&gt;
    },&amp;quot;official_name&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Official Name (P1448)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Official name&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;logo&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Logo (P154)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Logo image.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;image&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Image (P18)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Image.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;headquarters&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Headquarters (P159)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Headquarters.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;founding_date&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Founding Date (P571)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Founding date.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;dissolution_date&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Dissolution Date (P576)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Dissolution date.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;official_website&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Official Website (P856)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Official website.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;country&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Country (P17)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Country.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;parent_organization&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Parent Organization (P749)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Parent organization.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;member_count&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Member Count (P2124)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Most recent member count, by its point in time (P585) qualifier, with that date shown in brackets.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;social_media&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Social media (P2013, P2003, P2397/P11245, P7085, P2002, P11892, P12361, P4033, P4264/P6634)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Links to Facebook, Instagram, YouTube, TikTok, X, Threads, Bluesky, Mastodon and LinkedIn profiles. Fetched from Wikidata; deprecated-rank accounts are skipped.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;place_of_death&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Place of Death (P20)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Place of death, shown together with the date of death for people.&amp;quot;&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;coordinates&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;string&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Coordinate Location (P625)&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Coordinate location. Fetched from Wikidata and rendered as an OpenStreetMap (Leaflet) map via the Maps extension.&amp;quot;&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Infobox for an organization. Fetches all parameters dynamically from Wikidata based on the mandatory QID.&amp;quot;,&lt;br /&gt;
  &amp;quot;format&amp;quot;: &amp;quot;inline&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/templatedata&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Template:AIGenerated&amp;diff=2038</id>
		<title>Template:AIGenerated</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Template:AIGenerated&amp;diff=2038"/>
		<updated>2026-06-29T11:08:17Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;onlyinclude&amp;gt;&amp;lt;div style=&amp;quot;border: 2px solid light-dark(#f0a500, #c47f00); background-color: light-dark(#fff8e7, #2a2000); color: light-dark(#3a2a00, #f5d78e); padding: 8px 12px; margin-bottom: 1em; font-size: 0.9em; color-scheme: light dark;&amp;quot;&amp;gt;&lt;br /&gt;
⚠️ &#039;&#039;&#039;This page was generated by an AI&#039;&#039;&#039; and has not yet been proofread by a human editor. Information may be incomplete or inaccurate.&lt;br /&gt;
&amp;lt;/div&amp;gt;[[Category:AI-Generated]]{{#ifeq:{{{patrolled|false}}}|true|[[Category:Patrolled]]|[[Category:ToPatrol]]}}&amp;lt;/onlyinclude&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;noinclude&amp;gt;&lt;br /&gt;
== Usage ==&lt;br /&gt;
Place this template at the top of AI-generated pages to inform readers and track review status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;{{AIGenerated}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;{{AIGenerated|patrolled=true}}&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
; &amp;lt;code&amp;gt;patrolled&amp;lt;/code&amp;gt; (optional, default: &amp;lt;code&amp;gt;false&amp;lt;/code&amp;gt;)&lt;br /&gt;
: Set to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt; once the page has been reviewed. Adds [[Category:Patrolled]] instead of [[Category:ToPatrol]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;templatedata&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
  &amp;quot;description&amp;quot;: &amp;quot;Marks a page as AI-generated and not yet proofread. Adds maintenance categories based on patrol status.&amp;quot;,&lt;br /&gt;
  &amp;quot;params&amp;quot;: {&lt;br /&gt;
    &amp;quot;patrolled&amp;quot;: {&lt;br /&gt;
      &amp;quot;type&amp;quot;: &amp;quot;boolean&amp;quot;,&lt;br /&gt;
      &amp;quot;label&amp;quot;: &amp;quot;Patrolled&amp;quot;,&lt;br /&gt;
      &amp;quot;description&amp;quot;: &amp;quot;Set to true if the page has been reviewed by a human editor. Defaults to false.&amp;quot;,&lt;br /&gt;
      &amp;quot;default&amp;quot;: &amp;quot;false&amp;quot;,&lt;br /&gt;
      &amp;quot;required&amp;quot;: false&lt;br /&gt;
    }&lt;br /&gt;
  },&lt;br /&gt;
  &amp;quot;format&amp;quot;: &amp;quot;inline&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/templatedata&amp;gt;&lt;br /&gt;
&amp;lt;/noinclude&amp;gt;&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2037</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2037"/>
		<updated>2026-06-29T11:08:14Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: No Wikidata QID provided&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: Entity &#039; .. qid ..&lt;br /&gt;
                   &#039; not found&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value, valueType)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                -- Extract year-month-day from +2023-01-15T00:00:00Z format&lt;br /&gt;
                local dateStr = value.time&lt;br /&gt;
                local year, month, day =&lt;br /&gt;
                    dateStr:match(&#039;^[+-]?(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                if year then&lt;br /&gt;
                    local y = tonumber(year)&lt;br /&gt;
                    local m = tonumber(month) or 0&lt;br /&gt;
                    local d = tonumber(day) or 0&lt;br /&gt;
                    -- If month or day are zero/unknown, show only the year&lt;br /&gt;
                    if m == 0 or d == 0 then&lt;br /&gt;
                        return string.format(&#039;%04d&#039;, y)&lt;br /&gt;
                    end&lt;br /&gt;
                    return string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
                end&lt;br /&gt;
                return value.time&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    local label = (linkedEntity.labels and&lt;br /&gt;
                                      linkedEntity.labels.en) and&lt;br /&gt;
                                      linkedEntity.labels.en.value or value.id&lt;br /&gt;
                    -- Then prefer an en.wikipedia sitelink (external link)&lt;br /&gt;
                    if linkedEntity.sitelinks and linkedEntity.sitelinks.enwiki and&lt;br /&gt;
                        linkedEntity.sitelinks.enwiki.url then&lt;br /&gt;
                        return&lt;br /&gt;
                            &#039;[&#039; .. linkedEntity.sitelinks.enwiki.url .. &#039; &#039; ..&lt;br /&gt;
                                label .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the English label if available&lt;br /&gt;
                    if linkedEntity.labels and linkedEntity.labels.en then&lt;br /&gt;
                        return label&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for i, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a Leaflet/OpenStreetMap map for this entity.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function. A module&#039;s&lt;br /&gt;
    -- return value goes through the main parse pass but NOT the preprocessor, so&lt;br /&gt;
    -- parser-function syntax would otherwise be emitted literally. We expand it&lt;br /&gt;
    -- here with frame:preprocess() and add the resulting HTML to the infobox.&lt;br /&gt;
    local function addMap(box)&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                            mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return end&lt;br /&gt;
        local mapHtml = frame:preprocess(string.format(&lt;br /&gt;
                            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
                            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
        box:addWikitext(mapHtml)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    local function addWikidataLink(box)&lt;br /&gt;
        box:addWikitext(&lt;br /&gt;
            &#039;&amp;lt;div style=&amp;quot;width:100%; text-align:center; font-size:85%;&amp;quot;&amp;gt;[&#039; ..&lt;br /&gt;
                &#039;https://www.wikidata.org/wiki/&#039; .. qid ..&lt;br /&gt;
                &#039; View on Wikidata]&amp;lt;/div&amp;gt;&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    local instanceId = getClaimEntityId(&#039;P31&#039;)&lt;br /&gt;
    local infobox&lt;br /&gt;
&lt;br /&gt;
    if instanceId == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        local personTitle = qid&lt;br /&gt;
        if entity.labels and entity.labels.en then&lt;br /&gt;
            personTitle = entity.labels.en.value&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        infobox = capiunto.create({&lt;br /&gt;
            title = personTitle,&lt;br /&gt;
            bodyClass = &#039;infobox vevent&#039;,&lt;br /&gt;
            bodyStyle = &#039;width: 300px;&#039;&lt;br /&gt;
        })&lt;br /&gt;
&lt;br /&gt;
        -- Add image (P18) with media legend (P2096) as caption&lt;br /&gt;
        local imageClaim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        if imageClaim then&lt;br /&gt;
            local imageVal = imageClaim.mainsnak and&lt;br /&gt;
                                 imageClaim.mainsnak.datavalue and&lt;br /&gt;
                                 imageClaim.mainsnak.datavalue.value&lt;br /&gt;
            if imageVal then&lt;br /&gt;
                local imageStr = tostring(imageVal)&lt;br /&gt;
                local caption = getQualifierValue(imageClaim, &#039;P2096&#039;)&lt;br /&gt;
                if caption and caption ~= &#039;&#039; then&lt;br /&gt;
                    infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;,&lt;br /&gt;
                                     caption)&lt;br /&gt;
                else&lt;br /&gt;
                    infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Birthplace (P19)&lt;br /&gt;
        local birthplace = getPropertyValue(&#039;P19&#039;)&lt;br /&gt;
        if birthplace then&lt;br /&gt;
            infobox:addRow(&#039;Birthplace&#039;, formatValue(birthplace))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Birthday (P569)&lt;br /&gt;
        local birthday = getPropertyValue(&#039;P569&#039;)&lt;br /&gt;
        if birthday then&lt;br /&gt;
            infobox:addRow(&#039;Birthday&#039;, formatValue(birthday))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Death (P570)&lt;br /&gt;
        local death = getPropertyValue(&#039;P570&#039;)&lt;br /&gt;
        if death then infobox:addRow(&#039;Death&#039;, formatValue(death)) end&lt;br /&gt;
&lt;br /&gt;
        -- Occupation (P106)&lt;br /&gt;
        local occupation = getPropertyValue(&#039;P106&#039;)&lt;br /&gt;
        if occupation then&lt;br /&gt;
            infobox:addRow(&#039;Occupation&#039;, formatValue(occupation))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        addMap(infobox)&lt;br /&gt;
        addWikidataLink(infobox)&lt;br /&gt;
&lt;br /&gt;
        return tostring(infobox) .. &#039;\n[[Category:People]]&#039;&lt;br /&gt;
    else&lt;br /&gt;
        -- Default: organisation/troupe infobox (existing behavior)&lt;br /&gt;
        local title = qid&lt;br /&gt;
        if entity.labels and entity.labels.en then&lt;br /&gt;
            title = entity.labels.en.value&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        infobox = capiunto.create({&lt;br /&gt;
            title = title,&lt;br /&gt;
            bodyClass = &#039;infobox vevent&#039;,&lt;br /&gt;
            bodyStyle = &#039;width: 300px;&#039;&lt;br /&gt;
        })&lt;br /&gt;
&lt;br /&gt;
        -- Add official name (P1448)&lt;br /&gt;
        local officialName = getPropertyValue(&#039;P1448&#039;)&lt;br /&gt;
        if officialName then&lt;br /&gt;
            infobox:addRow(&#039;Official Name&#039;, formatValue(officialName))&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add logo (P154)&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if logo then&lt;br /&gt;
        local logoStr = formatValue(logo)&lt;br /&gt;
        if logoStr then&lt;br /&gt;
            infobox:addImage(&#039;[[File:&#039; .. logoStr .. &#039;|150px]]&#039;, &#039;Logo&#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add image (P18) with media legend (P2096) as caption&lt;br /&gt;
    local imageClaim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
    if imageClaim then&lt;br /&gt;
        local imageVal =&lt;br /&gt;
            imageClaim.mainsnak and imageClaim.mainsnak.datavalue and&lt;br /&gt;
                imageClaim.mainsnak.datavalue.value&lt;br /&gt;
        if imageVal then&lt;br /&gt;
            local imageStr = tostring(imageVal)&lt;br /&gt;
            local caption = getQualifierValue(imageClaim, &#039;P2096&#039;)&lt;br /&gt;
            if caption and caption ~= &#039;&#039; then&lt;br /&gt;
                infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;, caption)&lt;br /&gt;
            else&lt;br /&gt;
                infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add headquarters (P159)&lt;br /&gt;
    local headquarters = getPropertyValue(&#039;P159&#039;)&lt;br /&gt;
    if headquarters then&lt;br /&gt;
        infobox:addRow(&#039;Headquarters&#039;, formatValue(headquarters))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add founding date (P571)&lt;br /&gt;
    local foundingDate = getPropertyValue(&#039;P571&#039;)&lt;br /&gt;
    if foundingDate then&lt;br /&gt;
        infobox:addRow(&#039;Founding Date&#039;, formatValue(foundingDate))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add dissolution date (P576)&lt;br /&gt;
    local dissolutionDate = getPropertyValue(&#039;P576&#039;)&lt;br /&gt;
    if dissolutionDate then&lt;br /&gt;
        infobox:addRow(&#039;Dissolution Date&#039;, formatValue(dissolutionDate))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add country (P17)&lt;br /&gt;
    local country = getPropertyValue(&#039;P17&#039;)&lt;br /&gt;
    if country then infobox:addRow(&#039;Country&#039;, formatValue(country)) end&lt;br /&gt;
&lt;br /&gt;
    -- Add parent organization (P749)&lt;br /&gt;
    local parentOrg = getPropertyValue(&#039;P749&#039;)&lt;br /&gt;
    if parentOrg then&lt;br /&gt;
        infobox:addRow(&#039;Parent Organization&#039;, formatValue(parentOrg))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add official website (P856) as full-width row at bottom&lt;br /&gt;
    local website = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
    if website then&lt;br /&gt;
        local websiteStr = formatValue(website)&lt;br /&gt;
        if websiteStr then&lt;br /&gt;
            -- Strip http:// or https:// from display text&lt;br /&gt;
            local displayUrl = websiteStr:gsub(&#039;^https?://&#039;, &#039;&#039;)&lt;br /&gt;
            infobox:addWikitext(&lt;br /&gt;
                &#039;&amp;lt;div style=&amp;quot;width:100%; text-align:center;&amp;quot;&amp;gt;[&#039; .. websiteStr ..&lt;br /&gt;
                    &#039; &#039; .. displayUrl .. &#039;]&amp;lt;/div&amp;gt;&#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    addMap(infobox)&lt;br /&gt;
    addWikidataLink(infobox)&lt;br /&gt;
&lt;br /&gt;
    return tostring(infobox) ..&lt;br /&gt;
               &#039;\n[[Category:Clubs, Societies and Institutions]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2035</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2035"/>
		<updated>2026-06-28T11:20:09Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: No Wikidata QID provided&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: Entity &#039; .. qid ..&lt;br /&gt;
                   &#039; not found&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value, valueType)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                -- Extract year-month-day from +2023-01-15T00:00:00Z format&lt;br /&gt;
                local dateStr = value.time&lt;br /&gt;
                local year, month, day =&lt;br /&gt;
                    dateStr:match(&#039;^[+-]?(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                if year then&lt;br /&gt;
                    local y = tonumber(year)&lt;br /&gt;
                    local m = tonumber(month) or 0&lt;br /&gt;
                    local d = tonumber(day) or 0&lt;br /&gt;
                    -- If month or day are zero/unknown, show only the year&lt;br /&gt;
                    if m == 0 or d == 0 then&lt;br /&gt;
                        return string.format(&#039;%04d&#039;, y)&lt;br /&gt;
                    end&lt;br /&gt;
                    return string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
                end&lt;br /&gt;
                return value.time&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    local label = (linkedEntity.labels and&lt;br /&gt;
                                      linkedEntity.labels.en) and&lt;br /&gt;
                                      linkedEntity.labels.en.value or value.id&lt;br /&gt;
                    -- Then prefer an en.wikipedia sitelink (external link)&lt;br /&gt;
                    if linkedEntity.sitelinks and linkedEntity.sitelinks.enwiki and&lt;br /&gt;
                        linkedEntity.sitelinks.enwiki.url then&lt;br /&gt;
                        return&lt;br /&gt;
                            &#039;[&#039; .. linkedEntity.sitelinks.enwiki.url .. &#039; &#039; ..&lt;br /&gt;
                                label .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the English label if available&lt;br /&gt;
                    if linkedEntity.labels and linkedEntity.labels.en then&lt;br /&gt;
                        return label&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for i, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a Leaflet/OpenStreetMap map for this entity.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function. A module&#039;s&lt;br /&gt;
    -- return value goes through the main parse pass but NOT the preprocessor, so&lt;br /&gt;
    -- parser-function syntax would otherwise be emitted literally. We expand it&lt;br /&gt;
    -- here with frame:preprocess() and add the resulting HTML to the infobox.&lt;br /&gt;
    local function addMap(box)&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                            mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return end&lt;br /&gt;
        local mapHtml = frame:preprocess(string.format(&lt;br /&gt;
                            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
                            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
        box:addWikitext(mapHtml)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a full-width link to the source Wikidata item so the underlying data&lt;br /&gt;
    -- can always be inspected, even when a referenced entity has not resolved to&lt;br /&gt;
    -- a label yet. (Replaces the Wikidata interlanguage links, which are off.)&lt;br /&gt;
    local function addWikidataLink(box)&lt;br /&gt;
        box:addWikitext(&lt;br /&gt;
            &#039;&amp;lt;div style=&amp;quot;width:100%; text-align:center; font-size:85%;&amp;quot;&amp;gt;[&#039; ..&lt;br /&gt;
                &#039;https://www.wikidata.org/wiki/&#039; .. qid ..&lt;br /&gt;
                &#039; View on Wikidata]&amp;lt;/div&amp;gt;&#039;)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    local instanceId = getClaimEntityId(&#039;P31&#039;)&lt;br /&gt;
    local infobox&lt;br /&gt;
&lt;br /&gt;
    if instanceId == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        local personTitle = qid&lt;br /&gt;
        if entity.labels and entity.labels.en then&lt;br /&gt;
            personTitle = entity.labels.en.value&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        infobox = capiunto.create({&lt;br /&gt;
            title = personTitle,&lt;br /&gt;
            bodyClass = &#039;infobox vevent&#039;,&lt;br /&gt;
            bodyStyle = &#039;width: 300px;&#039;&lt;br /&gt;
        })&lt;br /&gt;
&lt;br /&gt;
        -- Add image (P18) with media legend (P2096) as caption&lt;br /&gt;
        local imageClaim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        if imageClaim then&lt;br /&gt;
            local imageVal = imageClaim.mainsnak and&lt;br /&gt;
                                 imageClaim.mainsnak.datavalue and&lt;br /&gt;
                                 imageClaim.mainsnak.datavalue.value&lt;br /&gt;
            if imageVal then&lt;br /&gt;
                local imageStr = tostring(imageVal)&lt;br /&gt;
                local caption = getQualifierValue(imageClaim, &#039;P2096&#039;)&lt;br /&gt;
                if caption and caption ~= &#039;&#039; then&lt;br /&gt;
                    infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;,&lt;br /&gt;
                                     caption)&lt;br /&gt;
                else&lt;br /&gt;
                    infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Birthplace (P19)&lt;br /&gt;
        local birthplace = getPropertyValue(&#039;P19&#039;)&lt;br /&gt;
        if birthplace then&lt;br /&gt;
            infobox:addRow(&#039;Birthplace&#039;, formatValue(birthplace))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Birthday (P569)&lt;br /&gt;
        local birthday = getPropertyValue(&#039;P569&#039;)&lt;br /&gt;
        if birthday then&lt;br /&gt;
            infobox:addRow(&#039;Birthday&#039;, formatValue(birthday))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Death (P570)&lt;br /&gt;
        local death = getPropertyValue(&#039;P570&#039;)&lt;br /&gt;
        if death then infobox:addRow(&#039;Death&#039;, formatValue(death)) end&lt;br /&gt;
&lt;br /&gt;
        -- Occupation (P106)&lt;br /&gt;
        local occupation = getPropertyValue(&#039;P106&#039;)&lt;br /&gt;
        if occupation then&lt;br /&gt;
            infobox:addRow(&#039;Occupation&#039;, formatValue(occupation))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        addMap(infobox)&lt;br /&gt;
        addWikidataLink(infobox)&lt;br /&gt;
&lt;br /&gt;
        return tostring(infobox) .. &#039;\n[[Category:People]]&#039;&lt;br /&gt;
    else&lt;br /&gt;
        -- Default: organisation/troupe infobox (existing behavior)&lt;br /&gt;
        local title = qid&lt;br /&gt;
        if entity.labels and entity.labels.en then&lt;br /&gt;
            title = entity.labels.en.value&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        infobox = capiunto.create({&lt;br /&gt;
            title = title,&lt;br /&gt;
            bodyClass = &#039;infobox vevent&#039;,&lt;br /&gt;
            bodyStyle = &#039;width: 300px;&#039;&lt;br /&gt;
        })&lt;br /&gt;
&lt;br /&gt;
        -- Add official name (P1448)&lt;br /&gt;
        local officialName = getPropertyValue(&#039;P1448&#039;)&lt;br /&gt;
        if officialName then&lt;br /&gt;
            infobox:addRow(&#039;Official Name&#039;, formatValue(officialName))&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add logo (P154)&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if logo then&lt;br /&gt;
        local logoStr = formatValue(logo)&lt;br /&gt;
        if logoStr then&lt;br /&gt;
            infobox:addImage(&#039;[[File:&#039; .. logoStr .. &#039;|150px]]&#039;, &#039;Logo&#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add image (P18) with media legend (P2096) as caption&lt;br /&gt;
    local imageClaim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
    if imageClaim then&lt;br /&gt;
        local imageVal =&lt;br /&gt;
            imageClaim.mainsnak and imageClaim.mainsnak.datavalue and&lt;br /&gt;
                imageClaim.mainsnak.datavalue.value&lt;br /&gt;
        if imageVal then&lt;br /&gt;
            local imageStr = tostring(imageVal)&lt;br /&gt;
            local caption = getQualifierValue(imageClaim, &#039;P2096&#039;)&lt;br /&gt;
            if caption and caption ~= &#039;&#039; then&lt;br /&gt;
                infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;, caption)&lt;br /&gt;
            else&lt;br /&gt;
                infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add headquarters (P159)&lt;br /&gt;
    local headquarters = getPropertyValue(&#039;P159&#039;)&lt;br /&gt;
    if headquarters then&lt;br /&gt;
        infobox:addRow(&#039;Headquarters&#039;, formatValue(headquarters))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add founding date (P571)&lt;br /&gt;
    local foundingDate = getPropertyValue(&#039;P571&#039;)&lt;br /&gt;
    if foundingDate then&lt;br /&gt;
        infobox:addRow(&#039;Founding Date&#039;, formatValue(foundingDate))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add dissolution date (P576)&lt;br /&gt;
    local dissolutionDate = getPropertyValue(&#039;P576&#039;)&lt;br /&gt;
    if dissolutionDate then&lt;br /&gt;
        infobox:addRow(&#039;Dissolution Date&#039;, formatValue(dissolutionDate))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add country (P17)&lt;br /&gt;
    local country = getPropertyValue(&#039;P17&#039;)&lt;br /&gt;
    if country then infobox:addRow(&#039;Country&#039;, formatValue(country)) end&lt;br /&gt;
&lt;br /&gt;
    -- Add parent organization (P749)&lt;br /&gt;
    local parentOrg = getPropertyValue(&#039;P749&#039;)&lt;br /&gt;
    if parentOrg then&lt;br /&gt;
        infobox:addRow(&#039;Parent Organization&#039;, formatValue(parentOrg))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add official website (P856) as full-width row at bottom&lt;br /&gt;
    local website = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
    if website then&lt;br /&gt;
        local websiteStr = formatValue(website)&lt;br /&gt;
        if websiteStr then&lt;br /&gt;
            -- Strip http:// or https:// from display text&lt;br /&gt;
            local displayUrl = websiteStr:gsub(&#039;^https?://&#039;, &#039;&#039;)&lt;br /&gt;
            infobox:addWikitext(&lt;br /&gt;
                &#039;&amp;lt;div style=&amp;quot;width:100%; text-align:center;&amp;quot;&amp;gt;[&#039; .. websiteStr ..&lt;br /&gt;
                    &#039; &#039; .. displayUrl .. &#039;]&amp;lt;/div&amp;gt;&#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    addMap(infobox)&lt;br /&gt;
    addWikidataLink(infobox)&lt;br /&gt;
&lt;br /&gt;
    return tostring(infobox) ..&lt;br /&gt;
               &#039;\n[[Category:Clubs, Societies and Institutions]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2033</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2033"/>
		<updated>2026-06-28T10:44:35Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: No Wikidata QID provided&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: Entity &#039; .. qid ..&lt;br /&gt;
                   &#039; not found&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value, valueType)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                -- Extract year-month-day from +2023-01-15T00:00:00Z format&lt;br /&gt;
                local dateStr = value.time&lt;br /&gt;
                local year, month, day =&lt;br /&gt;
                    dateStr:match(&#039;^[+-]?(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                if year then&lt;br /&gt;
                    local y = tonumber(year)&lt;br /&gt;
                    local m = tonumber(month) or 0&lt;br /&gt;
                    local d = tonumber(day) or 0&lt;br /&gt;
                    -- If month or day are zero/unknown, show only the year&lt;br /&gt;
                    if m == 0 or d == 0 then&lt;br /&gt;
                        return string.format(&#039;%04d&#039;, y)&lt;br /&gt;
                    end&lt;br /&gt;
                    return string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
                end&lt;br /&gt;
                return value.time&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    local label = (linkedEntity.labels and&lt;br /&gt;
                                      linkedEntity.labels.en) and&lt;br /&gt;
                                      linkedEntity.labels.en.value or value.id&lt;br /&gt;
                    -- Then prefer an en.wikipedia sitelink (external link)&lt;br /&gt;
                    if linkedEntity.sitelinks and linkedEntity.sitelinks.enwiki and&lt;br /&gt;
                        linkedEntity.sitelinks.enwiki.url then&lt;br /&gt;
                        return&lt;br /&gt;
                            &#039;[&#039; .. linkedEntity.sitelinks.enwiki.url .. &#039; &#039; ..&lt;br /&gt;
                                label .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the English label if available&lt;br /&gt;
                    if linkedEntity.labels and linkedEntity.labels.en then&lt;br /&gt;
                        return label&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for i, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a Leaflet/OpenStreetMap map for this entity.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function. A module&#039;s&lt;br /&gt;
    -- return value goes through the main parse pass but NOT the preprocessor, so&lt;br /&gt;
    -- parser-function syntax would otherwise be emitted literally. We expand it&lt;br /&gt;
    -- here with frame:preprocess() and add the resulting HTML to the infobox.&lt;br /&gt;
    local function addMap(box)&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                            mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return end&lt;br /&gt;
        local mapHtml = frame:preprocess(string.format(&lt;br /&gt;
                            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
                            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
        box:addWikitext(mapHtml)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    local instanceId = getClaimEntityId(&#039;P31&#039;)&lt;br /&gt;
    local infobox&lt;br /&gt;
&lt;br /&gt;
    if instanceId == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        local personTitle = qid&lt;br /&gt;
        if entity.labels and entity.labels.en then&lt;br /&gt;
            personTitle = entity.labels.en.value&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        infobox = capiunto.create({&lt;br /&gt;
            title = personTitle,&lt;br /&gt;
            bodyClass = &#039;infobox vevent&#039;,&lt;br /&gt;
            bodyStyle = &#039;width: 300px;&#039;&lt;br /&gt;
        })&lt;br /&gt;
&lt;br /&gt;
        -- Add image (P18) with media legend (P2096) as caption&lt;br /&gt;
        local imageClaim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        if imageClaim then&lt;br /&gt;
            local imageVal = imageClaim.mainsnak and&lt;br /&gt;
                                 imageClaim.mainsnak.datavalue and&lt;br /&gt;
                                 imageClaim.mainsnak.datavalue.value&lt;br /&gt;
            if imageVal then&lt;br /&gt;
                local imageStr = tostring(imageVal)&lt;br /&gt;
                local caption = getQualifierValue(imageClaim, &#039;P2096&#039;)&lt;br /&gt;
                if caption and caption ~= &#039;&#039; then&lt;br /&gt;
                    infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;,&lt;br /&gt;
                                     caption)&lt;br /&gt;
                else&lt;br /&gt;
                    infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Birthplace (P19)&lt;br /&gt;
        local birthplace = getPropertyValue(&#039;P19&#039;)&lt;br /&gt;
        if birthplace then&lt;br /&gt;
            infobox:addRow(&#039;Birthplace&#039;, formatValue(birthplace))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Birthday (P569)&lt;br /&gt;
        local birthday = getPropertyValue(&#039;P569&#039;)&lt;br /&gt;
        if birthday then&lt;br /&gt;
            infobox:addRow(&#039;Birthday&#039;, formatValue(birthday))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Death (P570)&lt;br /&gt;
        local death = getPropertyValue(&#039;P570&#039;)&lt;br /&gt;
        if death then infobox:addRow(&#039;Death&#039;, formatValue(death)) end&lt;br /&gt;
&lt;br /&gt;
        -- Occupation (P106)&lt;br /&gt;
        local occupation = getPropertyValue(&#039;P106&#039;)&lt;br /&gt;
        if occupation then&lt;br /&gt;
            infobox:addRow(&#039;Occupation&#039;, formatValue(occupation))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        addMap(infobox)&lt;br /&gt;
&lt;br /&gt;
        return tostring(infobox) .. &#039;\n[[Category:People]]&#039;&lt;br /&gt;
    else&lt;br /&gt;
        -- Default: organisation/troupe infobox (existing behavior)&lt;br /&gt;
        local title = qid&lt;br /&gt;
        if entity.labels and entity.labels.en then&lt;br /&gt;
            title = entity.labels.en.value&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        infobox = capiunto.create({&lt;br /&gt;
            title = title,&lt;br /&gt;
            bodyClass = &#039;infobox vevent&#039;,&lt;br /&gt;
            bodyStyle = &#039;width: 300px;&#039;&lt;br /&gt;
        })&lt;br /&gt;
&lt;br /&gt;
        -- Add official name (P1448)&lt;br /&gt;
        local officialName = getPropertyValue(&#039;P1448&#039;)&lt;br /&gt;
        if officialName then&lt;br /&gt;
            infobox:addRow(&#039;Official Name&#039;, formatValue(officialName))&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add logo (P154)&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if logo then&lt;br /&gt;
        local logoStr = formatValue(logo)&lt;br /&gt;
        if logoStr then&lt;br /&gt;
            infobox:addImage(&#039;[[File:&#039; .. logoStr .. &#039;|150px]]&#039;, &#039;Logo&#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add image (P18) with media legend (P2096) as caption&lt;br /&gt;
    local imageClaim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
    if imageClaim then&lt;br /&gt;
        local imageVal =&lt;br /&gt;
            imageClaim.mainsnak and imageClaim.mainsnak.datavalue and&lt;br /&gt;
                imageClaim.mainsnak.datavalue.value&lt;br /&gt;
        if imageVal then&lt;br /&gt;
            local imageStr = tostring(imageVal)&lt;br /&gt;
            local caption = getQualifierValue(imageClaim, &#039;P2096&#039;)&lt;br /&gt;
            if caption and caption ~= &#039;&#039; then&lt;br /&gt;
                infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;, caption)&lt;br /&gt;
            else&lt;br /&gt;
                infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add headquarters (P159)&lt;br /&gt;
    local headquarters = getPropertyValue(&#039;P159&#039;)&lt;br /&gt;
    if headquarters then&lt;br /&gt;
        infobox:addRow(&#039;Headquarters&#039;, formatValue(headquarters))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add founding date (P571)&lt;br /&gt;
    local foundingDate = getPropertyValue(&#039;P571&#039;)&lt;br /&gt;
    if foundingDate then&lt;br /&gt;
        infobox:addRow(&#039;Founding Date&#039;, formatValue(foundingDate))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add dissolution date (P576)&lt;br /&gt;
    local dissolutionDate = getPropertyValue(&#039;P576&#039;)&lt;br /&gt;
    if dissolutionDate then&lt;br /&gt;
        infobox:addRow(&#039;Dissolution Date&#039;, formatValue(dissolutionDate))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add country (P17)&lt;br /&gt;
    local country = getPropertyValue(&#039;P17&#039;)&lt;br /&gt;
    if country then infobox:addRow(&#039;Country&#039;, formatValue(country)) end&lt;br /&gt;
&lt;br /&gt;
    -- Add parent organization (P749)&lt;br /&gt;
    local parentOrg = getPropertyValue(&#039;P749&#039;)&lt;br /&gt;
    if parentOrg then&lt;br /&gt;
        infobox:addRow(&#039;Parent Organization&#039;, formatValue(parentOrg))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add official website (P856) as full-width row at bottom&lt;br /&gt;
    local website = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
    if website then&lt;br /&gt;
        local websiteStr = formatValue(website)&lt;br /&gt;
        if websiteStr then&lt;br /&gt;
            -- Strip http:// or https:// from display text&lt;br /&gt;
            local displayUrl = websiteStr:gsub(&#039;^https?://&#039;, &#039;&#039;)&lt;br /&gt;
            infobox:addWikitext(&lt;br /&gt;
                &#039;&amp;lt;div style=&amp;quot;width:100%; text-align:center;&amp;quot;&amp;gt;[&#039; .. websiteStr ..&lt;br /&gt;
                    &#039; &#039; .. displayUrl .. &#039;]&amp;lt;/div&amp;gt;&#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    addMap(infobox)&lt;br /&gt;
&lt;br /&gt;
    return tostring(infobox) ..&lt;br /&gt;
               &#039;\n[[Category:Clubs, Societies and Institutions]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
	<entry>
		<id>https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2032</id>
		<title>Module:DynamicCapiunto</title>
		<link rel="alternate" type="text/html" href="https://www.amateur-theatre-wiki.gwi.uni-muenchen.de/index.php?title=Module:DynamicCapiunto&amp;diff=2032"/>
		<updated>2026-06-28T10:37:06Z</updated>

		<summary type="html">&lt;p&gt;Maintenance script: Deployed from Ansible&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;local capiunto = require &#039;capiunto&#039;&lt;br /&gt;
local p = {}&lt;br /&gt;
&lt;br /&gt;
function p.main(frame)&lt;br /&gt;
    local args = frame:getParent().args&lt;br /&gt;
    local qid = args.qid or args[1]&lt;br /&gt;
&lt;br /&gt;
    if not qid then&lt;br /&gt;
        return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: No Wikidata QID provided&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Register the entity association&lt;br /&gt;
    frame:callParserFunction(&#039;#unlinkedwikibase&#039;, &#039;id=&#039; .. qid)&lt;br /&gt;
&lt;br /&gt;
    -- Get entity data from UnlinkedWikibase&lt;br /&gt;
    local entity = mw.ext.UnlinkedWikibase.getEntity(qid)&lt;br /&gt;
&lt;br /&gt;
    if not entity then&lt;br /&gt;
        return &#039;&amp;lt;span class=&amp;quot;error&amp;quot;&amp;gt;Error: Entity &#039; .. qid ..&lt;br /&gt;
                   &#039; not found&amp;lt;/span&amp;gt;&#039;&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to get property value from entity&lt;br /&gt;
    local function getPropertyValue(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
&lt;br /&gt;
        local claim = claims[1]&lt;br /&gt;
        if not claim.mainsnak or not claim.mainsnak.datavalue then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return claim.mainsnak.datavalue.value&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper function to format different value types&lt;br /&gt;
    local function formatValue(value, valueType)&lt;br /&gt;
        if not value then return nil end&lt;br /&gt;
&lt;br /&gt;
        if type(value) == &#039;table&#039; then&lt;br /&gt;
            -- Handle time values&lt;br /&gt;
            if value.time then&lt;br /&gt;
                -- Extract year-month-day from +2023-01-15T00:00:00Z format&lt;br /&gt;
                local dateStr = value.time&lt;br /&gt;
                local year, month, day =&lt;br /&gt;
                    dateStr:match(&#039;^[+-]?(%d+)-(%d+)-(%d+)&#039;)&lt;br /&gt;
                if year then&lt;br /&gt;
                    local y = tonumber(year)&lt;br /&gt;
                    local m = tonumber(month) or 0&lt;br /&gt;
                    local d = tonumber(day) or 0&lt;br /&gt;
                    -- If month or day are zero/unknown, show only the year&lt;br /&gt;
                    if m == 0 or d == 0 then&lt;br /&gt;
                        return string.format(&#039;%04d&#039;, y)&lt;br /&gt;
                    end&lt;br /&gt;
                    return string.format(&#039;%04d-%02d-%02d&#039;, y, m, d)&lt;br /&gt;
                end&lt;br /&gt;
                return value.time&lt;br /&gt;
                -- Handle entity references (Q-IDs)&lt;br /&gt;
            elseif value.id then&lt;br /&gt;
                -- Register a parser cache dependency so the page is invalidated&lt;br /&gt;
                -- when UnlinkedWikibase populates or updates this entity&#039;s data.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(value.id)&lt;br /&gt;
                local linkedEntity = mw.ext.UnlinkedWikibase.getEntity(value.id)&lt;br /&gt;
                if linkedEntity then&lt;br /&gt;
                    local label = (linkedEntity.labels and&lt;br /&gt;
                                      linkedEntity.labels.en) and&lt;br /&gt;
                                      linkedEntity.labels.en.value or value.id&lt;br /&gt;
                    -- Then prefer an en.wikipedia sitelink (external link)&lt;br /&gt;
                    if linkedEntity.sitelinks and linkedEntity.sitelinks.enwiki and&lt;br /&gt;
                        linkedEntity.sitelinks.enwiki.url then&lt;br /&gt;
                        return&lt;br /&gt;
                            &#039;[&#039; .. linkedEntity.sitelinks.enwiki.url .. &#039; &#039; ..&lt;br /&gt;
                                label .. &#039;]&#039;&lt;br /&gt;
                    end&lt;br /&gt;
                    -- Fallback to the English label if available&lt;br /&gt;
                    if linkedEntity.labels and linkedEntity.labels.en then&lt;br /&gt;
                        return label&lt;br /&gt;
                    end&lt;br /&gt;
                end&lt;br /&gt;
                return value.id&lt;br /&gt;
                -- Handle monolingual text&lt;br /&gt;
            elseif value.text then&lt;br /&gt;
                return value.text&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        return tostring(value)&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get claim entity id (if the claim is an entity)&lt;br /&gt;
    local function getClaimEntityId(pid)&lt;br /&gt;
        local v = getPropertyValue(pid)&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.id then return v.id end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get the first claim object for a property&lt;br /&gt;
    local function getFirstClaimObject(pid)&lt;br /&gt;
        if not entity.claims or not entity.claims[pid] then return nil end&lt;br /&gt;
        local claims = entity.claims[pid]&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        return claims[1]&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Helper to get a qualifier value (prefer English monolingual text for P2096)&lt;br /&gt;
    local function getQualifierValue(claim, qualPid)&lt;br /&gt;
        if not claim or not claim.qualifiers or not claim.qualifiers[qualPid] then&lt;br /&gt;
            return nil&lt;br /&gt;
        end&lt;br /&gt;
        local qsnaks = claim.qualifiers[qualPid]&lt;br /&gt;
        if not qsnaks or #qsnaks == 0 then return nil end&lt;br /&gt;
        for i, q in ipairs(qsnaks) do&lt;br /&gt;
            -- Check for valid snak with datavalue&lt;br /&gt;
            if q and q.snaktype == &#039;value&#039; and q.datavalue and q.datavalue.value then&lt;br /&gt;
                local v = q.datavalue.value&lt;br /&gt;
                if type(v) == &#039;table&#039; then&lt;br /&gt;
                    -- For monolingual text, prefer English&lt;br /&gt;
                    if v.language and v.language == &#039;en&#039; and v.text then&lt;br /&gt;
                        return v.text&lt;br /&gt;
                    end&lt;br /&gt;
                else&lt;br /&gt;
                    return tostring(v)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Extract a {latitude, longitude} coordinate (P625) from an entity object.&lt;br /&gt;
    local function getCoordFromEntity(ent)&lt;br /&gt;
        if not ent or not ent.claims or not ent.claims.P625 then return nil end&lt;br /&gt;
        local claims = ent.claims.P625&lt;br /&gt;
        if not claims or #claims == 0 then return nil end&lt;br /&gt;
        local snak = claims[1].mainsnak&lt;br /&gt;
        if not snak or not snak.datavalue then return nil end&lt;br /&gt;
        local v = snak.datavalue.value&lt;br /&gt;
        if type(v) == &#039;table&#039; and v.latitude and v.longitude then return v end&lt;br /&gt;
        return nil&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add a Leaflet/OpenStreetMap map for this entity.&lt;br /&gt;
    -- Prefer the entity&#039;s own coordinate location (P625). If it has none, fall&lt;br /&gt;
    -- back to the coordinates of the entity referenced as its headquarters&lt;br /&gt;
    -- location (P159), fetched via UnlinkedWikibase.&lt;br /&gt;
    -- Rendered via the Maps extension&#039;s #display_map parser function, which the&lt;br /&gt;
    -- wiki resolves when it parses this module&#039;s returned wikitext.&lt;br /&gt;
    local function addMap(box)&lt;br /&gt;
        local coord = getCoordFromEntity(entity)&lt;br /&gt;
        if not coord then&lt;br /&gt;
            local hqId = getClaimEntityId(&#039;P159&#039;)&lt;br /&gt;
            if hqId then&lt;br /&gt;
                -- Register a parser cache dependency on the HQ entity so the&lt;br /&gt;
                -- page is invalidated when its data is populated/updated.&lt;br /&gt;
                mw.ext.UnlinkedWikibase.getLocalTitle(hqId)&lt;br /&gt;
                coord = getCoordFromEntity(&lt;br /&gt;
                            mw.ext.UnlinkedWikibase.getEntity(hqId))&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
        if not coord then return end&lt;br /&gt;
        box:addWikitext(string.format(&lt;br /&gt;
                            &#039;{{#display_map:%s,%s|width=100%%|height=200|zoom=13|service=leaflet}}&#039;,&lt;br /&gt;
                            tostring(coord.latitude), tostring(coord.longitude)))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Decide which infobox to render based on instance (P31)&lt;br /&gt;
    local instanceId = getClaimEntityId(&#039;P31&#039;)&lt;br /&gt;
    local infobox&lt;br /&gt;
&lt;br /&gt;
    if instanceId == &#039;Q5&#039; then&lt;br /&gt;
        -- Person infobox&lt;br /&gt;
        local personTitle = qid&lt;br /&gt;
        if entity.labels and entity.labels.en then&lt;br /&gt;
            personTitle = entity.labels.en.value&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        infobox = capiunto.create({&lt;br /&gt;
            title = personTitle,&lt;br /&gt;
            bodyClass = &#039;infobox vevent&#039;,&lt;br /&gt;
            bodyStyle = &#039;width: 300px;&#039;&lt;br /&gt;
        })&lt;br /&gt;
&lt;br /&gt;
        -- Add image (P18) with media legend (P2096) as caption&lt;br /&gt;
        local imageClaim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
        if imageClaim then&lt;br /&gt;
            local imageVal = imageClaim.mainsnak and&lt;br /&gt;
                                 imageClaim.mainsnak.datavalue and&lt;br /&gt;
                                 imageClaim.mainsnak.datavalue.value&lt;br /&gt;
            if imageVal then&lt;br /&gt;
                local imageStr = tostring(imageVal)&lt;br /&gt;
                local caption = getQualifierValue(imageClaim, &#039;P2096&#039;)&lt;br /&gt;
                if caption and caption ~= &#039;&#039; then&lt;br /&gt;
                    infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;,&lt;br /&gt;
                                     caption)&lt;br /&gt;
                else&lt;br /&gt;
                    infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;)&lt;br /&gt;
                end&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Birthplace (P19)&lt;br /&gt;
        local birthplace = getPropertyValue(&#039;P19&#039;)&lt;br /&gt;
        if birthplace then&lt;br /&gt;
            infobox:addRow(&#039;Birthplace&#039;, formatValue(birthplace))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Birthday (P569)&lt;br /&gt;
        local birthday = getPropertyValue(&#039;P569&#039;)&lt;br /&gt;
        if birthday then&lt;br /&gt;
            infobox:addRow(&#039;Birthday&#039;, formatValue(birthday))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        -- Death (P570)&lt;br /&gt;
        local death = getPropertyValue(&#039;P570&#039;)&lt;br /&gt;
        if death then infobox:addRow(&#039;Death&#039;, formatValue(death)) end&lt;br /&gt;
&lt;br /&gt;
        -- Occupation (P106)&lt;br /&gt;
        local occupation = getPropertyValue(&#039;P106&#039;)&lt;br /&gt;
        if occupation then&lt;br /&gt;
            infobox:addRow(&#039;Occupation&#039;, formatValue(occupation))&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        addMap(infobox)&lt;br /&gt;
&lt;br /&gt;
        return tostring(infobox) .. &#039;\n[[Category:People]]&#039;&lt;br /&gt;
    else&lt;br /&gt;
        -- Default: organisation/troupe infobox (existing behavior)&lt;br /&gt;
        local title = qid&lt;br /&gt;
        if entity.labels and entity.labels.en then&lt;br /&gt;
            title = entity.labels.en.value&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        infobox = capiunto.create({&lt;br /&gt;
            title = title,&lt;br /&gt;
            bodyClass = &#039;infobox vevent&#039;,&lt;br /&gt;
            bodyStyle = &#039;width: 300px;&#039;&lt;br /&gt;
        })&lt;br /&gt;
&lt;br /&gt;
        -- Add official name (P1448)&lt;br /&gt;
        local officialName = getPropertyValue(&#039;P1448&#039;)&lt;br /&gt;
        if officialName then&lt;br /&gt;
            infobox:addRow(&#039;Official Name&#039;, formatValue(officialName))&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add logo (P154)&lt;br /&gt;
    local logo = getPropertyValue(&#039;P154&#039;)&lt;br /&gt;
    if logo then&lt;br /&gt;
        local logoStr = formatValue(logo)&lt;br /&gt;
        if logoStr then&lt;br /&gt;
            infobox:addImage(&#039;[[File:&#039; .. logoStr .. &#039;|150px]]&#039;, &#039;Logo&#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add image (P18) with media legend (P2096) as caption&lt;br /&gt;
    local imageClaim = getFirstClaimObject(&#039;P18&#039;)&lt;br /&gt;
    if imageClaim then&lt;br /&gt;
        local imageVal =&lt;br /&gt;
            imageClaim.mainsnak and imageClaim.mainsnak.datavalue and&lt;br /&gt;
                imageClaim.mainsnak.datavalue.value&lt;br /&gt;
        if imageVal then&lt;br /&gt;
            local imageStr = tostring(imageVal)&lt;br /&gt;
            local caption = getQualifierValue(imageClaim, &#039;P2096&#039;)&lt;br /&gt;
            if caption and caption ~= &#039;&#039; then&lt;br /&gt;
                infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;, caption)&lt;br /&gt;
            else&lt;br /&gt;
                infobox:addImage(&#039;[[File:&#039; .. imageStr .. &#039;|300px]]&#039;)&lt;br /&gt;
            end&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add headquarters (P159)&lt;br /&gt;
    local headquarters = getPropertyValue(&#039;P159&#039;)&lt;br /&gt;
    if headquarters then&lt;br /&gt;
        infobox:addRow(&#039;Headquarters&#039;, formatValue(headquarters))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add founding date (P571)&lt;br /&gt;
    local foundingDate = getPropertyValue(&#039;P571&#039;)&lt;br /&gt;
    if foundingDate then&lt;br /&gt;
        infobox:addRow(&#039;Founding Date&#039;, formatValue(foundingDate))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add dissolution date (P576)&lt;br /&gt;
    local dissolutionDate = getPropertyValue(&#039;P576&#039;)&lt;br /&gt;
    if dissolutionDate then&lt;br /&gt;
        infobox:addRow(&#039;Dissolution Date&#039;, formatValue(dissolutionDate))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add country (P17)&lt;br /&gt;
    local country = getPropertyValue(&#039;P17&#039;)&lt;br /&gt;
    if country then infobox:addRow(&#039;Country&#039;, formatValue(country)) end&lt;br /&gt;
&lt;br /&gt;
    -- Add parent organization (P749)&lt;br /&gt;
    local parentOrg = getPropertyValue(&#039;P749&#039;)&lt;br /&gt;
    if parentOrg then&lt;br /&gt;
        infobox:addRow(&#039;Parent Organization&#039;, formatValue(parentOrg))&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    -- Add official website (P856) as full-width row at bottom&lt;br /&gt;
    local website = getPropertyValue(&#039;P856&#039;)&lt;br /&gt;
    if website then&lt;br /&gt;
        local websiteStr = formatValue(website)&lt;br /&gt;
        if websiteStr then&lt;br /&gt;
            -- Strip http:// or https:// from display text&lt;br /&gt;
            local displayUrl = websiteStr:gsub(&#039;^https?://&#039;, &#039;&#039;)&lt;br /&gt;
            infobox:addWikitext(&lt;br /&gt;
                &#039;&amp;lt;div style=&amp;quot;width:100%; text-align:center;&amp;quot;&amp;gt;[&#039; .. websiteStr ..&lt;br /&gt;
                    &#039; &#039; .. displayUrl .. &#039;]&amp;lt;/div&amp;gt;&#039;)&lt;br /&gt;
        end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
    addMap(infobox)&lt;br /&gt;
&lt;br /&gt;
    return tostring(infobox) ..&lt;br /&gt;
               &#039;\n[[Category:Clubs, Societies and Institutions]]&#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return p&lt;/div&gt;</summary>
		<author><name>Maintenance script</name></author>
	</entry>
</feed>