post.twig 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. {% include 'header.twig' %}
  2. <div class="post">
  3. <div class="title">
  4. {% if post.link|length > 0 %}
  5. <a href="{{ post.link }}">
  6. {{ post.title }}
  7. </a>
  8. {% else %}
  9. {{ post.title }}
  10. {% endif %}
  11. </div>
  12. <div class="info">
  13. {%
  14. include 'vote.twig' with {
  15. target: 'post',
  16. hash_id: post.hashId,
  17. vote: votes.post[post.id] is defined ? votes.post[post.id].vote : null,
  18. vote_count: post.vote,
  19. user: user is defined ? user : null
  20. } only
  21. %}
  22. by <a href="{{ ('user/' ~ post.username|url_encode)|docroot }}">{{ post.username }}</a> <em>{{ post.created|ago }}</em>
  23. — {{ post.vote }} votes, <a href="#comments">{{ post.commentsCount }} comments</a>
  24. {% if user and post.userId == user.id %}
  25. — <a href="../edit?post={{ post.hashId }}">Edit</a>
  26. {% endif %}
  27. </div>
  28. <div class="text">
  29. {{ post.text|markdown|raw }}
  30. </div>
  31. {% if user %}
  32. {# "shortcut-submit" is a class used exclusively from javascript
  33. # to submit the form when a key (Ctrl+Enter) is pressed.
  34. #}
  35. <form action="" method="post" class="new_comment shortcut-submit">
  36. <textarea name="new_comment" required="required" class="form-control" placeholder="Write a comment"></textarea>
  37. <input type="submit" value="Add comment" class="button button_info" />
  38. </form>
  39. {% endif %}
  40. {# id="" used as anchor #}
  41. <div class="comments" id="comments">
  42. {% include 'comment.twig' with {
  43. 'post': post,
  44. 'comments': comments,
  45. 'votes': votes.comment,
  46. 'parent_id': 0,
  47. 'depth': 0
  48. } %}
  49. </div>
  50. </div>
  51. {% include 'footer.twig' %}