-
Notifications
You must be signed in to change notification settings - Fork 263
Places API JEP
An API for Firefox Places (History and Bookmarks).
-
Phase 1
- Provide easy to use API for CRUD, querying, and tagging behaviour for bookmarks (must have)
- Hook Bookmark instances to platform observers
-
Phase 2
- Provide easy to use API for CRUD, querying History and Bookmarks (nice to have)
- ~~Integration with awesomebar? ~~
- Goals?
- How are keywords used?
- Think about how events will hook into Folder/Bookmark via UI, and also from addon nsINavBookmarkObserver
- Separater support?
- Should Folder/Bookmark constructor also take just an ID instead of options so we can retrieve IDs from queries and create new Bookmark/Folder objects to return? May be too heavy.
- Should Backup/Restore be implemented? backup/restore
Bookmarks contains classes for Bookmark
and Folder
.
Instantiates a new Bookmark. options
can take the following arguments:
-
name
: required The name of the bookmark -
url
: required the url (either as aString
orURL
instance) -
parent
: The parent folder where the bookmark should live. Takes either aFolder
instance, or a constant of theFolder
object. -
index
: The position of the Folder within its parent. Defaults to-1
, the last position. (Default: -1)
-
remove()
docs -
move(index, [parent])
Can just change index, or index and parent docs -
addTag(String|Array tag)
Adds tag/s to bookmark (adds tags to all bookmarks that share this URI) -
removeTag(String|Array tag)
Removes tag/s from bookmark (removes tags from all bookmarks that share this URI)
id
dateAdded
-
name
(get/setable) -
isReadOnly
(get/setable) -
index
(get/setable)
Bookmark.getBookmarksByURL(String|URL url)
Bookmark.isBookmarked(String|URL url)
Bookmarks contains classes for Bookmark
and Folder
-- separate here for documentation purposes.
Instantiates a new Folder. options
can take the following arguments:
-
name
: required The name of the folder -
parent
: The parent folder where the parent lives. Takes either anotherFolder
instance, or a default folder constant onFolder
. (Default: Menu Folder)) -
index
: The position of the Folder within its parent. Defaults to-1
, the last position. (Default: -1)
id
-
name
(get/setable) -
index
(get/setable)
These constants store the IDs of default folders and are used in other methods in Folder
and Bookmark
Folder.MENU
Folder.PLACES
Folder.TAGS
Folder.TOOLBAR
Folder.UNSORTED
Tags are URL based, so if several bookmarks of http://mozilla.com
exist, adding a tag of moz
to this URL would add it to all bookmarks with that URL. This can be a utility to be used standalone for querying/editing tags, and also used within the Bookmarks module to tag bookmarks.
-
void Tags.tag(String|URL url, String|Array tags)
Tagsurl
withtags
-
void Tags.untag(String|URL url, String|Array tags)
Removestags
fromurl
-
[String] Tags.getURLsWithTag(String tag)
Returns an array of URLs that are tagged withtag
-
[String] Tags.getTagsFromURL(String|URL url)
Returns an array of tags that matchurl
var { Tags } = require('sdk/places/tags');
var url = 'http://mozilla.com';
Tags.tag(url, ['mozilla', 'javascript', 'jetpacks']);
Tags.untag(url, 'javascript');
Tags.getURLsWithTag('mozilla'); // ['http://mozilla.com']
Tags.getTagsFromURL(url); // ['mozilla', 'jetpacks']