From 271f2fa4a068588825728628ef12275604ea3320 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Wed, 3 Aug 2016 14:14:59 +0200 Subject: [PATCH 1/2] Initialise with 'url' url parameter if exists, enabling bookmarklet --- README.rst | 10 ++++++++++ digimarks.py | 5 ++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.rst b/README.rst index 9bc1cc7..4d6d84e 100644 --- a/README.rst +++ b/README.rst @@ -45,6 +45,16 @@ url's when wanted. Url's are of the form https://marks.example.com// +Bookmarklet +~~~~~~~~~~~ + +To easily save a link from your browser, open its bookmark manager and create a new bookmark with as url: + +.. code-block:: javascript + + javascript:location.href='http://marks.example.com/1234567890abcdef/add?url='+encodeURIComponent(location.href); + + Creating a new user ------------------- diff --git a/digimarks.py b/digimarks.py index 3ba55c2..0499118 100644 --- a/digimarks.py +++ b/digimarks.py @@ -279,7 +279,10 @@ def editbookmark(userkey, urlhash): @app.route('//add') def addbookmark(userkey): """ Bookmark add form """ - bookmark = Bookmark(title='', url='', tags='') + url = request.args.get('url') + if not url: + url = '' + bookmark = Bookmark(title='', url=url, tags='') message = request.args.get('message') tags = get_cached_tags(userkey) return render_template('edit.html', action='Add bookmark', userkey=userkey, bookmark=bookmark, tags=tags, message=message) From 4ee925de454695109d0f71a4dc0e89f083365834 Mon Sep 17 00:00:00 2001 From: Michiel Scholten Date: Wed, 3 Aug 2016 21:34:44 +0200 Subject: [PATCH 2/2] Use referrer when url encode doesn't work because of security scope --- digimarks.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/digimarks.py b/digimarks.py index 0499118..cb26f3b 100644 --- a/digimarks.py +++ b/digimarks.py @@ -282,6 +282,8 @@ def addbookmark(userkey): url = request.args.get('url') if not url: url = '' + if request.args.get('referrer'): + url = request.referrer bookmark = Bookmark(title='', url=url, tags='') message = request.args.get('message') tags = get_cached_tags(userkey)