Todo
Write documentation on bookmarks.js.
bookmarks.py - A plugin for Gate One that adds fancy bookmarking capabilities.
This Python plugin file implements the following hooks:
hooks = {
'Web': [
(r"/bookmarks/fetchicon", FaviconHandler),
(r"/bookmarks/export", ExportHandler),
(r"/bookmarks/import", ImportHandler),
],
'WebSocket': {
'bookmarks_sync': save_bookmarks,
'bookmarks_get': get_bookmarks,
'bookmarks_deleted': delete_bookmarks,
'bookmarks_rename_tags': rename_tags,
}
}
Unescape HTML code refs; c.f. http://wiki.python.org/moin/EscapingHtml
Reads the Netscape-style bookmarks.html in string, html and returns a list of Bookmark objects.
Recursively looks inside json_dict trying to find tags associated with the given url. Returns the tags found as a list.
Given a json_dict, updates urls_list with each URL as it is found within.
Note
Only works with Netscape-style bookmarks.json files.
Given json_str, returns a list of bookmark objects representing the data contained therein.
Used to read and write bookmarks to a file on disk. Can also synchronize a given list of bookmarks with what's on disk. Uses a given bookmark's updateSequenceNum to track what wins the "who is newer?" comparison.
Sets up our bookmarks database object and reads everything in.
Opens the bookmarks stored in self.user_dir. If not present, an empty file will be created.
Given bookmarks, synchronize with self.bookmarks doing conflict resolution and whatnot.
Retrives the biggest favicon-like icon at the given URL. It will try to fetch apple-touch-icons (which can be nice and big) before it falls back to grabbing the favicon.
Note
Works with GET and POST requests but POST is preferred since it keeps the URL from winding up in the server logs.
Parses html looking for a favicon URL. Returns a tuple of:
(<url>, <mimetime>)
If no favicon can be found, returns:
(None, None)
Takes a bookmarks.html in a POST and returns a list of bookmarks in JSON format
Takes a JSON-encoded list of bookmarks and returns a Netscape-style HTML file.
Returns a JSON-encoded list of bookmarks updated since the last updateSequenceNum.
If updateSequenceNum resolves to False, all bookmarks will be sent to the client.
Handles deleting bookmars given a deleted_bookmarks list.
Handles renaming tags.