list.html 15 KB

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