Remove compatibility hack from rdf.js. Fix Zotero code instead. Move all setup to init.js
This commit is contained in:
parent
805d3ed6a6
commit
1942fb6762
5 changed files with 43 additions and 51 deletions
|
@ -1,7 +0,0 @@
|
|||
// Tweaks to get the Tabulator RDF library to work without Tabulator. All of this happens in the
|
||||
// Zotero.RDF.AJAW namespace.
|
||||
$rdf.RDFIndexedFormula = $rdf.IndexedFormula;
|
||||
$rdf.RDFSymbol = $rdf.Symbol;
|
||||
$rdf.RDFBlankNode = $rdf.BlankNode;
|
||||
|
||||
Zotero.RDF.AJAW = $rdf;
|
|
@ -1,5 +1,5 @@
|
|||
/* Set up the environment before loading the rest of the files into Zotero */
|
||||
var $rdf = {
|
||||
Zotero.RDF.AJAW = {
|
||||
Util: {
|
||||
ArrayIndexOf: function (arr, item, i) {
|
||||
//supported in all browsers except IE<9
|
||||
|
@ -20,13 +20,13 @@ var $rdf = {
|
|||
throw "RDFArrayRemove: Array did not contain " + x;
|
||||
},
|
||||
},
|
||||
tabulator: {
|
||||
log: {
|
||||
debug: Zotero.debug,
|
||||
warn: Zotero.debug
|
||||
}
|
||||
},
|
||||
alert: Zotero.debug
|
||||
};
|
||||
|
||||
var tabulator = {
|
||||
log: {
|
||||
debug: Zotero.debug,
|
||||
warn: Zotero.debug
|
||||
}
|
||||
};
|
||||
|
||||
var alert = tabulator.log.warn;
|
||||
Zotero.RDF.AJAW.$rdf = Zotero.RDF.AJAW;
|
||||
|
|
|
@ -2151,7 +2151,7 @@ Zotero.Translate.IO.String.prototype = {
|
|||
|
||||
"_initRDF":function(callback) {
|
||||
Zotero.debug("Translate: Initializing RDF data store");
|
||||
this._dataStore = new Zotero.RDF.AJAW.RDFIndexedFormula();
|
||||
this._dataStore = new Zotero.RDF.IndexedFormula();
|
||||
this.RDF = new Zotero.Translate.IO._RDFSandbox(this._dataStore);
|
||||
|
||||
if(this.contentLength) {
|
||||
|
@ -2262,9 +2262,9 @@ Zotero.Translate.IO.String.prototype = {
|
|||
/**
|
||||
* @class An API for handling RDF from the sandbox. This is exposed to translators as Zotero.RDF.
|
||||
*
|
||||
* @property {Zotero.RDF.AJAW.RDFIndexedFormula} _dataStore
|
||||
* @property {Zotero.RDF.AJAW.IndexedFormula} _dataStore
|
||||
* @property {Integer[]} _containerCounts
|
||||
* @param {Zotero.RDF.AJAW.RDFIndexedFormula} dataStore
|
||||
* @param {Zotero.RDF.AJAW.IndexedFormula} dataStore
|
||||
*/
|
||||
Zotero.Translate.IO._RDFSandbox = function(dataStore) {
|
||||
this._dataStore = dataStore;
|
||||
|
@ -2289,12 +2289,12 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
},
|
||||
|
||||
/**
|
||||
* Gets a resource as a Zotero.RDF.AJAW.RDFSymbol, rather than a string
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} about
|
||||
* @return {Zotero.RDF.AJAW.RDFSymbol}
|
||||
* Gets a resource as a Zotero.RDF.AJAW.Symbol, rather than a string
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} about
|
||||
* @return {Zotero.RDF.AJAW.Symbol}
|
||||
*/
|
||||
"_getResource":function(about) {
|
||||
return (typeof about == "object" ? about : new Zotero.RDF.AJAW.RDFSymbol(about));
|
||||
return (typeof about == "object" ? about : new Zotero.RDF.AJAW.Symbol(about));
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -2327,9 +2327,9 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Adds an RDF triple
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} about
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} relation
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} value
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} about
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} relation
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} value
|
||||
* @param {Boolean} literal Whether value should be treated as a literal (true) or a resource
|
||||
* (false)
|
||||
*/
|
||||
|
@ -2356,16 +2356,16 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Creates a new anonymous resource
|
||||
* @return {Zotero.RDF.AJAW.RDFSymbol}
|
||||
* @return {Zotero.RDF.AJAW.Symbol}
|
||||
*/
|
||||
"newResource":function() {
|
||||
return new Zotero.RDF.AJAW.RDFBlankNode();
|
||||
return new Zotero.RDF.AJAW.BlankNode();
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a new container resource
|
||||
* @param {String} type The type of the container ("bag", "seq", or "alt")
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} about The URI of the resource
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} about The URI of the resource
|
||||
* @return {Zotero.Translate.RDF.prototype.newContainer
|
||||
*/
|
||||
"newContainer":function(type, about) {
|
||||
|
@ -2386,8 +2386,8 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Adds a new element to a container
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} about The container
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} element The element to add to the container
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} about The container
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} element The element to add to the container
|
||||
* @param {Boolean} literal Whether element should be treated as a literal (true) or a resource
|
||||
* (false)
|
||||
*/
|
||||
|
@ -2395,13 +2395,13 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
const rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
|
||||
|
||||
var about = this._getResource(about);
|
||||
this._dataStore.add(about, new Zotero.RDF.AJAW.RDFSymbol(rdf+"_"+(this._containerCounts[about.toNT()]++)), element, literal);
|
||||
this._dataStore.add(about, new Zotero.RDF.AJAW.Symbol(rdf+"_"+(this._containerCounts[about.toNT()]++)), element, literal);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets all elements within a container
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} about The container
|
||||
* @return {Zotero.RDF.AJAW.RDFSymbol[]}
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} about The container
|
||||
* @return {Zotero.RDF.AJAW.Symbol[]}
|
||||
*/
|
||||
"getContainerElements":function(about) {
|
||||
const liPrefix = "http://www.w3.org/1999/02/22-rdf-syntax-ns#_";
|
||||
|
@ -2439,7 +2439,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Gets the URI a specific resource
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} resource
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} resource
|
||||
* @return {String}
|
||||
*/
|
||||
"getResourceURI":function(resource) {
|
||||
|
@ -2451,7 +2451,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Gets all resources in the RDF data store
|
||||
* @return {Zotero.RDF.AJAW.RDFSymbol[]}
|
||||
* @return {Zotero.RDF.AJAW.Symbol[]}
|
||||
*/
|
||||
"getAllResources":function() {
|
||||
var returnArray = [];
|
||||
|
@ -2463,7 +2463,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Gets all arcs (predicates) into a resource
|
||||
* @return {Zotero.RDF.AJAW.RDFSymbol[]}
|
||||
* @return {Zotero.RDF.AJAW.Symbol[]}
|
||||
* @deprecated Since 2.1. Use {@link Zotero.Translate.IO["rdf"]._RDFBase#getStatementsMatching}
|
||||
*/
|
||||
"getArcsIn":function(resource) {
|
||||
|
@ -2479,7 +2479,7 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Gets all arcs (predicates) out of a resource
|
||||
* @return {Zotero.RDF.AJAW.RDFSymbol[]}
|
||||
* @return {Zotero.RDF.AJAW.Symbol[]}
|
||||
* @deprecated Since 2.1. Use {@link Zotero.Translate.IO["rdf"]._RDFBase#getStatementsMatching}
|
||||
*/
|
||||
"getArcsOut":function(resource) {
|
||||
|
@ -2495,9 +2495,9 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Gets all subjects whose predicates point to a resource
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} resource Subject that predicates should point to
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} property Predicate
|
||||
* @return {Zotero.RDF.AJAW.RDFSymbol[]}
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} resource Subject that predicates should point to
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} property Predicate
|
||||
* @return {Zotero.RDF.AJAW.Symbol[]}
|
||||
* @deprecated Since 2.1. Use {@link Zotero.Translate.IO["rdf"]._RDFBase#getStatementsMatching}
|
||||
*/
|
||||
"getSources":function(resource, property) {
|
||||
|
@ -2513,9 +2513,9 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
|
||||
/**
|
||||
* Gets all objects of a given subject with a given predicate
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} resource Subject
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} property Predicate
|
||||
* @return {Zotero.RDF.AJAW.RDFSymbol[]}
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} resource Subject
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} property Predicate
|
||||
* @return {Zotero.RDF.AJAW.Symbol[]}
|
||||
* @deprecated Since 2.1. Use {@link Zotero.Translate.IO["rdf"]._RDFBase#getStatementsMatching}
|
||||
*/
|
||||
"getTargets":function(resource, property) {
|
||||
|
@ -2532,9 +2532,9 @@ Zotero.Translate.IO._RDFSandbox.prototype = {
|
|||
/**
|
||||
* Gets statements matching a certain pattern
|
||||
*
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} subj Subject
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} predicate Predicate
|
||||
* @param {String|Zotero.RDF.AJAW.RDFSymbol} obj Object
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} subj Subject
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} predicate Predicate
|
||||
* @param {String|Zotero.RDF.AJAW.Symbol} obj Object
|
||||
* @param {Boolean} objLiteral Whether the object is a literal (as
|
||||
* opposed to a URI)
|
||||
* @param {Boolean} justOne Whether to stop when a single result is
|
||||
|
|
|
@ -419,7 +419,7 @@ Zotero.Translate.IO.Read.prototype = {
|
|||
var baseURI = fileHandler.getURLSpecFromFile(this.file);
|
||||
|
||||
Zotero.debug("Translate: Initializing RDF data store");
|
||||
this._dataStore = new Zotero.RDF.AJAW.RDFIndexedFormula();
|
||||
this._dataStore = new Zotero.RDF.AJAW.IndexedFormula();
|
||||
var parser = new Zotero.RDF.AJAW.RDFParser(this._dataStore);
|
||||
try {
|
||||
var nodes = Zotero.Translate.IO.parseDOMXML(this._rawStream, this._charset, this.file.fileSize);
|
||||
|
@ -521,7 +521,7 @@ Zotero.Translate.IO.Write.prototype = {
|
|||
|
||||
"_initRDF":function() {
|
||||
Zotero.debug("Translate: Initializing RDF data store");
|
||||
this._dataStore = new Zotero.RDF.AJAW.RDFIndexedFormula();
|
||||
this._dataStore = new Zotero.RDF.AJAW.IndexedFormula();
|
||||
this.RDF = new Zotero.Translate.IO._RDFSandbox(this._dataStore);
|
||||
},
|
||||
|
||||
|
|
|
@ -241,8 +241,7 @@ function makeZoteroContext(isConnector) {
|
|||
'rdf/match',
|
||||
'rdf/n3parser',
|
||||
'rdf/rdfparser',
|
||||
'rdf/serialize',
|
||||
'rdf'
|
||||
'rdf/serialize'
|
||||
];
|
||||
zContext.Zotero.RDF = {AJAW:{Zotero:zContext.Zotero}};
|
||||
for (var i=0; i<rdfXpcomFiles.length; i++) {
|
||||
|
|
Loading…
Reference in a new issue