Prompt if style in document is not from official source
This commit is contained in:
parent
02c43c3643
commit
3e69da7e4c
3 changed files with 12 additions and 9 deletions
|
@ -67,11 +67,8 @@ var Zotero_File_Interface_Bibliography = new function() {
|
|||
_io.style = Zotero.Prefs.get("export.lastStyle");
|
||||
}
|
||||
|
||||
// Initialize styles and try to load the style, attempting a download
|
||||
// Initialize styles
|
||||
yield Zotero.Styles.init();
|
||||
if (!Zotero.Styles.get(_io.style)) {
|
||||
yield Zotero.Styles.install({url: _io.style}, data.style.styleID, true);
|
||||
}
|
||||
|
||||
// add styles to list
|
||||
|
||||
|
|
|
@ -1027,6 +1027,16 @@ Zotero.Integration.Document.prototype._getSession = Zotero.Promise.coroutine(fun
|
|||
} catch(e) {
|
||||
// make sure style is defined
|
||||
if(e instanceof Zotero.Exception.Alert && e.name === "integration.error.invalidStyle") {
|
||||
if (data.style.styleID) {
|
||||
let displayError = Zotero.getString("integration.error.styleMissing", data.style.styleID);
|
||||
if (/^https?:\/\/(www\.)?(zotero\.org|citationstyles\.org)/.test(data.style.styleID) ||
|
||||
me._doc.displayAlert(displayError, DIALOG_ICON_WARNING, DIALOG_BUTTONS_YES_NO)) {
|
||||
|
||||
yield Zotero.Styles.install({url: data.style.styleID}, data.style.styleID, true);
|
||||
yield this._session.setData(data, true);
|
||||
return Zotero.Promise.resolve(this._session);
|
||||
}
|
||||
}
|
||||
return this._session.setDocPrefs(this._doc, this._app.primaryFieldType,
|
||||
this._app.secondaryFieldType).then(function(status) {
|
||||
me._doc.setDocumentData(me._session.data.serializeXML());
|
||||
|
@ -2081,10 +2091,6 @@ Zotero.Integration.Session.prototype.setData = Zotero.Promise.coroutine(function
|
|||
try {
|
||||
yield Zotero.Styles.init();
|
||||
var getStyle = Zotero.Styles.get(data.style.styleID);
|
||||
if (!getStyle) {
|
||||
yield Zotero.Styles.install({url: data.style.styleID}, data.style.styleID, true);
|
||||
getStyle = Zotero.Styles.get(data.style.styleID);
|
||||
}
|
||||
data.style.hasBibliography = getStyle.hasBibliography;
|
||||
this.style = getStyle.getCiteProc(data.style.locale, data.prefs.automaticJournalAbbreviations);
|
||||
this.style.setOutputFormat("rtf");
|
||||
|
@ -2092,7 +2098,6 @@ Zotero.Integration.Session.prototype.setData = Zotero.Promise.coroutine(function
|
|||
this.dateModified = new Object();
|
||||
} catch (e) {
|
||||
Zotero.logError(e);
|
||||
data.style.styleID = undefined;
|
||||
throw new Zotero.Exception.Alert("integration.error.invalidStyle");
|
||||
}
|
||||
|
||||
|
|
|
@ -818,6 +818,7 @@ integration.error.noBibliography = The current bibliographic style does not def
|
|||
integration.error.deletePipe = The pipe that Zotero uses to communicate with the word processor could not be initialized. Would you like Zotero to attempt to correct this error? You will be prompted for your password.
|
||||
integration.error.invalidStyle = The style you have selected does not appear to be valid. If you have created this style yourself, please ensure that it passes validation as described at https://github.com/citation-style-language/styles/wiki/Validation. Alternatively, try selecting another style.
|
||||
integration.error.fieldTypeMismatch = Zotero cannot update this document because it was created by a different word processing application with an incompatible field encoding. In order to make a document compatible with both Word and LibreOffice, open the document in the word processor with which it was originally created and switch the field type to Bookmarks in the Zotero Document Preferences.
|
||||
integration.error.styleMissing = The citation style used in this document is missing. Would you like to install it from %S?
|
||||
|
||||
integration.replace = Replace this Zotero field?
|
||||
integration.missingItem.single = The highlighted citation no longer exists in your Zotero database. Do you want to select a substitute item?
|
||||
|
|
Loading…
Reference in a new issue