comments.html 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. {% import "common_elements.html" as common_elements %}
  2. {% macro render_comment(comment, include_avatar, timestamp_links=False) %}
  3. <div class="comment-container">
  4. <div class="comment">
  5. <a class="author-avatar" href="{{ comment['author_url'] }}" title="{{ comment['author'] }}">
  6. {% if include_avatar %}
  7. <img class="author-avatar-img" alt="{{ comment['author'] }}" src="{{ comment['author_avatar'] }}">
  8. {% endif %}
  9. </a>
  10. <address class="author-name">
  11. <a class="author" href="{{ comment['author_url'] }}" title="{{ comment['author'] }}">{{ comment['author'] }}</a>
  12. </address>
  13. <a class="permalink" href="{{ comment['permalink'] }}" title="permalink">
  14. <span>{{ comment['time_published'] }}</span>
  15. </a>
  16. {% if timestamp_links %}
  17. <span class="comment-text">{{ common_elements.text_runs(comment['text'])|timestamps|safe }}</span>
  18. {% else %}
  19. <span class="comment-text">{{ common_elements.text_runs(comment['text']) }}</span>
  20. {% endif %}
  21. <span class="comment-likes">{{ comment['likes_text'] if comment['approx_like_count'] else ''}}</span>
  22. <div class="button-row">
  23. {% if comment['reply_count'] %}
  24. {% if settings.use_comments_js and comment['replies_url'] %}
  25. <details class="replies" data-src="{{ comment['replies_url'] }}">
  26. <summary>{{ comment['view_replies_text'] }}</summary>
  27. <a href="{{ comment['replies_url'] }}" class="replies-open-new-tab" target="_blank">Open in new tab</a>
  28. <div class="comment_page">loading...</div>
  29. </details>
  30. {% elif comment['replies_url'] %}
  31. <a href="{{ comment['replies_url'] }}" class="replies">{{ comment['view_replies_text'] }}</a>
  32. {% else %}
  33. <a class="replies">{{ comment['view_replies_text'] }} (error constructing url)</a>
  34. {% endif %}
  35. {% endif %}
  36. </div>
  37. </div>
  38. </div>
  39. {% endmacro %}
  40. {% macro video_comments(comments_info) %}
  41. <div class="comment-links">
  42. {% for link_text, link_url in comments_info['comment_links'] %}
  43. <a class="sort-button" href="{{ link_url }}">{{ link_text }}</a>
  44. {% endfor %}
  45. </div>
  46. {% if comments_info['error'] %}
  47. <div class="comments">
  48. <div class="code-box"><code>{{ comments_info['error'] }}</code></div>
  49. </div>
  50. {% else %}
  51. <div class="comments">
  52. {% for comment in comments_info['comments'] %}
  53. {{ render_comment(comment, comments_info['include_avatars'], True) }}
  54. {% endfor %}
  55. </div>
  56. {% if 'more_comments_url' is in comments_info %}
  57. <a class="page-button more-comments" href="{{ comments_info['more_comments_url'] }}">More comments</a>
  58. {% endif %}
  59. {% endif %}
  60. {% endmacro %}