list.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  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 forum.type == 'redirect' %}
  42. {{ redirect_stats(forum) }}
  43. {% else %}
  44. {{ forum_stats(forum) }}
  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>{% trans %}Thread{% endtrans %}</th>
  72. <th class="span1">{% trans %}Rating{% endtrans %}</th>
  73. <th class="span5">{% trans %}Activity{% endtrans %}</th>
  74. {% if user.is_authenticated() and list_form %}
  75. <th class="check-cell"><label class="checkbox"><input type="checkbox" class="checkbox-master"></label></th>
  76. {% endif %}
  77. </tr>
  78. </thead>
  79. <tbody>
  80. {% for thread in threads %}
  81. <tr>
  82. <td>
  83. <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 -%}
  84. {% trans %}Click to see first unread post{% endtrans %}
  85. {%- else -%}
  86. {% trans %}Click to see last post{% endtrans %}
  87. {%- endif %}"><i class="icon-comment"></i></a>
  88. <a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}" class="thread-name">{{ thread.name }}</a>
  89. <span class="thread-details">
  90. {% trans user=thread_starter(thread), start=thread.start|reldate|low %}by {{ user }} {{ start }}{% endtrans %}
  91. </span>
  92. <ul class="unstyled thread-flags">
  93. {% if thread.replies_reported %}
  94. <li><i class="icon-warning-sign tooltip-top" title="{% trans %}This thread has reported replies{% endtrans %}"></i></li>
  95. {% endif %}
  96. {% if thread.replies_moderated %}
  97. <li><i class="icon-question-sign tooltip-top" title="{% trans %}This thread has unreviewed replies{% endtrans %}"></i></li>
  98. {% endif %}
  99. {% if thread.weight == 2 %}
  100. <li><i class="icon-star tooltip-top" title="{% trans %}This thread is an annoucement{% endtrans %}"></i></li>
  101. {% endif %}
  102. {% if thread.weight == 1 %}
  103. <li><i class="icon-star-empty tooltip-top" title="{% trans %}This thread is sticky{% endtrans %}"></i></li>
  104. {% endif %}
  105. {% if thread.moderated %}
  106. <li><i class="icon-eye-close tooltip-top" title="{% trans %}This thread awaits review{% endtrans %}"></i></li>
  107. {% endif %}
  108. {% if thread.deleted %}
  109. <li><i class="icon-trash tooltip-top" title="{% trans %}This thread is deleted{% endtrans %}"></i></li>
  110. {% endif %}
  111. {% if thread.closed %}
  112. <li><i class="icon-lock tooltip-top" title="{% trans %}This thread is closed{% endtrans %}"></i></li>
  113. {% endif %}
  114. </ul>
  115. </td>
  116. <td>
  117. <div class="thread-rating{% if (thread.upvotes-thread.downvotes) > 0 %} thread-rating-positive{% elif (thread.upvotes-thread.downvotes) < 0 %} thread-rating-negative{% endif %}">
  118. {% if (thread.upvotes-thread.downvotes) > 0 %}+{% elif (thread.upvotes-thread.downvotes) < 0 %}-{% endif %}{{ (thread.upvotes-thread.downvotes)|abs|intcomma }}
  119. </div>
  120. </td>
  121. <td>
  122. <div class="thread-last-reply">
  123. {{ replies(thread.replies) }} - {% trans user=thread_reply(thread), last=thread.last|reldate|low %}last by {{ user }} {{ last }}{% endtrans %}
  124. </div>
  125. </td>
  126. {% if user.is_authenticated() and list_form %}
  127. <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>
  128. {% endif %}
  129. </tr>
  130. {% else %}
  131. <tr>
  132. <td colspan="4" class="threads-list-empty">
  133. {% trans %}There are no threads in this forum.{% endtrans %}
  134. </td>
  135. </tr>
  136. {% endfor %}
  137. </tbody>
  138. </table>
  139. {% if user.is_authenticated() and list_form %}
  140. <div class="threads-actions">
  141. <form id="threads_form" class="form-inline pull-right" action="{% url 'forum' slug=forum.slug, forum=forum.id, page=pagination['page'] %}" method="POST">
  142. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  143. {{ form_theme.input_select(list_form['list_action'],width=3) }}
  144. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  145. </form>
  146. </div>
  147. {% endif %}
  148. </div>
  149. <div class="forum-threads-extra">
  150. {{ pager() }}
  151. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  152. <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>
  153. {% endif %}
  154. </div>
  155. </div>
  156. {% endblock %}
  157. {% macro forum_stats(forum) -%}
  158. {% if forum.last_thread_id and not forum.attr('hidethread') -%}
  159. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta), thread=forum_thread(forum) -%}
  160. {{ posts }} post - last in {{ thread }}
  161. {%- pluralize -%}
  162. {{ posts }} posts - last in {{ thread }}
  163. {%- endtrans %}
  164. {%- else -%}
  165. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta) -%}
  166. {{ posts }} post
  167. {%- pluralize -%}
  168. {{ posts }} posts
  169. {%- endtrans %}
  170. {%- endif %}
  171. {%- endmacro %}
  172. {% macro forum_thread(forum) -%}
  173. <a href="{% url 'thread' thread=forum.last_thread_id, slug=forum.last_thread_slug %}">{{ forum.last_thread_name }}</a>
  174. {%- endmacro %}
  175. {% macro redirect_stats(forum) -%}
  176. {% trans count=forum.redirects, redirects=fancy_number(forum.redirects, forum.redirects_delta) -%}
  177. {{ redirects }} click
  178. {%- pluralize -%}
  179. {{ redirects }} clicks
  180. {%- endtrans %}
  181. {%- endmacro %}
  182. {% macro fancy_number(number, delta) -%}
  183. <strong{% if delta < number %} class="stat-increment"{% endif %}>{{ number|intcomma }}</strong>
  184. {%- endmacro %}
  185. {% macro replies(thread_replies) -%}
  186. {% trans count=thread_replies, replies=('<strong>' ~ (thread_replies|intcomma) ~ '</strong>')|safe -%}
  187. {{ replies }} reply
  188. {%- pluralize -%}
  189. {{ replies }} replies
  190. {%- endtrans %}
  191. {%- endmacro %}
  192. {% macro thread_starter(thread) -%}
  193. {% 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 %}
  194. {%- endmacro %}
  195. {% macro thread_reply(thread) -%}
  196. {% 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 %}
  197. {%- endmacro %}
  198. {% macro pager() %}
  199. {% if pagination['total'] > 0 %}
  200. <div class="pagination pull-left">
  201. <ul>
  202. <li class="count">{{ macros.pager_label(pagination) }}</li>
  203. {%- 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 -%}
  204. {%- 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 -%}
  205. {%- 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 -%}
  206. </ul>
  207. </div>
  208. {% endif %}
  209. {% endmacro %}
  210. {% block javascripts -%}
  211. {{ super() }}
  212. {%- if user.is_authenticated() and list_form %}
  213. <script type="text/javascript">
  214. $(function () {
  215. $('#threads_form').submit(function() {
  216. if ($('.check-cell[]:checked').length == 0) {
  217. alert("{% trans %}You have to select at least one thread.{% endtrans %}");
  218. return false;
  219. }
  220. if ($('#id_list_action').val() == 'hard') {
  221. var decision = confirm("{% trans %}Are you sure you want to delete selected threads? This action is not reversible!{% endtrans %}");
  222. return decision;
  223. }
  224. return true;
  225. });
  226. });
  227. </script>{% endif %}
  228. {%- endblock %}