From b684e97366fa64c8ba07403e9de3c6403badee9f Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Mon, 2 Oct 2006 00:00:50 +0000 Subject: [PATCH] Closes #252, Metadata not displaying for page snapshots Closes #304, change references to "website" to "web page" More changes as per discussions with Dan: - Linked URLs have been given a second chance at life, though they still shouldn't be used for (most, if any) scrapers (which should use snapshots or the URL field instead) - Renamed the "website" item type to "webpage" - Removed "web page" from the New Item menu - Added Save Link To Current Page toolbar button - Added toolbar separator between New Item buttons and link/attachment/note to differentiate - Added limited metadata (URL and accessDate) for attachments - URL for attachments now stored in itemData (itemAttachments.originalPath is no longer used, but I'm probably not gonna worry about it and just wait for SQLite to support dropping columns with ALTER TABLE) -- getURL() removed in favor of getField('url') - Snapshots now say "View Snapshot" - Added Show File button to file attachments to show in filesystem - Added timed note field to attachments for single notes and adjusted Item.updateNote(), etc. to work with attachments - Fixed bug with manually bound params in fulltext indexer and Item.save() (execute() vs. executeStep()) -- any recently added items probably aren't in the fulltext index because of this Known bugs/issues: - Attachment metadata and notes probably aren't properly imported/exported now (and accessDate definitely isn't) - Scrapers don't save metadata properly - Attachment title should be editable - File attachments could probably use some more metadata (#275, more or less, though they won't be getting tabs) --- .../content/scholar/bindings/noteeditor.xml | 4 +- .../chromeFiles/content/scholar/itemPane.xul | 1 + chrome/chromeFiles/content/scholar/overlay.js | 59 +++++++++++-- .../chromeFiles/content/scholar/overlay.xul | 15 +++- .../chromeFiles/content/scholar/xpcom/cite.js | 4 +- .../content/scholar/xpcom/data_access.js | 79 +++++++----------- .../content/scholar/xpcom/fulltext.js | 6 +- .../content/scholar/xpcom/schema.js | 9 ++ .../content/scholar/xpcom/translate.js | 12 +-- .../locale/en-US/scholar/scholar.dtd | 2 + .../locale/en-US/scholar/scholar.properties | 3 +- .../skin/default/scholar/overlay.css | 9 ++ .../skin/default/scholar/scholar.css | 3 +- .../skin/default/scholar/toolbar-link-add.png | Bin 0 -> 570 bytes ...eitem-website.png => treeitem-webpage.png} | Bin scrapers.sql | 42 +++++----- system.sql | 6 +- user.sql | 2 +- 18 files changed, 162 insertions(+), 94 deletions(-) create mode 100644 chrome/chromeFiles/skin/default/scholar/toolbar-link-add.png rename chrome/chromeFiles/skin/default/scholar/{treeitem-website.png => treeitem-webpage.png} (100%) diff --git a/chrome/chromeFiles/content/scholar/bindings/noteeditor.xml b/chrome/chromeFiles/content/scholar/bindings/noteeditor.xml index a590a4cba..e1ac667e1 100644 --- a/chrome/chromeFiles/content/scholar/bindings/noteeditor.xml +++ b/chrome/chromeFiles/content/scholar/bindings/noteeditor.xml @@ -19,8 +19,10 @@ if(citeLabel.firstChild) citeLabel.removeChild(citeLabel.firstChild); - if(this.item) + if(this.item && !this.getAttribute('notitle')=='1') + { citeLabel.appendChild(document.createTextNode(this.item.getField('title'))); + } ]]> diff --git a/chrome/chromeFiles/content/scholar/itemPane.xul b/chrome/chromeFiles/content/scholar/itemPane.xul index 12a0fce53..2157ece0f 100644 --- a/chrome/chromeFiles/content/scholar/itemPane.xul +++ b/chrome/chromeFiles/content/scholar/itemPane.xul @@ -58,6 +58,7 @@ + diff --git a/chrome/chromeFiles/content/scholar/overlay.js b/chrome/chromeFiles/content/scholar/overlay.js index e813881ff..783287f67 100644 --- a/chrome/chromeFiles/content/scholar/overlay.js +++ b/chrome/chromeFiles/content/scholar/overlay.js @@ -41,6 +41,7 @@ var ScholarPane = new function() this.addAttachmentFromDialog = addAttachmentFromDialog; this.addAttachmentFromPage = addAttachmentFromPage; this.viewSelectedAttachment = viewSelectedAttachment; + this.showSelectedAttachmentInFilesystem = showSelectedAttachmentInFilesystem; /* * Called when the window is open @@ -267,17 +268,47 @@ var ScholarPane = new function() label.appendChild(document.createTextNode(val)); } + // Metadata for URL's if (item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_LINKED_URL || item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_IMPORTED_URL) { - var str = Scholar.getString('pane.item.attachments.view.link'); + // "View Page"/"View Snapshot" label + if (item.ref.getAttachmentLinkMode() == Scholar.Attachments.LINK_MODE_IMPORTED_URL) + { + var str = Scholar.getString('pane.item.attachments.view.snapshot'); + } + else + { + var str = Scholar.getString('pane.item.attachments.view.link'); + } + + document.getElementById('scholar-attachment-show').setAttribute('hidden', true); + + // URL + document.getElementById('scholar-attachment-url').setAttribute('value', item.getField('url')); + document.getElementById('scholar-attachment-url').setAttribute('hidden', false); + + // Access date + document.getElementById('scholar-attachment-accessed').setAttribute('value', + Scholar.getString('itemFields.accessDate') + ': ' + + Scholar.Date.sqlToDate(item.getField('accessDate')).toLocaleString()); + document.getElementById('scholar-attachment-accessed').setAttribute('hidden', false); } + // Metadata for files else { var str = Scholar.getString('pane.item.attachments.view.file'); + document.getElementById('scholar-attachment-show').setAttribute('hidden', false); + document.getElementById('scholar-attachment-url').setAttribute('hidden', true); + document.getElementById('scholar-attachment-accessed').setAttribute('hidden', true); } + document.getElementById('scholar-attachment-view').setAttribute('label', str); - document.getElementById('scholar-attachment-links').item = item.ref; + + var noteEditor = document.getElementById('scholar-attachment-note-editor'); + noteEditor.item = null; + noteEditor.note = item.ref; + document.getElementById('item-pane').selectedIndex = 3; } else @@ -454,7 +485,7 @@ var ScholarPane = new function() { if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1) { - collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex); + var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex); if(collection && collection.isCollection()) return collection.ref; } @@ -464,7 +495,7 @@ var ScholarPane = new function() { if(collectionsView.selection.count > 0 && collectionsView.selection.currentIndex != -1) { - collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex); + var collection = collectionsView._getItemAtRow(collectionsView.selection.currentIndex); if(collection && collection.isSearch()) { return collection.ref; @@ -659,7 +690,7 @@ var ScholarPane = new function() accessDate: "CURRENT_TIMESTAMP" } - newItem(Scholar.ItemTypes.getID('website'), data); + newItem(Scholar.ItemTypes.getID('webpage'), data); } @@ -682,6 +713,7 @@ var ScholarPane = new function() } } + function viewSelectedAttachment() { if(itemsView && itemsView.selection.count == 1) @@ -701,7 +733,22 @@ var ScholarPane = new function() } else { - window.loadURI(attachment.getURL()); + window.loadURI(attachment.getField('url')); + } + } + } + + + function showSelectedAttachmentInFilesystem() + { + if(itemsView && itemsView.selection.count == 1) + { + var attachment = getSelectedItems()[0]; + + if (attachment.getAttachmentLinkMode() != Scholar.Attachments.LINK_MODE_LINKED_URL) + { + var file = attachment.getFile(); + file.reveal(); } } } diff --git a/chrome/chromeFiles/content/scholar/overlay.xul b/chrome/chromeFiles/content/scholar/overlay.xul index 51c3ef06f..73c4f8a3c 100644 --- a/chrome/chromeFiles/content/scholar/overlay.xul +++ b/chrome/chromeFiles/content/scholar/overlay.xul @@ -104,6 +104,8 @@ + + @@ -187,14 +189,23 @@