diff --git a/firefox_bookmarks.py b/firefox_bookmarks.py new file mode 100644 index 0000000..d067dc9 --- /dev/null +++ b/firefox_bookmarks.py @@ -0,0 +1,46 @@ +from pelican import signals + +""" +Author : Jay Rambhia +email : jayrambhia777@gmail.com +Git : https://github.com/jayrambhia +gist : https://gist.github.com/jayrambhia +============================================= +Name : bookmarkFirefox +Repo : Bookmark-Manager +Git : https://github.com/jayrambhia/Bookmark-Manager +version : 0.2 +""" + +import os +import json +import lz4 + + +def fetch_bookmarks(path): + ''' + Decodes browser bookmark backup files using json + Returns a dictionary with bookmark url as key and (title, tag, add_date) tuple as value + ''' + files = os.listdir(path) + files.sort() + filename = os.path.join(path, files[-1]) + + with open(filename) as f: + if f.read(8) != b"mozLz40\0": + print("unable to uncompress bookmarks") + database = json.loads(lz4.block.decompress(f.read())) + # Get Bookmarks Menu / Bookmarks toolbar / Tags / Unsorted Bookmarks + for category in database['children']: + if 'root' in category and category['root'] == 'unfiledBookmarksFolder': + bookmarks = category['children'] + return bookmarks + + +def fetch_firefox_bookmarks(gen, metadata): + if 'FIREFOX_BOOKMARKS_PATH' in gen.settings: + gen.context['bookmarks'] = fetch_bookmarks(gen.settings['FIREFOX_BOOKMARKS_PATH']) + + +def register(): + signals.article_generator_context.connect(fetch_firefox_bookmarks) diff --git a/pelican.conf.py b/pelican.conf.py index 749ed43..35fff5f 100644 --- a/pelican.conf.py +++ b/pelican.conf.py @@ -1,8 +1,4 @@ # -*- coding: utf-8 -*- -#import sys -#sys.path.append('plugins') - -#PLUGINS = ['touch', ] PATH = "content" AUTHOR = u'Alexis Métaireau' @@ -14,7 +10,6 @@ DISQUS_SITENAME = 'notmyidea' STATIC_PATHS = ['static'] SITEURL = '' -#SITEURL = 'http://blog.notmyidea.org' RELATIVE_URLS = True TIMEZONE = "Europe/Paris" @@ -29,4 +24,7 @@ LINKS = [ ] PIWIK_SERVER_URL = "//tracker.notmyidea.org/" +FIREFOX_BOOKMARKS_PATH = '/home/alexis/.mozilla/firefox/fymmscw3.default/bookmarkbackups/' PIWIK_SITE_ID = 3 +PLUGIN_PATHS = ['.'] +PLUGINS = ['firefox_bookmarks', ] diff --git a/pelicanyan/templates/tags.html b/pelicanyan/templates/tags.html index b5d1482..03f2e3a 100644 --- a/pelicanyan/templates/tags.html +++ b/pelicanyan/templates/tags.html @@ -1,10 +1,12 @@ {% extends "base.html" %} -{% block title %}{{ SITENAME }} - Tags{% endblock %} +{% block title %}{{ SITENAME }} - Marques pages{% endblock %} {% block content %} -

Tags for {{ SITENAME }}

- {%- for tag, articles in tags|sort %} -
  • {{ tag }} ({{ articles|count }})
  • +

    Quelques marque pages

    + {% endblock %}