list.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. {% extends "cranefly/layout.html" %}
  2. {% load i18n %}
  3. {% load url from future %}
  4. {% import "_forms.html" as form_theme with context %}
  5. {% import "cranefly/macros.html" as macros with context %}
  6. {% block title %}{{ macros.page_title(title=forum.name,page=pagination['page']) }}{% endblock %}
  7. {% block breadcrumb %}{{ super() }} <span class="divider"><i class="icon-chevron-right"></i></span></li>
  8. {% for parent in parents %}
  9. <li><a href="{{ parent.type|url(forum=parent.pk, slug=parent.slug) }}">{{ parent.name }}</a> <span class="divider"><i class="icon-chevron-right"></i></span></li>
  10. {% endfor %}
  11. <li class="active">{{ forum.name }}
  12. {%- endblock %}
  13. {% block container %}
  14. <div class="page-header header-primary">
  15. <div class="container">
  16. {{ messages_list(messages) }}
  17. <ul class="breadcrumb">
  18. {{ self.breadcrumb() }}</li>
  19. </ul>
  20. <h1>{{ forum.name }}</h1>
  21. </div>
  22. </div>
  23. <div class="container container-primary">
  24. {% if forum.description %}
  25. <div class="markdown lead page-description">
  26. {{ forum.description_preparsed|markdown_final|safe }}
  27. </div>
  28. {% endif %}
  29. {% if forum.subforums %}
  30. <div class="forum-subforums-list{% if forum.style %} forum-subforums-{{ forum.style }}{% endif %}">
  31. <table class="table">
  32. <caption>{% trans %}Child forums{% endtrans %}</caption>
  33. <tbody>
  34. {% for subforum in forum.subforums %}
  35. <tr>
  36. <td class="forum-icon"><span class="forum-icon-wrap{% if subforum.type == 'redirect' %} forum-icon-redirect{% elif not subforum.is_read %} forum-icon-new{% endif %}"><i class="icon-{% if subforum.type == 'redirect' %}circle-arrow-right{% else %}comment{% endif %} icon-white"></i></span></td>
  37. <td class="forum-main">
  38. <h3><a href="{{ subforum.type|url(slug=subforum.slug, forum=subforum.id) }}">{{ subforum.name }}</a></h3>
  39. {% if subforum.show_details %}
  40. <div class="forum-details">
  41. {% if subforum.type == 'redirect' %}
  42. <span class="label{% if subforum.redirects_delta < subforum.redirects %} label-success{% endif %}">{{ subforum.redirects|intcomma }}</span> {% trans %}Clicks{% endtrans %}
  43. {% else %}
  44. <span class="label{% if subforum.posts_delta < subforum.posts %} label-success{% endif %}">{{ subforum.posts|intcomma }}</span> {% trans %}Posts{% endtrans %}
  45. {% endif %}
  46. </div>
  47. {% endif %}
  48. {% if subforum.description %}<p class="forum-description">{{ subforum.description }}</p>{% endif %}
  49. </td>
  50. </tr>
  51. {% endfor %}
  52. </tbody>
  53. </table>
  54. </div>
  55. {% endif %}
  56. {% if message %}
  57. <div class="messages-list">
  58. {{ macros.draw_message(message) }}
  59. </div>
  60. {% endif %}
  61. <div class="forum-threads-extra extra-top">
  62. {{ pager() }}
  63. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  64. <a href="{% url 'thread_new' forum=forum.pk, slug=forum.slug %}" class="btn btn-inverse pull-right"><i class="icon-plus"></i> {% trans %}New Thread{% endtrans %}</a>
  65. {% endif %}
  66. </div>
  67. <div class="forum-threads-list">
  68. <table class="table">
  69. <thead>
  70. <tr>
  71. <th style="width: 1%;">&nbsp;</th>
  72. <th>{% trans %}Thread{% endtrans %}</th>
  73. <th class="span1">{% trans %}Rating{% endtrans %}</th>
  74. <th class="span5">{% trans %}Activity{% endtrans %}</th>
  75. {% if user.is_authenticated() and list_form %}
  76. <th class="check-cell"><label class="checkbox"><input type="checkbox" class="checkbox-master"></label></th>
  77. {% endif %}
  78. </tr>
  79. </thead>
  80. <tbody>
  81. {% for thread in threads %}
  82. <tr>
  83. <td>
  84. <a href="{% url 'thread_new' thread=thread.pk, slug=thread.slug %}" class="thread-icon{% if not thread.is_read %} thread-new{% endif %} tooltip-top" title="{% if not thread.is_read -%}
  85. {% trans %}Click to see first unread post{% endtrans %}
  86. {%- else -%}
  87. {% trans %}Click to see last post{% endtrans %}
  88. {%- endif %}"><i class="icon-comment"></i></a>
  89. </td>
  90. <td>
  91. <a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}" class="thread-name">{{ thread.name }}</a>
  92. <span class="thread-details">
  93. {% trans user=thread_starter(thread), start=thread.start|reldate|low %}by {{ user }} {{ start }}{% endtrans %}
  94. </span>
  95. <ul class="unstyled thread-flags">
  96. {% if thread.replies_reported %}
  97. <li><i class="icon-warning-sign tooltip-top" title="{% trans %}This thread has reported replies{% endtrans %}"></i></li>
  98. {% endif %}
  99. {% if thread.replies_moderated %}
  100. <li><i class="icon-question-sign tooltip-top" title="{% trans %}This thread has unreviewed replies{% endtrans %}"></i></li>
  101. {% endif %}
  102. {% if thread.weight == 2 %}
  103. <li><i class="icon-star tooltip-top" title="{% trans %}This thread is an annoucement{% endtrans %}"></i></li>
  104. {% endif %}
  105. {% if thread.weight == 1 %}
  106. <li><i class="icon-star-empty tooltip-top" title="{% trans %}This thread is sticky{% endtrans %}"></i></li>
  107. {% endif %}
  108. {% if thread.moderated %}
  109. <li><i class="icon-eye-close tooltip-top" title="{% trans %}This thread awaits review{% endtrans %}"></i></li>
  110. {% endif %}
  111. {% if thread.deleted %}
  112. <li><i class="icon-trash tooltip-top" title="{% trans %}This thread is deleted{% endtrans %}"></i></li>
  113. {% endif %}
  114. {% if thread.closed %}
  115. <li><i class="icon-lock tooltip-top" title="{% trans %}This thread is closed{% endtrans %}"></i></li>
  116. {% endif %}
  117. </ul>
  118. </td>
  119. <td>
  120. <div class="thread-rating{% if (thread.upvotes-thread.downvotes) > 0 %} thread-rating-positive{% elif (thread.upvotes-thread.downvotes) < 0 %} thread-rating-negative{% endif %}">
  121. {{ (thread.upvotes-thread.downvotes)|abs|intcomma }}
  122. </div>
  123. </td>
  124. <td>
  125. <div class="thread-last-reply">
  126. {{ replies(thread.replies) }} - {% trans user=thread_reply(thread), last=thread.last|reldate|low %}last by {{ user }} {{ last }}{% endtrans %}
  127. </div>
  128. </td>
  129. {% if user.is_authenticated() and list_form %}
  130. <td class="check-cell">{% if thread.forum_id == forum.pk %}<label class="checkbox"><input form="threads_form" name="{{ list_form['list_items']['html_name'] }}" type="checkbox" class="checkbox-member" value="{{ thread.pk }}"{% if list_form['list_items']['has_value'] and ('' ~ thread.pk) in list_form['list_items']['value'] %} checked="checked"{% endif %}></label>{% else %}&nbsp;{% endif %}</td>
  131. {% endif %}
  132. </tr>
  133. {% else %}
  134. <tr>
  135. <td colspan="4" class="threads-list-empty">
  136. {% trans %}There are no threads in this forum.{% endtrans %}
  137. </td>
  138. </tr>
  139. {% endfor %}
  140. </tbody>
  141. </table>
  142. {% if user.is_authenticated() and list_form %}
  143. <div class="threads-actions">
  144. <form id="threads_form" class="form-inline pull-right" action="{% url 'forum' slug=forum.slug, forum=forum.id, page=pagination['page'] %}" method="POST">
  145. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  146. {{ form_theme.input_select(list_form['list_action'],width=3) }}
  147. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  148. </form>
  149. </div>
  150. {% endif %}
  151. </div>
  152. <div class="forum-threads-extra">
  153. {{ pager() }}
  154. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  155. <a href="{% url 'thread_new' forum=forum.pk, slug=forum.slug %}" class="btn btn-inverse pull-right"><i class="icon-plus"></i> {% trans %}New Thread{% endtrans %}</a>
  156. {% endif %}
  157. </div>
  158. </div>
  159. {% endblock %}
  160. {% macro replies(thread_replies) -%}
  161. {% trans count=thread_replies, replies=('<strong>' ~ (thread_replies|intcomma) ~ '</strong>')|safe -%}
  162. {{ replies }} reply
  163. {%- pluralize -%}
  164. {{ replies }} replies
  165. {%- endtrans %}
  166. {%- endmacro %}
  167. {% macro thread_starter(thread) -%}
  168. {% if thread.start_poster_id %}<a href="{% url 'user' user=thread.start_poster_id, username=thread.start_poster_slug %}" class="user-link">{{ thread.start_poster_name }}</a>{% else %}{{ thread.start_poster_name }}{% endif %}
  169. {%- endmacro %}
  170. {% macro thread_reply(thread) -%}
  171. {% if thread.last_poster_id %}<a href="{% url 'user' user=thread.last_poster_id, username=thread.last_poster_slug %}" class="user-link">{{ thread.last_poster_name }}</a>{% else %}{{ thread.last_poster_name }}{% endif %}
  172. {%- endmacro %}
  173. {% macro pager() %}
  174. {% if pagination['total'] > 0 %}
  175. <div class="pagination pull-left">
  176. <ul>
  177. <li class="count">{{ macros.pager_label(pagination) }}</li>
  178. {%- if pagination['prev'] > 1 %}<li><a href="{% url 'forum' slug=forum.slug, forum=forum.id %}" class="tooltip-top" title="{% trans %}First Page{% endtrans %}"><i class="icon-chevron-left"></i> {% trans %}First{% endtrans %}</a></li>{% endif -%}
  179. {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{% url 'forum' slug=forum.slug, forum=forum.id, page=pagination['prev'] %}{% else %}{% url 'forum' slug=forum.slug, forum=forum.id %}{% endif %}" class="tooltip-top" title="{% trans %}Newest Threads{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  180. {%- if pagination['next'] > 0 %}<li><a href="{% url 'forum' slug=forum.slug, forum=forum.id, page=pagination['next'] %}" class="tooltip-top" title="{% trans %}Older Threads{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  181. </ul>
  182. </div>
  183. {% endif %}
  184. {% endmacro %}
  185. {% block javascripts -%}
  186. {{ super() }}
  187. {%- if user.is_authenticated() and list_form %}
  188. <script type="text/javascript">
  189. $(function () {
  190. $('#threads_form').submit(function() {
  191. if ($('.check-cell[]:checked').length == 0) {
  192. alert("{% trans %}You have to select at least one thread.{% endtrans %}");
  193. return false;
  194. }
  195. if ($('#id_list_action').val() == 'hard') {
  196. var decision = confirm("{% trans %}Are you sure you want to delete selected threads? This action is not reversible!{% endtrans %}");
  197. return decision;
  198. }
  199. return true;
  200. });
  201. });
  202. </script>{% endif %}
  203. {%- endblock %}