mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 22:05:09 +01:00
Moved autocompletion items to seperate javascript call
This commit is contained in:
13
digimarks.py
13
digimarks.py
@@ -582,6 +582,19 @@ def bookmarks_page(userkey, filtermethod=None, sortmethod=None):
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/<userkey>/js')
|
||||||
|
def bookmarks_js(userkey):
|
||||||
|
""" Return list of bookmarks with their favicons, to be used for autocompletion """
|
||||||
|
bookmarks = Bookmark.select().where(
|
||||||
|
Bookmark.userkey == userkey,
|
||||||
|
Bookmark.status == Bookmark.VISIBLE
|
||||||
|
).order_by(Bookmark.created_date.desc())
|
||||||
|
return render_template(
|
||||||
|
'bookmarks.js',
|
||||||
|
bookmarks=bookmarks
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/r/<userkey>/<urlhash>')
|
@app.route('/r/<userkey>/<urlhash>')
|
||||||
def bookmark_redirect(userkey, urlhash):
|
def bookmark_redirect(userkey, urlhash):
|
||||||
""" Securely redirect a bookmark to its url, stripping referrer (if browser plays nice) """
|
""" Securely redirect a bookmark to its url, stripping referrer (if browser plays nice) """
|
||||||
|
|||||||
@@ -90,13 +90,6 @@
|
|||||||
minLength: 3,
|
minLength: 3,
|
||||||
limit: 10,
|
limit: 10,
|
||||||
data: {
|
data: {
|
||||||
{% for bookmark in bookmarks %}
|
|
||||||
{% if bookmark.favicon %}
|
|
||||||
"{{ bookmark.title | replace('\n', '') }}": "{{ url_for('static', filename='favicons/' + bookmark.favicon) }}",
|
|
||||||
{% else %}
|
|
||||||
"{{ bookmark.title | replace('\n', '') }}": null,
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
var elem = document.querySelector('.autocomplete');
|
var elem = document.querySelector('.autocomplete');
|
||||||
@@ -106,4 +99,5 @@
|
|||||||
});
|
});
|
||||||
*/
|
*/
|
||||||
</script>
|
</script>
|
||||||
|
<script src="{{ url_for('bookmarks_js', userkey=userkey) }}" ></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
11
templates/bookmarks.js
Normal file
11
templates/bookmarks.js
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
var elem = document.querySelector('.autocomplete');
|
||||||
|
var instance = M.Autocomplete.getInstance(elem);
|
||||||
|
instance.updateData({
|
||||||
|
{% for bookmark in bookmarks %}
|
||||||
|
{% if bookmark.favicon %}
|
||||||
|
"{{ bookmark.title | replace('"', '\\"') | replace('\n', '') }}": "{{ url_for('static', filename='favicons/' + bookmark.favicon) }}",
|
||||||
|
{% else %}
|
||||||
|
"{{ bookmark.title | replace('"', '\\"') | replace('\n', '') }}": null,
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user