Merged revisions 3080-3081,3084,3087-3088,3090,3092,3099-3103,3113-3114,3132,3134-3143,3145,3148-3151,3154-3159,3165,3174,3194,3234-3235,3239-3240,3244,3246-3254,3258-3262,3268,3270,3274,3279,3286-3288,3294-3295 from 1.0 branch via svnmerge

This commit is contained in:
Dan Stillman 2008-09-01 01:54:00 +00:00
parent be2c8095c4
commit f37d724a9e
40 changed files with 8402 additions and 1378 deletions

View file

@ -10,7 +10,7 @@ locale zotero cs-CZ chrome/locale/cs-CZ/zotero/
locale zotero da-DK chrome/locale/da-DK/zotero/ locale zotero da-DK chrome/locale/da-DK/zotero/
locale zotero de-AT chrome/locale/de-AT/zotero/ locale zotero de-AT chrome/locale/de-AT/zotero/
locale zotero de-CH chrome/locale/de-CH/zotero/ locale zotero de-CH chrome/locale/de-CH/zotero/
locale zotero de-DE chrome/locale/de-DE/zotero/ locale zotero de chrome/locale/de-DE/zotero/
locale zotero el-GR chrome/locale/el-GR/zotero/ locale zotero el-GR chrome/locale/el-GR/zotero/
locale zotero es-ES chrome/locale/es-ES/zotero/ locale zotero es-ES chrome/locale/es-ES/zotero/
locale zotero et-EE chrome/locale/et-EE/zotero/ locale zotero et-EE chrome/locale/et-EE/zotero/

View file

@ -137,18 +137,20 @@
<parameter name="popupNode"/> <parameter name="popupNode"/>
<body> <body>
<![CDATA[ <![CDATA[
var controller = document.commandDispatcher.getControllerForCommand(command);
var children = popupNode.childNodes; var children = popupNode.childNodes;
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
var command = children[i].getAttribute("cmd"); var command = children[i].getAttribute("cmd");
if (command) { if (command) {
var controller = document.commandDispatcher.getControllerForCommand(command);
var enabled = controller.isCommandEnabled(command); var enabled = controller.isCommandEnabled(command);
if (enabled) if (enabled) {
children[i].removeAttribute("disabled"); children[i].removeAttribute("disabled");
else }
else {
children[i].setAttribute("disabled", "true"); children[i].setAttribute("disabled", "true");
} }
} }
}
]]> ]]>
</body> </body>
</method> </method>

View file

@ -41,7 +41,7 @@ var Zotero_Browser = new function() {
this.scrapeThisPage = scrapeThisPage; this.scrapeThisPage = scrapeThisPage;
this.annotatePage = annotatePage; this.annotatePage = annotatePage;
this.toggleMode = toggleMode; this.toggleMode = toggleMode;
this.setCollapsed = setCollapsed; this.toggleCollapsed = toggleCollapsed;
this.chromeLoad = chromeLoad; this.chromeLoad = chromeLoad;
this.chromeUnload = chromeUnload; this.chromeUnload = chromeUnload;
this.contentLoad = contentLoad; this.contentLoad = contentLoad;
@ -141,8 +141,6 @@ var Zotero_Browser = new function() {
else { else {
var tab = _getTabObject(this.tabbrowser.selectedBrowser); var tab = _getTabObject(this.tabbrowser.selectedBrowser);
} }
tab.annotateNextLoad = true;
tab.annotateID = id;
} }
/* /*
@ -182,9 +180,9 @@ var Zotero_Browser = new function() {
/* /*
* expands all annotations * expands all annotations
*/ */
function setCollapsed(status) { function toggleCollapsed() {
var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser); var tab = _getTabObject(Zotero_Browser.tabbrowser.selectedBrowser);
tab.page.annotations.setCollapsed(status); tab.page.annotations.toggleCollapsed();
} }
/* /*
@ -340,34 +338,26 @@ var Zotero_Browser = new function() {
var tab = _getTabObject(browser); var tab = _getTabObject(browser);
if(isHTML) { if(isHTML) {
if(tab.annotateNextLoad) { var annotationID = Zotero.Annotate.getAnnotationIDFromURL(browser.currentURI.spec);
if(Zotero.Annotate.isAnnotated(tab.annotateID)) { if(annotationID) {
if(Zotero.Annotate.isAnnotated(annotationID)) {
window.alert(Zotero.getString("annotations.oneWindowWarning")); window.alert(Zotero.getString("annotations.oneWindowWarning"));
} else { } else if(!tab.page.annotations) {
// enable annotation // enable annotation
tab.page.annotations = new Zotero.Annotations(this, browser, tab.annotateID); tab.page.annotations = new Zotero.Annotations(this, browser, annotationID);
Zotero.Annotate.setAnnotated(tab.annotateID, true); var saveAnnotations = function() {
browser.contentWindow.addEventListener('beforeunload', function() {
// save annotations
try {
tab.page.annotations.save(); tab.page.annotations.save();
} catch(e) { tab.page.annotations = undefined;
throw(e); };
} finally { browser.contentWindow.addEventListener('beforeunload', saveAnnotations, false);
Zotero.Annotate.setAnnotated(tab.page.annotations.itemID, false); browser.contentWindow.addEventListener('close', saveAnnotations, false);
} tab.page.annotations.load();
}, false);
} }
} }
} }
// detect translators // detect translators
tab.detectTranslators(rootDoc, doc); tab.detectTranslators(rootDoc, doc);
// clear annotateNextLoad
if(tab.annotateNextLoad) {
tab.annotateNextLoad = tab.annotateID = undefined;
}
} }
/* /*
@ -410,7 +400,7 @@ var Zotero_Browser = new function() {
// To execute if document object does not exist // To execute if document object does not exist
_deleteTabObject(event.target.linkedBrowser); _deleteTabObject(event.target.linkedBrowser);
toggleMode(null); toggleMode();
} }
@ -556,7 +546,7 @@ var Zotero_Browser = new function() {
if(selection.isCollapsed) return; if(selection.isCollapsed) return;
if(type == "highlight") { if(type == "highlight") {
tab.page.annotations.createHighlight(selection.getRangeAt(0)); tab.page.annotations.highlight(selection.getRangeAt(0));
} else if(type == "unhighlight") { } else if(type == "unhighlight") {
tab.page.annotations.unhighlight(selection.getRangeAt(0)); tab.page.annotations.unhighlight(selection.getRangeAt(0));
} }

View file

@ -28,9 +28,9 @@ Zotero_Charset_Menu = new function() {
* closer to the top * closer to the top
* *
* @param {DOMElement} charsetMenu The menu to populate * @param {DOMElement} charsetMenu The menu to populate
* @param {Boolean} showEndian Whether to show endian (e.g., UTF-32) options * @param {Boolean} exportMenu Whether the menu is to be used for export
**/ **/
function populate(charsetMenu, showEndian) { function populate(charsetMenu, exportMenu) {
var charsetMap = {}; var charsetMap = {};
// get charset popup and charset RDF // get charset popup and charset RDF
@ -60,16 +60,16 @@ Zotero_Charset_Menu = new function() {
var isUTF16 = charset.length >= 6 && charset.substr(0, 6) == "UTF-16"; var isUTF16 = charset.length >= 6 && charset.substr(0, 6) == "UTF-16";
// Show UTF-16 element appropriately depending on showEndian // Show UTF-16 element appropriately depending on exportMenu
if(isUTF16 && showEndian == (charset == "UTF-16") || if(isUTF16 && exportMenu == (charset == "UTF-16") ||
(!showEndian && charset == "UTF-32LE")) { (!exportMenu && charset == "UTF-32LE")) {
continue; continue;
} else if(charset == "x-mac-roman") { } else if(charset == "x-mac-roman") {
// use the IANA name // use the IANA name
value = "macintosh"; charset = "macintosh";
} else if(!showEndian && charset == "UTF-32BE") { } else if(!exportMenu && charset == "UTF-32BE") {
label = "Unicode (UTF-32)"; label = "Unicode (UTF-32)";
value = "UTF-32"; charset = "UTF-32";
} }
// add element // add element
@ -85,7 +85,7 @@ Zotero_Charset_Menu = new function() {
var oldFirst = (charsetPopup.firstChild ? charsetPopup.firstChild : null); var oldFirst = (charsetPopup.firstChild ? charsetPopup.firstChild : null);
charsetPopup.insertBefore(itemNode, oldFirst); charsetPopup.insertBefore(itemNode, oldFirst);
// also add (without BOM) if requested // also add (without BOM) if requested
if(showEndian) { if(exportMenu) {
var itemNode = document.createElement("menuitem"); var itemNode = document.createElement("menuitem");
itemNode.setAttribute("label", Zotero.getString("charset.UTF8withoutBOM")); itemNode.setAttribute("label", Zotero.getString("charset.UTF8withoutBOM"));
itemNode.setAttribute("value", charset+"xBOM"); itemNode.setAttribute("value", charset+"xBOM");
@ -97,6 +97,14 @@ Zotero_Charset_Menu = new function() {
} }
} }
if(!exportMenu) {
var itemNode = document.createElement("menuitem");
itemNode.setAttribute("label", Zotero.getString("charset.autoDetect"));
itemNode.setAttribute("value", "auto");
charsetMap["auto"] = itemNode;
charsetPopup.insertBefore(itemNode, charsetPopup.firstChild);
}
return charsetMap; return charsetMap;
} }
} }

View file

