list.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  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{% if subforum.type == 'redirect' %} forum-icon-redirect{% elif not subforum.is_read %} forum-icon-new{% endif %}">
  33. <i class="icon-{% if subforum.type == 'redirect' %}link{% elif not subforum.is_read %}comment{% else %}comment-alt{% endif %}"></i>
  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="{{ url(subforum.type, 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="{{ url(subforum.type, slug=subforum.slug, forum=subforum.id) }}#subforums" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-chevron-down"></i> {% trans %}Subforums{% 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="{{ url(subsubforum.type, slug=subsubforum.slug, forum=subsubforum.id) }}"><i class="icon-{% if subsubforum.type == 'redirect' %}circle-arrow-right{% else %}comments{% endif %}"></i> {{ subsubforum.name }}</a></li>
  69. {% endfor %}
  70. </ul>
  71. </div>
  72. </div>
  73. {% else %}
  74. <a href="{{ url(subforum.subforums[0].type, slug=subforum.subforums[0].slug, forum=subforum.subforums[0].id) }}" class="subforum tooltip-top" title="{% trans subforum=subforum.subforums[0].name %}Go to the {{ subforum }} subforum{% 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. {{ prefix_selection() }}
  102. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  103. <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>
  104. {% endif %}
  105. </div>
  106. <div class="forum-threads-list">
  107. {% if threads %}
  108. <ul>
  109. {% for thread in threads %}
  110. <li{% if not thread.is_read %} class="thread-new"{% endif %}>
  111. <div class="thread-icon">
  112. {% if thread.weight == 2 %}
  113. {% if thread.is_read %}
  114. <a href="{{ url('thread_new', thread=thread.pk, slug=thread.slug) }}" class="thread-icon-last tooltip-top" title="{% trans %}Announcement, click to see last post{% endtrans %}">
  115. {% else %}
  116. <a href="{{ url('thread_new', thread=thread.pk, slug=thread.slug) }}" class="thread-icon-new tooltip-top" title="{% trans %}Announcement, click to see first unread post{% endtrans %}">
  117. {% endif %}
  118. <i class="icon-star{% if thread.is_read %}-empty{% endif %}"></i>
  119. </a>
  120. {% elif thread.weight == 1 %}
  121. {% if thread.is_read %}
  122. <a href="{{ url('thread_new', thread=thread.pk, slug=thread.slug) }}" class="thread-icon-last tooltip-top" title="{% trans %}Pinned, click to see last post{% endtrans %}">
  123. {% else %}
  124. <a href="{{ url('thread_new', thread=thread.pk, slug=thread.slug) }}" class="thread-icon-new tooltip-top" title="{% trans %}Pinned, click to see first unread post{% endtrans %}">
  125. {% endif %}
  126. <i class="icon-bookmark{% if thread.is_read %}-empty{% endif %}"></i>
  127. </a>
  128. {% else %}
  129. {% if thread.is_read %}
  130. <a href="{{ url('thread_new', thread=thread.pk, slug=thread.slug) }}" class="thread-icon-last tooltip-top" title="{% trans %}Click to see last post{% endtrans %}">
  131. {% else %}
  132. <a href="{{ url('thread_new', thread=thread.pk, slug=thread.slug) }}" class="thread-icon-new tooltip-top" title="{% trans %}Click to see first unread post{% endtrans %}">
  133. {% endif %}
  134. <i class="icon-circle{% if thread.is_read %}-blank{% endif %}"></i>
  135. </a>
  136. {% endif %}
  137. </div>
  138. <div class="thread-body">
  139. <ul class="thread-activity">
  140. {% if user.is_authenticated() %}
  141. {% if thread.replies_reported and acl.threads.can_mod_posts(forum) %}
  142. <li class="thread-replies-reported tooltip-top" title="{% trans %}Reported replies{% endtrans %}">
  143. {{ thread.replies_reported|intcomma }}
  144. </li>
  145. {% endif %}
  146. {% if thread.replies_moderated and acl.threads.can_approve(forum) %}
  147. <li class="thread-replies-moderated tooltip-top" title="{% trans %}Unreviewed replies{% endtrans %}">
  148. {{ thread.replies_moderated|intcomma }}
  149. </li>
  150. {% endif %}
  151. {% endif %}
  152. {% if thread.replies %}
  153. <li class="thread-replies tooltip-top" title="{% trans %}Replies{% endtrans %}">
  154. {{ thread.replies|intcomma }}
  155. </li>
  156. {% endif %}
  157. <li class="thread-last-reply tooltip-top" title="{% trans last=thread.last|reldate %}Last post {{ last }}{% endtrans %}">
  158. <a href="{{ url('thread_last', thread=thread.pk, slug=thread.slug) }}">{{ thread.last|relcompact }}</a>
  159. </li>
  160. {% if thread.start_poster_name != thread.last_poster_name %}
  161. <li class="thread-author tooltip-top" title="{% trans username=thread.start_poster_name %}Thread by {{ username }}{% endtrans %}">
  162. {% if thread.start_poster_id %}
  163. <a href="{{ url('user', user=thread.start_poster_id, username=thread.start_poster_name) }}">{% if settings.avatars_on_threads_list %}<img src="{{ thread.start_poster.get_avatar(18) }}" alt="{{ thread.start_poster_name }}" class="user-avatar">{% else %}{{ thread.start_poster_name }}{% endif %}</a>
  164. {% else %}
  165. {% if settings.avatars_on_threads_list %}<img src="{{ macros.avatar_guest(24) }}" alt="{{ thread.start_poster_name }}" class="user-avatar">{% else %}{{ thread.start_poster_name }}{% endif %}
  166. {% endif %}
  167. </li>
  168. {% endif %}
  169. <li class="thread-poster tooltip-top" title="{% if thread.start_poster_name != thread.last_poster_name %}{% trans username=thread.last_poster_name %}Last reply by {{ username }}{% endtrans %}{% else %}{% trans username=thread.last_poster_name %}Thread and last post by {{ username }}{% endtrans %}{% endif %}">
  170. {% if thread.last_poster_id %}
  171. <a href="{{ url('user', user=thread.last_poster_id, username=thread.last_poster_name) }}">{% if settings.avatars_on_threads_list %}<img src="{{ thread.last_poster.get_avatar(18) }}" alt="{{ thread.last_poster_name }}" class="user-avatar">{% else %}{{ thread.last_poster_name }}{% endif %}</a>
  172. {% else %}
  173. {% if settings.avatars_on_threads_list %}<img src="{{ macros.avatar_guest(24) }}" alt="{{ thread.last_poster_name }}" class="user-avatar">{% else %}{{ thread.last_poster_name }}{% endif %}
  174. {% endif %}
  175. </li>
  176. {% if thread.has_poll %}
  177. <li class="thread-flag thread-poll tooltip-top" title="{% trans %}This thread has poll{% endtrans %}">
  178. <i class="icon-tasks"></i>
  179. </li>
  180. {% endif %}
  181. {% if thread.moderated %}
  182. <li class="thread-flag thread-moderated tooltip-top" title="{% trans %}This thread awaits review{% endtrans %}">
  183. <i class="icon-remove-circle"></i>
  184. </li>
  185. {% endif %}
  186. {% if thread.closed %}
  187. <li class="thread-flag thread-closed tooltip-top" title="{% trans %}This thread is closed{% endtrans %}">
  188. <i class="icon-remove-circle"></i>
  189. </li>
  190. {% endif %}
  191. {% if thread.deleted %}
  192. <li class="thread-flag thread-deleted tooltip-top" title="{% trans %}This thread is deleted{% endtrans %}">
  193. <i class="icon-trash"></i>
  194. </li>
  195. {% endif %}
  196. {% if user.is_authenticated() and list_form %}
  197. <li class="thread-select">
  198. <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>
  199. </li>
  200. {% endif %}
  201. </ul>
  202. <div class="thread-title">
  203. {% if thread.prefix_id %}{{ draw_prefix(prefixes[thread.prefix_id]) }}{% endif %}
  204. <a href="{{ url('thread', thread=thread.pk, slug=thread.slug) }}" class="thread-link">{{ thread.name }}</a>
  205. </div>
  206. </div>
  207. </li>
  208. {% endfor %}
  209. </ul>
  210. {% if user.is_authenticated() and list_form %}
  211. <div class="threads-actions">
  212. <form id="threads_form" class="form-inline pull-right" action="{{ request_path }}" method="POST">
  213. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  214. {% set list_form_context = list_form.list_action.field.widget.get_context(list_form.list_action.html_name, list_form.list_action.value()) %}
  215. {% if list_form_context['optgroups'][0][1]|length > 1 %}
  216. {{ form_theme.field(list_form.list_action, attrs={'class': 'span3'}) }}
  217. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  218. {% else %}
  219. <input type="hidden" name="{{ list_form_context.name }}" value="{{ list_form_context['optgroups'][0][1][0][0] }}">
  220. <button type="submit" class="btn btn-danger">{{ list_form_context['optgroups'][0][1][0][1] }}</button>
  221. {% endif %}
  222. </form>
  223. </div>
  224. {% endif %}
  225. {% else %}
  226. <div class="threads-list-empty">
  227. {% if active_prefix %}
  228. {% trans prefix=draw_prefix(active_prefix) %}There are no threads prefixed with {{ prefix }} in this forum.{% endtrans %}
  229. {% else %}
  230. {% trans %}There are no threads in this forum.{% endtrans %}
  231. {% endif %}
  232. </div>
  233. {% endif %}
  234. </div>
  235. <div class="forum-threads-extra">
  236. {{ pager() }}
  237. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  238. <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>
  239. {% elif not user.is_authenticated() and not user.is_crawler() %}
  240. <p class="lead threads-signin-message"><a href="{{ url('sign_in') }}">{% trans %}Sign in or register to start threads.{% endtrans %}</a></p>
  241. {% endif %}
  242. </div>
  243. </div>
  244. {% endblock %}
  245. {% macro forum_stats(forum) -%}
  246. {% if forum.last_thread_id and not forum.attr('hidethread') -%}
  247. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta), thread=forum_thread(forum) -%}
  248. {{ posts }} post - last in {{ thread }}
  249. {%- pluralize -%}
  250. {{ posts }} posts - last in {{ thread }}
  251. {%- endtrans %}
  252. {%- else -%}
  253. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta) -%}
  254. {{ posts }} post
  255. {%- pluralize -%}
  256. {{ posts }} posts
  257. {%- endtrans %}
  258. {%- endif %}
  259. {%- endmacro %}
  260. {% macro forum_thread(forum) -%}
  261. <a href="{{ url('thread_new', thread=forum.last_thread_id, slug=forum.last_thread_slug) }}">{{ forum.last_thread_name }}</a>
  262. {%- endmacro %}
  263. {% macro redirect_stats(forum) -%}
  264. {% trans count=forum.redirects, redirects=fancy_number(forum.redirects, forum.redirects_delta) -%}
  265. {{ redirects }} click
  266. {%- pluralize -%}
  267. {{ redirects }} clicks
  268. {%- endtrans %}
  269. {%- endmacro %}
  270. {% macro fancy_number(number, delta) -%}
  271. <strong{% if delta < number %} class="stat-increment"{% endif %}>{{ number|intcomma }}</strong>
  272. {%- endmacro %}
  273. {% macro pager() %}
  274. {% if pagination['total'] > 0 %}
  275. <div class="pagination pull-left">
  276. <ul>
  277. <li class="count">{{ macros.pager_label(pagination) }}</li>
  278. {% if active_prefix %}
  279. {%- if pagination['prev'] > 1 %}<li><a href="{{ url('forum_prefixed', slug=forum.slug, forum=forum.id, prefix=active_prefix.slug) }}" class="tooltip-top" title="{% trans %}First Page{% endtrans %}"><i class="icon-chevron-left"></i> {% trans %}First{% endtrans %}</a></li>{% endif -%}
  280. {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{{ url('forum_prefixed', slug=forum.slug, forum=forum.id, prefix=active_prefix.slug, page=pagination['prev']) }}{% else %}{{ url('forum_prefixed', slug=forum.slug, forum=forum.id, prefix=active_prefix.slug) }}{% endif %}" class="tooltip-top" title="{% trans %}Newest Threads{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  281. {%- if pagination['next'] > 0 %}<li><a href="{{ url('forum_prefixed', slug=forum.slug, forum=forum.id, prefix=active_prefix.slug, page=pagination['next']) }}" class="tooltip-top" title="{% trans %}Older Threads{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  282. {% else %}
  283. {%- 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 -%}
  284. {%- 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 -%}
  285. {%- 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 -%}
  286. {% endif %}
  287. </ul>
  288. </div>
  289. {% endif %}
  290. {% endmacro %}
  291. {% macro prefix_selection() %}
  292. {% if prefixes %}
  293. <div class="prefix-select pull-left">
  294. <ul>
  295. <li class="selection-title">{% trans %}Filter Threads:{% endtrans %}</li>
  296. {% for prefix in prefixes.values() %}
  297. <li>
  298. <a href="{{ url('forum_prefixed', slug=forum.slug, forum=forum.id, prefix=prefix.slug) }}" class="label{% if prefix.style %} label-{{ prefix.style }}{% endif %}{% if active_prefix == prefix %} label-active{% endif %}">{{ _(prefix.name) }}</a>
  299. </li>
  300. {% endfor %}
  301. {% if active_prefix %}
  302. <li>
  303. <a href="{{ url('forum', slug=forum.slug, forum=forum.id) }}" class="label label-cancel"><i class="icon-remove-sign"></i> {% trans %}Clear filters{% endtrans %}</a>
  304. </li>
  305. {% endif %}
  306. </ul>
  307. </div>
  308. {% endif %}
  309. {% endmacro %}
  310. {% macro draw_prefix(prefix) -%}
  311. <a href="{{ url('forum_prefixed', slug=forum.slug, forum=forum.id, prefix=prefix.slug) }}" class="label{% if prefix.style %} label-{{ prefix.style }}{% endif %} thread-prefix">{{ _(prefix.name) }}</a>
  312. {%- endmacro %}
  313. {% block javascripts -%}{{ super() }}
  314. <script type="text/javascript">
  315. $(function () {
  316. function populateForumTooltip(target) {
  317. return $('#forum-' + target + ' .forum-meta').html();
  318. };
  319. {% for subforum in forum.subforums %}
  320. $('#forum-{{ subforum.id }} .forum-title').tooltip({
  321. template: '<div class="tooltip forum-meta-tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
  322. placement: 'right',
  323. html: true,
  324. title: populateForumTooltip({{ subforum.id }})
  325. });
  326. {% endfor %}
  327. {%- if user.is_authenticated() and list_form %}
  328. $('#threads_form').submit(function() {
  329. if ($('.thread-select[]:checked').length == 0) {
  330. alert("{% trans %}You have to select at least one thread.{% endtrans %}");
  331. return false;
  332. }
  333. if ($('#id_list_action').val() == 'hard') {
  334. var decision = confirm("{% trans %}Are you sure you want to delete selected threads? This action is not reversible!{% endtrans %}");
  335. return decision;
  336. }
  337. return true;
  338. });{% endif %}
  339. });
  340. </script>
  341. {%- endblock %}