1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 20:55:10 +01:00

Support for redirecting a bookmark to its url

This commit is contained in:
2018-03-26 14:58:21 +02:00
parent 29c8c875be
commit 7e2f2f6f6e
2 changed files with 26 additions and 0 deletions

View File

@@ -582,6 +582,20 @@ def bookmarks_page(userkey, filtermethod=None, sortmethod=None):
) )
@app.route('/r/<userkey>/<urlhash>')
def bookmark_redirect(userkey, urlhash):
""" Securely redirect a bookmark to its url, stripping referrer (if browser plays nice) """
try:
bookmark = Bookmark.get(
Bookmark.url_hash == urlhash,
Bookmark.userkey == userkey,
Bookmark.status == Bookmark.VISIBLE
)
except Bookmark.DoesNotExist:
abort(404)
return render_template('redirect.html', url=bookmark.url)
@app.route('/api/v1/<userkey>', methods=['GET', 'POST']) @app.route('/api/v1/<userkey>', methods=['GET', 'POST'])
@app.route('/api/v1/<userkey>/filter/<filtermethod>', methods=['GET', 'POST']) @app.route('/api/v1/<userkey>/filter/<filtermethod>', methods=['GET', 'POST'])
@app.route('/api/v1/<userkey>/sort/<sortmethod>', methods=['GET', 'POST']) @app.route('/api/v1/<userkey>/sort/<sortmethod>', methods=['GET', 'POST'])

12
templates/redirect.html Normal file
View File

@@ -0,0 +1,12 @@
<!doctype html>
<html>
<head>
<title>Redirecting - digimarks</title>
<meta name="referrer" content="never">
<meta name="robots" content="noindex, nofollow">
<!-- <meta http-equiv=refresh content="3; URL={{ url }}">-->
</head>
<body>
<p>You're being redirected. If nothing happens, <a href="{{ url }}">click here instead</a>.</p>
</body>
</html>