Tags page
This commit is contained in:
parent
e943fd880b
commit
b301496421
3 changed files with 23 additions and 4 deletions
|
@ -26,7 +26,7 @@
|
||||||
Tags:
|
Tags:
|
||||||
{% if quote.tags|length > 0 and quote.tags[0].name|length>0%}
|
{% if quote.tags|length > 0 and quote.tags[0].name|length>0%}
|
||||||
{% for tag in quote.tags %}
|
{% for tag in quote.tags %}
|
||||||
<a href="tag/{{tag.name}}" class="badge"> {{tag.name}} </a>
|
<a href="/tag/{{tag.name}}" class="badge"> {{tag.name}} </a>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
<strong> No tags </strong>
|
<strong> No tags </strong>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
{% for tag in tags %}
|
{% for tag in tags %}
|
||||||
<a class="badge">{{tag.name}}</a><br />
|
<a class="badge" href="/tag/{{tag}}">{{tag}}</a><br />
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -135,9 +135,28 @@ def quote(id):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/tag/<tagname>')
|
||||||
|
def tag(tagname):
|
||||||
|
tag = Tag.query.filter_by(name=tagname).first()
|
||||||
|
|
||||||
|
if len(list(tag.quotes))>0:
|
||||||
|
# Replace line breaks with html breaks and escape special characters
|
||||||
|
for quote in tag.quotes:
|
||||||
|
quote.content = str(Markup.escape(quote.content)).replace('\n', '</br>')
|
||||||
|
|
||||||
|
return render_template(
|
||||||
|
"latest.html",
|
||||||
|
title="Latest",
|
||||||
|
quotes=tag.quotes
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
return message("alert-warning", "No quotes with this tag.")
|
||||||
|
|
||||||
|
|
||||||
@app.route('/tags')
|
@app.route('/tags')
|
||||||
def tags():
|
def tags():
|
||||||
tags = Tag.query.order_by(Tag.name).all()
|
tags = Tag.query.order_by(Tag.name).distinct().all()
|
||||||
|
tags = list(set([x.name for x in tags]))
|
||||||
|
|
||||||
return render_template(
|
return render_template(
|
||||||
"tags.html",
|
"tags.html",
|
||||||
|
|
Loading…
Add table
Reference in a new issue