Modul:LinkedWiki: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
Zeile 8: | Zeile 8: | ||
local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' | local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' | ||
local rdfs = 'http://www.w3.org/2000/01/rdf-schema#' | local rdfs = 'http://www.w3.org/2000/01/rdf-schema#' | ||
local xsd = 'http://www.w3.org/2001/XMLSchema#' | local xsd = 'http://www.w3.org/2001/XMLSchema#' | ||
local wdt = 'http://www.wikidata.org/prop/direct/' | local wdt = 'http://www.wikidata.org/prop/direct/' | ||
Zeile 49: | Zeile 47: | ||
if not linkedwiki.isEmpty(f.args['Wikidata ID']) then | if not linkedwiki.isEmpty(f.args['Wikidata ID']) then | ||
local idConfigWikidata = 'http://www.wikidata.org' | local idConfigWikidata = 'http://www.wikidata.org' | ||
local taglang = ' | local taglang = 'de' | ||
iriWikidata = wd .. f.args['Wikidata ID'] | iriWikidata = wd .. f.args['Wikidata ID'] | ||
objWikidata = linkedwiki.new(iriWikidata, idConfigWikidata, taglang) | objWikidata = linkedwiki.new(iriWikidata, idConfigWikidata, taglang) | ||
mw.log(object:addPropertyWithIri(rp .. 'WikidataID', iriWikidata)) | mw.log(object:addPropertyWithIri(rp .. 'WikidataID', iriWikidata)) | ||
objWikidataTitle = linkedwiki.new(objWikidata:getValue(wdt .. 'P1476'), idConfigWikidata, taglang) | |||
linkWikidata = '[' .. iriWikidata .. ' ' .. f.args['Wikidata ID'] .. ']' | linkWikidata = '[' .. iriWikidata .. ' ' .. f.args['Wikidata ID'] .. ']' | ||
Zeile 72: | Zeile 60: | ||
local infobox = capiunto.create({ | local infobox = capiunto.create({ | ||
bodyStyle = 'width : 50px', | bodyStyle = 'width : 50px', | ||
bodyClass = ' | bodyClass = 'zeitschriften', | ||
title = ' | title = 'Zeitschrift', | ||
top = objWikidata:checkString(rdfs .. 'label', f.args.Title), | top = objWikidata:checkString(rdfs .. 'label', f.args.Title), | ||
topStyle = 'background:#FFD200;height:50px;font-size: 25px;vertical-align:middle' | topStyle = 'background:#FFD200;height:50px;font-size: 25px;vertical-align:middle' | ||
}) | }) | ||
infobox:addRow('Titel', objWikidataTitle:checkString(wdt .. "P1476", f.args['Titel'])) | |||
infobox:addRow(' | |||
return infobox | return infobox |
Version vom 15. April 2021, 21:37 Uhr
Die Dokumentation für dieses Modul kann unter Modul:LinkedWiki/Doku erstellt werden
local p = {}
function p.infobox(f)
local capiunto = require 'capiunto'
local linkedwiki = require 'linkedwiki'
-- init the prefix
local rdf = 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'
local rdfs = 'http://www.w3.org/2000/01/rdf-schema#'
local xsd = 'http://www.w3.org/2001/XMLSchema#'
local wdt = 'http://www.wikidata.org/prop/direct/'
local wd = 'http://www.wikidata.org/entity/'
local p = 'http://www.wikidata.org/prop/'
local pq = 'http://www.wikidata.org/prop/qualifier/'
local ps = 'http://www.wikidata.org/prop/statement/'
local dateFormat = "d M Y"
local subject = f.args.iri or linkedwiki.getCurrentIRI(); --find the iri of the current page
local object = linkedwiki.new(subject)
--object:setDebug(true)
object:removeSubject() -- delete all triples of this subject
-- Save the data in the infobox in a knowledge base
mw.log(object:addPropertyWithIri(rdf .. 'type', ri .. 'Pape'))
mw.log(object:addPropertyString(rdfs .. 'label', f.args["Titre"]))
mw.log(object:addPropertyWithIri(rp .. 'picture', f.args["Image"]))
mw.log(object:addProperty(rp .. 'nomDeNaissance', f.args['Nom de naissance']))
mw.log(object:addProperty(rp .. 'naissance', f.args['Date de naissance'], xsd .. 'date', ''))
mw.log(object:addProperty(rp .. 'naissancePrecision', f.args['Naissance précision (années)'], xsd .. 'integer', ''))
mw.log(object:addPropertyString(rp .. 'lieuDeNaissance', f.args['Lieu de naissance']))
mw.log(object:addProperty(rp .. 'deces', f.args['Date de décès'], xsd .. 'date', ''))
mw.log(object:addPropertyString(rp .. 'lieuDeDeces', f.args['Lieu de décès']))
mw.log(object:addProperty(rp .. 'electionAuPontificat', f.args['Election au pontificat'], xsd .. 'date', ''))
mw.log(object:addProperty(rp .. 'intronisation', f.args['Intronisation'], xsd .. 'date', ''))
mw.log(object:addProperty(rp .. 'finDuPontificat', f.args['Fin du pontificat'], xsd .. 'date', ''))
--compare data with Wikidata
local iriWikidata = ""
local objWikidata = nil
local objWikidataLieuNaissance = nil
local objWikidataLieuDeces = nil
local objPapeFonction = nil
local linkWikidata = ""
if not linkedwiki.isEmpty(f.args['Wikidata ID']) then
local idConfigWikidata = 'http://www.wikidata.org'
local taglang = 'de'
iriWikidata = wd .. f.args['Wikidata ID']
objWikidata = linkedwiki.new(iriWikidata, idConfigWikidata, taglang)
mw.log(object:addPropertyWithIri(rp .. 'WikidataID', iriWikidata))
objWikidataTitle = linkedwiki.new(objWikidata:getValue(wdt .. 'P1476'), idConfigWikidata, taglang)
linkWikidata = '[' .. iriWikidata .. ' ' .. f.args['Wikidata ID'] .. ']'
end
--Make infobox with capiunto
local infobox = capiunto.create({
bodyStyle = 'width : 50px',
bodyClass = 'zeitschriften',
title = 'Zeitschrift',
top = objWikidata:checkString(rdfs .. 'label', f.args.Title),
topStyle = 'background:#FFD200;height:50px;font-size: 25px;vertical-align:middle'
})
infobox:addRow('Titel', objWikidataTitle:checkString(wdt .. "P1476", f.args['Titel']))
return infobox
end
return p