Update default locate engines (#4125)

This commit is contained in:
Abe Jellinek 2024-05-15 05:45:38 -04:00 committed by GitHub
parent 8f065d9f1f
commit bb146328b8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 35 additions and 18 deletions

View file

@ -49,6 +49,11 @@ Zotero.LocateManager = new function() {
catch (e) {
Zotero.logError(e);
}
if (this._needsMigration) {
this._needsMigration = false;
await this.migrateEngines();
}
}
/**
@ -149,6 +154,28 @@ Zotero.LocateManager = new function() {
for (let engine of this.getEngines()) engine._updateIcon();
}
this.migrateEngines = async function () {
if (!_locateEngines) {
this._needsMigration = true;
return;
}
for (let engine of this.getEngines()) {
try {
if (engine.name === 'CrossRef Lookup') {
this.removeEngine(engine);
}
else if (engine.name === 'Google Scholar Search') {
engine.name = 'Google Scholar';
}
}
catch (e) {
Zotero.logError(e);
}
}
_serializeLocateEngines();
};
/**
* Writes the engines to disk; called from the nsITimer spawned by _serializeLocateEngines
*/
@ -452,7 +479,7 @@ Zotero.LocateManager = new function() {
"image/vnd.microsoft.icon": "ico"
};
if (!this._iconSourceURI.startsWith('http') && !this._iconSourceURI.startsWith('https')) {
if (!this._iconSourceURI.startsWith('http:') && !this._iconSourceURI.startsWith('https:') && !this._iconSourceURI.startsWith('chrome:')) {
return;
}

View file

@ -44,7 +44,7 @@ Zotero.Prefs = new function() {
// Process pref version updates
var fromVersion = this.get('prefVersion');
var toVersion = 10;
var toVersion = 11;
if (!fromVersion) {
this.set('prefVersion', toVersion);
}
@ -134,6 +134,10 @@ Zotero.Prefs = new function() {
case 10:
// Used internally
break;
case 11:
await Zotero.LocateManager.migrateEngines();
break;
}
}
this.set('prefVersion', toVersion);

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

View file

@ -1,20 +1,6 @@
[
{
"name": "CrossRef Lookup",
"alias": "CrossRef",
"_urlTemplate": "https://crossref.org/openurl?{z:openURL}&pid=zter:zter321",
"description": "CrossRef Search Engine",
"hidden": false,
"_urlParams": [],
"_urlNamespaces": {
"z": "http://www.zotero.org/namespaces/openSearch#",
"": "http://a9.com/-/spec/opensearch/1.1/"
},
"_iconSourceURI": "https://crossref.org/favicon.ico"
},
{
"name": "Google Scholar Search",
"alias": "Google Scholar",
"name": "Google Scholar",
"_urlTemplate": "https://scholar.google.com/scholar?as_q=&as_epq={z:title}&as_occt=title&as_sauthors={rft:aufirst?}+{rft:aulast?}&as_ylo={z:year?}&as_yhi={z:year?}&as_sdt=1.&as_sdtp=on&as_sdtf=&as_sdts=22&",
"description": "Google Scholar Search",
"hidden": false,
@ -24,6 +10,6 @@
"z": "http://www.zotero.org/namespaces/openSearch#",
"": "http://a9.com/-/spec/opensearch/1.1/"
},
"_iconSourceURI": "https://scholar.google.com/favicon.ico"
"_iconSourceURI": "chrome://zotero/skin/logos/google-scholar.ico"
}
]