mirror of
https://github.com/aquatix/digimarks.git
synced 2025-12-06 23:05:10 +01:00
Filter on 'star' status, 'broken' status (non-http-200-OK)
This commit is contained in:
30
digimarks.py
30
digimarks.py
@@ -260,8 +260,9 @@ def index():
|
|||||||
|
|
||||||
|
|
||||||
@app.route('/<userkey>', methods=['GET', 'POST'])
|
@app.route('/<userkey>', methods=['GET', 'POST'])
|
||||||
|
@app.route('/<userkey>/filter/<filtermethod>', methods=['GET', 'POST'])
|
||||||
@app.route('/<userkey>/sort/<sortmethod>', methods=['GET', 'POST'])
|
@app.route('/<userkey>/sort/<sortmethod>', methods=['GET', 'POST'])
|
||||||
def bookmarks(userkey, sortmethod = None):
|
def bookmarks(userkey, filtermethod = None, sortmethod = None):
|
||||||
""" User homepage, list their bookmarks, optionally filtered and/or sorted """
|
""" User homepage, list their bookmarks, optionally filtered and/or sorted """
|
||||||
#return object_list('bookmarks.html', Bookmark.select())
|
#return object_list('bookmarks.html', Bookmark.select())
|
||||||
#user = User.select(key=userkey)
|
#user = User.select(key=userkey)
|
||||||
@@ -273,14 +274,31 @@ def bookmarks(userkey, sortmethod = None):
|
|||||||
message = request.args.get('message')
|
message = request.args.get('message')
|
||||||
tags = get_cached_tags(userkey)
|
tags = get_cached_tags(userkey)
|
||||||
|
|
||||||
if request.method == 'POST':
|
filter_text = None
|
||||||
filter_on = request.form['filter']
|
if request.form:
|
||||||
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.title.contains(filter_on),
|
filter_text = request.form['filter_text']
|
||||||
|
|
||||||
|
filter_starred = False
|
||||||
|
if filtermethod and filtermethod.lower() == 'starred':
|
||||||
|
filter_starred = True
|
||||||
|
|
||||||
|
filter_broken = False
|
||||||
|
if filtermethod and filtermethod.lower() == 'broken':
|
||||||
|
filter_broken = True
|
||||||
|
|
||||||
|
if filter_text:
|
||||||
|
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.title.contains(filter_text),
|
||||||
Bookmark.status == Bookmark.VISIBLE).order_by(Bookmark.created_date.desc())
|
Bookmark.status == Bookmark.VISIBLE).order_by(Bookmark.created_date.desc())
|
||||||
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, filter=filter_on, message=message)
|
elif filter_starred:
|
||||||
|
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey,
|
||||||
|
Bookmark.starred == True).order_by(Bookmark.created_date.desc())
|
||||||
|
elif filter_broken:
|
||||||
|
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey,
|
||||||
|
Bookmark.http_status != 200).order_by(Bookmark.created_date.desc())
|
||||||
else:
|
else:
|
||||||
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.status == Bookmark.VISIBLE).order_by(Bookmark.created_date.desc())
|
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.status == Bookmark.VISIBLE).order_by(Bookmark.created_date.desc())
|
||||||
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, message=message)
|
|
||||||
|
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags, filter_text=filter_text, message=message)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<form action="{{ url_for('bookmarks', userkey=userkey) }}" method="POST">
|
<form action="{{ url_for('bookmarks', userkey=userkey) }}" method="POST">
|
||||||
<div class="input-field col l10 m10 s8">
|
<div class="input-field col l10 m10 s8">
|
||||||
<input placeholder="filter" type="text" name="filter" id="filter" value="{{ filter }}" class="validate" />
|
<input placeholder="filter_text" type="text" name="filter_text" id="filter_text" value="{{ filter_text }}" class="validate" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="input-field col l2 m2 s4">
|
<div class="input-field col l2 m2 s4">
|
||||||
@@ -47,6 +47,12 @@
|
|||||||
{% if tags %}
|
{% if tags %}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<p>
|
<p>
|
||||||
|
<div class="chip">
|
||||||
|
<a href="{{ url_for('bookmarks', userkey=userkey, filtermethod='starred') }}"><i class="tiny material-icons yellow-text">star</i></a>
|
||||||
|
</div>
|
||||||
|
<div class="chip">
|
||||||
|
<a href="{{ url_for('bookmarks', userkey=userkey, filtermethod='broken') }}"><i class="tiny material-icons red-text">report_problem</i></a>
|
||||||
|
</div>
|
||||||
{% for tag in tags %}
|
{% for tag in tags %}
|
||||||
<div class="chip">
|
<div class="chip">
|
||||||
<a href="{{ url_for('tag', userkey=userkey, tag=tag) }}">{{ tag }}</a>
|
<a href="{{ url_for('tag', userkey=userkey, tag=tag) }}">{{ tag }}</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user