www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 05f56aa4898f0756344b5a1cd4eae3801ffef764
parent e0f6f023d8f51b39086d5e5310059fe3a3ef5e64
Author: Simon Kornblith <simon@simonster.com>
Date:   Tue,  5 Sep 2006 02:03:59 +0000

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.


Diffstat:
Mchrome/chromeFiles/content/scholar/fileInterface.js | 33++++++++++++++++++++++++++++-----
Mchrome/chromeFiles/content/scholar/xpcom/cite.js | 7+++++--
Mchrome/chromeFiles/locale/en-US/scholar/scholar.properties | 5++++-
3 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/chrome/chromeFiles/content/scholar/fileInterface.js b/chrome/chromeFiles/content/scholar/fileInterface.js @@ -91,6 +91,10 @@ var Scholar_File_Interface = new function() { function _exportDone(obj, worked) { Scholar_File_Interface.Progress.close(); _restoreUnresponsive(); + + if(!worked) { + window.alert(Scholar.getString("fileInterface.exportError")); + } } /* @@ -156,7 +160,7 @@ var Scholar_File_Interface = new function() { /* * closes items imported indicator */ - function _importDone(obj) { + function _importDone(obj, worked) { // add items to import collection for each(var itemID in obj.newItems) { _importCollection.addItem(itemID); @@ -234,6 +238,20 @@ var Scholar_File_Interface = new function() { * Shows bibliography options and creates a bibliography */ 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 newDialog = window.openDialog("chrome://scholar/content/bibliography.xul", "_blank","chrome,modal,centerscreen", io); @@ -245,9 +263,15 @@ var Scholar_File_Interface = new function() { } // generate bibliography - var csl = Scholar.Cite.getStyle(io.style); - csl.preprocessItems(items); - var bibliography = csl.createBibliography(items, format); + try { + var csl = Scholar.Cite.getStyle(io.style); + csl.preprocessItems(items); + var bibliography = csl.createBibliography(items, format); + } catch(e) { + window.alert(Scholar.getString("fileInterface.bibliographyGenerationError")); + throw(e); + return; + } if(io.output == "print") { // printable bibliography, using a hidden browser @@ -278,7 +302,6 @@ var Scholar_File_Interface = new function() { } Scholar.Browser.deleteHiddenBrowser(browser); - bibliographyStream.close(); } else if(io.output == "save-as-html") { var fStream = _saveBibliography(name, "HTML"); diff --git a/chrome/chromeFiles/content/scholar/xpcom/cite.js b/chrome/chromeFiles/content/scholar/xpcom/cite.js @@ -246,7 +246,10 @@ CSL.prototype.createBibliography = function(items, format) { var item = items[i]; var string = this._getCitation(item, "first", format, this._bib); - + if(!string) { + continue; + } + // add format if(this._bib.format) { // add citation prefix or suffix @@ -1207,7 +1210,7 @@ CSL.prototype._getCitation = function(item, position, format, bibCitElement) { } if(!type) { - throw("CSL: ERROR: no type found for item"); + return false; } Scholar.debug("CSL: using CSL type "+typeName); diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties @@ -103,9 +103,12 @@ fileInterface.export = Export fileInterface.exportedItems = Exported Items fileInterface.imported = Imported 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.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.isNot = is not