mirror of
https://github.com/zotero/zotero.git
synced 2026-10-08 03:08:19 +00:00
Fixes #74, Add an "Update Now" button in the prefs to manually query the repository for updated scrapers
This commit is contained in:
parent
67f68194af
commit
fb220f6b7b
5 changed files with 65 additions and 13 deletions
|
|
@ -97,7 +97,7 @@
|
|||
<menuitem label="&zotero.toolbar.import.label;" oncommand="Zotero_File_Interface.importFile();"/>
|
||||
<menuitem label="&zotero.toolbar.export.label;" oncommand="Zotero_File_Interface.exportFile();"/>
|
||||
<menuseparator/>
|
||||
<menuitem label="&zotero.toolbar.preferences.label;" oncommand="window.openDialog('chrome://zotero/content/preferences.xul','prefs','chrome,modal')"/>
|
||||
<menuitem label="&zotero.toolbar.preferences.label;" oncommand="window.openDialog('chrome://zotero/content/preferences.xul','zotero-prefs','chrome,modal')"/>
|
||||
<menuitem label="&zotero.toolbar.about.label;" oncommand="window.openDialog('chrome://zotero/content/about.xul','about','chrome,left=' + (window.screenX + 200) + ',top=' + (window.screenY + 100))"/>
|
||||
</menupopup>
|
||||
</toolbarbutton>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
<!-- TODO: change to prefWindow? -->
|
||||
<dialog id="winMain" title="&zotero.preferences.title;" style="min-width:400px;"
|
||||
onload="init();" ondialogaccept="accept()"
|
||||
windowtype="zotero:pref" onload="init();" ondialogaccept="accept()"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
|
||||
|
||||
<script src="preferences.js"/>
|
||||
|
|
@ -45,7 +45,10 @@
|
|||
<label value="&zotero.preferences.position.browser;"/>
|
||||
</hbox>
|
||||
|
||||
<checkbox id="autoUpdateBox" label="&zotero.preferences.autoUpdate.label;"/>
|
||||
<hbox align="center">
|
||||
<checkbox id="autoUpdateBox" label="&zotero.preferences.autoUpdate.label;"/>
|
||||
<button id="updateButton" style="margin-top:0" label="&zotero.preferences.updateNow.label;" oncommand="Zotero.Schema.updateScrapersRemote(true)"/>
|
||||
</hbox>
|
||||
|
||||
<checkbox id="reportTranslationFailure" label="&zotero.preferences.reportTranslationFailure.label;"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -127,7 +127,15 @@ Zotero.Schema = new function(){
|
|||
+ 'version=' + Zotero.version;
|
||||
|
||||
Zotero.debug('Checking repository for updates (' + url + ')');
|
||||
var get = Zotero.Utilities.HTTP.doGet(url, _updateScrapersRemoteCallback);
|
||||
|
||||
if (force){
|
||||
url += '&m=1';
|
||||
var get = Zotero.Utilities.HTTP.doGet(url, _updateScrapersRemoteCallbackManual);
|
||||
}
|
||||
else {
|
||||
var get = Zotero.Utilities.HTTP.doGet(url, _updateScrapersRemoteCallback);
|
||||
}
|
||||
|
||||
|
||||
// TODO: instead, add an observer to start and stop timer on online state change
|
||||
if (!get){
|
||||
|
|
@ -388,7 +396,7 @@ Zotero.Schema = new function(){
|
|||
/**
|
||||
* Process the response from the repository
|
||||
**/
|
||||
function _updateScrapersRemoteCallback(xmlhttp){
|
||||
function _updateScrapersRemoteCallback(xmlhttp, manual){
|
||||
if (!xmlhttp.responseXML){
|
||||
try {
|
||||
if (xmlhttp.status>1000){
|
||||
|
|
@ -401,7 +409,10 @@ Zotero.Schema = new function(){
|
|||
catch (e){
|
||||
Zotero.debug('Repository cannot be contacted');
|
||||
}
|
||||
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_RETRY_INTERVAL']);
|
||||
|
||||
if (!manual){
|
||||
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_RETRY_INTERVAL']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -415,15 +426,19 @@ Zotero.Schema = new function(){
|
|||
// Store the timestamp provided by the server
|
||||
_updateDBVersion('repository', currentTime);
|
||||
|
||||
// And the local timestamp of the update time
|
||||
var d = new Date();
|
||||
_updateDBVersion('lastcheck', Math.round(d.getTime()/1000)); // JS uses ms
|
||||
if (!manual){
|
||||
// And the local timestamp of the update time
|
||||
var d = new Date();
|
||||
_updateDBVersion('lastcheck', Math.round(d.getTime()/1000)); // JS uses ms
|
||||
}
|
||||
|
||||
if (!translatorUpdates.length && !styleUpdates.length){
|
||||
Zotero.debug('All translators and styles are up-to-date');
|
||||
Zotero.DB.commitTransaction();
|
||||
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']);
|
||||
return false;
|
||||
if (!manual){
|
||||
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
@ -438,16 +453,46 @@ Zotero.Schema = new function(){
|
|||
catch (e) {
|
||||
Zotero.debug(e, 1);
|
||||
Zotero.DB.rollbackTransaction();
|
||||
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_RETRY_INTERVAL']);
|
||||
if (!manual){
|
||||
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_RETRY_INTERVAL']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Zotero.DB.commitTransaction();
|
||||
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']);
|
||||
if (!manual){
|
||||
_setRepositoryTimer(ZOTERO_CONFIG['REPOSITORY_CHECK_INTERVAL']);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
function _updateScrapersRemoteCallbackManual(xmlhttp){
|
||||
var updated = _updateScrapersRemoteCallback(xmlhttp, true);
|
||||
|
||||
// Update the "Update Now" button in the pref dialog with the result
|
||||
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
var enumerator = wm.getEnumerator('zotero:pref');
|
||||
while (enumerator.hasMoreElements()){
|
||||
var win = enumerator.getNext();
|
||||
var button = win.window.document.getElementById('updateButton');
|
||||
if (button){
|
||||
if (updated===-1){
|
||||
var label = Zotero.getString('zotero.preferences.update.upToDate');
|
||||
}
|
||||
else if (updated){
|
||||
var label = Zotero.getString('zotero.preferences.update.updated');
|
||||
}
|
||||
else {
|
||||
var label = Zotero.getString('zotero.preferences.update.error');
|
||||
}
|
||||
button.setAttribute('label', label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the interval between repository queries
|
||||
*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
<!ENTITY zotero.preferences.title "Zotero Preferences">
|
||||
<!ENTITY zotero.preferences.autoUpdate.label "Automatically check for updated scrapers">
|
||||
<!ENTITY zotero.preferences.updateNow.label "Update now">
|
||||
<!ENTITY zotero.preferences.reportTranslationFailure.label "Report broken site translators">
|
||||
<!ENTITY zotero.preferences.position.label "Display Zotero">
|
||||
<!ENTITY zotero.preferences.position.above "above">
|
||||
|
|
|
|||
|
|
@ -187,6 +187,9 @@ db.dbCorruptedNoBackup = The Zotero database appears to have become corrupted,
|
|||
db.dbRestored = The Zotero database appears to have become corrupted.\n\nYour data was restored from the last automatic backup made on %1$S at %2$S. The damaged file was saved in your Zotero directory.
|
||||
db.dbRestoreFailed = The Zotero database appears to have become corrupted, and an attempt to restore from the last automatic backup failed.\n\nA new database file has been created. The damaged file was saved in your Zotero directory.
|
||||
|
||||
zotero.preferences.update.updated = Updated
|
||||
zotero.preferences.update.upToDate = Up to date
|
||||
zotero.preferences.update.error = Error
|
||||
zotero.preferences.status.positionChange = Position change will take effect in new windows only
|
||||
|
||||
fileInterface.itemsImported = Importing items...
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue