A Python content management system designed for kirsle.net featuring a blog, comments and photo albums. https://rophako.kirsle.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

89 lines
3.0KB

  1. {# Reusable template for showing a blog post content #}
  2. {% from "google-ads.inc.html" import leaderboard %}
  3. {% macro blog_entry(post, from=None) %}
  4. {% if from == "index" %}
  5. <a href="{{ url_for('blog.entry', fid=post['fid']) }}" class="blog-title-index">
  6. {{ post["subject"] }}
  7. </a><p>
  8. {% else %}
  9. {% include "blog/sibling-links.html" %}
  10. <p>
  11. {% endif %}
  12. <div class="blog-author">
  13. {% if post["avatar"] %}
  14. <img src="/static/avatars/{{ post['avatar'] }}" alt="{{ post['profile']['name'] }}" width="96" height="96">
  15. {% elif post["photo"] %}
  16. <img src="{{ post['photo_url'] }}/{{ post['photo'] }}" alt="{{ post['profile']['name'] }}" width="96" height="96">
  17. {% else %}
  18. <img src="/static/avatars/default.png" alt="{{ post['profile']['name'] }}" width="96" height="96">
  19. {% endif %}
  20. <br>
  21. {{ post["profile"]["username"] }}
  22. </div>
  23. <div class="blog-timestamp">
  24. Posted by {{ post["profile"]["name"] }}
  25. on <span title="{{ post['time'] }}">{{ post["pretty_time"] }}</span>
  26. </div>
  27. {{ post["rendered_body"] | safe }}
  28. <p>
  29. <div class="clear">
  30. <strong>Categories:</strong>
  31. {% if post["categories"]|length == 0 %}
  32. <a href="{{ url_for('blog.category', category=Uncategorized) }}">Uncategorized</a>{# TODO hardcoded name #}
  33. {% else %}
  34. <ul class="blog-categories">
  35. {% for tag in post["categories"] %}
  36. <li><a href="{{ url_for('blog.category', category=tag) }}">{{ tag }}</a></li>
  37. {% endfor %}
  38. </ul>
  39. {% endif %}
  40. <p>
  41. [
  42. {% if from == "index" %}
  43. {% if post["comments"] %}{# Allowed comments #}
  44. <a href="{{ url_for('blog.entry', fid=post['fid']) }}#comments">{{ post["comment_count"] }} comment{% if post["comment_count"] != 1 %}s{% endif %}</a>
  45. |
  46. <a href="{{ url_for('blog.entry', fid=post['fid']) }}#addcomment">Add comment</a>
  47. |
  48. {% endif %}
  49. <a href="{{ url_for('blog.entry', fid=post['fid']) }}">Permalink</a>
  50. {% else %}
  51. <a href="{{ url_for('blog.index') }}">Blog</a>
  52. {% endif %}
  53. {% if session["login"] %}
  54. |
  55. <a href="{{ url_for('blog.update', id=post['post_id']) }}">Edit</a>
  56. |
  57. <a href="{{ url_for('blog.delete', id=post['post_id']) }}">Delete</a>
  58. {% endif %}
  59. ]
  60. </div>
  61. <p>
  62. {# Show the Google ad after the first post. #}
  63. {% if from == "index" and post["position_index"] == 1 %}
  64. {{ leaderboard() }}
  65. {% endif %}
  66. {% if from != "index" %}
  67. {% include "blog/sibling-links.html" %}
  68. <p>
  69. {{ include_page("comment.partial_index",
  70. thread="blog-"+post["post_id"]|string,
  71. subject=post["subject"],
  72. ) | safe }}
  73. {% endif %}
  74. {% endmacro %}