@ -36,7 +36,7 @@ var Zotero_File_Interface_Export = new function() {
this.accept = accept; this.accept = accept;
this.cancel = cancel; this.cancel = cancel;
var _charsets; var _charsets = false;
/* /*
* add options to export * add options to export
@ -100,7 +100,9 @@ var Zotero_File_Interface_Export = new function() {
} }
// from charsetMenu.js // from charsetMenu.js
if(Zotero.Prefs.get("export.displayCharsetOption")) {
_charsets = Zotero_Charset_Menu.populate(document.getElementById(OPTION_PREFIX+"exportCharset"), true); _charsets = Zotero_Charset_Menu.populate(document.getElementById(OPTION_PREFIX+"exportCharset"), true);
}
updateOptions(Zotero.Prefs.get("export.translatorSettings")); updateOptions(Zotero.Prefs.get("export.translatorSettings"));
} }
@ -156,11 +158,11 @@ var Zotero_File_Interface_Export = new function() {
} }
// handle charset popup // handle charset popup
var charsetMenu = document.getElementById(OPTION_PREFIX+"exportCharset"); if(_charsets && translatorOptions.exportCharset) {
if(translatorOptions.exportCharset) {
document.getElementById("charset-box").hidden = undefined;
optionsBox.hidden = undefined; optionsBox.hidden = undefined;
var charset = "UTF-8xBOM"; document.getElementById("charset-box").hidden = undefined;
var charsetMenu = document.getElementById(OPTION_PREFIX+"exportCharset");
var charset = "UTF-8";
if(options && options.exportCharset && _charsets[options.exportCharset]) { if(options && options.exportCharset && _charsets[options.exportCharset]) {
charset = options.exportCharset; charset = options.exportCharset;
} else if(translatorOptions.exportCharset && _charsets[translatorOptions.exportCharset]) { } else if(translatorOptions.exportCharset && _charsets[translatorOptions.exportCharset]) {
@ -168,6 +170,8 @@ var Zotero_File_Interface_Export = new function() {
} }
charsetMenu.selectedItem = _charsets[charset]; charsetMenu.selectedItem = _charsets[charset];
} else {
document.getElementById("charset-box").hidden = true;
} }
window.sizeToContent(); window.sizeToContent();
@ -192,17 +196,16 @@ var Zotero_File_Interface_Export = new function() {
var element = document.getElementById(OPTION_PREFIX+option); var element = document.getElementById(OPTION_PREFIX+option);
if(option == "exportCharset") { if(option == "exportCharset") {
if(_charsets) {
optionsAvailable[option] = element.selectedItem.value; optionsAvailable[option] = element.selectedItem.value;
}
} else if(typeof(defValue) == "boolean") { } else if(typeof(defValue) == "boolean") {
optionsAvailable[option] = !!element.checked; optionsAvailable[option] = !!element.checked;
} }
} }
// save options // save options
Zotero.debug("EXPORT OPTIONS");
Zotero.debug(optionsAvailable);
optionString = Zotero.JSON.serialize(optionsAvailable); optionString = Zotero.JSON.serialize(optionsAvailable);
Zotero.debug(optionString);
Zotero.Prefs.set("export.translatorSettings", optionString); Zotero.Prefs.set("export.translatorSettings", optionString);
} }

View file

@ -850,6 +850,7 @@ var ZoteroPane = new function()
// Create a <description> element, essentially // Create a <description> element, essentially
else else
{ {
label.removeAttribute('value');
label.appendChild(document.createTextNode(val)); label.appendChild(document.createTextNode(val));
} }
@ -863,11 +864,35 @@ var ZoteroPane = new function()
var checkState = { value: Zotero.Prefs.get('lastRenameAssociatedFile') }; var checkState = { value: Zotero.Prefs.get('lastRenameAssociatedFile') };
while (true) { while (true) {
var result = nsIPS.prompt(window, // Don't show "Rename associated file" option for
// linked URLs
if (linkMode = item.ref.getAttachmentLinkMode() ==
Zotero.Attachments.LINK_MODE_LINKED_URL) {
var result = nsIPS.prompt(
window,
'',
Zotero.getString('pane.item.attachments.rename.title'), Zotero.getString('pane.item.attachments.rename.title'),
'', newTitle, newTitle,
null,
{}
);
// If they hit cancel or left it blank
if (!result || !newTitle.value) {
return;
}
break;
}
var result = nsIPS.prompt(
window,
'',
Zotero.getString('pane.item.attachments.rename.title'),
newTitle,
Zotero.getString('pane.item.attachments.rename.renameAssociatedFile'), Zotero.getString('pane.item.attachments.rename.renameAssociatedFile'),
checkState); checkState
);
// If they hit cancel or left it blank // If they hit cancel or left it blank
if (!result || !newTitle.value) { if (!result || !newTitle.value) {
@ -1701,36 +1726,13 @@ var ZoteroPane = new function()
var tab = gBrowser.addTab(uri); var tab = gBrowser.addTab(uri);
var browser = gBrowser.getBrowserForTab(tab); var browser = gBrowser.getBrowserForTab(tab);
if (data && data.attachmentID) {
Zotero_Browser.annotatePage(data.attachmentID, browser);
// In case the page has already loaded, update
Zotero_Browser.updateStatus();
}
if (event.shiftKey) { if (event.shiftKey) {
gBrowser.selectedTab = tab; gBrowser.selectedTab = tab;
} }
} } else if (event.shiftKey) {
else if (event.shiftKey) {
window.open(uri, "zotero-loaded-page", window.open(uri, "zotero-loaded-page",
"menubar=yes,location=yes,toolbar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes"); "menubar=yes,location=yes,toolbar=yes,personalbar=yes,resizable=yes,scrollbars=yes,status=yes");
} else {
if (data && data.attachmentID) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var newWindow = wm.getMostRecentWindow("navigator:browser");
//var browser = newWindow.getBrowser();
newWindow.Zotero_Browser.annotatePage(data.attachmentID);
// In case the page has already loaded, update
newWindow.Zotero_Browser.updateStatus();
}
}
else {
if (data && data.attachmentID) {
// Enable annotation
Zotero_Browser.annotatePage(data.attachmentID);
}
window.loadURI(uri); window.loadURI(uri);
} }
} }

View file

@ -404,8 +404,7 @@
<!-- Annotation Toolbar --> <!-- Annotation Toolbar -->
<toolbar id="zotero-annotate-tb" crop="end" insertbefore="content" hidden="true"> <toolbar id="zotero-annotate-tb" crop="end" insertbefore="content" hidden="true">
<toolbarbutton id="zotero-annotate-tb-add" tooltiptext="&zotero.annotate.toolbar.add.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/> <toolbarbutton id="zotero-annotate-tb-add" tooltiptext="&zotero.annotate.toolbar.add.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>
<toolbarbutton id="zotero-annotate-tb-collapse" tooltiptext="&zotero.annotate.toolbar.collapse.label;" oncommand="Zotero_Browser.setCollapsed(true);"/> <toolbarbutton id="zotero-annotate-tb-collapse" tooltiptext="&zotero.annotate.toolbar.collapse.label;" oncommand="Zotero_Browser.toggleCollapsed();"/>
<toolbarbutton id="zotero-annotate-tb-expand" tooltiptext="&zotero.annotate.toolbar.expand.label;" oncommand="Zotero_Browser.setCollapsed(false);"/>
<toolbarseparator/> <toolbarseparator/>
<toolbarbutton id="zotero-annotate-tb-highlight" tooltiptext="&zotero.annotate.toolbar.highlight.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/> <toolbarbutton id="zotero-annotate-tb-highlight" tooltiptext="&zotero.annotate.toolbar.highlight.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>
<toolbarbutton id="zotero-annotate-tb-unhighlight" tooltiptext="&zotero.annotate.toolbar.unhighlight.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/> <toolbarbutton id="zotero-annotate-tb-unhighlight" tooltiptext="&zotero.annotate.toolbar.unhighlight.label;" oncommand="Zotero_Browser.toggleMode(this.id);"/>

View file

@ -23,6 +23,7 @@
var openURLServerField; var openURLServerField;
var openURLVersionMenu; var openURLVersionMenu;
var proxies; var proxies;
var charsets;
function init() function init()
{ {
@ -37,6 +38,10 @@ function init()
populateQuickCopyList(); populateQuickCopyList();
updateQuickCopyInstructions(); updateQuickCopyInstructions();
initSearchPane(); initSearchPane();
var charsetMenu = document.getElementById("zotero-import-charsetMenu");
charsetMap = Zotero_Charset_Menu.populate(charsetMenu, false);
charsetMenu.selectedItem = charsetMap[Zotero.Prefs.get("import.charset")] ? charsetMap[Zotero.Prefs.get("import.charset")] : charsetMap["auto"];
} }
@ -54,7 +59,7 @@ function onDataDirUpdate(event) {
// If triggered from the Choose button, don't show the dialog, since // If triggered from the Choose button, don't show the dialog, since
// Zotero.chooseZoteroDirectory() shows its own // Zotero.chooseZoteroDirectory() shows its own
if (event.originalTarget.tagName == 'button') { if (event.originalTarget && event.originalTarget.tagName == 'button') {
return true; return true;
} }
// If directory not set or invalid, prompt for location // If directory not set or invalid, prompt for location

View file

@ -568,6 +568,8 @@ To add a new preference:
<preferences> <preferences>
<preference id="pref-useDataDir" name="extensions.zotero.useDataDir" type="bool"/> <preference id="pref-useDataDir" name="extensions.zotero.useDataDir" type="bool"/>
<preference id="pref-dataDir" name="extensions.zotero.dataDir" type="string"/> <preference id="pref-dataDir" name="extensions.zotero.dataDir" type="string"/>
<preference id="pref-export-displayCharsetOption" name="extensions.zotero.export.displayCharsetOption" type="bool"/>
<preference id="pref-import-charset" name="extensions.zotero.import.charset" type="string"/>
</preferences> </preferences>
<groupbox> <groupbox>
@ -598,10 +600,29 @@ To add a new preference:
<button label="&zotero.preferences.dbMaintenance.resetTranslatorsAndStyles;" oncommand="resetTranslatorsAndStyles()"/> <button label="&zotero.preferences.dbMaintenance.resetTranslatorsAndStyles;" oncommand="resetTranslatorsAndStyles()"/>
</hbox> </hbox>
</groupbox> </groupbox>
<groupbox>
<caption label="&zotero.preferences.charset;"/>
<checkbox id="zotero-export-displayCharsetOption" label="&zotero.preferences.charset.displayExportOption;"
preference="pref-export-displayCharsetOption"/>
<hbox align="center">
<label value="&zotero.preferences.charset.importCharset;:" control="zotero-import-charsetMenu"/>
<menulist id="zotero-import-charsetMenu" preference="pref-import-charset"/>
</hbox>
</groupbox>
</prefpane> </prefpane>
<!-- These mess up the prefwindow (more) if they come before the prefpanes <!-- These mess up the prefwindow (more) if they come before the prefpanes
https://bugzilla.mozilla.org/show_bug.cgi?id=296418 --> https://bugzilla.mozilla.org/show_bug.cgi?id=296418 -->
<script src="chrome://zotero/content/include.js"/> <script src="chrome://zotero/content/include.js"/>
<script src="chrome://zotero/content/charsetMenu.js"/>
<script type="application/javascript">
<![CDATA[
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.notifyObservers(null, "charsetmenu-selected", "other");
]]>
</script>
<script src="preferences.js"/> <script src="preferences.js"/>
</prefwindow> </prefwindow>

View file

@ -137,7 +137,7 @@
var bibliography = '<hr/><h1>Bibliography</h1>' + var bibliography = '<hr/><h1>Bibliography</h1>' +
csl.formatBibliography(itemSet, "HTML"); csl.formatBibliography(itemSet, "HTML");
iframe.contentDocument.documentElement.innerHTML = iframe.contentDocument.documentElement.innerHTML =
'<div style="white-space: pre">' '<div style="white-space: pre-wrap">'
+ citations + multCitations + bibliography + citations + multCitations + bibliography
+ '</div>'; + '</div>';
} }

View file

@ -133,7 +133,7 @@
// Generate bibliography // Generate bibliography
var bibliography = '<p>' + csl.formatBibliography(itemSet, "HTML"); var bibliography = '<p>' + csl.formatBibliography(itemSet, "HTML");
return '<div style="white-space: pre">' + return '<div style="white-space: pre-wrap">' +
citations + bibliography + '</div>'; citations + bibliography + '</div>';
} }

File diff suppressed because it is too large Load diff

View file

@ -185,7 +185,7 @@ Zotero.Attachments = new function(){
Zotero.debug('Importing attachment from URL'); Zotero.debug('Importing attachment from URL');
// Throw error on invalid URLs // Throw error on invalid URLs
urlRe = /^https?:\/\/[^\s]*$/; var urlRe = /^https?:\/\/[^\s]*$/;
var matches = urlRe.exec(url); var matches = urlRe.exec(url);
if (!matches) { if (!matches) {
throw ("Invalid URL '" + url + "' in Zotero.Attachments.importFromURL()"); throw ("Invalid URL '" + url + "' in Zotero.Attachments.importFromURL()");
@ -365,7 +365,7 @@ Zotero.Attachments = new function(){
Zotero.debug('Linking attachment from URL'); Zotero.debug('Linking attachment from URL');
// Throw error on invalid URLs // Throw error on invalid URLs
urlRe = /^https?:\/\/[^\s]*$/; var urlRe = /^https?:\/\/[^\s]*$/;
var matches = urlRe.exec(url); var matches = urlRe.exec(url);
if (!matches) { if (!matches) {
throw ("Invalid URL '" + url + "' in Zotero.Attachments.linkFromURL()"); throw ("Invalid URL '" + url + "' in Zotero.Attachments.linkFromURL()");
@ -1099,27 +1099,24 @@ Zotero.Attachments = new function(){
var browser = Zotero.Browser.createHiddenBrowser(); var browser = Zotero.Browser.createHiddenBrowser();
Zotero.File.addCharsetListener(browser, new function(){ var callback = function(charset, args) {
return function(charset, id){
var charsetID = Zotero.CharacterSets.getID(charset); var charsetID = Zotero.CharacterSets.getID(charset);
if (charsetID) {
var disabled = Zotero.Notifier.disable(); var disabled = Zotero.Notifier.disable();
var item = Zotero.Items.get(itemID); var item = Zotero.Items.get(itemID);
item.attachmentCharset = charsetID; item.attachmentCharset = charsetID;
item.save(); item.save();
if (disabled) { if (disabled) {
Zotero.Notifier.enable(); Zotero.Notifier.enable();
} }
}
// Chain fulltext indexer inside the charset callback, // Chain fulltext indexer inside the charset callback,
// since it's asynchronous and a prerequisite // since it's asynchronous and a prerequisite
Zotero.Fulltext.indexDocument(browser.contentDocument, itemID); Zotero.Fulltext.indexDocument(browser.contentDocument, itemID);
Zotero.Browser.deleteHiddenBrowser(browser);
}; };
}, itemID);
Zotero.File.addCharsetListener(browser, callback, itemID);
var url = Components.classes["@mozilla.org/network/protocol;1?name=file"] var url = Components.classes["@mozilla.org/network/protocol;1?name=file"]
.getService(Components.interfaces.nsIFileProtocolHandler) .getService(Components.interfaces.nsIFileProtocolHandler)

View file

@ -2252,8 +2252,8 @@ Zotero.CSL.Item._optionalTypeMap = {
audioRecording:"song", // ?? audioRecording:"song", // ??
presentation:"speech", presentation:"speech",
videoRecording:"motion_picture", videoRecording:"motion_picture",
tvBroadcast:"motion_picture", tvBroadcast:"broadcast",
radioBroadcast:"motion_picture", radioBroadcast:"broadcast",
podcast:"song", // ?? podcast:"song", // ??
computerProgram:"book" // ?? computerProgram:"book" // ??
}; };

View file

@ -2210,6 +2210,7 @@ Zotero.Item.prototype.getFile = function(row, skipExistsCheck) {
Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) { Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) {
var file = this.getFile(); var file = this.getFile();
if (!file) { if (!file) {
Zotero.debug("Attachment file not found in renameAttachmentFile()", 2);
return false; return false;
} }
@ -2234,6 +2235,8 @@ Zotero.Item.prototype.renameAttachmentFile = function(newName, overwrite) {
return true; return true;
} }
catch (e) { catch (e) {
Zotero.debug(e);
Components.utils.reportError(e);
return -2; return -2;
} }
} }

View file

@ -181,7 +181,7 @@ Zotero.File = new function(){
/* /*
* Not implemented, but it'd sure be great if it were * Not implemented, but it'd sure be great if it were
*/ */
function getCharsetFromString(str){ function getCharsetFromByteArray(arr) {
} }
@ -213,7 +213,10 @@ Zotero.File = new function(){
.getService(Components.interfaces.nsIFileProtocolHandler) .getService(Components.interfaces.nsIFileProtocolHandler)
.getURLSpecFromFile(file); .getURLSpecFromFile(file);
this.addCharsetListener(browser, callback, args); this.addCharsetListener(browser, function (charset, args) {
callback(charset, args);
Zotero.Browser.deleteHiddenBrowser(browser);
}, args);
browser.loadURI(url); browser.loadURI(url);
} }

