1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 22:05:09 +01:00

Better tags in bookmarks, tag page works, filter form

This commit is contained in:
2016-07-21 15:41:17 +02:00
parent caa7ea2711
commit 74e832ec3a
3 changed files with 50 additions and 19 deletions

View File

@@ -178,8 +178,7 @@ def index():
return render_template('index.html') return render_template('index.html')
@app.route('/<userkey>/') @app.route('/<userkey>', methods=['GET', 'POST'])
@app.route('/<userkey>')
def bookmarks(userkey): def bookmarks(userkey):
""" User homepage, list their (unfiltered) bookmarks """ """ User homepage, list their (unfiltered) bookmarks """
#return object_list('bookmarks.html', Bookmark.select()) #return object_list('bookmarks.html', Bookmark.select())
@@ -189,7 +188,11 @@ def bookmarks(userkey):
# return render_template('bookmarks.html', bookmarks) # return render_template('bookmarks.html', bookmarks)
#else: #else:
# abort(404) # abort(404)
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey) if request.method == 'POST':
filter_on = request.form['filter']
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.title % "%" + filter + "%")
else:
bookmarks = Bookmark.select().where(Bookmark.userkey == userkey)
tags = get_tags_for_user(userkey) tags = get_tags_for_user(userkey)
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags) return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags)
@@ -214,7 +217,7 @@ def viewbookmarkjson(userkey, urlhash):
def editbookmark(userkey, urlhash): def editbookmark(userkey, urlhash):
""" Bookmark edit form """ """ Bookmark edit form """
# bookmark = getbyurlhash() # bookmark = getbyurlhash()
bookmark = Bookmark.get(Bookmark.url_hash == urlhash) bookmark = Bookmark.get(Bookmark.url_hash == urlhash, Bookmark.userkey == userkey)
print bookmark.url print bookmark.url
return render_template('edit.html', action='Edit bookmark', userkey=userkey, bookmark=bookmark) return render_template('edit.html', action='Edit bookmark', userkey=userkey, bookmark=bookmark)
@@ -243,7 +246,12 @@ def addingbookmark(userkey):
starred = False starred = False
print starred print starred
if url: if url:
bookmark = Bookmark(url=url, title=title, starred=starred, userkey=userkey) #bookmark = Bookmark(url=url, title=title, starred=starred, userkey=userkey)
bookmark, created = Bookmark.get_or_create(url=url, userkey=userkey)
print created
if created:
bookmark.title = title
bookmark.starred = starred
bookmark.set_tags(tags) bookmark.set_tags(tags)
bookmark.set_hash() bookmark.set_hash()
#bookmark.fetch_image() #bookmark.fetch_image()
@@ -281,7 +289,9 @@ def tags(userkey):
@app.route('/<userkey>/tag/<tag>') @app.route('/<userkey>/tag/<tag>')
def tag(userkey, tag): def tag(userkey, tag):
""" Overview of all bookmarks with a certain tag """ """ Overview of all bookmarks with a certain tag """
return render_template('index.html') bookmarks = Bookmark.select().where(Bookmark.userkey == userkey, Bookmark.tags.contains(tag))
tags = get_tags_for_user(userkey)
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags)
@app.route('/<systemkey>/adduser') @app.route('/<systemkey>/adduser')

View File

@@ -42,3 +42,9 @@
{ {
color: #FFF; color: #FFF;
} }
.chip a,
.white-text .chip a
{
color: #1b5e20; /* green darken-4 */
}

View File

@@ -2,13 +2,28 @@
{% block title %}Bookmarks{% endblock %} {% block title %}Bookmarks{% endblock %}
{% block pageheader %}Bookmarks{% endblock %} {% block pageheader %}Bookmarks{% endblock %}
{% block pagecontent %} {% block pagecontent %}
<div class="row">
<form action="{{ url_for('bookmarks', userkey=userkey) }}" method="POST">
<div class="input-field col s10">
<input placeholder="filter" type="text" name="filter" id="filter" value="{{ filter }}" class="validate" />
</div>
<div class="input-field col s2">
<p class="left-align"><button class="btn btn-large waves-effect waves-light" type="submit" name="submit">Filter</button></p>
</div>
</form>
</div>
{% if tags %} {% if tags %}
<div class="row"> <div class="row">
<p>
{% 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>
</div> </div>
{% endfor %} {% endfor %}
</p>
</div> </div>
{% endif %} {% endif %}
@@ -27,7 +42,6 @@
<div class="card green darken-3"> <div class="card green darken-3">
<div class="card-content white-text"> <div class="card-content white-text">
<span class="card-title activator"><i class="material-icons right">more_vert</i></span> <span class="card-title activator"><i class="material-icons right">more_vert</i></span>
<a href="{{ bookmark.url }}" title="{{ bookmark.url }}" rel="noreferrer">
{% if bookmark.http_status != 200 %} {% if bookmark.http_status != 200 %}
<i class="material-icons" title="HTTP status {{ bookmark.http_status }}">report_problem</i> <i class="material-icons" title="HTTP status {{ bookmark.http_status }}">report_problem</i>
{% endif %} {% endif %}
@@ -35,19 +49,20 @@
<img src="{{ url_for('static', filename='favicons/' + bookmark.favicon) }}" />&nbsp;&nbsp;&nbsp; <img src="{{ url_for('static', filename='favicons/' + bookmark.favicon) }}" />&nbsp;&nbsp;&nbsp;
{% endif %} {% endif %}
{% for tag in bookmark.tags_list %} {% for tag in bookmark.tags_list %}
<span class="tag">{{ tag }}</span> <div class="chip">
<a href="{{ url_for('tag', userkey=userkey, tag=tag) }}">{{ tag }}</a>
</div>
{% endfor %} {% endfor %}
<p> <p><a href="{{ bookmark.url }}" title="{{ bookmark.url }}" rel="noreferrer">
{% if bookmark.starred == True %} {% if bookmark.starred == True %}
<i class="material-icons">star</i> <i class="material-icons">star</i>
{% endif %} {% endif %}
{% if bookmark.title %} {% if bookmark.title %}
{{ bookmark.title }} {{ bookmark.title }}
{% else %} {% else %}
[ no title ] [ no title ]
{% endif %} {% endif %}
</p> </a></p>
</a>
</div> </div>
<div class="card-reveal green darken-3"> <div class="card-reveal green darken-3">
<span class="card-title white-text">Added @ {{ bookmark.created_date.strftime('%Y-%m-%d %H:%M') }}<i class="material-icons right">close</i></span> <span class="card-title white-text">Added @ {{ bookmark.created_date.strftime('%Y-%m-%d %H:%M') }}<i class="material-icons right">close</i></span>