diff --git a/chrome/chromeFiles/content/scholar/exportOptions.js b/chrome/chromeFiles/content/scholar/exportOptions.js
new file mode 100644
index 000000000..51dc33be8
--- /dev/null
+++ b/chrome/chromeFiles/content/scholar/exportOptions.js
@@ -0,0 +1,72 @@
+//////////////////////////////////////////////////////////////////////////////
+//
+// Scholar_File_Interface_Export
+//
+//////////////////////////////////////////////////////////////////////////////
+
+// Class to provide options for export
+
+Scholar_File_Interface_Export = new function() {
+ var _options;
+
+ this.init = init;
+ this.accept = accept;
+ this.cancel = cancel;
+
+ /*
+ * add options to export
+ */
+ function init() {
+ _options = window.arguments[0].options;
+
+ // add options to dialog
+ var dialog = document.getElementById("scholar-export-options");
+ for(var option in _options) {
+ var defValue = _options[option];
+
+ // get readable name for option
+ try {
+ var optionLabel = Scholar.getString("exportOptions."+option);
+ } catch(e) {
+ var optionLabel = option;
+ }
+
+ // right now, option interface supports only boolean values, which
+ // it interprets as checkboxes
+ Scholar.debug(option+" ("+optionLabel+") = "+defValue+" ("+typeof(defValue)+")");
+ if(typeof(defValue) == "boolean") {
+ var checkbox = document.createElement("checkbox");
+ checkbox.setAttribute("id", option);
+ checkbox.setAttribute("label", optionLabel);
+ checkbox.setAttribute("checked", (defValue ? "true" : "false"));
+ dialog.appendChild(checkbox);
+ }
+ }
+ }
+
+ /*
+ * make option array reflect status
+ */
+ function accept() {
+ for(var option in _options) {
+ var defValue = _options[option];
+ var element = document.getElementById(option);
+
+ if(typeof(defValue) == "bool") {
+ if(element.checked == "true") {
+ _options[option] = true;
+ } else {
+ _options[option] = false;
+ }
+ }
+ }
+ Scholar.debug(_options);
+ }
+
+ /*
+ * make option array reflect status
+ */
+ function cancel() {
+ window.arguments[0].options = false;
+ }
+}
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/scholar/exportOptions.xul b/chrome/chromeFiles/content/scholar/exportOptions.xul
new file mode 100644
index 000000000..8d70005de
--- /dev/null
+++ b/chrome/chromeFiles/content/scholar/exportOptions.xul
@@ -0,0 +1,14 @@
+
+
+
+
\ No newline at end of file
diff --git a/chrome/chromeFiles/content/scholar/fileInterface.js b/chrome/chromeFiles/content/scholar/fileInterface.js
index f2b59dee0..4f8787008 100644
--- a/chrome/chromeFiles/content/scholar/fileInterface.js
+++ b/chrome/chromeFiles/content/scholar/fileInterface.js
@@ -23,8 +23,7 @@ Scholar_File_Interface = new function() {
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
translation.setLocation(fp.file);
translation.setTranslator(translators[fp.filterIndex]);
- //translation.setHandler("itemCount", _exportItemCount);
- //translation.setHandler("itemDone", _exportItemDone);
+ translation.setHandler("options", _exportOptions);
translation.setHandler("done", _exportDone);
_disableUnresponsive();
Scholar_File_Interface.Progress.show(
@@ -36,18 +35,19 @@ Scholar_File_Interface = new function() {
}
/*
- * set progress indicator length
+ * closes items exported indicator
*/
- function _exportItemCount(obj, number) {
- Scholar.debug("count called with "+number);
- Scholar_File_Interface.Progress.setNumber(number);
- }
-
- /*
- * Increment progress for each item exported
- */
- function _exportItemDone(obj, item) {
- Scholar_File_Interface.Progress.increment();
+ function _exportOptions(obj, options) {
+ var io = {options:options}
+ window.openDialog("chrome://scholar/content/exportOptions.xul",
+ "_blank","chrome,modal,centerscreen", io);
+ if(io.options) {
+ // refocus dialog
+ Scholar_File_Interface.Progress.show();
+ return options;
+ } else {
+ return false;
+ }
}
/*
@@ -58,7 +58,6 @@ Scholar_File_Interface = new function() {
_restoreUnresponsive();
}
-
/*
* Creates Scholar.Translate instance and shows file picker for file import
*/
@@ -105,7 +104,6 @@ Scholar_File_Interface = new function() {
* "items imported" indicator, too.
*/
function _importItemDone(obj, item) {
- //Scholar_File_Interface.Progress.increment();
_importCollection.addItem(item.getID());
}
@@ -256,12 +254,11 @@ Scholar_File_Interface.Progress = new function() {
var _loadHeadline, _loadNumber, _outOf, _callback;
this.show = show;
- //this.setNumber = setNumber;
- //this.increment = increment;
this.close = close;
function show(headline, callback) {
if(_windowLoading || _windowLoaded) { // already loading or loaded
+ _progressWindow.focus();
return false;
}
_windowLoading = true;
@@ -275,26 +272,6 @@ Scholar_File_Interface.Progress = new function() {
_progressWindow.addEventListener("pageshow", _onWindowLoaded, false);
}
- /*function setNumber(number) {
- _outOf = number;
- if(_windowLoaded) {
- var progressMeter = _progressWindow.document.getElementById("progress-indicator");
- progressMeter.mode = "normal";
- progressMeter.value = "0%";
- }
- }
-
- function increment() {
- _loadNumber++;
- if(_windowLoaded) {
- _progressWindow.document.getElementById("progress-items").value = _loadNumber;
- if(_outOf) {
- _progressWindow.document.getElementById("progress-indicator").value = ((_loadNumber/_outOf)*100).toString()+"%";
- }
- _progressWindow.getSelection();
- }
- }*/
-
function close() {
_windowLoaded = false;
try {
@@ -307,12 +284,6 @@ Scholar_File_Interface.Progress = new function() {
_windowLoaded = true;
// do things we delayed because the winodw was loading
- /*if(_outOf) {
- var progressMeter = _progressWindow.document.getElementById("progress-indicator");
- progressMeter.mode = "normal";
- progressMeter.value = ((_loadNumber/_outOf)*100).toString()+"%";
- }
- _progressWindow.document.getElementById("progress-items").value = _loadNumber;*/
_progressWindow.document.getElementById("progress-label").value = _loadHeadline;
if(_callback) {
diff --git a/chrome/chromeFiles/content/scholar/xpcom/translate.js b/chrome/chromeFiles/content/scholar/xpcom/translate.js
index 6184cf6f2..a7681091e 100644
--- a/chrome/chromeFiles/content/scholar/xpcom/translate.js
+++ b/chrome/chromeFiles/content/scholar/xpcom/translate.js
@@ -216,6 +216,12 @@ Scholar.Translate.prototype.setTranslator = function(translator) {
* as the first argument, all handlers will be passed the current function. the
* second argument is dependent on the handler.
*
+ * options
+ * valid: export
+ * called: when options requiring user interaction are available
+ * passed: an associative array of options and default values
+ * returns: an associative array of options
+ *
* select
* valid: web
* called: when the user needs to select from a list of available items
@@ -291,13 +297,10 @@ Scholar.Translate.prototype.getTranslators = function() {
}
/*
- * gets translator options to be displayed in a dialog
- *
- * NOT IMPLEMENTED
+ * finds applicable translators from a list. if the second argument is given,
+ * extension-based exclusion is inverted, so that only detectCode is used to
+ * determine if a translator can be run.
*/
-Scholar.Translate.prototype.displayOptions = function() {
-}
-
Scholar.Translate.prototype._findTranslators = function(translators, ignoreExtensions) {
var possibleTranslators = new Array();
for(var i in translators) {
@@ -323,6 +326,9 @@ Scholar.Translate.prototype._findTranslators = function(translators, ignoreExten
return possibleTranslators;
}
+/*
+ * loads a translator into a sandbox
+ */
Scholar.Translate.prototype._loadTranslator = function() {
if(!this._sandbox || this.type == "search") {
// create a new sandbox if none exists, or for searching (so that it's
@@ -367,7 +373,16 @@ Scholar.Translate.prototype.translate = function() {
return;
}
- this._sandbox.Scholar.scraperName = this.translator[0].label;
+
+ // hack to see if there are any options, bc length does not work on objects
+ for(var i in this._displayOptions) {
+ // run handler for options if there are any
+ if(!(this._displayOptions = this._runHandler("options", this._displayOptions))) {
+ this._translationComplete(true);
+ return false;
+ }
+ break;
+ }
var returnValue;
if(this.type == "web") {
@@ -461,6 +476,8 @@ Scholar.Translate.prototype._generateSandbox = function() {
this._sandbox.Scholar.configure = function(option, value) {me._configure(option, value) };
// for adding displayed options
this._sandbox.Scholar.addOption = function(option, value) {me._addOption(option, value) };
+ // for getting the value of displayed options
+ this._sandbox.Scholar.getOption = function(option) { return me._getOption(option) };
// for loading other translators and accessing their methods
this._sandbox.Scholar.loadTranslator = function(type, translatorID) {
@@ -488,6 +505,7 @@ Scholar.Translate.prototype._generateSandbox = function() {
safeTranslator.setItem = function(arg) { return translation.setItem(arg) };
safeTranslator.setBrowser = function(arg) { return translation.setBrowser(arg) };
safeTranslator.setHandler = function(arg1, arg2) { translation.setHandler(arg1, arg2) };
+ safeTranslator.setString = function(arg) { translation.setString(arg) };
safeTranslator.setTranslator = function(arg) { return translation.setTranslator(arg) };
safeTranslator.getTranslators = function() { return translation.getTranslators() };
safeTranslator.translate = function() { return translation.translate() };
@@ -521,6 +539,11 @@ Scholar.Translate.prototype._canTranslate = function(translator, ignoreExtension
// if we're ignoring extensions, that means we already tried
// everything without ignoring extensions and it didn't work
canTranslate = !canTranslate;
+
+ // if a translator has no detectCode, don't offer it as an option
+ if(!translator.detectCode) {
+ return false;
+ }
}
} else {
var canTranslate = true;
@@ -630,6 +653,16 @@ Scholar.Translate.prototype._addOption = function(option, value) {
Scholar.debug("setting display option "+option+" to "+value);
}
+/*
+ * gets translator options that were displayed in a dialog
+ *
+ * called as getOption() in detect code
+ *
+ */
+Scholar.Translate.prototype._getOption = function(option) {
+ return this._displayOptions[option];
+}
+
/*
* makes translation API wait until done() has been called from the translator
* before executing _translationComplete
diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd b/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
index c4dd43bdd..88af8d1f9 100644
--- a/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
+++ b/chrome/chromeFiles/locale/en-US/scholar/scholar.dtd
@@ -51,4 +51,6 @@
-
\ No newline at end of file
+
+
+
\ No newline at end of file
diff --git a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties
index 9f8599b2f..2d9805c10 100644
--- a/chrome/chromeFiles/locale/en-US/scholar/scholar.properties
+++ b/chrome/chromeFiles/locale/en-US/scholar/scholar.properties
@@ -99,4 +99,7 @@ searchOperator.doesNotContain = does not contain
searchOperator.lessThan = is less than
searchOperator.greaterThan = is greater than
searchOperator.isBefore = is before
-searchOperator.isAfter = is after
\ No newline at end of file
+searchOperator.isAfter = is after
+
+exportOptions.exportNotes = Export Notes
+exportOptions.exportFileData = Export Files
\ No newline at end of file
diff --git a/scrapers.sql b/scrapers.sql
index 33c9aa80a..4cc25101a 100644
--- a/scrapers.sql
+++ b/scrapers.sql
@@ -1,4 +1,4 @@
--- 40
+-- 41
-- Set the following timestamp to the most recent scraper update date
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-08 17:12:00'));
@@ -2738,7 +2738,6 @@ function doSearch(item) {
REPLACE INTO "translators" VALUES ('0e2235e7-babf-413c-9acf-f27cce5f059c', '2006-07-05 23:40:00', 3, 'MODS (XML)', 'Simon Kornblith', 'xml',
'Scholar.addOption("exportNotes", true);
-Scholar.addOption("exportFileData", true);
function detectImport() {
var read = Scholar.read(512);
@@ -3003,10 +3002,12 @@ function doExport() {
/** NOTES **/
- for(var j in item.notes) {
- // Add note tag
- var note = {item.notes[j].note};
- mods.note += note;
+ if(Scholar.getOption("exportNotes")) {
+ for(var j in item.notes) {
+ // Add note tag
+ var note = {item.notes[j].note};
+ mods.note += note;
+ }
}
/** TAGS **/
@@ -3335,6 +3336,9 @@ function doExport() {
type = "Document";
} else if(item.itemType == "note") {
type = "Memo";
+ if(!Scholar.getOption("exportNotes")) {
+ continue;
+ }
}
if(type) {
Scholar.RDF.addStatement(resource, rdf+"type", n.bib+type, false);
@@ -3530,22 +3534,24 @@ function doExport() {
/** NOTES **/
- for(var j in item.notes) {
- var noteResource = itemResources[item.notes[j].itemID];
+ if(Scholar.getOption("exportNotes")) {
+ for(var j in item.notes) {
+ var noteResource = itemResources[item.notes[j].itemID];
+
+ // add note tag
+ Scholar.RDF.addStatement(noteResource, rdf+"type", n.bib+"Memo", false);
+ // add note value
+ Scholar.RDF.addStatement(noteResource, rdf+"value", item.notes[j].note, true);
+ // add relationship between resource and note
+ Scholar.RDF.addStatement(resource, n.dcterms+"isReferencedBy", noteResource, false);
+
+ // Add see also info to RDF
+ generateSeeAlso(resource, item.notes[j].seeAlso);
+ }
- // add note tag
- Scholar.RDF.addStatement(noteResource, rdf+"type", n.bib+"Memo", false);
- // add note value
- Scholar.RDF.addStatement(noteResource, rdf+"value", item.notes[j].note, true);
- // add relationship between resource and note
- Scholar.RDF.addStatement(resource, n.dcterms+"isReferencedBy", noteResource, false);
-
- // Add see also info to RDF
- generateSeeAlso(resource, item.notes[j].seeAlso);
- }
-
- if(item.note) {
- Scholar.RDF.addStatement(resource, rdf+"value", item.note, true);
+ if(item.note) {
+ Scholar.RDF.addStatement(resource, rdf+"value", item.note, true);
+ }
}
/** TAGS **/
@@ -4326,8 +4332,10 @@ function doExport() {
}
// notes
- for(var j in item.notes) {
- addTag("N1", item.notes[j].note);
+ if(Scholar.getOption("exportNotes")) {
+ for(var j in item.notes) {
+ addTag("N1", item.notes[j].note.replace(/[\r\n]/g, " "));
+ }
}
// tags