View file

@ -66,6 +66,8 @@ Zotero.MIME = new function(){
'text/css': true, 'text/css': true,
'image/jpeg': true, 'image/jpeg': true,
'image/gif': true, 'image/gif': true,
'image/png': true,
'image/svg+xml': true,
'text/xml': true, 'text/xml': true,
'application/xhtml+xml': true, 'application/xhtml+xml': true,
'application/xml': true, 'application/xml': true,

View file

@ -1387,7 +1387,8 @@ Zotero.Search.prototype._buildQuery = function(){
if (includeParentsAndChildren || includeChildren) { if (includeParentsAndChildren || includeChildren) {
var childrenSQL = "SELECT itemID FROM itemAttachments WHERE " var childrenSQL = "SELECT itemID FROM itemAttachments WHERE "
+ "sourceItemID IN (" + condSQL + ") UNION " + "sourceItemID IN (" + condSQL + ") UNION "
+ "SELECT itemID FROM itemNotes WHERE sourceItemID IN (" + condSQL + ")"; + "SELECT itemID FROM itemNotes "
+ "WHERE sourceItemID IN (" + condSQL + ")";
var childSQLParams = condSQLParams.concat(condSQLParams); var childSQLParams = condSQLParams.concat(condSQLParams);
} }

View file

@ -437,7 +437,7 @@ Zotero.Translate.prototype.runHandler = function(type, argument) {
var returnValue = undefined; var returnValue = undefined;
if(this._handlers[type]) { if(this._handlers[type]) {
for(var i in this._handlers[type]) { for(var i in this._handlers[type]) {
Zotero.debug("Translate: running handler "+i+" for "+type); Zotero.debug("Translate: running handler "+i+" for "+type, 5);
try { try {
if(this._parentTranslator) { if(this._parentTranslator) {
returnValue = this._handlers[type][i](null, argument); returnValue = this._handlers[type][i](null, argument);
@ -453,7 +453,7 @@ Zotero.Translate.prototype.runHandler = function(type, argument) {
} else { } else {
// otherwise, fail silently, so as not to interfere with // otherwise, fail silently, so as not to interfere with
// interface cleanup // interface cleanup
Zotero.debug("Translate: "+e+' in handler '+i+' for '+type); Zotero.debug("Translate: "+e+' in handler '+i+' for '+type, 5);
} }
} }
} }
@ -492,7 +492,7 @@ Zotero.Translate.prototype.getTranslators = function() {
this._setSandboxMode("detect"); this._setSandboxMode("detect");
var possibleTranslators = new Array(); var possibleTranslators = new Array();
Zotero.debug("Translate: searching for translators for "+(this.path ? this.path : "an undisclosed location")); Zotero.debug("Translate: Searching for translators for "+(this.path ? this.path : "an undisclosed location"), 3);
// see which translators can translate // see which translators can translate
this._translatorSearch = new Zotero.Translate.TranslatorSearch(this, translators); this._translatorSearch = new Zotero.Translate.TranslatorSearch(this, translators);
@ -518,7 +518,7 @@ Zotero.Translate.prototype._loadTranslator = function() {
// parse detect code for the translator // parse detect code for the translator
this._parseDetectCode(this.translator[0]); this._parseDetectCode(this.translator[0]);
Zotero.debug("Translate: parsing code for "+this.translator[0].label); Zotero.debug("Translate: Parsing code for "+this.translator[0].label, 4);
try { try {
Components.utils.evalInSandbox(this.translator[0].code, this._sandbox); Components.utils.evalInSandbox(this.translator[0].code, this._sandbox);
@ -526,7 +526,7 @@ Zotero.Translate.prototype._loadTranslator = function() {
if(this._parentTranslator) { if(this._parentTranslator) {
throw(e); throw(e);
} else { } else {
this._debug(e+' in parsing code for '+this.translator[0].label); this._debug(e+' in parsing code for '+this.translator[0].label, 3);
this._translationComplete(false, e); this._translationComplete(false, e);
return false; return false;
} }
@ -611,7 +611,7 @@ Zotero.Translate.prototype._parseDetectCode = function(translator) {
try { try {
Components.utils.evalInSandbox(detectCode, this._sandbox); Components.utils.evalInSandbox(detectCode, this._sandbox);
} catch(e) { } catch(e) {
this._debug(e+' in parsing detectCode for '+translator.label); this._debug(e+' in parsing detectCode for '+translator.label, 3);
return; return;
} }
} }
@ -620,49 +620,36 @@ Zotero.Translate.prototype._parseDetectCode = function(translator) {
/* /*
* generates a sandbox for scraping/scraper detection * generates a sandbox for scraping/scraper detection
*/ */
Zotero.Translate._searchSandboxRegexp = new RegExp();
Zotero.Translate._searchSandboxRegexp.compile("^http://[\\w.]+/");
Zotero.Translate.prototype._generateSandbox = function() { Zotero.Translate.prototype._generateSandbox = function() {
var me = this; var me = this;
if(this.type == "web" || this.type == "search") {
// get sandbox URL // get sandbox URL
var sandboxLocation = "http://www.example.com/"; var sandboxLocation = "http://www.example.com/";
if(this.type == "web") { if(this.type == "web") {
// use real URL, not proxied version, to create sandbox // use real URL, not proxied version, to create sandbox
sandboxLocation = this.document.defaultView; sandboxLocation = this.document.defaultView;
Zotero.debug("Translate: binding sandbox to "+this.document.location.href); Zotero.debug("Translate: Binding sandbox to "+this.document.location.href, 4);
} else { } else {
// generate sandbox for search by extracting domain from translator if (this.type == "search") {
// target, if one exists // generate sandbox for search by extracting domain from translator target
if(this.translator && this.translator[0] && this.translator[0].target) { if(this.translator && this.translator[0] && this.translator[0].target) {
// so that web translators work too // so that web translators work too
const searchSandboxRe = /^http:\/\/[\w.]+\//;
var tempURL = this.translator[0].target.replace(/\\/g, "").replace(/\^/g, ""); var tempURL = this.translator[0].target.replace(/\\/g, "").replace(/\^/g, "");
var m = Zotero.Translate._searchSandboxRegexp.exec(tempURL); var m = searchSandboxRe.exec(tempURL);
if(m) { if(m) sandboxLocation = m[0];
sandboxLocation = m[0];
} }
} }
Zotero.debug("Translate: binding sandbox to "+sandboxLocation); Zotero.debug("Translate: Binding sandbox to "+sandboxLocation, 4);
} }
// set up sandbox
this._sandbox = new Components.utils.Sandbox(sandboxLocation); this._sandbox = new Components.utils.Sandbox(sandboxLocation);
this._sandbox.Zotero = new Object(); this._sandbox.Zotero = new Object();
// add ingester utilities // add utilities
this._sandbox.Zotero.Utilities = new Zotero.Utilities.Ingester(this); this._sandbox.Zotero.Utilities = new Zotero.Utilities.Translate(this);
this._sandbox.Zotero.Utilities.HTTP = new Zotero.Utilities.Ingester.HTTP(this); this._sandbox.Zotero.Utilities.HTTP = this._sandbox.Zotero.Utilities;
// set up selectItems handler
this._sandbox.Zotero.selectItems = function(options) { return me._selectItems(options) };
} else {
// use null URL to create sandbox. no idea why a blank string doesn't
// work on all installations, but this should fix things.
this._sandbox = new Components.utils.Sandbox("http://www.example.com/");
this._sandbox.Zotero = new Object();
this._sandbox.Zotero.Utilities = new Zotero.Utilities();
}
if(this.type == "export") { if(this.type == "export") {
// add routines to retrieve items and collections // add routines to retrieve items and collections
@ -678,13 +665,16 @@ Zotero.Translate.prototype._generateSandbox = function() {
this._sandbox.Zotero.Collection = Zotero.Translate.GenerateZoteroCollectionClass(); this._sandbox.Zotero.Collection = Zotero.Translate.GenerateZoteroCollectionClass();
// attach the function to be run when a collection is done // attach the function to be run when a collection is done
this._sandbox.Zotero.Collection.prototype.complete = function() {me._collectionDone(this)}; this._sandbox.Zotero.Collection.prototype.complete = function() {me._collectionDone(this)};
} else if(this.type == "web" || this.type == "search") {
// set up selectItems handler
this._sandbox.Zotero.selectItems = function(options) { return me._selectItems(options) };
} }
} }
this._sandbox.XPathResult = Components.interfaces.nsIDOMXPathResult; this._sandbox.XPathResult = Components.interfaces.nsIDOMXPathResult;
// for debug messages // for debug messages
this._sandbox.Zotero.debug = function(string) {me._debug(string)}; this._sandbox.Zotero.debug = function(string) {me._debug(string, 4)};
// for adding configuration options // for adding configuration options
this._sandbox.Zotero.configure = function(option, value) {me._configure(option, value) }; this._sandbox.Zotero.configure = function(option, value) {me._configure(option, value) };
@ -706,7 +696,7 @@ Zotero.Translate.prototype._generateSandbox = function() {
// note that setLocation() is not allowed // note that setLocation() is not allowed
var safeTranslator = new Object(); var safeTranslator = new Object();
safeTranslator.setSearch = function(arg) { return translation.setSearch(arg) }; safeTranslator.setSearch = function(arg) { return translation.setSearch(arg) };
safeTranslator.setBrowser = function(arg) { return translation.setBrowser(arg) }; safeTranslator.setDocument = function(arg) { return translation.setDocument(arg) };
safeTranslator.setHandler = function(arg1, arg2) { translation.setHandler(arg1, arg2) }; safeTranslator.setHandler = function(arg1, arg2) { translation.setHandler(arg1, arg2) };
safeTranslator.setString = function(arg) { translation.setString(arg) }; safeTranslator.setString = function(arg) { translation.setString(arg) };
safeTranslator.setTranslator = function(arg) { return translation.setTranslator(arg) }; safeTranslator.setTranslator = function(arg) { return translation.setTranslator(arg) };
@ -799,7 +789,7 @@ Zotero.Translate.prototype._setSandboxMode = function(mode) {
*/ */
Zotero.Translate.prototype._configure = function(option, value) { Zotero.Translate.prototype._configure = function(option, value) {
this.configOptions[option] = value; this.configOptions[option] = value;
Zotero.debug("Translate: setting configure option "+option+" to "+value); Zotero.debug("Translate: Setting configure option "+option+" to "+value, 4);
} }
/* /*
@ -811,7 +801,7 @@ Zotero.Translate.prototype._configure = function(option, value) {
*/ */
Zotero.Translate.prototype._addOption = function(option, value) { Zotero.Translate.prototype._addOption = function(option, value) {
this.displayOptions[option] = value; this.displayOptions[option] = value;
Zotero.debug("Translate: setting display option "+option+" to "+value); Zotero.debug("Translate: Setting display option "+option+" to "+value, 4);
} }
/* /*
@ -884,8 +874,8 @@ Zotero.Translate.prototype._translationComplete = function(returnValue, error) {
if(this.type == "search" && !this._itemsDone) { if(this.type == "search" && !this._itemsDone) {
// if we're performing a search and didn't get any results, go on // if we're performing a search and didn't get any results, go on
// to the next translator // to the next translator
Zotero.debug("Translate: could not find a result using "+this.translator[0].label+": \n" Zotero.debug("Translate: Could not find a result using "+this.translator[0].label+": \n"
+this._generateErrorString(error)); +this._generateErrorString(error), 3);
if(this.translator.length > 1) { if(this.translator.length > 1) {
this.translator.shift(); this.translator.shift();
this.translate(); this.translate();
@ -903,7 +893,7 @@ Zotero.Translate.prototype._translationComplete = function(returnValue, error) {
// report error to debug log // report error to debug log
var errorString = this._generateErrorString(error); var errorString = this._generateErrorString(error);
this._debug("Translation using "+(this.translator && this.translator[0] && this.translator[0].label ? this.translator[0].label : "no translator")+" failed: \n"+errorString); this._debug("Translation using "+(this.translator && this.translator[0] && this.translator[0].label ? this.translator[0].label : "no translator")+" failed: \n"+errorString, 2);
if(this.type == "web") { if(this.type == "web") {
// report translation error for webpages // report translation error for webpages
@ -937,12 +927,8 @@ Zotero.Translate.prototype._generateErrorString = function(error) {
} }
errorString += "\nurl => "+this.path errorString += "\nurl => "+this.path
+ "\nextensions.zotero.cacheTranslatorData => "+Zotero.Prefs.get("cacheTranslatorData") + "\ndownloadAssociatedFiles => "+Zotero.Prefs.get("downloadAssociatedFiles")
// TODO: Currently using automaticSnapshots pref for everything + "\nautomaticSnapshots => "+Zotero.Prefs.get("automaticSnapshots");
// Eventually downloadAssociatedFiles may be a separate pref
// for PDFs and other large files
+ "\nextensions.zotero.downloadAssociatedFiles => "+Zotero.Prefs.get("downloadAssociatedFiles");
+ "\nextensions.zotero.automaticSnapshots => "+Zotero.Prefs.get("automaticSnapshots");
return errorString.substr(1); return errorString.substr(1);
} }
@ -951,10 +937,10 @@ Zotero.Translate.prototype._generateErrorString = function(error) {
*/ */
Zotero.Translate.prototype._reportTranslationFailure = function(errorData) { Zotero.Translate.prototype._reportTranslationFailure = function(errorData) {
if(this.translator[0].inRepository && Zotero.Prefs.get("reportTranslationFailure")) { if(this.translator[0].inRepository && Zotero.Prefs.get("reportTranslationFailure")) {
var postBody = "ids[]="+escape(this.translator[0].translatorID)+ var postBody = "id=" + encodeURIComponent(this.translator[0].translatorID) +
"&lastUpdated="+escape(this.translator[0].lastUpdated)+ "&lastUpdated=" + encodeURIComponent(this.translator[0].lastUpdated) +
"&extVersion="+escape(Zotero.version)+ "&diagnostic=" + encodeURIComponent(Zotero.getSystemInfo()) +
"&errorData="+escape(errorData); "&errorData=" + encodeURIComponent(errorData);
Zotero.Utilities.HTTP.doPost("http://www.zotero.org/repo/report", postBody); Zotero.Utilities.HTTP.doPost("http://www.zotero.org/repo/report", postBody);
} }
} }
@ -1081,7 +1067,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
if(this._parentTranslator) { if(this._parentTranslator) {
var pt = this._parentTranslator; var pt = this._parentTranslator;
item.complete = function() { pt._itemDone(this) }; item.complete = function() { pt._itemDone(this) };
Zotero.debug("Translate: calling done from parent sandbox"); Zotero.debug("Translate: Calling done from parent sandbox", 4);
} }
this.runHandler("itemDone", item); this.runHandler("itemDone", item);
return; return;
@ -1111,14 +1097,14 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
// create new item // create new item
if(type == "attachment") { if(type == "attachment") {
if(this.type != "import") { if(this.type != "import") {
Zotero.debug("Translate: discarding standalone attachment"); Zotero.debug("Translate: Discarding standalone attachment", 2);
return; return;
} }
Zotero.debug("Translate: adding attachment"); Zotero.debug("Translate: Adding attachment", 4);
if(!item.url && !item.path) { if(!item.url && !item.path) {
Zotero.debug("Translate: ignoring attachment: no path or URL specified"); Zotero.debug("Translate: Ignoring attachment: no path or URL specified", 2);
return; return;
} }
@ -1130,7 +1116,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
item.path = item.url; item.path = item.url;
item.url = false; item.url = false;
} else if(protocol != "http" && protocol != "https") { } else if(protocol != "http" && protocol != "https") {
Zotero.debug("Translate: unrecognized protocol "+protocol); Zotero.debug("Translate: Unrecognized protocol "+protocol, 2);
return; return;
} }
} }
@ -1142,10 +1128,10 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
(item.mimeType ? item.mimeType : undefined), (item.mimeType ? item.mimeType : undefined),
(item.title ? item.title : undefined)); (item.title ? item.title : undefined));
} catch(e) { } catch(e) {
Zotero.debug("Translate: error adding attachment "+item.url); Zotero.debug("Translate: Error adding attachment "+item.url, 2);
return; return;
} }
Zotero.debug("Translate: created attachment; id is "+myID); Zotero.debug("Translate: Created attachment; id is "+myID, 4);
var newItem = Zotero.Items.get(myID); var newItem = Zotero.Items.get(myID);
} else { } else {
// generate nsIFile // generate nsIFile
@ -1205,7 +1191,11 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
for(var j in data) { for(var j in data) {
// try to assign correct creator type // try to assign correct creator type
if(data[j].creatorType) { if(data[j].creatorType) {
var creatorTypeID = Zotero.CreatorTypes.getID(data[j].creatorType); try {
var creatorType = Zotero.CreatorTypes.getID(data[j].creatorType);
} catch(e) {
Zotero.debug("Translate: Invalid creator type "+data[j].creatorType+" for creator index "+j, 2);
}
} }
if(!creatorTypeID) { if(!creatorTypeID) {
var creatorTypeID = 1; var creatorTypeID = 1;
@ -1240,14 +1230,14 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
// try to map from base field // try to map from base field
if(Zotero.ItemFields.isBaseField(fieldID)) { if(Zotero.ItemFields.isBaseField(fieldID)) {
var fieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID); var fieldID = Zotero.ItemFields.getFieldIDFromTypeAndBase(typeID, fieldID);
if(fieldID) Zotero.debug("Translate: mapping "+field+" to "+Zotero.ItemFields.getName(fieldID)); if(fieldID) Zotero.debug("Translate: Mapping "+field+" to "+Zotero.ItemFields.getName(fieldID), 5);
} }
// if field is valid for this type, set field // if field is valid for this type, set field
if(fieldID && Zotero.ItemFields.isValidForType(fieldID, typeID)) { if(fieldID && Zotero.ItemFields.isValidForType(fieldID, typeID)) {
newItem.setField(fieldID, data); newItem.setField(fieldID, data);
} else { } else {
Zotero.debug("Translate: discarded field "+field+" for item: field not valid for type "+type); Zotero.debug("Translate: Discarded field "+field+" for item: field not valid for type "+type, 3);
} }
} }
} }
@ -1316,11 +1306,13 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
var downloadAssociatedFiles = Zotero.Prefs.get("downloadAssociatedFiles"); var downloadAssociatedFiles = Zotero.Prefs.get("downloadAssociatedFiles");
// handle attachments // handle attachments
if(item.attachments && this.saveAttachments && (automaticSnapshots || downloadAssociatedFiles)) { if(item.attachments && this.saveAttachments &&
// DEBUG: is "this.type == 'import'" still necessary with this.saveAttachments?
(this.type == 'import' || automaticSnapshots || downloadAssociatedFiles)) {
for each(var attachment in item.attachments) { for each(var attachment in item.attachments) {
if(this.type == "web") { if(this.type == "web") {
if(!attachment.url && !attachment.document) { if(!attachment.url && !attachment.document) {
Zotero.debug("Translate: not adding attachment: no URL specified"); Zotero.debug("Translate: Not adding attachment: no URL specified", 2);
} else { } else {
if(attachment.snapshot === false) { if(attachment.snapshot === false) {
if(!automaticSnapshots) { if(!automaticSnapshots) {
@ -1334,7 +1326,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
(attachment.title ? attachment.title : attachment.document.title)); (attachment.title ? attachment.title : attachment.document.title));
} else { } else {
if(!attachment.mimeType || !attachment.title) { if(!attachment.mimeType || !attachment.title) {
Zotero.debug("Translate: NOTICE: either mimeType or title is missing; attaching file will be slower"); Zotero.debug("Translate: Either mimeType or title is missing; attaching file will be slower", 3);
} }
try { try {
@ -1342,7 +1334,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
(attachment.mimeType ? attachment.mimeType : undefined), (attachment.mimeType ? attachment.mimeType : undefined),
(attachment.title ? attachment.title : undefined)); (attachment.title ? attachment.title : undefined));
} catch(e) { } catch(e) {
Zotero.debug("Translate: error adding attachment "+attachment.url); Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
} }
} }
} else if(attachment.document } else if(attachment.document
@ -1354,7 +1346,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
try { try {
Zotero.Attachments.importFromDocument(attachment.document, myID, attachment.title); Zotero.Attachments.importFromDocument(attachment.document, myID, attachment.title);
} catch(e) { } catch(e) {
Zotero.debug("Translate: error attaching document"); Zotero.debug("Translate: Error attaching document", 2);
} }
// Save attachment if snapshot pref enabled or not HTML // Save attachment if snapshot pref enabled or not HTML
// (in which case downloadAssociatedFiles applies) // (in which case downloadAssociatedFiles applies)
@ -1386,7 +1378,7 @@ Zotero.Translate.prototype._itemDone = function(item, attachedTo) {
try { try {
Zotero.Attachments.importFromURL(attachment.url, myID, title, fileBaseName); Zotero.Attachments.importFromURL(attachment.url, myID, title, fileBaseName);
} catch(e) { } catch(e) {
Zotero.debug("Zotero.Translate: error adding attachment "+attachment.url); Zotero.debug("Translate: Error adding attachment "+attachment.url, 2);
} }
} }
} }
@ -1493,10 +1485,10 @@ Zotero.Translate.prototype._processCollection = function(collection, parentID) {
} else { } else {
// add mapped items to collection // add mapped items to collection
if(this._IDMap[child.id]) { if(this._IDMap[child.id]) {
Zotero.debug("Translate: adding "+this._IDMap[child.id]); Zotero.debug("Translate: Adding "+this._IDMap[child.id], 5);
newCollection.addItem(this._IDMap[child.id]); newCollection.addItem(this._IDMap[child.id]);
} else { } else {
Zotero.debug("Translate: could not map "+child.id+" to an imported item"); Zotero.debug("Translate: Could not map "+child.id+" to an imported item", 2);
} }
} }
} }
@ -1507,10 +1499,13 @@ Zotero.Translate.prototype._processCollection = function(collection, parentID) {
/* /*
* logs a debugging message * logs a debugging message
*/ */
Zotero.Translate.prototype._debug = function(string) { Zotero.Translate.prototype._debug = function(string, level) {
// if handler does not return anything explicitly false, show debug // if handler does not return anything explicitly false, show debug
// message in console // message in console
if(this.runHandler("debug", string) !== false) Zotero.debug(string, 4); if(this.runHandler("debug", string) !== false) {
if(typeof string == "string") string = "Translate: "+string;
Zotero.debug(string, level);
}
} }
/* /*
@ -1550,41 +1545,41 @@ Zotero.Translate.prototype._search = function() {
**/ **/
Zotero.Translate.prototype._import = function() { Zotero.Translate.prototype._import = function() {
this.waitForCompletion = true; this.waitForCompletion = true;
var me = this; this._importSniffCharacterSet();
this._importGetCharacterSet(function(charset) { me._importDoComplete(charset) });
return true;
} }
/** /**
* Sniff file if a real file exists * Sniff file for its character set, then proceed with the rest of translation
* */
* @param {Function} callback A callback function to be executed after sniffing Zotero.Translate.prototype._importSniffCharacterSet = function(callback) {
**/
Zotero.Translate.prototype._importGetCharacterSet = function(callback) {
if(!this._storage) { if(!this._storage) {
// need to check charset
if(this._charset) { if(this._charset) {
// have charset already; just go on // have charset already; just go on
callback(this._charset); this._importDoneSniffing(this._charset);
} else { } else {
// need to check charset
importCharset = Zotero.Prefs.get("import.charset");
if(importCharset == "auto") {
// look for charset // look for charset
var me = this; var me = this;
Zotero.File.getCharsetFromFile(this.location, "text/plain", Zotero.File.getCharsetFromFile(this.location, "text/plain",
function(charset) { function(charset) {
me._charset = charset; me._charset = charset;
callback(charset); me._importDoneSniffing(charset);
}); });
} else {
this._importDoneSniffing(importCharset);
}
} }
} else { } else {
callback(); this._importDoneSniffing();
} }
} }
/** /**
* Complete import (used as callback after sniffing) * Complete import (used as callback after sniffing)
**/ **/
Zotero.Translate.prototype._importDoComplete = function(charset) { Zotero.Translate.prototype._importDoneSniffing = function(charset) {
this._importConfigureIO(charset); this._importConfigureIO(charset);
try { try {
@ -1659,19 +1654,22 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
this._streams.push(this._inputStream); this._streams.push(this._inputStream);
} }
var filePosition = 0; var bomLength = 0;
if(charset === undefined || (charset && charset.length > 3 && charset.substr(0, 3) == "UTF")) {
if(charset) { // if have detected charset
Zotero.debug("Using detected character set "+charset);
// seek past BOM // seek past BOM
if(charset.length > 3 && charset.substr(0, 3) == "UTF") { var bomCharset = this._importGetBOM();
var BOMLength = this._importGetBOMLength(); var bomLength = (bomCharset ? BOMs[bomCharset].length : 0);
this._inputStream.QueryInterface(Components.interfaces.nsISeekableStream) this._inputStream.QueryInterface(Components.interfaces.nsISeekableStream)
.seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, BOMLength); .seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, bomLength);
if(bomCharset) charset = this._charset = bomCharset;
} }
var intlStream = null;
if(charset) {
// if have detected charset
Zotero.debug("Translate: Using detected character set "+charset, 3);
// convert from detected charset // convert from detected charset
var intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"] intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
.createInstance(Components.interfaces.nsIConverterInputStream); .createInstance(Components.interfaces.nsIConverterInputStream);
intlStream.init(this._inputStream, charset, 65535, intlStream.init(this._inputStream, charset, 65535,
Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER); Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER);
@ -1680,12 +1678,9 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
// allow translator to set charset // allow translator to set charset
this._sandbox.Zotero.setCharacterSet = function(charset) { this._sandbox.Zotero.setCharacterSet = function(charset) {
// seek // seek back to the beginning
if(filePosition != 0) {
me._inputStream.QueryInterface(Components.interfaces.nsISeekableStream) me._inputStream.QueryInterface(Components.interfaces.nsISeekableStream)
.seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, filePosition); .seek(Components.interfaces.nsISeekableStream.NS_SEEK_SET, bomLength);
me._inputStream.QueryInterface(Components.interfaces.nsIFileInputStream);
}
intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"] intlStream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
.createInstance(Components.interfaces.nsIConverterInputStream); .createInstance(Components.interfaces.nsIConverterInputStream);
@ -1695,7 +1690,6 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
} catch(e) { } catch(e) {
throw "Text encoding not supported"; throw "Text encoding not supported";
} }
me._streams.push(intlStream); me._streams.push(intlStream);
} }
@ -1710,7 +1704,6 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
var amountRead = me._inputStream.readLine(str); var amountRead = me._inputStream.readLine(str);
} }
if(amountRead) { if(amountRead) {
filePosition += amountRead;
return str.value; return str.value;
} else { } else {
return false; return false;
@ -1725,7 +1718,6 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
var amountRead = intlStream.readString(amount, str); var amountRead = intlStream.readString(amount, str);
if(amountRead) { if(amountRead) {
filePosition += amountRead;
return str.value; return str.value;
} else { } else {
return false; return false;
@ -1740,7 +1732,6 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
// read from the scriptable input stream // read from the scriptable input stream
var string = sStream.read(amount); var string = sStream.read(amount);
filePosition += string.length;
return string; return string;
} }
} }
@ -1757,7 +1748,7 @@ Zotero.Translate.prototype._importConfigureIO = function(charset) {
* *
* @return The length of the UTF BOM. * @return The length of the UTF BOM.
*/ */
Zotero.Translate.prototype._importGetBOMLength = function() { Zotero.Translate.prototype._importGetBOM = function() {
// if not checked for a BOM, open a binary input stream and read // if not checked for a BOM, open a binary input stream and read
var binStream = Components.classes["@mozilla.org/binaryinputstream;1"]. var binStream = Components.classes["@mozilla.org/binaryinputstream;1"].
createInstance(Components.interfaces.nsIBinaryInputStream); createInstance(Components.interfaces.nsIBinaryInputStream);
@ -1778,7 +1769,7 @@ Zotero.Translate.prototype._importGetBOMLength = function() {
if(possibleBOMs[charset][0] == readChar) { if(possibleBOMs[charset][0] == readChar) {
if(possibleBOMs[charset].length == 1) { if(possibleBOMs[charset].length == 1) {
// have checked entire BOM // have checked entire BOM
return BOMs[charset].length; return charset;
} else { } else {
// keep checking // keep checking
newBOMs[charset] = possibleBOMs[charset].substr(1); newBOMs[charset] = possibleBOMs[charset].substr(1);
@ -1790,7 +1781,7 @@ Zotero.Translate.prototype._importGetBOMLength = function() {
possibleBOMs = newBOMs; possibleBOMs = newBOMs;
} }
return 0; return null;
} }
/** /**
@ -1940,7 +1931,6 @@ Zotero.Translate.prototype._exportConfigureIO = function() {
if(streamCharset == "MACINTOSH") { if(streamCharset == "MACINTOSH") {
// fix buggy Mozilla MacRoman // fix buggy Mozilla MacRoman
splitData = data.split(/([\r\n]+)/); splitData = data.split(/([\r\n]+)/);
Zotero.debug(splitData);
for(var i=0; i<splitData.length; i+=2) { for(var i=0; i<splitData.length; i+=2) {
// write raw newlines straight to the string // write raw newlines straight to the string
intlStream.writeString(splitData[i]); intlStream.writeString(splitData[i]);
@ -2291,20 +2281,16 @@ Zotero.Translate.TranslatorSearch.prototype.execute = function() {
if(this.translate.type == "import") { if(this.translate.type == "import") {
var me = this; var me = this;
this.translate._importGetCharacterSet(function(charset) {
try { try {
me.translate._importConfigureIO(charset); // so it can read this.translate._importConfigureIO(); // so it can read
} catch(e) { } catch(e) {
Zotero.debug("Translate: "+e+' in opening IO for '+translator.label); Zotero.debug("Translate: "+e+' in opening IO for '+translator.label);
me.execute(); this.execute();
return; return;
} }
me.runDetectCode(translator);
});
} else {
this.runDetectCode(translator);
} }
this.runDetectCode(translator);
} else { } else {
this.execute(); this.execute();
} }
@ -2336,7 +2322,7 @@ Zotero.Translate.TranslatorSearch.prototype.runDetectCode = function(translator)
return; return;
} }
Zotero.debug("Translate: executed detectCode for "+translator.label); Zotero.debug("Translate: Executed detectCode for "+translator.label, 4);
if(this.translate.type == "web" && this.translate.waitForCompletion) { if(this.translate.type == "web" && this.translate.waitForCompletion) {
this.asyncMode = true; this.asyncMode = true;
@ -2382,7 +2368,7 @@ Zotero.Translate.TranslatorSearch.prototype.checkDone = function() {
* Processes the return value from a translator * Processes the return value from a translator
*/ */
Zotero.Translate.TranslatorSearch.prototype.processReturnValue = function(translator, returnValue) { Zotero.Translate.TranslatorSearch.prototype.processReturnValue = function(translator, returnValue) {
Zotero.debug("Translate: found translator "+translator.label); Zotero.debug("Translate: Found translator "+translator.label, 3);
if(typeof(returnValue) == "string") { if(typeof(returnValue) == "string") {
translator.itemType = returnValue; translator.itemType = returnValue;
@ -2402,7 +2388,7 @@ Zotero.Translate.TranslatorSearch.prototype.complete = function(returnValue, err
this.processReturnValue(this.currentTranslator, returnValue); this.processReturnValue(this.currentTranslator, returnValue);
} else if(error) { } else if(error) {
var errorString = this.translate._generateErrorString(error); var errorString = this.translate._generateErrorString(error);
this.translate._debug("detectCode for "+(this.currentTranslator ? this.currentTranslator.label : "no translator")+" failed: \n"+errorString); this.translate._debug("detectCode for "+(this.currentTranslator ? this.currentTranslator.label : "no translator")+" failed: \n"+errorString, 4);
} }
this.currentTranslator = undefined; this.currentTranslator = undefined;

File diff suppressed because it is too large Load diff

View file

@ -38,10 +38,13 @@ var Zotero = new function(){
this.stateCheck = stateCheck; this.stateCheck = stateCheck;
//this.shutdown = shutdown; //this.shutdown = shutdown;
this.getProfileDirectory = getProfileDirectory; this.getProfileDirectory = getProfileDirectory;
this.getInstallDirectory = getInstallDirectory;
this.getZoteroDirectory = getZoteroDirectory; this.getZoteroDirectory = getZoteroDirectory;
this.getStorageDirectory = getStorageDirectory; this.getStorageDirectory = getStorageDirectory;
this.getZoteroDatabase = getZoteroDatabase; this.getZoteroDatabase = getZoteroDatabase;
this.getTempDirectory = getTempDirectory; this.getTempDirectory = getTempDirectory;
this.convertChromeURLToFile = convertChromeURLToFile;
this.convertChromeURLToFileURL = convertChromeURLToFileURL;
this.chooseZoteroDirectory = chooseZoteroDirectory; this.chooseZoteroDirectory = chooseZoteroDirectory;
this.debug = debug; this.debug = debug;
this.log = log; this.log = log;
@ -310,6 +313,15 @@ var Zotero = new function(){
} }
function getInstallDirectory() {
var id = ZOTERO_CONFIG.GUID;
var em = Components.classes["@mozilla.org/extensions/manager;1"].
getService(Components.interfaces.nsIExtensionManager);
var installDir = em.getInstallLocation(id).getItemLocation(id);
return installDir;
}
function getZoteroDirectory(){ function getZoteroDirectory(){
if (_zoteroDirectory != false) { if (_zoteroDirectory != false) {
// Return a clone of the file pointer so that callers can modify it // Return a clone of the file pointer so that callers can modify it
@ -319,7 +331,14 @@ var Zotero = new function(){
if (Zotero.Prefs.get('useDataDir')) { if (Zotero.Prefs.get('useDataDir')) {
var file = Components.classes["@mozilla.org/file/local;1"]. var file = Components.classes["@mozilla.org/file/local;1"].
createInstance(Components.interfaces.nsILocalFile); createInstance(Components.interfaces.nsILocalFile);
try {
file.persistentDescriptor = Zotero.Prefs.get('dataDir'); file.persistentDescriptor = Zotero.Prefs.get('dataDir');
}
catch (e) {
Zotero.debug("Persistent descriptor in extensions.zotero.dataDir did not resolve", 1);
e = { name: "NS_ERROR_FILE_NOT_FOUND" };
throw (e);
}
if (!file.exists()) { if (!file.exists()) {
var e = { name: "NS_ERROR_FILE_NOT_FOUND" }; var e = { name: "NS_ERROR_FILE_NOT_FOUND" };
throw (e); throw (e);
@ -378,6 +397,72 @@ var Zotero = new function(){
} }
/**
* Get a file from a chrome://zotero URL
*
* Currently only works for skin URLs
*
* @param {String} chromeURI
* @return {nsIFile}
*/
function convertChromeURLToFile(chromeURL) {
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var uri = ios.newURI(chromeURL, null, null);
uri.QueryInterface(Components.interfaces.nsIStandardURL);
if (uri.scheme != 'chrome') {
throw ("URI " + uri.spec +
" not a chrome URI in Zotero.convertChromeURLToFileURL()");
}
if (uri.host != 'zotero') {
throw ("URI " + uri.spec +
" not a Zotero chrome URI in Zotero.convertChromeURLToFileURL()");
}
var parts = uri.path.substr(1).split('/');
// Auto-expand URL if necessary
var chromeReg = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
.getService(Components.interfaces.nsIChromeRegistry);
uri = chromeReg.convertChromeURL(uri);
var file = this.getInstallDirectory();
file.append('chrome');
switch (parts[0]) {
case 'skin':
file.append('skin');
file.append('default');
file.append('zotero');
for (var i=1; i<parts.length; i++) {
file.append(parts[i]);
}
break;
default:
throw ("Chrome URI part '" + parts[0]
+ "' not implemented in Zotero.convertChromeURLToFileURL()")
}
return file;
}
/**
* @param {String} chromeURI
* @return {nsIURL} file:// nsIURL
*/
function convertChromeURLToFileURL(chromeURL) {
var ios = Components.classes["@mozilla.org/network/io-service;1"].
getService(Components.interfaces.nsIIOService);
var file = this.convertChromeURLToFile(chromeURL);
return ios.newFileURI(file).spec;
}
function chooseZoteroDirectory(forceRestartNow, useProfileDir) { function chooseZoteroDirectory(forceRestartNow, useProfileDir) {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator); .getService(Components.interfaces.nsIWindowMediator);
@ -590,7 +675,8 @@ var Zotero = new function(){
platform: Zotero.platform, platform: Zotero.platform,
locale: Zotero.locale, locale: Zotero.locale,
appName: appInfo.name, appName: appInfo.name,
appVersion: appInfo.version appVersion: appInfo.version,
extensions: this.getInstalledExtensions().join(', ')
}; };
var str = ''; var str = '';
@ -602,6 +688,31 @@ var Zotero = new function(){
} }
/**
* @return {String[]} Array of extension names and versions
*/
this.getInstalledExtensions = function () {
var em = Components.classes["@mozilla.org/extensions/manager;1"].
getService(Components.interfaces.nsIExtensionManager);
var installed = em.getItemList(
Components.interfaces.nsIUpdateItem.TYPE_ANY, {}
);
var addons = [];
for each(var addon in installed) {
switch (addon.id) {
case "zotero@chnm.gmu.edu":
case "{972ce4c6-7e08-4474-a285-3208198ce6fd}": // Default theme
continue;
}
addons.push(addon.name + " (" + addon.version
+ (addon.type != 2 ? ", " + addon.type : "") + ")");
}
return addons;
}
/** /**
* PHP var_dump equivalent for JS * PHP var_dump equivalent for JS
* *
@ -1803,6 +1914,11 @@ Zotero.Browser = new function() {
hiddenBrowser.setAttribute('type', 'content'); hiddenBrowser.setAttribute('type', 'content');
hiddenBrowser.setAttribute('disablehistory', 'true'); hiddenBrowser.setAttribute('disablehistory', 'true');
win.document.documentElement.appendChild(hiddenBrowser); win.document.documentElement.appendChild(hiddenBrowser);
// Disable some features
hiddenBrowser.docShell.allowImages = false;
hiddenBrowser.docShell.allowJavascript = false;
hiddenBrowser.docShell.allowMetaRedirects = false;
hiddenBrowser.docShell.allowPlugins = false;
Zotero.debug("created hidden browser (" Zotero.debug("created hidden browser ("
+ win.document.getElementsByTagName('browser').length + ")"); + win.document.getElementsByTagName('browser').length + ")");
return hiddenBrowser; return hiddenBrowser;

View file

@ -102,6 +102,10 @@
<!ENTITY zotero.preferences.prefpane.advanced "Advanced"> <!ENTITY zotero.preferences.prefpane.advanced "Advanced">
<!ENTITY zotero.preferences.charset "Character Encoding">
<!ENTITY zotero.preferences.charset.importCharset "Import Character Encoding">
<!ENTITY zotero.preferences.charset.displayExportOption "Display character encoding option on export">
<!ENTITY zotero.preferences.dataDir "Storage Location"> <!ENTITY zotero.preferences.dataDir "Storage Location">
<!ENTITY zotero.preferences.dataDir.useProfile "Use Firefox profile directory"> <!ENTITY zotero.preferences.dataDir.useProfile "Use Firefox profile directory">
<!ENTITY zotero.preferences.dataDir.custom "Custom:"> <!ENTITY zotero.preferences.dataDir.custom "Custom:">

View file

@ -123,7 +123,6 @@
<!ENTITY zotero.charset.label "Character Encoding"> <!ENTITY zotero.charset.label "Character Encoding">
<!ENTITY zotero.moreEncodings.label "More Encodings"> <!ENTITY zotero.moreEncodings.label "More Encodings">
<!ENTITY zotero.charset.auto "auto detect">
<!ENTITY zotero.citation.keepSorted.label "Keep Sources Sorted"> <!ENTITY zotero.citation.keepSorted.label "Keep Sources Sorted">

View file

@ -455,6 +455,7 @@ fulltext.indexState.partial = Partial
exportOptions.exportNotes = Export Notes exportOptions.exportNotes = Export Notes
exportOptions.exportFileData = Export Files exportOptions.exportFileData = Export Files
charset.UTF8withoutBOM = Unicode (UTF-8 without BOM) charset.UTF8withoutBOM = Unicode (UTF-8 without BOM)
charset.autoDetect = (auto detect)
date.daySuffixes = st, nd, rd, th date.daySuffixes = st, nd, rd, th
date.abbreviation.year = y date.abbreviation.year = y

Binary file not shown.

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 682 B

After

Width:  |  Height:  |  Size: 530 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 670 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 678 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

After

Width:  |  Height:  |  Size: 788 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 987 B

After

Width:  |  Height:  |  Size: 927 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 845 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 976 B

View file

@ -0,0 +1,54 @@
body {
margin: 0;
padding: 0;
background-color: #fff580;
border: 1px solid #878244;
width: auto;
}
#bar {
display: block;
padding: 1px 1px 1px 0;
background-color: #c0b860;
border-bottom: 1px solid #878244;
height: 10px;
}
#close, #move, #collapse {
position: absolute;
display: block;
top: 2px;
cursor: pointer;
width: 10px;
height: 10px;
}
#close {
left: 1px;
}
#move {
right: 14px;
}
#collapse {
right: 2px;
}
#grippy {
position: absolute;
display: block;
right: 0;
bottom: 0;
cursor: se-resize;
width: 8px;
height: 8px;
}
#text {
font-family: Arial, Lucida Grande, FreeSans, sans;
font-size: 12px;
border: none;
margin: 3px 2px 5px 2px;
background-color: #fff580;
}

View file

@ -0,0 +1,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<link type="text/css" rel="stylesheet" href="annotation.css" />
</head>
<body>
<div id="bar">
<img id="close" src="annotation-close.png"/>
<img id="move" src="annotation-move.png"/>
<img id="collapse" src="annotation-hide.png"/>
</div>
<img id="grippy" src="annotation-grippy.png"/>
<textarea id="text" wrap="soft"></textarea>
</body>
</html>

View file

@ -345,12 +345,7 @@
#zotero-annotate-tb-collapse #zotero-annotate-tb-collapse
{ {
list-style-image: url('chrome://zotero/skin/annotate-collapse-all.png'); list-style-image: url('chrome://zotero/skin/annotate-collapse.png');
}
#zotero-annotate-tb-expand
{
list-style-image: url('chrome://zotero/skin/annotate-expand-all.png');
} }
#zotero-annotate-tb-highlight #zotero-annotate-tb-highlight

View file

@ -28,7 +28,6 @@ ul.report {
font-size: 1.4em; font-size: 1.4em;
width: 680px; width: 680px;
margin: 0 auto; margin: 0 auto;
overflow: auto;
padding: 20px 20px; padding: 20px 20px;
} }

View file

@ -73,6 +73,8 @@ function ChromeExtensionHandler() {
var ReportExtension = new function(){ var ReportExtension = new function(){
this.newChannel = newChannel; this.newChannel = newChannel;
this.__defineGetter__('loadAsChrome', function () { return true; });
function newChannel(uri){ function newChannel(uri){
var ioService = Components.classes["@mozilla.org/network/io-service;1"] var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService); .getService(Components.interfaces.nsIIOService);
@ -414,6 +416,8 @@ function ChromeExtensionHandler() {
var TimelineExtension = new function(){ var TimelineExtension = new function(){
this.newChannel = newChannel; this.newChannel = newChannel;
this.__defineGetter__('loadAsChrome', function () { return true; });
/* /*
queryString key abbreviations: intervals = i | dateType = t | timelineDate = d queryString key abbreviations: intervals = i | dateType = t | timelineDate = d
@ -625,6 +629,8 @@ function ChromeExtensionHandler() {
var AttachmentExtension = new function() { var AttachmentExtension = new function() {
this.newChannel = newChannel; this.newChannel = newChannel;
this.__defineGetter__('loadAsChrome', function () { return false; });
function newChannel(uri) { function newChannel(uri) {
var ioService = Components.classes["@mozilla.org/network/io-service;1"] var ioService = Components.classes["@mozilla.org/network/io-service;1"]
.getService(Components.interfaces.nsIIOService); .getService(Components.interfaces.nsIIOService);
@ -638,15 +644,29 @@ function ChromeExtensionHandler() {
var [id, fileName] = uri.path.substr(1).split('/'); var [id, fileName] = uri.path.substr(1).split('/');
if (parseInt(id) != id) { if (parseInt(id) != id) {
// Proxy annotation icons
if (id.match(/^annotation.*\.(png|html|css|gif)$/)) {
var chromeURL = 'chrome://zotero/skin/' + id;
var file = Zotero.convertChromeURLToFile(chromeURL);
if (!file.exists()) {
Zotero.debug(file.path + " not found");
Components.utils.reportError(file.path + " not found");
return _errorChannel("File not found");
}
}
else {
return _errorChannel("Attachment id not an integer"); return _errorChannel("Attachment id not an integer");
} }
}
if (!file) {
var item = Zotero.Items.get(id); var item = Zotero.Items.get(id);
if (!item) { if (!item) {
return _errorChannel("Item not found"); return _errorChannel("Item not found");
} }
var file = item.getFile(); var file = item.getFile();
}
if (!file) { if (!file) {
return _errorChannel("File not found"); return _errorChannel("File not found");
} }
@ -661,7 +681,7 @@ function ChromeExtensionHandler() {
var ph = Components.classes["@mozilla.org/network/protocol;1?name=file"]. var ph = Components.classes["@mozilla.org/network/protocol;1?name=file"].
createInstance(Components.interfaces.nsIFileProtocolHandler); createInstance(Components.interfaces.nsIFileProtocolHandler);
fileURI = ph.newFileURI(file); var fileURI = ph.newFileURI(file);
var channel = ioService.newChannelFromURI(fileURI); var channel = ioService.newChannelFromURI(fileURI);
return channel; return channel;
} }
@ -745,7 +765,10 @@ ChromeExtensionHandler.prototype = {
defaultPort : -1, defaultPort : -1,
protocolFlags : Components.interfaces.nsIProtocolHandler.URI_STD, protocolFlags :
Components.interfaces.nsIProtocolHandler.URI_NORELATIVE |
Components.interfaces.nsIProtocolHandler.URI_NOAUTH |
Components.interfaces.nsIProtocolHandler.URI_IS_LOCAL_FILE,
allowPort : function(port, scheme) { allowPort : function(port, scheme) {
return false; return false;
@ -755,7 +778,6 @@ ChromeExtensionHandler.prototype = {
var newURL = Components.classes["@mozilla.org/network/standard-url;1"] var newURL = Components.classes["@mozilla.org/network/standard-url;1"]
.createInstance(Components.interfaces.nsIStandardURL); .createInstance(Components.interfaces.nsIStandardURL);
newURL.init(1, -1, spec, charset, baseURI); newURL.init(1, -1, spec, charset, baseURI);
return newURL.QueryInterface(Components.interfaces.nsIURI); return newURL.QueryInterface(Components.interfaces.nsIURI);
}, },
@ -771,11 +793,11 @@ ChromeExtensionHandler.prototype = {
try { try {
var uriString = uri.spec.toLowerCase(); var uriString = uri.spec.toLowerCase();
for (extSpec in this._extensions) { for (var extSpec in this._extensions) {
var ext = this._extensions[extSpec]; var ext = this._extensions[extSpec];
if (uriString.indexOf(extSpec) == 0) { if (uriString.indexOf(extSpec) == 0) {
if (this._systemPrincipal == null) { if (ext.loadAsChrome && this._systemPrincipal == null) {
var chromeURI = chromeService.newURI(DUMMY_CHROME_URL, null, null); var chromeURI = chromeService.newURI(DUMMY_CHROME_URL, null, null);
var chromeChannel = chromeService.newChannel(chromeURI); var chromeChannel = chromeService.newChannel(chromeURI);
@ -796,8 +818,8 @@ ChromeExtensionHandler.prototype = {
chromeRequest.cancel(0x804b0002); // BINDING_ABORTED chromeRequest.cancel(0x804b0002); // BINDING_ABORTED
} }
if (this._systemPrincipal != null) { // Apply cached system principal to extension channel
// applying cached system principal to extension channel if (ext.loadAsChrome) {
extChannel.owner = this._systemPrincipal; extChannel.owner = this._systemPrincipal;
} }

View file

@ -69,6 +69,8 @@ pref("extensions.zotero.export.lastStyle", 'http://www.zotero.org/styles/chicago
pref("extensions.zotero.export.bibliographySettings", 'save-as-rtf'); pref("extensions.zotero.export.bibliographySettings", 'save-as-rtf');
pref("extensions.zotero.export.bibliographyLocale", ''); pref("extensions.zotero.export.bibliographyLocale", '');
pref("extensions.zotero.export.citePaperJournalArticleURL", false); pref("extensions.zotero.export.citePaperJournalArticleURL", false);
pref("extensions.zotero.export.displayCharsetOption", false);
pref("extensions.zotero.import.charset", "auto");
pref("extensions.zotero.export.quickCopy.setting", 'bibliography=http://www.zotero.org/styles/chicago-note'); pref("extensions.zotero.export.quickCopy.setting", 'bibliography=http://www.zotero.org/styles/chicago-note');

File diff suppressed because it is too large Load diff