thread.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. {% extends "sora/layout.html" %}
  2. {% load i18n %}
  3. {% load url from future %}
  4. {% import "sora/editor.html" as editor with context %}
  5. {% import "sora/macros.html" as macros with context %}
  6. {% block title %}{{ macros.page_title(title=thread.name,parent=forum.name,page=pagination['page']) }}{% endblock %}
  7. {% block breadcrumb %}{{ super() }} <span class="divider">/</span></li>
  8. {% for parent in parents %}
  9. <li><a href="{{ parent.type|url(forum=forum.pk, slug=forum.slug) }}">{{ parent.name }}</a> <span class="divider">/</span></li>
  10. {% endfor %}
  11. <li class="active">{{ thread.name }}
  12. {%- endblock %}
  13. {% block content %}
  14. <div class="page-header">
  15. <ul class="breadcrumb">
  16. {{ self.breadcrumb() }}</li>
  17. </ul>
  18. <h1>{{ thread.name }}</h1>
  19. <ul class="unstyled thread-info">
  20. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  21. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  22. <li><i class="icon-user"></i> {% if thread.start_poster_id %}<a href="{% url 'user' user=thread.start_poster_id, username=thread.start_poster_slug %}">{{ thread.start_poster_name }}</a>{% else %}{{ thread.start_poster_name }}{% endif %}</li>
  23. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  24. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  25. {%- else -%}
  26. {% trans %}No replies{% endtrans %}
  27. {%- endif %}</li>
  28. </ul>
  29. </div>
  30. {% if message %}{{ macros.draw_message(message) }}{% endif %}
  31. <div class="list-nav">
  32. {{ pager() }}
  33. {% if user.is_authenticated() %}
  34. <ul class="nav nav-pills pull-right">
  35. <li class="info"><a href="{% url 'thread_new' forum=forum.pk, slug=forum.slug %}"><i class="icon-ok"></i> {% trans %}Watch Thread{% endtrans %}</a></li>{% if acl.threads.can_reply(thread) %}
  36. <li class="primary"><a href="{% url 'thread_reply' thread=thread.pk, slug=thread.slug %}"><i class="icon-plus"></i> {% trans %}Reply{% endtrans %}</a></li>{% endif %}
  37. </ul>
  38. {% endif %}
  39. </div>
  40. <div class="posts-list">
  41. {% for post in posts %}
  42. {% if post.message %}{{ macros.draw_message(post.message) }}{% endif %}
  43. <div id="post-{{ post.pk }}" class="well well-post{% if post.user and post.user.rank and post.user.rank.style %} {{ post.user.rank.style }}{% endif %}">
  44. <div class="post-author">
  45. <img src="{{ post.user.get_avatar(80) }}" alt="" class="avatar-normal">
  46. <div class="post-bit">
  47. <a href="{% url 'user' user=post.user.pk, username=post.user.username_slug %}" class="lead">{{ post.user.username }}</a>{% if post.user.get_title() %}
  48. <p class="user-title">{{ _(post.user.get_title()) }}</p>{% endif %}
  49. <p class="post-date">{{ post.date|reltimesince|low }}</p>
  50. </div>
  51. </div>
  52. <div class="post-content">
  53. <div class="post-extra">
  54. <a href="{% if pagination['page'] > 1 -%}
  55. {% url 'thread' thread=thread.pk, slug=thread.slug, page=pagination['page'] %}
  56. {%- else -%}
  57. {% url 'thread' thread=thread.pk, slug=thread.slug %}
  58. {%- endif %}#post-{{ post.pk }}" class="post-perma pull-right tooltip-left" title="{% trans %}Direct link to this post{% endtrans %}">#{{ pagination['start'] + loop.index }}</a>
  59. {% if not post.is_read %}
  60. <span class="label label-warning pull-right">
  61. {% trans %}New{% endtrans %}
  62. </span>
  63. {% endif %}
  64. {% if post.moderated %}
  65. <span class="label label-purple pull-right">
  66. {% trans %}Unreviewed{% endtrans %}
  67. </span>
  68. {% endif %}
  69. {% if post.reported %}
  70. <span class="label label-important pull-right">
  71. {% trans %}Reported{% endtrans %}
  72. </span>
  73. {% endif %}
  74. {% if post.deleted %}
  75. <span class="label label-inverse pull-right">
  76. {% trans %}Deleted{% endtrans %}
  77. </span>
  78. {% endif %}
  79. </div>
  80. <div class="markdown">
  81. {{ post.post_preparsed|safe }}
  82. </div>
  83. {% if post.user.signature %}
  84. <div class="post-foot">
  85. {# <p class='lead'><a href="{% url 'user' user=post.user.pk, username=post.user.username_slug %}" class="lead">{{ post.user.username }}</a>, {{ post.date|reltimesince|low }}</p> #}
  86. {% if post.user.signature %}
  87. <div class="signature">
  88. <div class="markdown">
  89. {{ post.user.signature_preparsed|safe }}
  90. </div>
  91. </div>
  92. {% endif %}
  93. </div>
  94. {% endif %}
  95. </div>
  96. <div class="post-nav">
  97. {% if user.is_authenticated() %}
  98. <ul class="nav nav-pills pull-right">
  99. {% if 1 == 2 %}
  100. <li><a href="#"><i class="icon-info-sign"></i> {% trans %}Info{% endtrans %}</a></li>
  101. <li><button class="btn danger"><i class="icon-remove"></i> {% trans %}Delete{% endtrans %}</button></li>
  102. <li><a href="#"><i class="icon-edit"></i> {% trans %}Edit{% endtrans %}</a></li>
  103. {% endif %}
  104. {% if acl.threads.can_reply(thread) %}<li><a href="{% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=post.pk %}"><i class="icon-comment"></i> {% trans %}Reply{% endtrans %}</a></li>{% endif %}
  105. </ul>
  106. {% endif %}
  107. </div>
  108. </div>
  109. {% if post.checkpoint_set.all() %}
  110. <div class="post-checkpoints">
  111. {% for checkpoint in post.checkpoint_set.all() %}
  112. <div class="checkpoint">
  113. <hr>
  114. <span>
  115. {%- if checkpoint.action == 'limit' -%}
  116. <i class="icon-lock"></i> {% trans %}This thread has reached its post limit and has been closed.{% endtrans %}
  117. {%- elif checkpoint.action == 'accepted' -%}
  118. <i class="icon-ok"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} accepted this thread {{ date }}{% endtrans %}
  119. {%- elif checkpoint.action == 'closed' -%}
  120. <i class="icon-lock"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} closed this thread {{ date }}{% endtrans %}
  121. {%- elif checkpoint.action == 'opened' -%}
  122. <i class="icon-lock"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} opened this thread {{ date }}{% endtrans %}
  123. {%- elif checkpoint.action == 'deleted' -%}
  124. <i class="icon-trash"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} deleted this thread {{ date }}{% endtrans %}
  125. {%- elif checkpoint.action == 'undeleted' -%}
  126. <i class="icon-trash"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} restored this thread {{ date }}{% endtrans %}
  127. {%- endif -%}
  128. </span>
  129. </div>
  130. {% endfor %}
  131. </div>
  132. {% endif %}
  133. {% endfor %}
  134. </div>
  135. <div class="list-nav last">
  136. {{ pager(false) }}
  137. {% if user.is_authenticated() and acl.threads.can_reply(thread) %}
  138. <ul class="nav nav-pills pull-right">
  139. <li class="primary"><a href="{% url 'thread_reply' thread=thread.pk, slug=thread.slug %}"><i class="icon-plus"></i> {% trans %}Reply{% endtrans %}</a></li>
  140. </ul>
  141. {% endif %}
  142. </div>
  143. {% if user.is_authenticated() and acl.threads.can_reply(thread) %}
  144. <div class="quick-reply">
  145. <form action="{% url 'thread_reply' thread=thread.pk, slug=thread.slug %}" method="post">
  146. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  147. <input type="hidden" name="quick_reply" value="1">
  148. <img src="{{ user.get_avatar() }}" alt="{% trans %}Your Avatar{% endtrans %}" class="avatar-big">
  149. <div class="arrow"></div>
  150. {{ editor.editor(quick_reply.post, _('Post Reply')) }}
  151. </form>
  152. </div>
  153. {% endif %}
  154. {% endblock %}
  155. {% macro pager(extra=true) %}
  156. <ul class="pager pull-left">
  157. {%- if pagination['prev'] > 1 %}<li><a href="{% url 'thread' slug=thread.slug, thread=thread.id %}" class="tooltip-top" title="{% trans %}Go to first page{% endtrans %}"><i class="icon-chevron-left"></i> {% trans %}First{% endtrans %}</a></li>{% endif -%}
  158. {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{% url 'thread' slug=thread.slug, thread=thread.id, page=pagination['prev'] %}{% else %}{% url 'thread' slug=thread.slug, thread=thread.id %}{% endif %}" class="tooltip-top" title="{% trans %}Older Posts{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  159. {%- if pagination['next'] > 0 %}<li><a href="{% url 'thread' slug=thread.slug, thread=thread.id, page=pagination['next'] %}" class="tooltip-top" title="{% trans %}Newest Posts{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  160. {%- if pagination['next'] > 0 and pagination['next'] < pagination['total'] %}<li><a href="{% url 'thread' slug=thread.slug, thread=thread.id, page=pagination['total'] %}" class="tooltip-top" title="{% trans %}Go to last page{% endtrans %}">{% trans %}Last{% endtrans %} <i class="icon-chevron-right"></i></a></li>{% endif -%}
  161. <li class="count">
  162. {%- trans current_page=pagination['page'], pages=pagination['total'] -%}
  163. Page {{ current_page }} of {{ pages }}
  164. {%- endtrans -%}
  165. </li>
  166. {% if extra and user.is_authenticated() %}
  167. {% if not is_read %}<li class="unread"><a href="{% url 'thread_new' slug=thread.slug, thread=thread.id %}" class="tooltip-top" title="{% trans %}Go to first unread{% endtrans %}"><i class="icon-star"></i> {% trans %}First Unread{% endtrans %}</a></li>{% endif %}
  168. {% if thread.replies_moderated > 0 and acl.threads.can_approve(forum) %}<li class="moderated"><a href="{% url 'thread_moderated' slug=thread.slug, thread=thread.id %}" class="tooltip-top" title="{% trans %}Go to first post awaiting review{% endtrans %}"><i class="icon-eye-close"></i> {% trans %}First Unreviewed{% endtrans %}</a></li>{% endif %}
  169. {% if thread.replies_reported > 0 and acl.threads.can_mod_posts(thread) %}<li class="reported"><a href="{% url 'thread_reported' slug=thread.slug, thread=thread.id %}" class="tooltip-top" title="{% trans %}Go to first reported post{% endtrans %}"><i class="icon-fire"></i> {% trans %}First Reported{% endtrans %}</a></li>{% endif %}
  170. {% endif %}
  171. </ul>
  172. {% endmacro %}
  173. {% macro checkpoint_user(checkpoint) -%}
  174. {{ ('<a href="' ~ 'user'|url(user=checkpoint.user_id, username=checkpoint.user_slug) ~ '">')|safe ~ (checkpoint.user_name) ~ ("</a>")|safe }}
  175. {%- endmacro %}