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.
 
 
 
 
 

93 lines
3.3 KiB

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