closes #273, no location asked for in bibliography export (i think)
- improved bibliography (especially Chicago Manual of Style) - improved error handling for import/export/bibliography - bibliographic export now ignores notes and standalone attachment (before, they made export silently fail). an error appears if you try to generate a bibliography from only notes or standalone attachments.
This commit is contained in:
parent
e0f6f023d8
commit
05f56aa489
3 changed files with 37 additions and 8 deletions
|
@ -91,6 +91,10 @@ var Scholar_File_Interface = new function() {
|
||||||
function _exportDone(obj, worked) {
|
function _exportDone(obj, worked) {
|
||||||
Scholar_File_Interface.Progress.close();
|
Scholar_File_Interface.Progress.close();
|
||||||
_restoreUnresponsive();
|
_restoreUnresponsive();
|
||||||
|
|
||||||
|
if(!worked) {
|
||||||
|
window.alert(Scholar.getString("fileInterface.exportError"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -156,7 +160,7 @@ var Scholar_File_Interface = new function() {
|
||||||
/*
|
/*
|
||||||
* closes items imported indicator
|
* closes items imported indicator
|
||||||
*/
|
*/
|
||||||
function _importDone(obj) {
|
function _importDone(obj, worked) {
|
||||||
// add items to import collection
|
// add items to import collection
|
||||||
for each(var itemID in obj.newItems) {
|
for each(var itemID in obj.newItems) {
|
||||||
_importCollection.addItem(itemID);
|
_importCollection.addItem(itemID);
|
||||||
|
@ -234,6 +238,20 @@ var Scholar_File_Interface = new function() {
|
||||||
* Shows bibliography options and creates a bibliography
|
* Shows bibliography options and creates a bibliography
|
||||||
*/
|
*/
|
||||||
function _doBibliographyOptions(name, items) {
|
function _doBibliographyOptions(name, items) {
|
||||||
|
// make sure at least one item is not a standalone note or attachment
|
||||||
|
var haveNonNote = false;
|
||||||
|
for(var i in items) {
|
||||||
|
var type = Scholar.ItemTypes.getName(items[i].getType());
|
||||||
|
if(type != "note" && type != "attachment") {
|
||||||
|
haveNonNote = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!haveNonNote) {
|
||||||
|
window.alert(Scholar.getString("fileInterface.noReferencesError"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var io = new Object();
|
var io = new Object();
|
||||||
var newDialog = window.openDialog("chrome://scholar/content/bibliography.xul",
|
var newDialog = window.openDialog("chrome://scholar/content/bibliography.xul",
|
||||||
"_blank","chrome,modal,centerscreen", io);
|
"_blank","chrome,modal,centerscreen", io);
|
||||||
|
@ -245,9 +263,15 @@ var Scholar_File_Interface = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate bibliography
|
// generate bibliography
|
||||||
var csl = Scholar.Cite.getStyle(io.style);
|
try {
|
||||||
csl.preprocessItems(items);
|
var csl = Scholar.Cite.getStyle(io.style);
|
||||||
var bibliography = csl.createBibliography(items, format);
|
csl.preprocessItems(items);
|
||||||
|
var bibliography = csl.createBibliography(items, format);
|
||||||
|
} catch(e) {
|
||||||
|
window.alert(Scholar.getString("fileInterface.bibliographyGenerationError"));
|
||||||
|
throw(e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(io.output == "print") {
|
if(io.output == "print") {
|
||||||
// printable bibliography, using a hidden browser
|
// printable bibliography, using a hidden browser
|
||||||
|
@ -278,7 +302,6 @@ var Scholar_File_Interface = new function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
Scholar.Browser.deleteHiddenBrowser(browser);
|
Scholar.Browser.deleteHiddenBrowser(browser);
|
||||||
bibliographyStream.close();
|
|
||||||
} else if(io.output == "save-as-html") {
|
} else if(io.output == "save-as-html") {
|
||||||
var fStream = _saveBibliography(name, "HTML");
|
var fStream = _saveBibliography(name, "HTML");
|
||||||
|
|
||||||
|
|
|
@ -246,7 +246,10 @@ CSL.prototype.createBibliography = function(items, format) {
|
||||||
var item = items[i];
|
var item = items[i];
|
||||||
|
|
||||||
var string = this._getCitation(item, "first", format, this._bib);
|
var string = this._getCitation(item, "first", format, this._bib);
|
||||||
|
if(!string) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
// add format
|
// add format
|
||||||
if(this._bib.format) {
|
if(this._bib.format) {
|
||||||
// add citation prefix or suffix
|
// add citation prefix or suffix
|
||||||
|
@ -1207,7 +1210,7 @@ CSL.prototype._getCitation = function(item, position, format, bibCitElement) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!type) {
|
if(!type) {
|
||||||
throw("CSL: ERROR: no type found for item");
|
return false;
|
||||||
}
|
}
|
||||||
Scholar.debug("CSL: using CSL type "+typeName);
|
Scholar.debug("CSL: using CSL type "+typeName);
|
||||||
|
|
||||||
|
|
|
@ -103,9 +103,12 @@ fileInterface.export = Export
|
||||||
fileInterface.exportedItems = Exported Items
|
fileInterface.exportedItems = Exported Items
|
||||||
fileInterface.imported = Imported
|
fileInterface.imported = Imported
|
||||||
fileInterface.fileFormatUnsupported = No translator could be found for the given file.
|
fileInterface.fileFormatUnsupported = No translator could be found for the given file.
|
||||||
fileInterface.importError = An error occurred while trying to import the selected file. Please ensure that the file is valid and try again.
|
|
||||||
fileInterface.untitledBibliography = Untitled Bibliography
|
fileInterface.untitledBibliography = Untitled Bibliography
|
||||||
fileInterface.bibliographyHTMLTitle = Bibliography
|
fileInterface.bibliographyHTMLTitle = Bibliography
|
||||||
|
fileInterface.importError = An error occurred while trying to import the selected file. Please ensure that the file is valid and try again.
|
||||||
|
fileInterface.noReferencesError = The items you have selected contain no references. Please select one or more references and try again.
|
||||||
|
fileInterface.bibliographyGenerationError = An error occurred generating your bibliography. Please try again.
|
||||||
|
fileInterface.exportError = An error occurred while trying to export the selected file.
|
||||||
|
|
||||||
searchOperator.is = is
|
searchOperator.is = is
|
||||||
searchOperator.isNot = is not
|
searchOperator.isNot = is not
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue