{
"translatorID": "eaef8d43-2f17-45b3-a5cb-affb49bc5e81",
"label": "Wikidata",
"creator": "Philipp Zumstein",
"target": "^https?://(www\\.)?wikidata\\.org/wiki/Q",
"minVersion": "3.0",
"maxVersion": "",
"priority": 100,
"inRepository": true,
"translatorType": 4,
"browserSupport": "gcsibv",
"lastUpdated": "2018-12-13 10:42:07"
}
/*
***** BEGIN LICENSE BLOCK *****
Copyright © 2017 Philipp Zumstein
This file is part of Zotero.
Zotero is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Zotero is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Zotero. If not, see .
***** END LICENSE BLOCK *****
*/
//see also https://github.com/UB-Mannheim/zotkat/blob/master/Wikidata%20QuickStatements.js
var typeMapping = {
"Q838948" : "artwork",
"Q30070318" : "audioRecording",
"Q686822" : "bill",
"Q17928402" : "blogPost",
"Q571" : "book",
"Q3331189" : "book", // Edition
"Q47461344" : "book", // written work
"Q1980247" : "bookSection",
"Q2334719" : "case",
"Q40056" : "computerProgram",
"Q23927052" : "conferencePaper",
"Q30070414" : "dictionaryEntry",
"Q49848" : "document",
"Q30070439" : "email",
"Q17329259" : "encyclopediaArticle",
"Q11424" : "film",
"Q7216866" : "forumPost",
"Q30070550" : "hearing",
"Q30070565" : "instantMessage",
"Q178651" : "interview",
"Q13442814" : "journalArticle",
"Q133492" : "letter",
"Q30070590" : "magazineArticle",
"Q87167" : "manuscript",
"Q4006" : "map",
"Q5707594" : "newspaperArticle",
"Q253623" : "patent",
"Q24634210" : "podcast",
"Q604733" : "presentation",
"Q1555508" : "radioBroadcast",
"Q10870555" : "report",
"Q820655" : "statute",
"Q1266946" : "thesis",
"Q15416" : "tvBroadcast",
"Q30070675" : "videoRecording",
"Q36774" : "webpage"
};
//see also https://www.wikidata.org/wiki/Template:Bibliographical_properties
var mapping = {
'wdt:P1476': 'title',
'wdt:P1680': 'subtitle',
'wdt:P123': 'publisher',
'wdt:P577': 'date',
'wdt:P356': 'DOI',
'wdt:P407': 'language',
'wdt:P1433': 'publicationTitle',
'wdt:P921': 'tagString',
'wdt:P50': 'creator',
'wdt:P2093': 'creator',
'wdt:P98': 'creator',
'wdt:P655': 'creator',
'wdt:P110': 'creator',
'wdt:P57': 'creator',
'wdt:P58': 'creator',
'wdt:P161': 'creator',
'wdt:P162': 'creator',
'wdt:P953': 'url',
'wdt:P478': 'volume',
'wdt:P433': 'issue',
'wdt:P304': 'pages',
'wdt:P179': 'series',
'wdt:P212': 'ISBN',
'wdt:P957': 'ISBN',
'wdt:P236': 'ISSN',
'wdt:P136': 'genre',
'wdt:P275': 'rights',
'wdt:P2047': 'runningTime',
'wdt:P750': 'distributor'
};
//creators with no special role here are treated as contributor
var creatorMapping = {
'wdt:P50': 'author',
'wdt:P2093': 'author',
'wdt:P98': 'editor',
'wdt:P655': 'translator',
'wdt:P110': 'illustrator',
'wdt:P57': 'director',
'wdt:P58': 'scriptwriter',
'wdt:P162': 'producer'
};
var namespaces = {
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"xsd": "http://www.w3.org/2001/XMLSchema#",
"rdfs": "http://www.w3.org/2000/01/rdf-schema#",
"owl": "http://www.w3.org/2002/07/owl#",
"wikibase": "http://wikiba.se/ontology-beta#",
"wdata": "https://www.wikidata.org/wiki/Special:EntityData/",
"wd": "http://www.wikidata.org/entity/",
"wds": "http://www.wikidata.org/entity/statement/",
"wdref": "http://www.wikidata.org/reference/",
"wdv": "http://www.wikidata.org/value/",
"wdt": "http://www.wikidata.org/prop/direct/",
"p": "http://www.wikidata.org/prop/",
"ps": "http://www.wikidata.org/prop/statement/",
"psv": "http://www.wikidata.org/prop/statement/value/",
"psn": "http://www.wikidata.org/prop/statement/value-normalized/",
"pq": "http://www.wikidata.org/prop/qualifier/",
"pqv": "http://www.wikidata.org/prop/qualifier/value/",
"pqn": "http://www.wikidata.org/prop/qualifier/value-normalized/",
"pr": "http://www.wikidata.org/prop/reference/",
"prv": "http://www.wikidata.org/prop/reference/value/",
"prn": "http://www.wikidata.org/prop/reference/value-normalized/",
"wdno": "http://www.wikidata.org/prop/novalue/",
"skos": "http://www.w3.org/2004/02/skos/core#",
"schema": "http://schema.org/",
"cc": "http://creativecommons.org/ns#",
"geo": "http://www.opengis.net/ont/geosparql#",
"prov": "http://www.w3.org/ns/prov#",
//usually the defintion of the xml namespace is not needed, but
//here we have to explicitely define it before using ZU.xpath
"xml": "http://www.w3.org/XML/1998/namespace"
};
function detectWeb(doc, url) {
var p31statement = doc.getElementById("P31");
if (p31statement) {
var p31values = ZU.xpath(p31statement, './/div[contains(@class, "wikibase-statementlistview")]//div[contains(@class, "wikibase-snakview-value")]/a/@title');
for (var i=0; i