Make File.getResource expect full URLs
This change makes is easier to support different URL schemes when overriding on other platforms.
This commit is contained in:
parent
6fd25419a9
commit
07464d5c84
3 changed files with 19 additions and 9 deletions
|
@ -47,7 +47,7 @@ Zotero.Date = new function(){
|
||||||
throw new Error("Unimplemented");
|
throw new Error("Unimplemented");
|
||||||
}
|
}
|
||||||
|
|
||||||
var json = JSON.parse(Zotero.File.getResource('schema/dateFormats.json'));
|
var json = JSON.parse(Zotero.File.getResource('resource://zotero/schema/dateFormats.json'));
|
||||||
var locale = Zotero.locale;
|
var locale = Zotero.locale;
|
||||||
var english = locale.startsWith('en');
|
var english = locale.startsWith('en');
|
||||||
// If no exact match, try first two characters ('de')
|
// If no exact match, try first two characters ('de')
|
||||||
|
|
|
@ -339,15 +339,25 @@ Zotero.File = new function(){
|
||||||
return xmlhttp.responseText;
|
return xmlhttp.responseText;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* Returns the contents of the given local resource.
|
* Return the contents of resource. Use this for loading
|
||||||
|
* resource/chrome URLs.
|
||||||
|
*
|
||||||
|
* @param {String} url - the resource url
|
||||||
|
* @return {String} the resource contents as a string
|
||||||
*/
|
*/
|
||||||
this.getResource = function (res) {
|
this.getResource = function (url) {
|
||||||
return getContentsFromURL(`resource://zotero/${res}`);
|
return getContentsFromURL(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getResourceAsync = function (res) {
|
/**
|
||||||
return getContentsFromURLAsync(`resource://zotero/${res}`);
|
* Return a promise for the contents of resource.
|
||||||
|
*
|
||||||
|
* @param {String} url - the resource url
|
||||||
|
* @return {Promise<String>} the resource contents as a string
|
||||||
|
*/
|
||||||
|
this.getResourceAsync = function (url) {
|
||||||
|
return getContentsFromURLAsync(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -574,7 +574,7 @@ Zotero.Schema = new function(){
|
||||||
var ModeType = Zotero.Utilities.capitalize(modeType);
|
var ModeType = Zotero.Utilities.capitalize(modeType);
|
||||||
var Mode = Zotero.Utilities.capitalize(mode);
|
var Mode = Zotero.Utilities.capitalize(mode);
|
||||||
|
|
||||||
var repotime = yield Zotero.File.getResourceAsync("schema/repotime.txt");
|
var repotime = yield Zotero.File.getResourceAsync("resource://zotero/schema/repotime.txt");
|
||||||
var date = Zotero.Date.sqlToDate(repotime.trim(), true);
|
var date = Zotero.Date.sqlToDate(repotime.trim(), true);
|
||||||
repotime = Zotero.Date.toUnixTimestamp(date);
|
repotime = Zotero.Date.toUnixTimestamp(date);
|
||||||
|
|
||||||
|
@ -1446,7 +1446,7 @@ Zotero.Schema = new function(){
|
||||||
throw ('Schema type not provided to _getSchemaSQL()');
|
throw ('Schema type not provided to _getSchemaSQL()');
|
||||||
}
|
}
|
||||||
|
|
||||||
return Zotero.File.getResourceAsync(`schema/${schema}.sql`);
|
return Zotero.File.getResourceAsync(`resource://zotero/schema/${schema}.sql`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue