mirror of
https://github.com/almet/notmyidea.git
synced 2025-04-28 11:32:39 +02:00
Add a firefox bookmarks plugin
This commit is contained in:
parent
d2a1abb5ab
commit
8440e22c57
3 changed files with 55 additions and 9 deletions
46
firefox_bookmarks.py
Normal file
46
firefox_bookmarks.py
Normal file
|
@ -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)
|
|
@ -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', ]
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ SITENAME }} - Tags{% endblock %}
|
||||
{% block title %}{{ SITENAME }} - Marques pages{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Tags for {{ SITENAME }}</h1>
|
||||
{%- for tag, articles in tags|sort %}
|
||||
<li><a href="{{ SITEURL }}/{{ tag.url }}">{{ tag }}</a> ({{ articles|count }})</li>
|
||||
<h1>Quelques marque pages</h1>
|
||||
<ul>
|
||||
{% for bookmark in bookmarks %}
|
||||
<li><a href="{{ bookmark['uri'] }}">{{ bookmark['title']}} {% if 'tags' in bookmark %}{% for tag in bookmark['tags'].split(',') %}#{{tag}} {% endfor %}{% endif %}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
||||
|
|
Loading…
Reference in a new issue