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.
 
 
 
 
 

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