- closes #391, Second export to same location with attached files fails

- removes extraneous debug code from Zotero RDF export
This commit is contained in:
Simon Kornblith 2006-12-13 05:23:39 +00:00
parent 857f0a907c
commit c6d4cdd57b
3 changed files with 53 additions and 40 deletions

View File

@ -53,8 +53,15 @@ var Zotero_File_Interface = new function() {
// set file name and extension
name = (name ? name : Zotero.getString("pane.collections.library"));
fp.defaultString = name+"."+io.selectedTranslator.target;
fp.appendFilter(io.selectedTranslator.label, "*."+io.selectedTranslator.target);
if(io.selectedTranslator.displayOptions.exportFileData) {
// if the result will be a folder, don't append any extension or use
// filters
fp.defaultString = name;
} else {
// if the result will be a file, append an extension and use filters
fp.defaultString = name+"."+io.selectedTranslator.target;
fp.appendFilter(io.selectedTranslator.label, "*."+io.selectedTranslator.target);
}
var rv = fp.show();
if (rv == nsIFilePicker.returnOK || rv == nsIFilePicker.returnReplace) {
@ -78,19 +85,9 @@ var Zotero_File_Interface = new function() {
* exports a collection or saved search
*/
function exportCollection() {
var collection = ZoteroPane.getSelectedCollection();
if (collection)
{
exportFile(collection.getName(), Zotero.getItems(collection.getID()));
return;
}
var searchRef = ZoteroPane.getSelectedSavedSearch();
if (searchRef)
{
var search = new Zotero.Search();
search.load(searchRef['id']);
exportFile(search.getName(), Zotero.Items.get(search.search()));
var nameAndItems = _getSortedSelectedCollection();
if(nameAndItems) {
exportFile(nameAndItems[0], nameAndItems[1]);
return;
}
@ -108,6 +105,33 @@ var Zotero_File_Interface = new function() {
exportFile(Zotero.getString("fileInterface.exportedItems"), items);
}
/*
* gets selected collection or saved search sorted
*/
function _getSortedSelectedCollection() {
var name = false;
var items = false;
var collection = ZoteroPane.getSelectedCollection();
if (collection) {
name = collection.getName();
items = Zotero.getItems(collection.getID());
} else {
var searchRef = ZoteroPane.getSelectedSavedSearch();
if (searchRef) {
var search = new Zotero.Search();
search.load(searchRef['id']);
name = search.getName();
items = Zotero.Items.get(search.search());
}
}
if(items) {
return [name, items];
}
return false;
}
/*
* closes items exported indicator
*/
@ -228,19 +252,9 @@ var Zotero_File_Interface = new function() {
* Creates a bibliography from a collection or saved search
*/
function bibliographyFromCollection() {
var collection = ZoteroPane.getSelectedCollection();
if (collection)
{
_doBibliographyOptions(collection.getName(), Zotero.getItems(collection.getID()));
return;
}
var searchRef = ZoteroPane.getSelectedSavedSearch();
if (searchRef)
{
var search = new Zotero.Search();
search.load(searchRef['id']);
_doBibliographyOptions(search.getName(), Zotero.Items.get(search.search()));
var nameAndItems = _getSortedSelectedCollection();
if(nameAndItems) {
_doBibliographyOptions(nameAndItems[0], nameAndItems[1]);
return;
}

View File

@ -1691,24 +1691,24 @@ Zotero.Translate.prototype._export = function() {
createInstance(Components.interfaces.nsILocalFile);
directory.initWithFile(this.location.parent);
// delete this file if it exists
if(this.location.exists()) {
this.location.remove(false);
}
// get name
var name = this.location.leafName;
var extensionMatch = /^(.*)\.[a-zA-Z0-9]+$/
var m = extensionMatch.exec(name);
if(m) {
name = m[1];
}
directory.append(name);
// create directory
directory.create(Components.interfaces.nsIFile.DIRECTORY_TYPE, 0700);
// generate a new location
var originalName = this.location.leafName;
// generate a new location for the exported file, with the appropriate
// extension
this.location = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile);
this.location.initWithFile(directory);
this.location.append(originalName);
this.location.append(name+"."+this.translator[0].target);
// create files directory
this._exportFileDirectory = Components.classes["@mozilla.org/file/local;1"].

View File

@ -1,4 +1,4 @@
-- 123
-- 124
-- ***** BEGIN LICENSE BLOCK *****
--
@ -22,7 +22,7 @@
-- Set the following timestamp to the most recent scraper update date
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-12-12 23:41:00'));
REPLACE INTO "version" VALUES ('repository', STRFTIME('%s', '2006-12-13 00:19:00'));
REPLACE INTO translators VALUES ('96b9f483-c44d-5784-cdad-ce21b984fe01', '1.0.0b3.r1', '', '2006-12-12 23:41:00', 1, 100, 4, 'Amazon.com', 'Sean Takats', '^http://(?:www\.)amazon',
'function detectWeb(doc, url) {
@ -5017,7 +5017,7 @@ function doImport() {
}
}');
REPLACE INTO translators VALUES ('14763d24-8ba0-45df-8f52-b8d1108e7ac9', '1.0.0b3.r1', '', '2006-12-12 22:34:00', 1, 25, 2, 'Zotero RDF', 'Simon Kornblith', 'rdf',
REPLACE INTO translators VALUES ('14763d24-8ba0-45df-8f52-b8d1108e7ac9', '1.0.0b3.r1', '', '2006-12-13 00:19:00', 1, 25, 2, 'Zotero RDF', 'Simon Kornblith', 'rdf',
'Zotero.configure("getCollections", true);
Zotero.configure("dataMode", "rdf");
Zotero.addOption("exportNotes", true);
@ -5212,7 +5212,6 @@ function generateItem(item, zoteroType, resource) {
var value = item[property];
if(!value) continue;
Zotero.Utilities.debug("processing "+property);
if(property == "title") { // title
Zotero.RDF.addStatement(resource, n.dc+"title", value, true);
} else if(property == "creators") { // authors/editors/contributors