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.

112 lines
3.3KB

  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. <div>{{ post["profile"]["username"] }}</div>
  21. </div>
  22. <div class="blog-timestamp">
  23. {% if post["privacy"] == "private" %}
  24. <span class="blog-entry-private">[Private]</span>
  25. {% elif post["privacy"] == "draft" %}
  26. <span class="blog-entry-draft">[Draft]</span>
  27. {% endif %}
  28. {% if post["sticky"] %}
  29. <span class="blog-entry-sticky">[Sticky]</span>
  30. {% endif %}
  31. Posted by {{ post["profile"]["name"] }}
  32. on <span title="{{ post['time'] }}">{{ post["pretty_time"] }}</span>
  33. </div>
  34. {{ post["rendered_body"] | safe }}
  35. {% if post["snipped"] %}
  36. <p>
  37. <a href="{{ url_for('blog.entry', fid=post['fid']) }}#snip">Read more...</a>
  38. {% endif %}
  39. <p>
  40. <div class="clear">
  41. <strong>Categories:</strong>
  42. {% if post["categories"]|length == 0 or (post["categories"]|length == 1 and post["categories"][0] == "") %}
  43. <a href="{{ url_for('blog.category', category=settings().blog.default_category) }}">
  44. {{ settings().blog.default_category }}
  45. </a>
  46. {% else %}
  47. <ul class="blog-categories">
  48. {% for tag in post["categories"] %}
  49. <li><a href="{{ url_for('blog.category', category=tag) }}">{{ tag }}</a></li>
  50. {% endfor %}
  51. </ul>
  52. {% endif %}
  53. <p>
  54. [
  55. {% if from == "index" %}
  56. {% if post["comments"] %}{# Allowed comments #}
  57. <a href="{{ url_for('blog.entry', fid=post['fid']) }}#comments">{{ post["comment_count"] }} comment{% if post["comment_count"] != 1 %}s{% endif %}</a>
  58. |
  59. <a href="{{ url_for('blog.entry', fid=post['fid']) }}#addcomment">Add comment</a>
  60. |
  61. {% endif %}
  62. <a href="{{ url_for('blog.entry', fid=post['fid']) }}">Permalink</a>
  63. {% else %}
  64. <a href="{{ url_for('blog.index') }}">Blog</a>
  65. {% endif %}
  66. {% if post["privacy"] == "private" %}
  67. | <a href="{{ url_for('blog.private') }}">Private posts</a>
  68. {% endif %}
  69. {% if post["privacy"] == "draft" %}
  70. | <a href="{{ url_for('blog.drafts') }}">Drafts</a>
  71. {% endif %}
  72. {% if session["login"] %}
  73. |
  74. <a href="{{ url_for('blog.update', id=post['post_id']) }}">Edit</a>
  75. |
  76. <a href="{{ url_for('blog.delete', id=post['post_id']) }}">Delete</a>
  77. {% endif %}
  78. ]
  79. </div>
  80. <p>
  81. {# Show the Google ad after the first post. #}
  82. {% if from == "index" and post["position_index"] == 1 %}
  83. {{ leaderboard() }}
  84. {% endif %}
  85. {% if from != "index" %}
  86. {% include "blog/sibling-links.html" %}
  87. <p>
  88. {{ include_page("comment.partial_index",
  89. thread="blog-"+post["post_id"]|string,
  90. subject=post["subject"],
  91. addable=post["comments"],
  92. ) | safe }}
  93. {% endif %}
  94. {% endmacro %}