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:
22
digimarks.py
22
digimarks.py
@@ -178,8 +178,7 @@ def index():
|
||||
return render_template('index.html')
|
||||
|
||||
|
||||
@app.route('/<userkey>/')
|
||||
@app.route('/<userkey>')
|
||||
@app.route('/<userkey>', methods=['GET', 'POST'])
|
||||
def bookmarks(userkey):
|
||||
""" User homepage, list their (unfiltered) bookmarks """
|
||||
#return object_list('bookmarks.html', Bookmark.select())
|
||||
@@ -189,7 +188,11 @@ def bookmarks(userkey):
|
||||
# return render_template('bookmarks.html', bookmarks)
|
||||
#else:
|
||||
# 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)
|
||||
return render_template('bookmarks.html', bookmarks=bookmarks, userkey=userkey, tags=tags)
|
||||
|
||||
@@ -214,7 +217,7 @@ def viewbookmarkjson(userkey, urlhash):
|
||||
def editbookmark(userkey, urlhash):
|
||||
""" Bookmark edit form """
|
||||
# bookmark = getbyurlhash()
|
||||
bookmark = Bookmark.get(Bookmark.url_hash == urlhash)
|
||||
bookmark = Bookmark.get(Bookmark.url_hash == urlhash, Bookmark.userkey == userkey)
|
||||
print bookmark.url
|
||||
return render_template('edit.html', action='Edit bookmark', userkey=userkey, bookmark=bookmark)
|
||||
|
||||
@@ -243,7 +246,12 @@ def addingbookmark(userkey):
|
||||
starred = False
|
||||
print starred
|
||||
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_hash()
|
||||
#bookmark.fetch_image()
|
||||
@@ -281,7 +289,9 @@ def tags(userkey):
|
||||
@app.route('/<userkey>/tag/<tag>')
|
||||
def tag(userkey, 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')
|
||||
|
||||
@@ -42,3 +42,9 @@
|
||||
{
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
.chip a,
|
||||
.white-text .chip a
|
||||
{
|
||||
color: #1b5e20; /* green darken-4 */
|
||||
}
|
||||
|
||||
@@ -2,13 +2,28 @@
|
||||
{% block title %}Bookmarks{% endblock %}
|
||||
{% block pageheader %}Bookmarks{% endblock %}
|
||||
{% 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 %}
|
||||
<div class="row">
|
||||
<p>
|
||||
{% for tag in tags %}
|
||||
<div class="chip">
|
||||
<a href="{{ url_for('tag', userkey=userkey, tag=tag) }}">{{ tag }}</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -27,7 +42,6 @@
|
||||
<div class="card green darken-3">
|
||||
<div class="card-content white-text">
|
||||
<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 %}
|
||||
<i class="material-icons" title="HTTP status {{ bookmark.http_status }}">report_problem</i>
|
||||
{% endif %}
|
||||
@@ -35,19 +49,20 @@
|
||||
<img src="{{ url_for('static', filename='favicons/' + bookmark.favicon) }}" />
|
||||
{% endif %}
|
||||
{% 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 %}
|
||||
<p>
|
||||
{% if bookmark.starred == True %}
|
||||
<i class="material-icons">star</i>
|
||||
{% endif %}
|
||||
{% if bookmark.title %}
|
||||
{{ bookmark.title }}
|
||||
{% else %}
|
||||
[ no title ]
|
||||
{% endif %}
|
||||
</p>
|
||||
</a>
|
||||
<p><a href="{{ bookmark.url }}" title="{{ bookmark.url }}" rel="noreferrer">
|
||||
{% if bookmark.starred == True %}
|
||||
<i class="material-icons">star</i>
|
||||
{% endif %}
|
||||
{% if bookmark.title %}
|
||||
{{ bookmark.title }}
|
||||
{% else %}
|
||||
[ no title ]
|
||||
{% endif %}
|
||||
</a></p>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
Reference in New Issue
Block a user