list.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 forum.type == 'redirect' %} forum-icon-redirect{% elif not forum.is_read %} forum-icon-new{% endif %}"><i class="icon-{% if forum.type == 'redirect' %}circle-arrow-right{% else %}comment{% endif %} icon-white"></i></span></td>
  35. <td id="forum-{{ forum.id }}" class="forum-main">
  36. <h3 class="forum-title{% if not forum.is_read %} forum-title-new{% endif %}"><a href="{{ forum.type|url(slug=forum.slug, forum=forum.id) }}">{{ forum.name }}</a></h3>
  37. {% if forum.show_details and forum.type != 'redirect' %}
  38. <div class="forum-details">
  39. {% if acl.forums.can_browse(forum) and (acl.threads.can_read_threads(forum) == 2 or (acl.threads.can_read_threads(forum) == 1 and forum.last_poster_id == user.pk)) %}
  40. {% if forum.last_thread_id -%}
  41. {% trans %}Latest{% endtrans %}: <a href="{% url 'thread_new' thread=forum.last_thread_id, slug=forum.last_thread_slug %}" class="tooltip-top" title="{{ forum.last_thread_name }}">{{ forum.last_thread_name|short_string(28) }}</a>
  42. {%- else -%}
  43. <em>{% trans %}This forum is empty{% endtrans %}</em>
  44. {%- endif %}
  45. {%- else -%}
  46. <em>{% trans %}This forum is protected{% endtrans %}</em>
  47. {%- endif %}
  48. </div>
  49. {% endif %}
  50. <div class="hide forum-meta">
  51. {% if forum.description %}<p class="forum-description">{{ forum.description }}</p>{% endif %}
  52. <div class="forum-stats">
  53. {% if forum.type != 'redirect' %}
  54. <span>{% trans %}Posts{% endtrans %}: <strong>{{ forum.posts|intcomma }}</strong></span>
  55. {% trans %}Threads{% endtrans %}: <strong>{{ forum.threads|intcomma }}</strong>
  56. {% else %}
  57. {% trans %}Clicks{% endtrans %}: <strong>{{ forum.redirects|intcomma }}</strong>
  58. {% endif %}
  59. </div>
  60. </div>
  61. </td>
  62. </tr>
  63. {% endfor %}
  64. </tbody>
  65. </table>
  66. </div>
  67. {% endif %}
  68. {% if message %}
  69. <div class="messages-list">
  70. {{ macros.draw_message(message) }}
  71. </div>
  72. {% endif %}
  73. <div class="forum-threads-extra extra-top">
  74. {{ pager() }}
  75. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  76. <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>
  77. {% endif %}
  78. </div>
  79. <div class="forum-threads-list">
  80. <table class="table">
  81. <thead>
  82. <tr>
  83. <th>{% trans %}Thread{% endtrans %}</th>
  84. <th class="span1">{% trans %}Rating{% endtrans %}</th>
  85. <th class="span5">{% trans %}Activity{% endtrans %}</th>
  86. {% if user.is_authenticated() and list_form %}
  87. <th class="check-cell"><label class="checkbox"><input type="checkbox" class="checkbox-master"></label></th>
  88. {% endif %}
  89. </tr>
  90. </thead>
  91. <tbody>
  92. {% for thread in threads %}
  93. <tr>
  94. <td>
  95. <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 -%}
  96. {% trans %}Click to see first unread post{% endtrans %}
  97. {%- else -%}
  98. {% trans %}Click to see last post{% endtrans %}
  99. {%- endif %}"><i class="icon-comment"></i></a>
  100. <a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}" class="thread-name">{{ thread.name }}</a>
  101. <span class="thread-details">
  102. {% trans user=thread_starter(thread), start=thread.start|reldate|low %}by {{ user }} {{ start }}{% endtrans %}
  103. </span>
  104. <ul class="unstyled thread-flags">
  105. {% if thread.replies_reported %}
  106. <li><i class="icon-warning-sign tooltip-top" title="{% trans %}This thread has reported replies{% endtrans %}"></i></li>
  107. {% endif %}
  108. {% if thread.replies_moderated %}
  109. <li><i class="icon-question-sign tooltip-top" title="{% trans %}This thread has unreviewed replies{% endtrans %}"></i></li>
  110. {% endif %}
  111. {% if thread.weight == 2 %}
  112. <li><i class="icon-star tooltip-top" title="{% trans %}This thread is an annoucement{% endtrans %}"></i></li>
  113. {% endif %}
  114. {% if thread.weight == 1 %}
  115. <li><i class="icon-star-empty tooltip-top" title="{% trans %}This thread is sticky{% endtrans %}"></i></li>
  116. {% endif %}
  117. {% if thread.moderated %}
  118. <li><i class="icon-eye-close tooltip-top" title="{% trans %}This thread awaits review{% endtrans %}"></i></li>
  119. {% endif %}
  120. {% if thread.deleted %}
  121. <li><i class="icon-trash tooltip-top" title="{% trans %}This thread is deleted{% endtrans %}"></i></li>
  122. {% endif %}
  123. {% if thread.closed %}
  124. <li><i class="icon-lock tooltip-top" title="{% trans %}This thread is closed{% endtrans %}"></i></li>
  125. {% endif %}
  126. </ul>
  127. </td>
  128. <td>
  129. <div class="thread-rating{% if (thread.upvotes-thread.downvotes) > 0 %} thread-rating-positive{% elif (thread.upvotes-thread.downvotes) < 0 %} thread-rating-negative{% endif %}">
  130. {% if (thread.upvotes-thread.downvotes) > 0 %}+{% elif (thread.upvotes-thread.downvotes) < 0 %}-{% endif %}{{ (thread.upvotes-thread.downvotes)|abs|intcomma }}
  131. </div>
  132. </td>
  133. <td>
  134. <div class="thread-last-reply">
  135. {{ replies(thread.replies) }} - {% trans user=thread_reply(thread), last=thread.last|reltimesince|low %}last by {{ user }} {{ last }}{% endtrans %}
  136. </div>
  137. </td>
  138. {% if user.is_authenticated() and list_form %}
  139. <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>
  140. {% endif %}
  141. </tr>
  142. {% else %}
  143. <tr>
  144. <td colspan="4" class="threads-list-empty">
  145. {% trans %}There are no threads in this forum.{% endtrans %}
  146. </td>
  147. </tr>
  148. {% endfor %}
  149. </tbody>
  150. </table>
  151. {% if user.is_authenticated() and list_form %}
  152. <div class="threads-actions">
  153. <form id="threads_form" class="form-inline pull-right" action="{% url 'forum' slug=forum.slug, forum=forum.id, page=pagination['page'] %}" method="POST">
  154. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  155. {{ form_theme.input_select(list_form['list_action'],width=3) }}
  156. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  157. </form>
  158. </div>
  159. {% endif %}
  160. </div>
  161. <div class="forum-threads-extra">
  162. {{ pager() }}
  163. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  164. <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>
  165. {% elif not user.is_authenticated() and not user.is_crawler() %}
  166. <p class="lead threads-signin-message"><a href="{% url 'sign_in' %}">{% trans %}Sign in or register to start threads.{% endtrans %}</a></p>
  167. {% endif %}
  168. </div>
  169. </div>
  170. {% endblock %}
  171. {% macro forum_stats(forum) -%}
  172. {% if forum.last_thread_id and not forum.attr('hidethread') -%}
  173. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta), thread=forum_thread(forum) -%}
  174. {{ posts }} post - last in {{ thread }}
  175. {%- pluralize -%}
  176. {{ posts }} posts - last in {{ thread }}
  177. {%- endtrans %}
  178. {%- else -%}
  179. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta) -%}
  180. {{ posts }} post
  181. {%- pluralize -%}
  182. {{ posts }} posts
  183. {%- endtrans %}
  184. {%- endif %}
  185. {%- endmacro %}
  186. {% macro forum_thread(forum) -%}
  187. <a href="{% url 'thread_new' thread=forum.last_thread_id, slug=forum.last_thread_slug %}">{{ forum.last_thread_name }}</a>
  188. {%- endmacro %}
  189. {% macro redirect_stats(forum) -%}
  190. {% trans count=forum.redirects, redirects=fancy_number(forum.redirects, forum.redirects_delta) -%}
  191. {{ redirects }} click
  192. {%- pluralize -%}
  193. {{ redirects }} clicks
  194. {%- endtrans %}
  195. {%- endmacro %}
  196. {% macro fancy_number(number, delta) -%}
  197. <strong{% if delta < number %} class="stat-increment"{% endif %}>{{ number|intcomma }}</strong>
  198. {%- endmacro %}
  199. {% macro replies(thread_replies) -%}
  200. {% trans count=thread_replies, replies=('<strong>' ~ (thread_replies|intcomma) ~ '</strong>')|safe -%}
  201. {{ replies }} reply
  202. {%- pluralize -%}
  203. {{ replies }} replies
  204. {%- endtrans %}
  205. {%- endmacro %}
  206. {% macro thread_starter(thread) -%}
  207. {% 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 %}
  208. {%- endmacro %}
  209. {% macro thread_reply(thread) -%}
  210. {% 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 %}
  211. {%- endmacro %}
  212. {% macro pager() %}
  213. {% if pagination['total'] > 0 %}
  214. <div class="pagination pull-left">
  215. <ul>
  216. <li class="count">{{ macros.pager_label(pagination) }}</li>
  217. {%- 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 -%}
  218. {%- 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 -%}
  219. {%- 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 -%}
  220. </ul>
  221. </div>
  222. {% endif %}
  223. {% endmacro %}
  224. {% block javascripts -%}{{ super() }}
  225. <script type="text/javascript">
  226. $(function () {
  227. function populateForumTooltip(target) {
  228. return $('#forum-' + target + ' .forum-meta').html();
  229. };
  230. {% for category in forums_list %}{% for forum in category.subforums %}
  231. $('#forum-{{ forum.id }} .forum-title').tooltip({
  232. template: '<div class="tooltip forum-meta-tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  233. placement: 'right',
  234. html: true,
  235. title: populateForumTooltip({{ forum.id }})
  236. });
  237. {% endfor %}{% endfor %}
  238. {%- if user.is_authenticated() and list_form %}
  239. $('#threads_form').submit(function() {
  240. if ($('.check-cell[]:checked').length == 0) {
  241. alert("{% trans %}You have to select at least one thread.{% endtrans %}");
  242. return false;
  243. }
  244. if ($('#id_list_action').val() == 'hard') {
  245. var decision = confirm("{% trans %}Are you sure you want to delete selected threads? This action is not reversible!{% endtrans %}");
  246. return decision;
  247. }
  248. return true;
  249. });{% endif %}
  250. });
  251. </script>
  252. {%- endblock %}