Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions firefly/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,13 @@ def get_locale():
def before_request():
g.locale = get_locale()

@app.context_processor
def inject_builtin():
return {
'hasattr': hasattr,
'len': len
}


def plug_to_db(db):
from firefly.models.utils import dict_filter
Expand Down
29 changes: 29 additions & 0 deletions firefly/templates/categories/detail.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "base.html" %}

{% block outlet %}
<h1>{{category}}</h1>
{% for post in posts %}
<h2>
<a href="{{post.url()}}">{{post.title}}</a>
{% if post.body %}
{% if post.post_type == 'Quote' %}
<blockquote>{{post.body}}</blockquote>
<p>{{post.author}}</p>
{% else %}
<p>{{post.body}}</p>
{% endif %}
{% endif %}
{% if hasattr(post, 'embed_code') and post.embed_code %}
{{post.embed_code}}
{% endif %}
{% if hasattr(post, 'image_url') and post.image_url %}
<p>
<img alt="" src="{{post.image_url}}"/>
</p>
{% endif %}
<p>{{post.created_at.strftime('%H:%M %Y-%m-%d')}}</p>
{% set total = len(post.comments) %}
{{total}} comment
</h2>
{% endfor %}
{% endblock %}
28 changes: 0 additions & 28 deletions firefly/templates/categories/list.html

This file was deleted.

2 changes: 1 addition & 1 deletion firefly/views/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def get(self, slug):
posts = Post.objects.filter(
category=category
).order_by("-recent_activity_time")
return render_template('categories/list.html',
return render_template('categories/detail.html',
category=category.name,
posts=posts)

Expand Down
2 changes: 1 addition & 1 deletion firefly/views/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class DetailView(MethodView):
def get(self, id):
post = Post.objects.get_or_404(id=id)
Post.objects(id=id).update_one(inc__views=1)
return render_template('posts/detail.html', post=post, hasattr=hasattr,
return render_template('posts/detail.html', post=post,
Markdown=Markdown, gen_author=gen_author,
gen_author_name=gen_author_name,
short_timesince=short_timesince)
Expand Down