list.html 15 KB

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