Home
Random
Recent changes
Special pages
Community portal
Preferences
About Stockhub
Disclaimers
Search
User menu
Talk
Contributions
Create account
Log in
Editing
Module:Sandbox/Marsupium/Object
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
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 = {'en', 'de'} local label local i = 0 while not label and i <= #langs do i = i + 1 label = mw.wikibase.getLabelByLang(qid, langs[i]) end return label end 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 ('[[' .. sitelink .. '|' .. label .. ']]') or label local nativeLabel = wd._properties( {'multilanguage', qid, 'P1705'} ) nativeLabel = (nativeLabel and nativeLabel ~= '' and mw.ustring.format('/<small>%s</small>', nativeLabel)) or '' local name = linkedLabel .. nativeLabel .. ' [[File:Wikidata-logo.svg|12px|Wikidata|link=//www.wikidata.org/wiki/' .. qid .. ']][[File:Wikidata-Reasonator_small_logo.svg|12px|Reasonator|link=//tools.wmflabs.org/reasonator/test/?q=' .. qid .. ']]' -- time local demolished = false local timesList = {} local demolitionDate = wd._properties({qid, 'P576'}) demolitionDate = demolitionDate ~= '' and ('demolished: ' .. demolitionDate) or nil local inception = wikidata.claim({args={'P571', id=qid}}) timesList[#timesList+1] = inception local startTime = wikidata.claim({args={'P580', id=qid}}) local endTime = wikidata.claim({args={'P582', id=qid}}) local timespan = (startTime or endTime) and ((startTime or '') .. '-' .. (endTime or '')) timesList[#timesList+1] = timespan local conservationStatus = wd._properties({'raw', qid, 'P5816'}) local architecturalStyle = wikidata.claim({args={'P149', id=qid, list=', ', parameter='link'}}) timesList[#timesList+1] = (architecturalStyle and mw.ustring.format('<small>%s</small>', 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, '; ') -- architect local architect = wikidata.claim({args={'P84', id=qid, list=', ', parameter='link'}}) or '' -- 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 -- image local image = wikidata.claim({args={'P18', id=qid}}) local img = image and mw.ustring.format('[[File:%s|50x50px]]', image) or '' local catName = wikidata.claim({args={'P373', id=qid}}) local cat = catName and mw.ustring.format('[[File:Commons-logo.svg|x16px|alt=|link=//commons.wikimedia.org/wiki/Category:%s|Commons]]', 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('[[File:%s|100x100px]]', image) or '' -- TODO: implement maybe more local maplinkTemplate = [=[<maplink text="map" zoom=15 > [ { "type": "Feature", "geometry": { "type": "Point", "coordinates": [%s, %s] }, "properties": { "title": "%s", "description": "%s", "marker-symbol": "-number" } }, { "type": "ExternalData", "service": "geoshape", "ids": "%s", }, ]</maplink>]=] local mf = mw.ustring.format(maplinkTemplate, long, lat, linkedLabel, description, qid) map = frame:preprocess(mf) end -- local coordTemplate = coordinates._coord({qid=qid, name=label}) -- coordTemplate = (not coordError and coordTemplate and mw.ustring.format('<small>%s</small>', 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('{{coord|%s|%s|type:landmark|name=%s}}', coordArgs[1], coordArgs[2], label) coordTemplate2 = coordTemplate2 and frame:preprocess(coordTemplate2) coordTemplate2 = (coordTemplate2 and mw.ustring.format('<small>%s</small>', coordTemplate2)) or nil local locList = {} locList[#locList+1] = map -- locList[#locList+1] = coordTemplate locList[#locList+1] = coordTemplate2 locList[#locList+1] = wikidata.claim({args={'P131', id=qid, list=', ', parameter='link'}}) locList[#locList+1] = wikidata.claim({args={'P969', id=qid, list=', ', parameter='link'}}) -- "located on street" (P669) with "street number" (P670) qualifier local street = wd._properties( {'qualifiers', qid, 'P669', 'P670'} ) locList[#locList+1] = (street and street ~= '' and street) or nil local address = wd._properties( {'multilanguage', qid, 'P6375'} ) locList[#locList+1] = (address and address ~= '' and mw.ustring.format('<small>%s</small>', address)) or nil locList[#locList+1] = args.hours local fee = wd._properties( {'qualifiers', qid, 'P2555', 'P6001'} ) locList[#locList+1] = (fee and fee ~= '' and 'fee: ' .. fee) or nil local opening = wd._properties( {['format']="''%q <small>(%p)</small>[%s][%r]''", ['sep%q']='-', 'qualifiers', 'qualifiers', 'qualifiers', qid, 'P3025', 'P8626', 'P8627', 'P1264'} ) locList[#locList+1] = ((type(opening) == 'string') and (opening ~= '') and 'open: ' .. opening) or nil local location = table.concat(locList, '; ') -- literature local litList = {} litList[#litList+1] = args.lit -- local describedBySourceIB = wikidataIB._getValue({'P1343', parameterset=1, qid=qid, qual='P304'}) -- litList[#litList+1] = describedBySourceIB local describedBySource2 = wd._properties( {'linked', 'qualifiers', qid, 'P1343', 'P304'} ) litList[#litList+1] = describedBySource2 -- TODO: use [[Module:Cite Q]] for the books local structuraeID = wikidata.claim({args={'P454', id=qid}}) litList[#litList+1] = structuraeID and mw.ustring.format('[https://structurae.net/structures/%s Structurae]', structuraeID) local emporisID = wikidata.claim({args={'P455', id=qid}}) litList[#litList+1] = emporisID and mw.ustring.format('[https://www.emporis.com/buildings/%s Emporis]', emporisID) local archinformID = wikidata.claim({args={'P5383', id=qid}}) litList[#litList+1] = archinformID and mw.ustring.format('[https://www.archinform.net/projekte/%s.htm archINFORM]', archinformID) local berlinDID = wikidata.claim({args={'P2424', id=qid}}) litList[#litList+1] = berlinDID and mw.ustring.format('[https://www.berlin.de/landesdenkmalamt/denkmale/liste-karte-datenbank/denkmaldatenbank/daobj.php?obj_dok_nr=%s Berlin D]', berlinDID) local memoriademadridID = wikidata.claim({args={'P7372', id=qid}}) litList[#litList+1] = memoriademadridID and mw.ustring.format('[http://www.memoriademadrid.es/buscador.php?accion=VerFicha&id=%s memoriademadrid]', memoriademadridID) local misasorgID = wikidata.claim({args={'P7054', id=qid}}) litList[#litList+1] = misasorgID and mw.ustring.format('[https://misas.org/p/%s misas.org]', misasorgID) local coamID = wikidata.claim({args={'P2917', id=qid}}) litList[#litList+1] = coamID and mw.ustring.format('[https://guia-arquitectura-madrid.coam.org/#inm.%s 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, architect, location, lit, img) return tablerow end return p
Summary:
Please note that all contributions to Stockhub may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Stockhub:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Template used on this page:
Module:Sandbox/Marsupium/Object/doc
(
edit
)