1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 20:55:10 +01:00

Refactored the public tag overviews

This commit is contained in:
2018-03-17 18:34:58 +01:00
parent fec54c51f7
commit c4f921ac68
3 changed files with 20 additions and 19 deletions

View File

@@ -762,17 +762,23 @@ def tag(userkey, tag):
) )
def get_publictag(tagkey):
""" Return tag and bookmarks in this public tag collection """
this_tag = PublicTag.get(PublicTag.tagkey == tagkey)
bookmarks = Bookmark.select().where(
Bookmark.userkey == this_tag.userkey,
Bookmark.tags.contains(this_tag.tag),
Bookmark.status == Bookmark.VISIBLE
).order_by(Bookmark.created_date.desc())
return this_tag, bookmarks
@app.route('/pub/<tagkey>') @app.route('/pub/<tagkey>')
def publictag(tagkey): def publictag_page(tagkey):
""" Read-only overview of the bookmarks in the userkey/tag of this PublicTag """ """ Read-only overview of the bookmarks in the userkey/tag of this PublicTag """
#this_tag = get_object_or_404(PublicTag.select().where(PublicTag.tagkey == tagkey)) #this_tag = get_object_or_404(PublicTag.select().where(PublicTag.tagkey == tagkey))
try: try:
this_tag = PublicTag.get(PublicTag.tagkey == tagkey) this_tag, bookmarks = get_publictag(tagkey)
bookmarks = Bookmark.select().where(
Bookmark.userkey == this_tag.userkey,
Bookmark.tags.contains(this_tag.tag),
Bookmark.status == Bookmark.VISIBLE
).order_by(Bookmark.created_date.desc())
theme = themes[DEFAULT_THEME] theme = themes[DEFAULT_THEME]
return render_template( return render_template(
'publicbookmarks.html', 'publicbookmarks.html',
@@ -786,16 +792,11 @@ def publictag(tagkey):
abort(404) abort(404)
@app.route('/pub/<tagkey>/json') @app.route('/api/v1/pub/<tagkey>')
def publictagjson(tagkey): def publictag_json(tagkey):
""" json representation of the Read-only overview of the bookmarks in the userkey/tag of this PublicTag """ """ json representation of the Read-only overview of the bookmarks in the userkey/tag of this PublicTag """
try: try:
this_tag = PublicTag.get(PublicTag.tagkey == tagkey) this_tag, bookmarks = get_publictag(tagkey)
bookmarks = Bookmark.select().where(
Bookmark.userkey == this_tag.userkey,
Bookmark.tags.contains(this_tag.tag),
Bookmark.status == Bookmark.VISIBLE
)
result = {'count': len(bookmarks), 'items': []} result = {'count': len(bookmarks), 'items': []}
for bookmark in bookmarks: for bookmark in bookmarks:
result['items'].append(bookmark.to_dict()) result['items'].append(bookmark.to_dict())
@@ -805,7 +806,7 @@ def publictagjson(tagkey):
@app.route('/pub/<tagkey>/feed') @app.route('/pub/<tagkey>/feed')
def publictagfeed(tagkey): def publictag_feed(tagkey):
""" rss/atom representation of the Read-only overview of the bookmarks in the userkey/tag of this PublicTag """ """ rss/atom representation of the Read-only overview of the bookmarks in the userkey/tag of this PublicTag """
try: try:
this_tag = PublicTag.get(PublicTag.tagkey == tagkey) this_tag = PublicTag.get(PublicTag.tagkey == tagkey)
@@ -814,7 +815,7 @@ def publictagfeed(tagkey):
Bookmark.tags.contains(this_tag.tag), Bookmark.tags.contains(this_tag.tag),
Bookmark.status == Bookmark.VISIBLE Bookmark.status == Bookmark.VISIBLE
).limit(15) ).limit(15)
feed = AtomFeed(this_tag.tag, feed_url=request.url, url=make_external(url_for('publictag', tagkey=tagkey))) feed = AtomFeed(this_tag.tag, feed_url=request.url, url=make_external(url_for('publictag_page', tagkey=tagkey)))
for bookmark in bookmarks: for bookmark in bookmarks:
updated_date = bookmark.modified_date updated_date = bookmark.modified_date
if not bookmark.modified_date: if not bookmark.modified_date:

View File

@@ -20,7 +20,7 @@
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<a href="{{ url_for('publictagfeed', tagkey=tagkey) }}"><i class="material-icons tiny">rss_feed</i> feed</a> <a href="{{ url_for('publictag_feed', tagkey=tagkey) }}"><i class="material-icons tiny">rss_feed</i> feed</a>
</div> </div>
</div> </div>

View File

@@ -48,7 +48,7 @@
</td> </td>
<td> <td>
{% if tag['publictag'] %} {% if tag['publictag'] %}
<a href="{{ url_for('publictag', tagkey=tag['publictag'].tagkey) }}">Public link</a> (<a href="{{ url_for('removepublictag', tag=tag['tag'], tagkey=tag['publictag'].tagkey, userkey=userkey) }}">Delete</a> <i class="tiny material-icons red-text">warning</i>) <a href="{{ url_for('publictag_page', tagkey=tag['publictag'].tagkey) }}">Public link</a> (<a href="{{ url_for('removepublictag', tag=tag['tag'], tagkey=tag['publictag'].tagkey, userkey=userkey) }}">Delete</a> <i class="tiny material-icons red-text">warning</i>)
{% else %} {% else %}
<a href="{{ url_for('addpublictag', userkey=userkey, tag=tag['tag']) }}">Create</a> <a href="{{ url_for('addpublictag', userkey=userkey, tag=tag['tag']) }}">Create</a>
{% endif %} {% endif %}