list.html 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. {% extends "cranefly/layout.html" %}
  2. {% import "_forms.html" as form_theme with context %}
  3. {% import "cranefly/macros.html" as macros with context %}
  4. {% block title %}{{ macros.page_title(title=forum.name,page=pagination['page']) }}{% endblock %}
  5. {% block breadcrumb %}{{ super() }} <span class="divider"><i class="icon-chevron-right"></i></span></li>
  6. {% for parent in parents %}
  7. <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>
  8. {% endfor %}
  9. <li class="active">{{ forum.name }}
  10. {%- endblock %}
  11. {% block container %}
  12. <div class="page-header header-primary">
  13. <div class="container">
  14. {{ messages_list(messages) }}
  15. <ul class="breadcrumb" {{ macros.itemprop_bread() }}>
  16. {{ self.breadcrumb() }}</li>
  17. </ul>
  18. <h1>{{ forum.name }}</h1>
  19. </div>
  20. </div>
  21. <div class="container container-primary">
  22. {% if forum.description %}
  23. <div class="markdown lead page-description">
  24. {{ forum.description_preparsed|markdown_final|safe }}
  25. </div>
  26. {% endif %}
  27. {% if forum.subforums %}
  28. <div class="forum-subforums-list{% if forum.style %} forum-subforums-{{ forum.style }}{% endif %}">
  29. <table class="table">
  30. <caption>{% trans %}Child forums{% endtrans %}</caption>
  31. <tbody>
  32. {% for subforum in forum.subforums %}
  33. <tr>
  34. <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>
  35. <td class="forum-main">
  36. <h3><a href="{{ subforum.type|url(slug=subforum.slug, forum=subforum.id) }}">{{ subforum.name }}</a></h3>
  37. {% if subforum.show_details %}
  38. <div class="forum-details">
  39. {% if forum.type == 'redirect' %}
  40. {{ redirect_stats(forum) }}
  41. {% else %}
  42. {{ forum_stats(forum) }}
  43. {% endif %}
  44. </div>
  45. {% endif %}
  46. {% if subforum.description %}<p class="forum-description">{{ subforum.description }}</p>{% endif %}
  47. </td>
  48. </tr>
  49. {% endfor %}
  50. </tbody>
  51. </table>
  52. </div>
  53. {% endif %}
  54. {% if message %}
  55. <div class="messages-list">
  56. {{ macros.draw_message(message) }}
  57. </div>
  58. {% endif %}
  59. <div class="forum-threads-extra extra-top">
  60. {{ pager() }}
  61. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  62. <a href="{% url 'thread_start' forum=forum.pk, slug=forum.slug %}" class="btn btn-inverse pull-right"><i class="icon-plus"></i> {% trans %}New Thread{% endtrans %}</a>
  63. {% endif %}
  64. </div>
  65. <div class="forum-threads-list">
  66. <table class="table">
  67. <thead>
  68. <tr>
  69. <th>{% trans %}Thread{% endtrans %}</th>
  70. <th class="span1">{% trans %}Rating{% endtrans %}</th>
  71. <th class="span5">{% trans %}Activity{% endtrans %}</th>
  72. {% if user.is_authenticated() and list_form %}
  73. <th class="check-cell"><label class="checkbox"><input type="checkbox" class="checkbox-master"></label></th>
  74. {% endif %}
  75. </tr>
  76. </thead>
  77. <tbody>
  78. {% for thread in threads %}
  79. <tr>
  80. <td>
  81. <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 -%}
  82. {% trans %}Click to see first unread post{% endtrans %}
  83. {%- else -%}
  84. {% trans %}Click to see last post{% endtrans %}
  85. {%- endif %}"><i class="icon-comment"></i></a>
  86. <a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}" class="thread-name">{{ thread.name }}</a>
  87. <span class="thread-details">
  88. {% trans user=thread_starter(thread), start=thread.start|reldate|low %}by {{ user }} {{ start }}{% endtrans %}
  89. </span>
  90. <ul class="unstyled thread-flags">
  91. {% if thread.replies_reported %}
  92. <li><i class="icon-warning-sign tooltip-top" title="{% trans %}This thread has reported replies{% endtrans %}"></i></li>
  93. {% endif %}
  94. {% if thread.replies_moderated %}
  95. <li><i class="icon-question-sign tooltip-top" title="{% trans %}This thread has unreviewed replies{% endtrans %}"></i></li>
  96. {% endif %}
  97. {% if thread.weight == 2 %}
  98. <li><i class="icon-star tooltip-top" title="{% trans %}This thread is an annoucement{% endtrans %}"></i></li>
  99. {% endif %}
  100. {% if thread.weight == 1 %}
  101. <li><i class="icon-star-empty tooltip-top" title="{% trans %}This thread is sticky{% endtrans %}"></i></li>
  102. {% endif %}
  103. {% if thread.moderated %}
  104. <li><i class="icon-eye-close tooltip-top" title="{% trans %}This thread awaits review{% endtrans %}"></i></li>
  105. {% endif %}
  106. {% if thread.deleted %}
  107. <li><i class="icon-trash tooltip-top" title="{% trans %}This thread is deleted{% endtrans %}"></i></li>
  108. {% endif %}
  109. {% if thread.closed %}
  110. <li><i class="icon-lock tooltip-top" title="{% trans %}This thread is closed{% endtrans %}"></i></li>
  111. {% endif %}
  112. </ul>
  113. </td>
  114. <td>
  115. <div class="thread-rating{% if (thread.upvotes-thread.downvotes) > 0 %} thread-rating-positive{% elif (thread.upvotes-thread.downvotes) < 0 %} thread-rating-negative{% endif %}">
  116. {% if (thread.upvotes-thread.downvotes) > 0 %}+{% elif (thread.upvotes-thread.downvotes) < 0 %}-{% endif %}{{ (thread.upvotes-thread.downvotes)|abs|intcomma }}
  117. </div>
  118. </td>
  119. <td>
  120. <div class="thread-last-reply">
  121. {{ replies(thread.replies) }} - {% trans user=thread_reply(thread), last=thread.last|reltimesince|low %}last by {{ user }} {{ last }}{% endtrans %}
  122. </div>
  123. </td>
  124. {% if user.is_authenticated() and list_form %}
  125. <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>
  126. {% endif %}
  127. </tr>
  128. {% else %}
  129. <tr>
  130. <td colspan="4" class="threads-list-empty">
  131. {% trans %}There are no threads in this forum.{% endtrans %}
  132. </td>
  133. </tr>
  134. {% endfor %}
  135. </tbody>
  136. </table>
  137. {% if user.is_authenticated() and list_form %}
  138. <div class="threads-actions">
  139. <form id="threads_form" class="form-inline pull-right" action="{% url 'forum' slug=forum.slug, forum=forum.id, page=pagination['page'] %}" method="POST">
  140. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  141. {{ form_theme.input_select(list_form['list_action'],width=3) }}
  142. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  143. </form>
  144. </div>
  145. {% endif %}
  146. </div>
  147. <div class="forum-threads-extra">
  148. {{ pager() }}
  149. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  150. <a href="{% url 'thread_start' forum=forum.pk, slug=forum.slug %}" class="btn btn-inverse pull-right"><i class="icon-plus"></i> {% trans %}New Thread{% endtrans %}</a>
  151. {% elif not user.is_authenticated() and not user.is_crawler() %}
  152. <p class="lead threads-signin-message"><a href="{% url 'sign_in' %}">{% trans %}Sign in or register to start threads.{% endtrans %}</a></p>
  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_new' 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 %}