mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 22:05:09 +01:00
Support for redirecting a bookmark to its url
This commit is contained in:
14
digimarks.py
14
digimarks.py
@@ -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>/filter/<filtermethod>', methods=['GET', 'POST'])
|
||||
@app.route('/api/v1/<userkey>/sort/<sortmethod>', methods=['GET', 'POST'])
|
||||
|
||||
12
templates/redirect.html
Normal file
12
templates/redirect.html
Normal 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>
|
||||
Reference in New Issue
Block a user