Module:Sandbox/Marsupium/Object Explained
local p =
local wd = require('Module:Wd')local wikidata = require('Module:Wikidata')-- local wikidataIB = require('Module:WikidataIB')local coordinates = require('Module:Coordinates')-- local mapframe = require('Module:Mapframe')
local function findLabel(qid) local langs = local label local i = 0 while not label and i <= #langs do i = i + 1 label = mw.wikibase.getLabelByLang(qid, langs[i]) end return labelend
function p.object(frame) local args = frame:getParent.args local qid = mw.text.trim(frame.args[1]) or 'Q4115189' -- name local sitelink = mw.wikibase.getSitelink(qid) local label = findLabel(qid) or qid local linkedLabel = sitelink and ('' .. label .. '') or label local nativeLabel = wd._properties nativeLabel = (nativeLabel and nativeLabel ~= and mw.ustring.format('/%s', nativeLabel)) or local name = linkedLabel .. nativeLabel .. ' ' -- time local demolished = false local timesList = local demolitionDate = wd._properties demolitionDate = demolitionDate ~= and ('demolished: ' .. demolitionDate) or nil local inception = wikidata.claim timesList[#timesList+1] = inception local startTime = wikidata.claim local endTime = wikidata.claim local timespan = (startTime or endTime) and ((startTime or ) .. '-' .. (endTime or )) timesList[#timesList+1] = timespan local conservationStatus = wd._properties local architecturalStyle = wikidata.claim timesList[#timesList+1] = (architecturalStyle and mw.ustring.format('%s', architecturalStyle)) if demolitionDate or (conservationStatus
'Q56556915') then demolished = true timesList[#timesList+1] = demolitionDate timesList[#timesList+1] = 'demolished or destroyed' end local timesAndStyles = table.concat(timesList, '; ') -- creators local creatorList = -- architect creatorList[#creatorList+1] = wikidata.claim or nil -- architect sortkey local architectSort = local bestArchStmts = mw.wikibase.getBestStatements(qid, 'P84') if bestArchStmts[1] and bestArchStmts[1].mainsnak.datavalue then -- no "datavalue" for unknown value local bestArchID = bestArchStmts[1].mainsnak.datavalue.value.id local bestFamilyNameStmts = mw.wikibase.getBestStatements(bestArchID, 'P734') if bestFamilyNameStmts[1] and bestFamilyNameStmts[1].mainsnak.datavalue then local bestFamilyNameID = bestFamilyNameStmts[1].mainsnak.datavalue.value.id local i = 0 while not label and i <= #langs do i = i + 1 label = mw.wikibase.getLabelByLang(qid, langs[i]) end
local architectSortValue = findLabel(bestFamilyNameID) architectSort = architectSortValue and mw.ustring.format('data-sort-value="%s"|', architectSortValue) or end end creatorList[#creatorList+1] = wikidata.claim or nil local creators = table.concat(creatorList, '; ') -- image local image = wikidata.claim local img = image and mw.ustring.format('', image) or local catName = wikidata.claim local cat = catName and mw.ustring.format('', mw.uri.encode(catName, 'WIKI')) or local img = img .. cat -- location local coordStatements = mw.wikibase.getBestStatements(qid, 'P625') local coordError = false if not coordStatements or #coordStatements
0 then coordError = true end local hasNoValue = not coordError and (coordStatements[1].mainsnak and (coordStatements[1].mainsnak.snaktype
'novalue' or coordStatements[1].mainsnak.snaktype
'somevalue')) if hasNoValue then coordError = true end local map local wdCoords = not coordError and coordStatements[1]['mainsnak']['datavalue']['value'] if wdCoords then local lat, long = tonumber(wdCoords['latitude']), tonumber(wdCoords['longitude']) local description = image and mw.ustring.format('', image) or -- TODO: implement maybe more local maplinkTemplate = [=[<maplink text="map" zoom=15 >
[
{
"type": "Feature",
"geometry": { "type": "Point", "coordinates": [%s, %s] }, "properties": }, , ]]=] local mf = mw.ustring.format(maplinkTemplate, long, lat, linkedLabel, description, qid) map = frame:preprocess(mf) end-- local coordTemplate = coordinates._coord-- coordTemplate = (not coordError and coordTemplate and mw.ustring.format('%s', coordTemplate)) or nil local coordArgs = local math_mod = require("Module:Math") local entity = mw.wikibase.getEntityObject(qid) if entity and entity.claims and entity.claims.P625 and entity.claims.P625[1].mainsnak.snaktype
'value' then local precision = entity.claims.P625[1].mainsnak.datavalue.value.precision coordArgs[1] = entity.claims.P625[1].mainsnak.datavalue.value.latitude coordArgs[2] = entity.claims.P625[1].mainsnak.datavalue.value.longitude if precision then precision = -math_mod._round(math.log(precision)/math.log(10),0) coordArgs[1] = math_mod._round(coordArgs[1],precision) coordArgs[2] = math_mod._round(coordArgs[2],precision) end end local coordTemplate2 = not coordError and mw.ustring.format('', coordArgs[1], coordArgs[2], label) coordTemplate2 = coordTemplate2 and frame:preprocess(coordTemplate2) coordTemplate2 = (coordTemplate2 and mw.ustring.format('%s', coordTemplate2)) or nil local locList = locList[#locList+1] = map-- locList[#locList+1] = coordTemplate locList[#locList+1] = coordTemplate2 locList[#locList+1] = wikidata.claim locList[#locList+1] = wikidata.claim locList[#locList+1] = wikidata.claim -- "located on street" (P669) with "street number" (P670) qualifier local street = wd._properties locList[#locList+1] = (street and street ~= and street) or nil local address = wd._properties locList[#locList+1] = (address and address ~= and mw.ustring.format('%s', address)) or nil locList[#locList+1] = args.hours local fee = wd._properties locList[#locList+1] = (fee and fee ~= and 'fee: ' .. fee) or nil local opening = wd._properties locList[#locList+1] = ((type(opening)
'string') and (opening ~= ) and 'open: ' .. opening) or nil local location = table.concat(locList, '; ') local osmElement = wikidata.claim location = osmElement and location .. mw.ustring.format(' ', osmElement) or location local osmRelation = wikidata.claim location = osmRelation and location .. mw.ustring.format(' ', osmRelation) or location -- literature local litList = litList[#litList+1] = args.lit-- local describedBySourceIB = wikidataIB._getValue-- litList[#litList+1] = describedBySourceIB local describedBySource2 = wd._properties litList[#litList+1] = describedBySource2 -- TODO: use for the books local archnetID = wikidata.claim litList[#litList+1] = archnetID and mw.ustring.format('Archnet', archnetID) local structuraeID = wikidata.claim litList[#litList+1] = structuraeID and mw.ustring.format('Structurae', structuraeID) local emporisID = wikidata.claim litList[#litList+1] = emporisID and mw.ustring.format('Emporis', emporisID) local berlinDID = wikidata.claim litList[#litList+1] = berlinDID and mw.ustring.format('Berlin D', berlinDID) local bildindexID = wikidata.claim litList[#litList+1] = bildindexID and mw.ustring.format('Bildindex', bildindexID) local archinformID = wikidata.claim litList[#litList+1] = archinformID and mw.ustring.format('archINFORM', archinformID) local memoriademadridID = wikidata.claim litList[#litList+1] = memoriademadridID and mw.ustring.format('memoriademadrid', memoriademadridID) local misasorgID = wikidata.claim litList[#litList+1] = misasorgID and mw.ustring.format('misas.org', misasorgID) local coamID = wikidata.claim litList[#litList+1] = coamID and mw.ustring.format('COAM', coamID) local lit = '\n* ' .. table.concat(litList, '\n* ') local demolishedStyle = demolished and ('style="background: pink;"') or local tablerow = mw.ustring.format('\n|-%s\n| %s \n| %s \n|%s %s \n| %s \n| %s \n| %s', demolishedStyle, name, timesAndStyles, architectSort, creators, location, lit, img) return tablerowend
return p