diff --git a/chrome/content/zotero/timelineInterface.js b/chrome/content/zotero/timelineInterface.js index ec1e383997..c52e0f93df 100644 --- a/chrome/content/zotero/timelineInterface.js +++ b/chrome/content/zotero/timelineInterface.js @@ -22,26 +22,24 @@ var Zotero_Timeline_Interface = new function() { - this.loadTimeline = loadTimeline; - /* * Load a timeline for the currently selected collection */ - function loadTimeline() { + this.loadTimeline = function () { var uri = 'zotero://timeline/'; - var id = ZoteroPane.getSelectedCollection(true); + var col = ZoteroPane.getSelectedCollection(); - if (id) { - window.loadURI(uri + 'collection/' + id); + if (col) { + window.loadURI(uri + 'collection/' + Zotero.Collections.getLibraryKeyHash(col)); return; } - var id = ZoteroPane.getSelectedSavedSearch(true); - if (id) { - window.loadURI(uri + 'search/' + id); + var s = ZoteroPane.getSelectedSavedSearch(); + if (s) { + window.loadURI(uri + 'search/' + Zotero.Searches.getLibraryKeyHash(s)); return; } - window.loadURI(uri); + window.loadURI(uri); } } diff --git a/components/zotero-protocol-handler.js b/components/zotero-protocol-handler.js index 42a25c4735..707b23df21 100644 --- a/components/zotero-protocol-handler.js +++ b/components/zotero-protocol-handler.js @@ -49,17 +49,17 @@ function ChromeExtensionHandler() { * Example URLs: * * zotero://report/ -- library - * zotero://report/collection/12345 - * zotero://report/search/12345 - * zotero://report/items/12345-23456-34567 - * zotero://report/item/12345 + * zotero://report/collection/0_ABCD1234 + * zotero://report/search/0_ABCD1234 + * zotero://report/items/0_ABCD1234-0_BCDE2345-0_CDEF3456 + * zotero://report/item/0_ABCD1234 * - * Optional format can be specified after ids + * Optional format can be specified after hashes * - * - 'html', 'rtf', 'csv' + * - 'html', 'rtf', 'csv' ['rtf' and 'csv' not yet supported] * - defaults to 'html' if not specified * - * e.g. zotero://report/collection/12345/rtf + * e.g. zotero://report/collection/0_ABCD1234/rtf * * * Sorting: @@ -68,7 +68,11 @@ function ChromeExtensionHandler() { * - format is field[/order] [, field[/order], ...] * - order can be 'asc', 'a', 'desc' or 'd'; defaults to ascending order * - * zotero://report/collection/13245?sort=itemType/d,title + * zotero://report/collection/0_ABCD1234?sort=itemType/d,title + * + * + * Also supports ids (e.g., zotero://report/collection/1234), but ids are not + * guaranteed to be consistent across synced machines */ var ReportExtension = new function(){ this.newChannel = newChannel; @@ -546,6 +550,54 @@ function ChromeExtensionHandler() { } var pathParts = path.split('/'); + if (pathParts[0] != 'data') { + var [type, id] = pathParts; + } + else { + var [, type, id] = pathParts; + } + + // Get the collection or search object + var collection, search; + switch (type) { + case 'collection': + var lkh = Zotero.Collections.parseLibraryKeyHash(id); + if (lkh) { + collection = Zotero.Collections.getByLibraryAndKey(lkh.libraryID, lkh.key); + } + else { + collection = Zotero.Collections.get(id); + } + if (!collection) { + mimeType = 'text/html'; + content = 'Invalid collection ID or key'; + break generateContent; + } + break; + + case 'search': + var lkh = Zotero.Searches.parseLibraryKeyHash(id); + if (lkh) { + var s = Zotero.Searches.getByLibraryAndKey(lkh.libraryID, lkh.key); + } + else { + var s = Zotero.Searches.get(id); + } + if (!s) { + mimeType = 'text/html'; + content = 'Invalid search ID or key'; + break generateContent; + } + + // FIXME: Hack to exclude group libraries for now + var search = new Zotero.Search(); + search.setScope(s); + var groups = Zotero.Groups.getAll(); + for each(var group in groups) { + search.addCondition('libraryID', 'isNot', group.libraryID); + } + break; + } if (pathParts[0] != 'data') { //creates HTML file @@ -580,12 +632,10 @@ function ChromeExtensionHandler() { theTemp = 'document.write("