closes #236, Export windows should offer a default filename with extension
closes #238, present dialog if no import translator is available for a file closes #240, change XML namespaces
This commit is contained in:
parent
50a50a67ac
commit
27617ee152
7 changed files with 67 additions and 27 deletions
|
@ -40,7 +40,7 @@ var Scholar_File_Interface_Bibliography = new function() {
|
||||||
styleMenu.selectedIndex = 0;
|
styleMenu.selectedIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(document.getElementById("copy-to-clipboard") && navigator.appVersion.indexOf('Mac') != -1) {
|
if(Scholar.isMac && document.getElementById("copy-to-clipboard")) {
|
||||||
document.getElementById("copy-to-clipboard").hidden = "true";
|
document.getElementById("copy-to-clipboard").hidden = "true";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,17 +11,32 @@ var Scholar_File_Interface = new function() {
|
||||||
/*
|
/*
|
||||||
* Creates Scholar.Translate instance and shows file picker for file export
|
* Creates Scholar.Translate instance and shows file picker for file export
|
||||||
*/
|
*/
|
||||||
function exportFile(items) {
|
function exportFile(name, items) {
|
||||||
var translation = new Scholar.Translate("export");
|
var translation = new Scholar.Translate("export");
|
||||||
var translators = translation.getTranslators();
|
var translators = translation.getTranslators();
|
||||||
|
|
||||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||||
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
||||||
.createInstance(nsIFilePicker);
|
.createInstance(nsIFilePicker);
|
||||||
fp.init(window, "Export", nsIFilePicker.modeSave);
|
|
||||||
|
fp.init(window, Scholar.getString("fileInterface.export"), nsIFilePicker.modeSave);
|
||||||
|
|
||||||
|
// set file name and extension.
|
||||||
|
name = (name ? name : Scholar.getString("pane.collections.library"));
|
||||||
|
fp.defaultString = name+"."+translators[0].target;
|
||||||
|
|
||||||
|
// add save filters
|
||||||
for(var i in translators) {
|
for(var i in translators) {
|
||||||
fp.appendFilter(translators[i].label, translators[i].target);
|
var label = translators[i].label;
|
||||||
|
|
||||||
|
// put extensions in parentheses if Mac (Windows users already
|
||||||
|
// get extension)
|
||||||
|
label += " (."+translators[i].target+")";
|
||||||
|
|
||||||
|
fp.appendFilter(label, "*."+translators[i].target);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var rv = fp.show();
|
var rv = fp.show();
|
||||||
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
|
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
|
||||||
if(items) {
|
if(items) {
|
||||||
|
@ -47,7 +62,7 @@ var Scholar_File_Interface = new function() {
|
||||||
var collection = ScholarPane.getSelectedCollection();
|
var collection = ScholarPane.getSelectedCollection();
|
||||||
if (collection)
|
if (collection)
|
||||||
{
|
{
|
||||||
exportFile(Scholar.getItems(collection.getID()));
|
exportFile(collection.getName(), Scholar.getItems(collection.getID()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +71,7 @@ var Scholar_File_Interface = new function() {
|
||||||
{
|
{
|
||||||
var search = new Scholar.Search();
|
var search = new Scholar.Search();
|
||||||
search.load(searchRef['id']);
|
search.load(searchRef['id']);
|
||||||
exportFile(Scholar.Items.get(search.search()));
|
exportFile(search.getName(), Scholar.Items.get(search.search()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +86,7 @@ var Scholar_File_Interface = new function() {
|
||||||
var items = ScholarPane.getSelectedItems();
|
var items = ScholarPane.getSelectedItems();
|
||||||
if(!items || !items.length) throw("no items currently selected");
|
if(!items || !items.length) throw("no items currently selected");
|
||||||
|
|
||||||
exportFile(items);
|
exportFile(Scholar.getString("fileInterface.exportedItems"), items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -93,7 +108,7 @@ var Scholar_File_Interface = new function() {
|
||||||
/*
|
/*
|
||||||
* closes items exported indicator
|
* closes items exported indicator
|
||||||
*/
|
*/
|
||||||
function _exportDone(obj) {
|
function _exportDone(obj, worked) {
|
||||||
Scholar_File_Interface.Progress.close();
|
Scholar_File_Interface.Progress.close();
|
||||||
_restoreUnresponsive();
|
_restoreUnresponsive();
|
||||||
}
|
}
|
||||||
|
@ -108,7 +123,9 @@ var Scholar_File_Interface = new function() {
|
||||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||||
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
||||||
.createInstance(nsIFilePicker);
|
.createInstance(nsIFilePicker);
|
||||||
fp.init(window, "Import", nsIFilePicker.modeOpen);
|
fp.init(window, Scholar.getString("fileInterface.import"), nsIFilePicker.modeOpen);
|
||||||
|
|
||||||
|
fp.appendFilters(nsIFilePicker.filterAll);
|
||||||
for(var i in translators) {
|
for(var i in translators) {
|
||||||
fp.appendFilter(translators[i].label, "*."+translators[i].target);
|
fp.appendFilter(translators[i].label, "*."+translators[i].target);
|
||||||
}
|
}
|
||||||
|
@ -121,7 +138,7 @@ var Scholar_File_Interface = new function() {
|
||||||
if(translators.length) {
|
if(translators.length) {
|
||||||
// create a new collection to take in imported items
|
// create a new collection to take in imported items
|
||||||
var date = new Date();
|
var date = new Date();
|
||||||
_importCollection = Scholar.Collections.add("Imported "+date.toLocaleString());
|
_importCollection = Scholar.Collections.add(Scholar.getString("fileInterface.imported")+" "+date.toLocaleString());
|
||||||
|
|
||||||
// import items
|
// import items
|
||||||
translation.setTranslator(translators[0]);
|
translation.setTranslator(translators[0]);
|
||||||
|
@ -138,6 +155,8 @@ var Scholar_File_Interface = new function() {
|
||||||
function() {
|
function() {
|
||||||
translation.translate();
|
translation.translate();
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
window.alert(Scholar.getString("fileInterface.fileFormatUnsupported"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -172,6 +191,10 @@ var Scholar_File_Interface = new function() {
|
||||||
|
|
||||||
Scholar_File_Interface.Progress.close();
|
Scholar_File_Interface.Progress.close();
|
||||||
_restoreUnresponsive();
|
_restoreUnresponsive();
|
||||||
|
|
||||||
|
if(!worked) {
|
||||||
|
window.alert(Scholar.getString("fileInterface.importError"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -201,7 +224,7 @@ var Scholar_File_Interface = new function() {
|
||||||
var collection = ScholarPane.getSelectedCollection();
|
var collection = ScholarPane.getSelectedCollection();
|
||||||
if (collection)
|
if (collection)
|
||||||
{
|
{
|
||||||
_doBibliographyOptions(Scholar.getItems(collection.getID()));
|
_doBibliographyOptions(collection.getName(), Scholar.getItems(collection.getID()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -210,7 +233,7 @@ var Scholar_File_Interface = new function() {
|
||||||
{
|
{
|
||||||
var search = new Scholar.Search();
|
var search = new Scholar.Search();
|
||||||
search.load(searchRef['id']);
|
search.load(searchRef['id']);
|
||||||
_doBibliographyOptions(Scholar.Items.get(search.search()));
|
_doBibliographyOptions(search.getName(), Scholar.Items.get(search.search()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,13 +247,13 @@ var Scholar_File_Interface = new function() {
|
||||||
var items = ScholarPane.getSelectedItems();
|
var items = ScholarPane.getSelectedItems();
|
||||||
if(!items || !items.length) throw("no items currently selected");
|
if(!items || !items.length) throw("no items currently selected");
|
||||||
|
|
||||||
_doBibliographyOptions(items);
|
_doBibliographyOptions(Scholar.getString("fileInterface.untitledBibliography"), items);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Shows bibliography options and creates a bibliography
|
* Shows bibliography options and creates a bibliography
|
||||||
*/
|
*/
|
||||||
function _doBibliographyOptions(items) {
|
function _doBibliographyOptions(name, items) {
|
||||||
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);
|
||||||
|
@ -275,7 +298,7 @@ var Scholar_File_Interface = new function() {
|
||||||
Scholar.Browser.deleteHiddenBrowser(browser);
|
Scholar.Browser.deleteHiddenBrowser(browser);
|
||||||
bibliographyStream.close();
|
bibliographyStream.close();
|
||||||
} else if(io.output == "save-as-html") {
|
} else if(io.output == "save-as-html") {
|
||||||
var fStream = _saveBibliography("HTML");
|
var fStream = _saveBibliography(name, "HTML");
|
||||||
|
|
||||||
if(fStream !== false) {
|
if(fStream !== false) {
|
||||||
var html = "";
|
var html = "";
|
||||||
|
@ -283,7 +306,7 @@ var Scholar_File_Interface = new function() {
|
||||||
html +='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n';
|
html +='<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\n';
|
||||||
html +='<head>\n';
|
html +='<head>\n';
|
||||||
html +='<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n';
|
html +='<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>\n';
|
||||||
html +='<title>Bibliography</title>\n';
|
html +='<title>'+Scholar.getString("fileInterface.bibliographyHTMLTitle")+'</title>\n';
|
||||||
html +='</head>\n';
|
html +='</head>\n';
|
||||||
html +='<body>\n';
|
html +='<body>\n';
|
||||||
html += bibliography;
|
html += bibliography;
|
||||||
|
@ -301,7 +324,7 @@ var Scholar_File_Interface = new function() {
|
||||||
fStream.close();
|
fStream.close();
|
||||||
}
|
}
|
||||||
} else if(io.output == "save-as-rtf") {
|
} else if(io.output == "save-as-rtf") {
|
||||||
var fStream = _saveBibliography("RTF");
|
var fStream = _saveBibliography(name, "RTF");
|
||||||
if(fStream !== false) {
|
if(fStream !== false) {
|
||||||
fStream.write(bibliography, bibliography.length);
|
fStream.write(bibliography, bibliography.length);
|
||||||
fStream.close();
|
fStream.close();
|
||||||
|
@ -331,7 +354,7 @@ var Scholar_File_Interface = new function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _saveBibliography(format) {
|
function _saveBibliography(name, format) {
|
||||||
// savable bibliography, using a file stream
|
// savable bibliography, using a file stream
|
||||||
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
const nsIFilePicker = Components.interfaces.nsIFilePicker;
|
||||||
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
var fp = Components.classes["@mozilla.org/filepicker;1"]
|
||||||
|
@ -339,11 +362,15 @@ var Scholar_File_Interface = new function() {
|
||||||
fp.init(window, "Save Bibliography", nsIFilePicker.modeSave);
|
fp.init(window, "Save Bibliography", nsIFilePicker.modeSave);
|
||||||
|
|
||||||
if(format == "RTF") {
|
if(format == "RTF") {
|
||||||
|
var extension = "rtf";
|
||||||
fp.appendFilter("RTF", "*.rtf");
|
fp.appendFilter("RTF", "*.rtf");
|
||||||
} else {
|
} else {
|
||||||
|
var extension = "html";
|
||||||
fp.appendFilters(nsIFilePicker.filterHTML);
|
fp.appendFilters(nsIFilePicker.filterHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fp.defaultString = name+"."+extension;
|
||||||
|
|
||||||
var rv = fp.show();
|
var rv = fp.show();
|
||||||
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
|
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
|
||||||
// open file
|
// open file
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Scholar.Integration = new function() {
|
Scholar.Integration = new function() {
|
||||||
var _contentLengthRe = /[\r\n]Content-Length: *([0-9]+)/i;
|
var _contentLengthRe = /[\r\n]Content-Length: *([0-9]+)/i;
|
||||||
var _XMLRe = /<\?[^>]+\?>/;
|
var _XMLRe = /<\?[^>]+\?>/;
|
||||||
this.ns = "http://chnm.gmu.edu/firefoxscholar/soap";
|
this.ns = "http://www.zotero.org/namespaces/SOAP";
|
||||||
|
|
||||||
this.init = init;
|
this.init = init;
|
||||||
this.handleHeader = handleHeader;
|
this.handleHeader = handleHeader;
|
||||||
|
|
|
@ -74,6 +74,7 @@ var Scholar = new function(){
|
||||||
.getService(Components.interfaces.nsIAppShellService)
|
.getService(Components.interfaces.nsIAppShellService)
|
||||||
.hiddenDOMWindow;
|
.hiddenDOMWindow;
|
||||||
this.platform = win.navigator.platform;
|
this.platform = win.navigator.platform;
|
||||||
|
this.isMac = (this.platform.substr(0, 3) == "Mac");
|
||||||
|
|
||||||
// Load in the localization stringbundle for use by getString(name)
|
// Load in the localization stringbundle for use by getString(name)
|
||||||
var src = 'chrome://scholar/locale/scholar.properties';
|
var src = 'chrome://scholar/locale/scholar.properties';
|
||||||
|
|
|
@ -125,7 +125,9 @@ Scholar.Translate.init = function() {
|
||||||
|
|
||||||
if(cachePref) {
|
if(cachePref) {
|
||||||
// fetch translator list
|
// fetch translator list
|
||||||
var translators = Scholar.DB.query("SELECT translatorID, type, label, target, detectCode IS NULL as noDetectCode FROM translators ORDER BY target IS NULL");
|
var translators = Scholar.DB.query("SELECT translatorID, type, label, "+
|
||||||
|
"target, detectCode IS NULL as noDetectCode FROM translators "+
|
||||||
|
"ORDER BY target IS NULL, translatorID = '14763d24-8ba0-45df-8f52-b8d1108e7ac9' DESC");
|
||||||
var detectCodes = Scholar.DB.query("SELECT translatorID, detectCode FROM translators WHERE target IS NULL");
|
var detectCodes = Scholar.DB.query("SELECT translatorID, detectCode FROM translators WHERE target IS NULL");
|
||||||
|
|
||||||
Scholar.Translate.cache = new Object();
|
Scholar.Translate.cache = new Object();
|
||||||
|
@ -370,7 +372,9 @@ Scholar.Translate.prototype.getTranslators = function() {
|
||||||
if(Scholar.Translate.cache) {
|
if(Scholar.Translate.cache) {
|
||||||
var translators = Scholar.Translate.cache[this.type];
|
var translators = Scholar.Translate.cache[this.type];
|
||||||
} else {
|
} else {
|
||||||
var sql = "SELECT translatorID, label, target, detectCode IS NULL as noDetectCode FROM translators WHERE type IN ("+this._numericTypes+") ORDER BY target IS NULL";
|
var sql = "SELECT translatorID, label, target, detectCode IS NULL as "+
|
||||||
|
"noDetectCode FROM translators WHERE type IN ("+this._numericTypes+") "+
|
||||||
|
"ORDER BY target IS NULL, translatorID = '14763d24-8ba0-45df-8f52-b8d1108e7ac9' DESC";
|
||||||
var translators = Scholar.DB.query(sql);
|
var translators = Scholar.DB.query(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,14 @@ db.dbRestoreFailed = The Zotero database appears to have become corrupted, an
|
||||||
|
|
||||||
fileInterface.itemsImported = Importing items...
|
fileInterface.itemsImported = Importing items...
|
||||||
fileInterface.itemsExported = Exporting items...
|
fileInterface.itemsExported = Exporting items...
|
||||||
|
fileInterface.import = Import
|
||||||
|
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
|
||||||
|
|
||||||
searchOperator.is = is
|
searchOperator.is = is
|
||||||
searchOperator.isNot = is not
|
searchOperator.isNot = is not
|
||||||
|
|
12
scrapers.sql
12
scrapers.sql
|
@ -1,4 +1,4 @@
|
||||||
-- 64
|
-- 65
|
||||||
|
|
||||||
-- Set the following timestamp to the most recent scraper update date
|
-- Set the following timestamp to the most recent scraper update date
|
||||||
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-15 15:42:00'));
|
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-08-15 15:42:00'));
|
||||||
|
@ -3779,7 +3779,7 @@ function doSearch(item) {
|
||||||
Scholar.wait();
|
Scholar.wait();
|
||||||
}');
|
}');
|
||||||
|
|
||||||
REPLACE INTO "translators" VALUES ('0e2235e7-babf-413c-9acf-f27cce5f059c', '2006-07-05 23:40:00', 3, 'MODS (XML)', 'Simon Kornblith', 'xml',
|
REPLACE INTO "translators" VALUES ('0e2235e7-babf-413c-9acf-f27cce5f059c', '2006-07-05 23:40:00', 3, 'MODS', 'Simon Kornblith', 'xml',
|
||||||
'Scholar.addOption("exportNotes", true);
|
'Scholar.addOption("exportNotes", true);
|
||||||
|
|
||||||
function detectImport() {
|
function detectImport() {
|
||||||
|
@ -4256,7 +4256,7 @@ function doImport() {
|
||||||
}
|
}
|
||||||
}');
|
}');
|
||||||
|
|
||||||
REPLACE INTO "translators" VALUES ('14763d24-8ba0-45df-8f52-b8d1108e7ac9', '2006-07-07 12:44:00', 2, 'Biblio/DC/FOAF/PRISM/VCard (RDF/XML)', 'Simon Kornblith', 'rdf',
|
REPLACE INTO "translators" VALUES ('14763d24-8ba0-45df-8f52-b8d1108e7ac9', '2006-08-30 11:37:00', 2, 'Zotero RDF', 'Simon Kornblith', 'rdf',
|
||||||
'Scholar.configure("getCollections", true);
|
'Scholar.configure("getCollections", true);
|
||||||
Scholar.configure("dataMode", "rdf");
|
Scholar.configure("dataMode", "rdf");
|
||||||
Scholar.addOption("exportNotes", true);
|
Scholar.addOption("exportNotes", true);
|
||||||
|
@ -4334,7 +4334,7 @@ function doExport() {
|
||||||
foaf:"http://xmlns.com/foaf/0.1/",
|
foaf:"http://xmlns.com/foaf/0.1/",
|
||||||
vcard:"http://nwalsh.com/rdf/vCard#",
|
vcard:"http://nwalsh.com/rdf/vCard#",
|
||||||
link:"http://purl.org/rss/1.0/modules/link/",
|
link:"http://purl.org/rss/1.0/modules/link/",
|
||||||
fs:"http://chnm.gmu.edu/firefoxscholar/rdf#"
|
fs:"http://www.zotero.org/namespaces/export#"
|
||||||
};
|
};
|
||||||
|
|
||||||
// add namespaces
|
// add namespaces
|
||||||
|
@ -4673,7 +4673,7 @@ function doExport() {
|
||||||
}
|
}
|
||||||
}');
|
}');
|
||||||
|
|
||||||
REPLACE INTO "translators" VALUES ('6e372642-ed9d-4934-b5d1-c11ac758ebb7', '2006-07-05 23:40:00', 2, 'Unqualified Dublin Core (RDF/XML)', 'Simon Kornblith', 'rdf',
|
REPLACE INTO "translators" VALUES ('6e372642-ed9d-4934-b5d1-c11ac758ebb7', '2006-07-05 23:40:00', 2, 'Unqualified Dublin Core RDF', 'Simon Kornblith', 'rdf',
|
||||||
'Scholar.configure("dataMode", "rdf");',
|
'Scholar.configure("dataMode", "rdf");',
|
||||||
'function doExport() {
|
'function doExport() {
|
||||||
var dc = "http://purl.org/dc/elements/1.1/";
|
var dc = "http://purl.org/dc/elements/1.1/";
|
||||||
|
@ -4977,7 +4977,7 @@ function doImport() {
|
||||||
foaf:"http://xmlns.com/foaf/0.1/",
|
foaf:"http://xmlns.com/foaf/0.1/",
|
||||||
vcard:"http://nwalsh.com/rdf/vCard#",
|
vcard:"http://nwalsh.com/rdf/vCard#",
|
||||||
link:"http://purl.org/rss/1.0/modules/link/",
|
link:"http://purl.org/rss/1.0/modules/link/",
|
||||||
fs:"http://chnm.gmu.edu/firefoxscholar/rdf#"
|
fs:"http://www.zotero.org/namespaces/export#"
|
||||||
};
|
};
|
||||||
|
|
||||||
callNumberTypes = [
|
callNumberTypes = [
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue