1
0
Fork 0
rophako/rophako/www/blog/entry.inc.html

69 Zeilen
2.3 KiB
HTML

{# Reusable template for showing a blog post content #}
{% macro blog_entry(post, from=None) %}
{% if from == "index" %}
<a href="{{ url_for('blog.entry', fid=post['fid']) }}" class="blog-title-index">
{{ post["subject"] }}
</a><p>
{% endif %}
<div class="blog-author">
<a href="#">{# TODO #}
{% if post["avatar"] %}
<img src="/static/avatars/{{ post['avatar'] }}">
{% else %}
<img src="/static/avatars/default.png">
{% endif %}
</a><br>
<a href="#">
{{ post["profile"]["username"] }}
</a>
</div>
<div class="blog-timestamp">
Posted by <a href="#">{{ post["profile"]["name"] }}</a>
on <span title="{{ post['time'] }}">{{ post["pretty_time"] }}</span>
</div>
{{ post["body"] | safe }}
<p>
<div class="clear">
<strong>Categories:</strong>
{% if post["categories"]|length == 0 %}
<a href="{{ url_for('blog.category', category=Uncategorized) }}">Uncategorized</a>{# TODO hardcoded name #}
{% else %}
<ul class="blog-categories">
{% for tag in post["categories"] %}
<li><a href="{{ url_for('blog.category', category=tag) }}">{{ tag }}</a></li>
{% endfor %}
</ul>
{% endif %}
<p>
[
{% if from == "index" %}
{% if post["comments"] %}{# Allowed comments #}
<a href="{{ url_for('blog.entry', fid=post['fid']) }}#comments">{{ post["comment_count"] }} comment{% if post["comment_count"] != 1 %}s{% endif %}</a>
|
<a href="{{ url_for('blog.entry', fid=post['fid']) }}#addcomment">Add comment</a>
|
{% endif %}
<a href="{{ url_for('blog.entry', fid=post['fid']) }}">Permalink</a>
{% else %}
<a href="{{ url_for('blog.index') }}">Blog</a>
{% endif %}
{% if session["login"] %}
|
<a href="{{ url_for('blog.update', id=post['post_id']) }}">Edit</a>
|
<a href="{{ url_for('blog.delete', id=post['post_id']) }}">Delete</a>
{% endif %}
]
</div>
{% endmacro %}