2007-10-23 07:11:59 +00:00
|
|
|
const ZOTERO_CONTRACTID = '@zotero.org/Zotero;1';
|
2006-10-02 23:15:27 +00:00
|
|
|
const ZOTERO_CLASSNAME = 'Zotero';
|
|
|
|
const ZOTERO_CID = Components.ID('{e4c61080-ec2d-11da-8ad9-0800200c9a66}');
|
2007-10-23 07:11:59 +00:00
|
|
|
const ZOTERO_IID = Components.interfaces.chnmIZoteroService; //unused
|
2006-05-27 00:20:27 +00:00
|
|
|
|
|
|
|
const Cc = Components.classes;
|
|
|
|
const Ci = Components.interfaces;
|
|
|
|
|
|
|
|
// Assign the global scope to a variable to passed via wrappedJSObject
|
2006-10-02 23:15:27 +00:00
|
|
|
var ZoteroWrapped = this;
|
2006-05-27 00:20:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
/********************************************************************
|
|
|
|
* Include the core objects to be stored within XPCOM
|
|
|
|
*********************************************************************/
|
|
|
|
|
2008-08-13 06:38:47 +00:00
|
|
|
var xpcomFiles = [
|
|
|
|
'zotero',
|
|
|
|
'annotate',
|
|
|
|
'attachments',
|
|
|
|
'collectionTreeView',
|
2009-08-13 10:56:47 +00:00
|
|
|
'commons',
|
2008-09-16 19:14:52 +00:00
|
|
|
'csl',
|
2008-08-13 06:38:47 +00:00
|
|
|
'dataServer',
|
|
|
|
'data_access',
|
|
|
|
'data/dataObjects',
|
|
|
|
'data/cachedTypes',
|
|
|
|
'data/item',
|
|
|
|
'data/items',
|
|
|
|
'data/collection',
|
|
|
|
'data/collections',
|
|
|
|
'data/creator',
|
|
|
|
'data/creators',
|
2.0b3 megacommit
- Support for group libraries
- General support for multiple libraries of different types
- Streamlined sync support
- Using solely libraryID and key rather than itemID, and removed all itemID-changing code
- Combined two requests for increased performance and decreased server load
- Added warning on user account change
- Provide explicit error message on SSL failure
- Removed snapshot and link toolbar buttons and changed browser context menu options and drags to create parent items + snapshots
- Closes #786, Add numPages field
- Fixes #1063, Duplicate item with tags broken in Sync Preview
- Added better purging of deleted tags
- Added local user key before first sync
- Add clientDateModified to all objects for more flexibility in syncing
- Added new triples-based Relation object type, currently used to store links between items copied between local and group libraries
- Updated zotero.org translator for groups
- Additional trigger-based consistency checks
- Fixed broken URL drag in Firefox 3.5
- Disabled zeroconf menu option (no longer functional)
Developer-specific changes:
- Overhauled data layer
- Data object constructors no longer take arguments (return to 1.0-like API)
- Existing objects can be retrieved by setting id or library/key properties
- id/library/key must be set for new objects before other fields
- New methods:
- ZoteroPane.getSelectedLibraryID()
- ZoteroPane.getSelectedGroup(asID)
- ZoteroPane.addItemFromDocument(doc, itemType, saveSnapshot)
- ZoteroPane.addItemFromURL(url, itemType)
- ZoteroPane.canEdit()
- Zotero.CollectionTreeView.selectLibrary(libraryID)
- New Zotero.URI methods
- Changed methods
- Many data object methods now take a libraryID
- ZoteroPane.addAttachmentFromPage(link, itemID)
- Removed saveItem and saveAttachments parameters from Zotero.Translate constructor
- translate() now takes a libraryID, null for local library, or false to not save items (previously on constructor)
- saveAttachments is now a translate() parameter
- Zotero.flattenArguments() better handles passed objects
- Zotero.File.getFileHash() (not currently used)
2009-05-14 18:23:40 +00:00
|
|
|
'data/group',
|
|
|
|
'data/groups',
|
2008-08-13 06:38:47 +00:00
|
|
|
'data/itemFields',
|
|
|
|
'data/notes',
|
2.0b3 megacommit
- Support for group libraries
- General support for multiple libraries of different types
- Streamlined sync support
- Using solely libraryID and key rather than itemID, and removed all itemID-changing code
- Combined two requests for increased performance and decreased server load
- Added warning on user account change
- Provide explicit error message on SSL failure
- Removed snapshot and link toolbar buttons and changed browser context menu options and drags to create parent items + snapshots
- Closes #786, Add numPages field
- Fixes #1063, Duplicate item with tags broken in Sync Preview
- Added better purging of deleted tags
- Added local user key before first sync
- Add clientDateModified to all objects for more flexibility in syncing
- Added new triples-based Relation object type, currently used to store links between items copied between local and group libraries
- Updated zotero.org translator for groups
- Additional trigger-based consistency checks
- Fixed broken URL drag in Firefox 3.5
- Disabled zeroconf menu option (no longer functional)
Developer-specific changes:
- Overhauled data layer
- Data object constructors no longer take arguments (return to 1.0-like API)
- Existing objects can be retrieved by setting id or library/key properties
- id/library/key must be set for new objects before other fields
- New methods:
- ZoteroPane.getSelectedLibraryID()
- ZoteroPane.getSelectedGroup(asID)
- ZoteroPane.addItemFromDocument(doc, itemType, saveSnapshot)
- ZoteroPane.addItemFromURL(url, itemType)
- ZoteroPane.canEdit()
- Zotero.CollectionTreeView.selectLibrary(libraryID)
- New Zotero.URI methods
- Changed methods
- Many data object methods now take a libraryID
- ZoteroPane.addAttachmentFromPage(link, itemID)
- Removed saveItem and saveAttachments parameters from Zotero.Translate constructor
- translate() now takes a libraryID, null for local library, or false to not save items (previously on constructor)
- saveAttachments is now a translate() parameter
- Zotero.flattenArguments() better handles passed objects
- Zotero.File.getFileHash() (not currently used)
2009-05-14 18:23:40 +00:00
|
|
|
'data/libraries',
|
|
|
|
'data/relation',
|
|
|
|
'data/relations',
|
2008-08-13 06:38:47 +00:00
|
|
|
'data/tag',
|
|
|
|
'data/tags',
|
|
|
|
'db',
|
2009-08-10 16:44:15 +00:00
|
|
|
'debug',
|
2009-03-06 21:45:49 +00:00
|
|
|
'duplicate',
|
2008-08-13 06:38:47 +00:00
|
|
|
'enstyle',
|
2009-07-06 10:13:02 +00:00
|
|
|
'error',
|
2008-08-13 06:38:47 +00:00
|
|
|
'file',
|
|
|
|
'fulltext',
|
|
|
|
'id',
|
|
|
|
'ingester',
|
|
|
|
'integration',
|
2009-08-20 05:02:55 +00:00
|
|
|
'integration_compat',
|
2008-08-13 06:38:47 +00:00
|
|
|
'itemTreeView',
|
|
|
|
'mime',
|
2008-09-16 19:14:52 +00:00
|
|
|
'mimeTypeHandler',
|
2008-08-13 06:38:47 +00:00
|
|
|
'notifier',
|
|
|
|
'progressWindow',
|
|
|
|
'proxy',
|
|
|
|
'quickCopy',
|
|
|
|
'report',
|
|
|
|
'schema',
|
|
|
|
'search',
|
2008-09-16 19:14:52 +00:00
|
|
|
'style',
|
2008-08-13 06:38:47 +00:00
|
|
|
'sync',
|
2008-08-31 23:36:01 +00:00
|
|
|
'storage',
|
Zotero File Storage megacommit
- Group file sync via Zotero File Storage
- Split file syncing into separate modules for ZFS and WebDAV
- Dragging items between libraries copies child notes, snapshots/files, and links based on checkboxes for each (enabled by default) in the Zotero preferences
- Sync errors now trigger an exclamation/error icon separate from the sync icon, with a popup window displaying the error and an option to report it
- Various errors that could cause perpetual sync icon spinning now stop the sync properly
- Zotero.Utilities.md5(str) is now md5(strOrFile, base64)
- doPost(), doHead(), and retrieveSource() now takes a headers parameter instead of requestContentType
- doHead() can now accept an nsIURI (with login credentials), is a background request, and isn't cached
- When library access or file writing access is denied during sync, display a warning and then reset local group to server version
- Perform additional steps (e.g., removing local groups) when switching sync users to prevent errors
- Compare hash as well as mod time when checking for modified local files
- Don't trigger notifications when removing groups from the client
- Clear relation links to items in removed groups
- Zotero.Item.attachmentHash property to get file MD5
- importFromFile() now takes libraryID as a third parameter
- Zotero.Attachments.getNumFiles() returns the number of files in the attachment directory
- Zotero.Attachments.copyAttachmentToLibrary() copies an attachment item, including files, to another library
- Removed Zotero.File.getFileHash() in favor of updated Zotero.Utilities.md5()
- Zotero.File.copyDirectory(dir, newDir) copies all files from dir into newDir
- Preferences shuffling: OpenURL to Advanced, import/export character set options to Export, "Include URLs of paper articles in references" to Styles
- Other stuff I don't remember
Suffice it to say, this could use testing.
2009-09-13 07:23:29 +00:00
|
|
|
'storage/session',
|
|
|
|
'storage/zfs',
|
|
|
|
'storage/webdav',
|
2008-08-13 06:38:47 +00:00
|
|
|
'timeline',
|
|
|
|
'translate',
|
2.0b3 megacommit
- Support for group libraries
- General support for multiple libraries of different types
- Streamlined sync support
- Using solely libraryID and key rather than itemID, and removed all itemID-changing code
- Combined two requests for increased performance and decreased server load
- Added warning on user account change
- Provide explicit error message on SSL failure
- Removed snapshot and link toolbar buttons and changed browser context menu options and drags to create parent items + snapshots
- Closes #786, Add numPages field
- Fixes #1063, Duplicate item with tags broken in Sync Preview
- Added better purging of deleted tags
- Added local user key before first sync
- Add clientDateModified to all objects for more flexibility in syncing
- Added new triples-based Relation object type, currently used to store links between items copied between local and group libraries
- Updated zotero.org translator for groups
- Additional trigger-based consistency checks
- Fixed broken URL drag in Firefox 3.5
- Disabled zeroconf menu option (no longer functional)
Developer-specific changes:
- Overhauled data layer
- Data object constructors no longer take arguments (return to 1.0-like API)
- Existing objects can be retrieved by setting id or library/key properties
- id/library/key must be set for new objects before other fields
- New methods:
- ZoteroPane.getSelectedLibraryID()
- ZoteroPane.getSelectedGroup(asID)
- ZoteroPane.addItemFromDocument(doc, itemType, saveSnapshot)
- ZoteroPane.addItemFromURL(url, itemType)
- ZoteroPane.canEdit()
- Zotero.CollectionTreeView.selectLibrary(libraryID)
- New Zotero.URI methods
- Changed methods
- Many data object methods now take a libraryID
- ZoteroPane.addAttachmentFromPage(link, itemID)
- Removed saveItem and saveAttachments parameters from Zotero.Translate constructor
- translate() now takes a libraryID, null for local library, or false to not save items (previously on constructor)
- saveAttachments is now a translate() parameter
- Zotero.flattenArguments() better handles passed objects
- Zotero.File.getFileHash() (not currently used)
2009-05-14 18:23:40 +00:00
|
|
|
'uri',
|
2008-08-13 06:38:47 +00:00
|
|
|
'utilities',
|
|
|
|
'zeroconf'
|
|
|
|
];
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
|
|
|
|
for (var i=0; i<xpcomFiles.length; i++) {
|
2009-07-06 10:13:02 +00:00
|
|
|
try {
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/" + xpcomFiles[i] + ".js");
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
Components.utils.reportError("Error loading " + xpcomFiles[i] + ".js");
|
|
|
|
throw (e);
|
|
|
|
}
|
Initial Zotero 1.5 Megacommit
Apologies for the massive (and, due to data_access.js splitting, difficult-to-follow) commit. Please note that external code that accesses the data layer may need to be tweaked for compatibility. Here's a comprehensive-as-possible changelog:
- Added server sync functionality (incomplete)
- Overhaul of data layer
- Split data_access.js into separate files (item.js, items.js, creator.js, etc.)
- Made creators and collections first-class objects, similar to items
- Constructors now take id as first parameter, e.g. new Zotero.Item(1234, 'book'), to allow explicit id setting and id changing
- Made various data layer operations (including attachment fields) require a save() rather than making direct DB changes
- Better handling of unsaved objects
- Item.setCreator() now takes creator objects instead of creator ids, and Item.save() will auto-save unsaved creators
- clone() now works on unsaved objects
- Newly created object instances are now disabled after save() to force refetch of globally accessible instance using Zotero.(Items|Creators|etc.).get()
- Added secondary lookup key to data objects
- Deprecated getID() and getItemType() methods in favor of .id and .itemTypeID properties
- toArray() deprecated in favor of serialize(), which has a somewhat modified format
- Added support for multiple creators with identical data -- currently unimplemented in interface and most of data layer
- Added Item.diff() for comparing item metadata
- Database changes
- Added SQLite triggers to enforce foreign key constraints
- Added Zotero.DB.transactionVacuum flag to run a VACUUM after a transaction
- Added Zotero.DB.transactionDate, .transactionDateTime, and transactionTimestamp to retrieve consistent timestamps for entire transaction
- Properly store 64-bit integers
- Set PRAGMA locking_mode=EXCLUSIVE on database
- Set SQLite page size to 4096 on new databases
- Set SQLite page cache to 8MB
- Do some database cleanup and integrity checking on migration from 1.0 branch
- Removed IF NOT EXISTS from userdata.sql CREATE statements -- userdata.sql is now processed only on DB initialization
- Removed itemNoteTitles table and moved titles into itemNotes
- Abstracted metadata edit box and note box into flexible XBL bindings with various modes, including read-only states
- Massive speed-up of item tree view
- Several fixes from 1.0 branch for Fx3 compatibility
- Added Notifier observer to log delete events for syncing
- Zotero.Utilities changes
- New methods getSQLDataType() and md5()
- Removed onError from Zotero.Utilities.HTTP.doGet()
- Don't display more than 1024 characters in doPost() debug output
- Don't display passwords in doPost() debug output
- Added Zotero.Notifier.untrigger() -- currently unused
- Added Zotero.reloadDataObjects() to reset all in-memory objects
- Added |chars| parameter to Zotero.randomString(len, chars)
- Added Zotero.Date.getUnixTimestamp() and Date.toUnixTimestamp(JSDate)
- Adjusted zotero-service.js to simplify file inclusion
Various things (such as tags) are temporarily broken.
2008-05-04 08:32:48 +00:00
|
|
|
}
|
2007-10-23 07:11:59 +00:00
|
|
|
|
2009-06-24 20:42:41 +00:00
|
|
|
|
|
|
|
// Load RDF files into Zotero.RDF.AJAW namespace (easier than modifying all of the references)
|
|
|
|
var rdfXpcomFiles = [
|
|
|
|
'rdf/uri',
|
|
|
|
'rdf/term',
|
|
|
|
'rdf/identity',
|
|
|
|
'rdf/match',
|
|
|
|
'rdf/n3parser',
|
|
|
|
'rdf/rdfparser',
|
|
|
|
'rdf/serialize',
|
|
|
|
'rdf'
|
|
|
|
];
|
|
|
|
|
|
|
|
Zotero.RDF = {AJAW:{}};
|
|
|
|
|
|
|
|
for (var i=0; i<rdfXpcomFiles.length; i++) {
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://zotero/content/xpcom/" + rdfXpcomFiles[i] + ".js", Zotero.RDF.AJAW);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-08-25 19:15:03 +00:00
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://global/content/nsTransferable.js");
|
|
|
|
|
|
|
|
Cc["@mozilla.org/moz/jssubscript-loader;1"]
|
|
|
|
.getService(Ci.mozIJSSubScriptLoader)
|
|
|
|
.loadSubScript("chrome://global/content/nsDragAndDrop.js");
|
|
|
|
|
2006-05-27 00:20:27 +00:00
|
|
|
/********************************************************************/
|
|
|
|
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
// Initialize the Zotero service
|
2006-05-27 00:20:27 +00:00
|
|
|
//
|
2006-10-02 23:15:27 +00:00
|
|
|
// This runs when ZoteroService is first requested.
|
2006-05-27 00:20:27 +00:00
|
|
|
// Calls to other XPCOM components must be in here rather than in top-level
|
|
|
|
// code, as other components may not have yet been initialized.
|
|
|
|
function setupService(){
|
2008-07-03 16:44:52 +00:00
|
|
|
try {
|
|
|
|
Zotero.init();
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
var msg = typeof e == 'string' ? e : e.name;
|
|
|
|
dump(e + "\n\n");
|
|
|
|
Components.utils.reportError(e);
|
|
|
|
throw (e);
|
|
|
|
}
|
2006-05-27 00:20:27 +00:00
|
|
|
}
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
function ZoteroService(){
|
|
|
|
this.wrappedJSObject = ZoteroWrapped.Zotero;
|
2006-05-27 00:20:27 +00:00
|
|
|
setupService();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to replicate window.alert()
|
|
|
|
**/
|
|
|
|
function alert(msg){
|
|
|
|
Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Ci.nsIPromptService)
|
|
|
|
.alert(null, "", msg);
|
|
|
|
}
|
|
|
|
|
2006-06-01 21:57:12 +00:00
|
|
|
/**
|
|
|
|
* Convenience method to replicate window.confirm()
|
|
|
|
**/
|
|
|
|
function confirm(msg){
|
|
|
|
return Cc["@mozilla.org/embedcomp/prompt-service;1"]
|
|
|
|
.getService(Ci.nsIPromptService)
|
|
|
|
.confirm(null, "", msg);
|
|
|
|
}
|
2006-05-27 00:20:27 +00:00
|
|
|
|
Fulltext search support
There are currently two types of fulltext searching: an SQL-based word index and a file scanner. They each have their advantages and drawbacks.
The word index is very fast to search and is currently used for the find-as-you-type quicksearch. However, indexing files takes some time, so we should probably offer a preference to turn it off ("Index attachment content for quicksearch" or something). There's also an issue with Chinese characters (which are indexed by character rather than word, since there are no spaces to go by, so a search for a word with common characters could produce erroneous results). The quicksearch doesn't use a left-bound index (since that would probably upset German speakers searching for "musik" in "nachtmusik," though I don't know for sure how they think of words) but still seems pretty fast.
* Note: There will be a potentially long delay when you start Firefox with this revision as it builds a fulltext word index of your existing items. We obviously need a notification/option for this. *
The file scanner, used in the Attachment Content condition of the search dialog, offers phrase searching as well as regex support (both case-sensitive and not, and defaulting to multiline). It doesn't require an index, though it should probably be optimized to use the word index, if available, for narrowing the results when not in regex mode. (It does only scan files that pass all the other search conditions, which speeds it up considerably for multi-condition searches, and skips non-text files unless instructed otherwise, but it's still relatively slow.)
Both convert HTML to text before searching (with the exception of the binary file scanning mode).
There are some issues with which files get indexed and which don't that we can't do much about and that will probably confuse users immensely. Dan C. suggested some sort of indicator (say, a green dot) to show which files are indexed.
Also added (very ugly) charset detection (anybody want to figure out getCharsetFromString(str)?), a setTimeout() replacement in the XPCOM service, an arrayToHash() method, and a new header to timedtextarea.xml, since it's really not copyright CHNM (it's really just a few lines off from the toolkit timed-textbox binding--I tried to change it to extend timed-textbox and just ignore Return keypress events so that we didn't need to duplicate the Mozilla code, but timed-textbox's reliance on html:input instead of html:textarea made things rather difficult).
To do:
- Pref/buttons to disable/clear/rebuild fulltext index
- Hidden prefs to set maximum file size to index/scan
- Don't index words of fewer than 3 non-Asian characters
- MRU cache for saved searches
- Use word index if available to narrow search scope of fulltext scanner
- Cache attachment info methods
- Show content excerpt in search results (at least in advanced search window, when it exists)
- Notification window (a la scraping) to show when indexing
- Indicator of indexed status
- Context menu option to index
- Indicator that a file scanning search is in progress, if possible
- Find other ways to make it index the NYT front page in under 10 seconds
- Probably fix lots of bugs, which you will likely start telling me about...now.
2006-09-21 00:10:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Convenience method to replicate window.setTimeout()
|
|
|
|
**/
|
|
|
|
function setTimeout(func, ms){
|
|
|
|
var timer = Components.classes["@mozilla.org/timer;1"].
|
|
|
|
createInstance(Components.interfaces.nsITimer);
|
|
|
|
// {} implements nsITimerCallback
|
|
|
|
timer.initWithCallback({notify:func}, ms,
|
|
|
|
Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
2008-06-30 01:01:53 +00:00
|
|
|
return timer;
|
Fulltext search support
There are currently two types of fulltext searching: an SQL-based word index and a file scanner. They each have their advantages and drawbacks.
The word index is very fast to search and is currently used for the find-as-you-type quicksearch. However, indexing files takes some time, so we should probably offer a preference to turn it off ("Index attachment content for quicksearch" or something). There's also an issue with Chinese characters (which are indexed by character rather than word, since there are no spaces to go by, so a search for a word with common characters could produce erroneous results). The quicksearch doesn't use a left-bound index (since that would probably upset German speakers searching for "musik" in "nachtmusik," though I don't know for sure how they think of words) but still seems pretty fast.
* Note: There will be a potentially long delay when you start Firefox with this revision as it builds a fulltext word index of your existing items. We obviously need a notification/option for this. *
The file scanner, used in the Attachment Content condition of the search dialog, offers phrase searching as well as regex support (both case-sensitive and not, and defaulting to multiline). It doesn't require an index, though it should probably be optimized to use the word index, if available, for narrowing the results when not in regex mode. (It does only scan files that pass all the other search conditions, which speeds it up considerably for multi-condition searches, and skips non-text files unless instructed otherwise, but it's still relatively slow.)
Both convert HTML to text before searching (with the exception of the binary file scanning mode).
There are some issues with which files get indexed and which don't that we can't do much about and that will probably confuse users immensely. Dan C. suggested some sort of indicator (say, a green dot) to show which files are indexed.
Also added (very ugly) charset detection (anybody want to figure out getCharsetFromString(str)?), a setTimeout() replacement in the XPCOM service, an arrayToHash() method, and a new header to timedtextarea.xml, since it's really not copyright CHNM (it's really just a few lines off from the toolkit timed-textbox binding--I tried to change it to extend timed-textbox and just ignore Return keypress events so that we didn't need to duplicate the Mozilla code, but timed-textbox's reliance on html:input instead of html:textarea made things rather difficult).
To do:
- Pref/buttons to disable/clear/rebuild fulltext index
- Hidden prefs to set maximum file size to index/scan
- Don't index words of fewer than 3 non-Asian characters
- MRU cache for saved searches
- Use word index if available to narrow search scope of fulltext scanner
- Cache attachment info methods
- Show content excerpt in search results (at least in advanced search window, when it exists)
- Notification window (a la scraping) to show when indexing
- Indicator of indexed status
- Context menu option to index
- Indicator that a file scanning search is in progress, if possible
- Find other ways to make it index the NYT front page in under 10 seconds
- Probably fix lots of bugs, which you will likely start telling me about...now.
2006-09-21 00:10:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-05-27 00:20:27 +00:00
|
|
|
//
|
|
|
|
// XPCOM goop
|
|
|
|
//
|
2006-10-02 23:15:27 +00:00
|
|
|
ZoteroService.prototype = {
|
2006-05-27 00:20:27 +00:00
|
|
|
QueryInterface: function(iid){
|
|
|
|
if (!iid.equals(Components.interfaces.nsISupports) &&
|
2007-10-23 07:11:59 +00:00
|
|
|
!iid.equals(ZOTERO_IID)){ // interface unused
|
2006-05-27 00:20:27 +00:00
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var ZoteroFactory = {
|
2006-05-27 00:20:27 +00:00
|
|
|
createInstance: function(outer, iid){
|
|
|
|
if (outer != null){
|
|
|
|
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
|
|
|
}
|
2006-10-02 23:15:27 +00:00
|
|
|
return new ZoteroService().QueryInterface(iid);
|
2006-05-27 00:20:27 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
var ZoteroModule = {
|
2006-05-27 00:20:27 +00:00
|
|
|
_firstTime: true,
|
|
|
|
|
|
|
|
registerSelf: function(compMgr, fileSpec, location, type){
|
|
|
|
if (!this._firstTime){
|
|
|
|
throw Components.results.NS_ERROR_FACTORY_REGISTER_AGAIN;
|
|
|
|
}
|
|
|
|
this._firstTime = false;
|
|
|
|
|
|
|
|
compMgr =
|
|
|
|
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
compMgr.registerFactoryLocation(ZOTERO_CID,
|
|
|
|
ZOTERO_CLASSNAME,
|
|
|
|
ZOTERO_CONTRACTID,
|
2006-05-27 00:20:27 +00:00
|
|
|
fileSpec,
|
|
|
|
location,
|
|
|
|
type);
|
|
|
|
},
|
|
|
|
|
|
|
|
unregisterSelf: function(compMgr, location, type){
|
|
|
|
compMgr =
|
|
|
|
compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
2006-10-02 23:15:27 +00:00
|
|
|
compMgr.unregisterFactoryLocation(ZOTERO_CID, location);
|
2006-05-27 00:20:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
getClassObject: function(compMgr, cid, iid){
|
2006-10-02 23:15:27 +00:00
|
|
|
if (!cid.equals(ZOTERO_CID)){
|
2006-05-27 00:20:27 +00:00
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
|
|
}
|
|
|
|
if (!iid.equals(Components.interfaces.nsIFactory)){
|
|
|
|
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
2006-10-02 23:15:27 +00:00
|
|
|
return ZoteroFactory;
|
2006-05-27 00:20:27 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
canUnload: function(compMgr){ return true; }
|
|
|
|
};
|
|
|
|
|
2006-10-02 23:15:27 +00:00
|
|
|
function NSGetModule(comMgr, fileSpec){ return ZoteroModule; }
|