From d921d8239a7812549d7c2fe981fe9381d4abe0b3 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sun, 15 Jul 2007 18:18:22 +0000 Subject: [PATCH] - Added UI elements for fulltext indexing, including new Search prefpane - Added pdfinfo support to determine number of PDF pages (requires custom binary) - Automatic downloading and installation of customized Xpdf tools from zotero.org Other changes: - Various API Zotero.Fulltext API changes - Prevent buggy automatic prefpane sizing - New 'refresh' Notifier action to just reselect the currently selected item without sending a 'modify' trigger - Zotero.File.putContents(file, str) -- can only handle ASCII text - Zotero.isLinux property --- chrome/content/zotero/overlay.js | 109 +++- chrome/content/zotero/overlay.xul | 17 +- .../content/zotero/preferences/preferences.js | 464 ++++++++++++- .../zotero/preferences/preferences.xul | 102 ++- chrome/content/zotero/xpcom/attachments.js | 19 +- chrome/content/zotero/xpcom/file.js | 18 + chrome/content/zotero/xpcom/fulltext.js | 616 ++++++++++++++---- chrome/content/zotero/xpcom/itemTreeView.js | 13 +- chrome/content/zotero/xpcom/notifier.js | 2 +- chrome/content/zotero/xpcom/schema.js | 28 +- chrome/content/zotero/xpcom/search.js | 2 +- chrome/content/zotero/xpcom/zotero.js | 1 + chrome/locale/en-US/zotero/preferences.dtd | 9 + chrome/locale/en-US/zotero/zotero.properties | 35 + chrome/skin/default/zotero/arrow_refresh.png | Bin 0 -> 685 bytes chrome/skin/default/zotero/overlay.css | 33 + chrome/skin/default/zotero/preferences.css | 146 ++++- chrome/skin/default/zotero/prefs-search.png | Bin 0 -> 1636 bytes userdata.sql | 22 +- 19 files changed, 1466 insertions(+), 170 deletions(-) create mode 100755 chrome/skin/default/zotero/arrow_refresh.png create mode 100644 chrome/skin/default/zotero/prefs-search.png diff --git a/chrome/content/zotero/overlay.js b/chrome/content/zotero/overlay.js index 647ba7d73..8f4f6e35e 100644 --- a/chrome/content/zotero/overlay.js +++ b/chrome/content/zotero/overlay.js @@ -50,6 +50,8 @@ var ZoteroPane = new function() this.updateTagFilter = updateTagFilter; this.onCollectionSelected = onCollectionSelected; this.itemSelected = itemSelected; + this.updateItemIndexedState = updateItemIndexedState; + this.reindexItem = reindexItem; this.duplicateSelectedItem = duplicateSelectedItem; this.deleteSelectedItem = deleteSelectedItem; this.deleteSelectedCollection = deleteSelectedCollection; @@ -852,6 +854,20 @@ var ZoteroPane = new function() document.getElementById('zotero-attachment-view').setAttribute('label', str); + // Display page count + var pages = Zotero.Fulltext.getPages(item.ref.getID()).total; + var pagesRow = document.getElementById('zotero-attachment-pages'); + if (pages) { + var str = Zotero.getString('itemFields.pages') + ': ' + pages; + pagesRow.setAttribute('value', str); + pagesRow.setAttribute('hidden', false); + } + else { + pagesRow.setAttribute('hidden', true); + } + + this.updateItemIndexedState(); + var noteEditor = document.getElementById('zotero-attachment-note-editor'); noteEditor.item = null; noteEditor.note = item.ref; @@ -869,7 +885,7 @@ var ZoteroPane = new function() document.getElementById('zotero-item-pane-content').selectedIndex = 0; var label = document.getElementById('zotero-view-selected-label'); - + if (this.itemsView && this.itemsView.selection.count) { label.value = Zotero.getString('pane.item.selected.multiple', this.itemsView.selection.count); } @@ -881,6 +897,65 @@ var ZoteroPane = new function() } + /* + * Update Indexed: (Yes|No|Partial) line in attachment info pane + */ + function updateItemIndexedState() { + var indexBox = document.getElementById('zotero-attachment-index-box'); + var indexStatus = document.getElementById('zotero-attachment-index-status'); + var reindexButton = document.getElementById('zotero-attachment-reindex'); + + var item = this.itemsView._getItemAtRow(this.itemsView.selection.currentIndex); + var status = Zotero.Fulltext.getIndexedState(item.ref.getID()); + var str = 'fulltext.indexState.'; + switch (status) { + case Zotero.Fulltext.INDEX_STATE_UNAVAILABLE: + str += 'unavailable'; + break; + case Zotero.Fulltext.INDEX_STATE_UNINDEXED: + str = 'general.no'; + break; + case Zotero.Fulltext.INDEX_STATE_PARTIAL: + str += 'partial'; + break; + case Zotero.Fulltext.INDEX_STATE_INDEXED: + str = 'general.yes'; + break; + } + str = Zotero.getString('fulltext.indexState.indexed') + ': ' + + Zotero.getString(str); + indexStatus.setAttribute('value', str); + + // Reindex button tooltip (string stored in zotero.properties) + var str = Zotero.getString('pane.items.menu.reindexItem'); + reindexButton.setAttribute('tooltiptext', str); + + if (Zotero.Fulltext.canReindex(item.ref.getID())) { + reindexButton.setAttribute('hidden', false); + } + else { + reindexButton.setAttribute('hidden', true); + } + } + + + function reindexItem() { + var items = this.getSelectedItems(); + if (!items) { + return false; + } + + for (var i=0; i + + @@ -305,10 +307,17 @@