aboutsummaryrefslogtreecommitdiff
path: root/src/web/views/bookmark.py
diff options
context:
space:
mode:
authorCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-24 22:26:47 +0200
committerCédric Bonhomme <cedric@cedricbonhomme.org>2017-05-24 22:26:47 +0200
commit05f30c772b71fd30115ec012a3371f4478b74192 (patch)
tree78582f430ec00fbbfc59fe5164eecf04b702e007 /src/web/views/bookmark.py
parentA bookmarklet for bookmarks has been added. (diff)
downloadnewspipe-05f30c772b71fd30115ec012a3371f4478b74192.tar.gz
newspipe-05f30c772b71fd30115ec012a3371f4478b74192.tar.bz2
newspipe-05f30c772b71fd30115ec012a3371f4478b74192.zip
Import bookmarks from pinboard.in
Diffstat (limited to 'src/web/views/bookmark.py')
-rw-r--r--src/web/views/bookmark.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/web/views/bookmark.py b/src/web/views/bookmark.py
index 546f4996..87142024 100644
--- a/src/web/views/bookmark.py
+++ b/src/web/views/bookmark.py
@@ -8,6 +8,7 @@ from flask_login import login_required, current_user
import conf
from lib.utils import redirect_url
+from lib.data import import_pinboard_json
from bootstrap import db
from web.forms import BookmarkForm
from web.controllers import BookmarkController, BookmarkTagController
@@ -124,3 +125,17 @@ def bookmarklet():
new_bookmark = bookmark_contr.create(**bookmark_attr)
flash(gettext('Bookmark successfully created.'), 'success')
return redirect(url_for('bookmark.form', bookmark_id=new_bookmark.id))
+
+@bookmark_bp.route('/import_pinboard', methods=['POST'])
+@login_required
+def import_pinboard():
+ bookmarks = request.files.get('jsonfile', None)
+ if bookmarks:
+ try:
+ nb_bookmarks = import_pinboard_json(current_user, bookmarks.read())
+ flash(gettext("%(nb_bookmarks)s bookmarks successfully imported.",
+ nb_bookmarks=nb_bookmarks), 'success')
+ except:
+ flash(gettext('Error when importing bookmarks.'), 'error')
+
+ return redirect(redirect_url())
bgstack15