|
- {# Reusable template for showing a blog post content #}
- {% from "google-ads.inc.html" import leaderboard %}
-
- {% 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>
- {% else %}
- {% include "blog/sibling-links.html" %}
- <p>
- {% endif %}
-
- <div class="blog-author">
- {% if post["avatar"] %}
- <img src="/static/avatars/{{ post['avatar'] }}" alt="{{ post['profile']['name'] }}" width="96" height="96">
- {% elif post["photo"] %}
- <img src="{{ post['photo_url'] }}/{{ post['photo'] }}" alt="{{ post['profile']['name'] }}" width="96" height="96">
- {% else %}
- <img src="/static/avatars/default.png" alt="{{ post['profile']['name'] }}" width="96" height="96">
- {% endif %}
-
- <div>{{ post["profile"]["username"] }}</div>
- </div>
-
- <div class="blog-timestamp">
- {% if post["privacy"] == "private" %}
- <span class="blog-entry-private">[Private]</span>
- {% elif post["privacy"] == "draft" %}
- <span class="blog-entry-draft">[Draft]</span>
- {% endif %}
- {% if post["sticky"] %}
- <span class="blog-entry-sticky">[Sticky]</span>
- {% endif %}
-
- Posted by {{ post["profile"]["name"] }}
- on <span title="{{ post['time'] }}">{{ post["pretty_time"] }}</span>
- </div>
-
- {{ post["rendered_body"] | safe }}
- {% if post["snipped"] %}
- <p>
- <a href="{{ url_for('blog.entry', fid=post['fid']) }}#snip">Read more...</a>
- {% endif %}
-
- <p>
- <div class="clear">
- <strong>Categories:</strong>
- {% if post["categories"]|length == 0 or (post["categories"]|length == 1 and post["categories"][0] == "") %}
- <a href="{{ url_for('blog.category', category=settings().blog.default_category) }}">
- {{ settings().blog.default_category }}
- </a>
- {% 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 post["privacy"] == "private" %}
- | <a href="{{ url_for('blog.private') }}">Private posts</a>
- {% endif %}
-
- {% if post["privacy"] == "draft" %}
- | <a href="{{ url_for('blog.drafts') }}">Drafts</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>
- <p>
-
- {# Show the Google ad after the first post. #}
- {% if from == "index" and post["position_index"] == 1 %}
- {{ leaderboard() }}
- {% endif %}
-
- {% if from != "index" %}
- {% include "blog/sibling-links.html" %}
- <p>
-
- {{ include_page("comment.partial_index",
- thread="blog-"+post["post_id"]|string,
- subject=post["subject"],
- addable=post["comments"],
- ) | safe }}
- {% endif %}
-
- {% endmacro %}
|