list.html 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  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=_('Global Announcements'),page=pagination['page']) }}{% endblock %}
  5. {% block container %}
  6. <div class="page-header header-primary">
  7. <div class="container">
  8. {{ messages_list(messages) }}
  9. <h1>{% trans %}Global Announcements{% endtrans %}</h1>
  10. </div>
  11. </div>
  12. <div class="container container-primary">
  13. <div class="lead page-description">
  14. <p>{% trans%}Global announcements are visible of top of all forums threads lists.{% endtrans %}</p>
  15. </div>
  16. {% if message %}
  17. <div class="messages-list">
  18. {{ macros.draw_message(message) }}
  19. </div>
  20. {% endif %}
  21. <div class="forum-threads-extra extra-top">
  22. {{ pager() }}
  23. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  24. <a href="{% url 'thread_new' forum=forum.pk, slug=forum.slug %}" class="btn btn-inverse pull-right"><i class="icon-plus"></i> {% trans %}New Thread{% endtrans %}</a>
  25. {% endif %}
  26. </div>
  27. <div class="forum-threads-list">
  28. <table class="table">
  29. <thead>
  30. <tr>
  31. <th>{% trans %}Thread{% endtrans %}</th>
  32. <th class="span1">{% trans %}Rating{% endtrans %}</th>
  33. <th class="span5">{% trans %}Activity{% endtrans %}</th>
  34. {% if user.is_authenticated() and list_form %}
  35. <th class="check-cell"><label class="checkbox"><input type="checkbox" class="checkbox-master"></label></th>
  36. {% endif %}
  37. </tr>
  38. </thead>
  39. <tbody>
  40. {% for thread in threads %}
  41. <tr>
  42. <td>
  43. <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 -%}
  44. {% trans %}Click to see first unread post{% endtrans %}
  45. {%- else -%}
  46. {% trans %}Click to see last post{% endtrans %}
  47. {%- endif %}"><i class="icon-comment"></i></a>
  48. <a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}" class="thread-name">{{ thread.name }}</a>
  49. <span class="thread-details">
  50. {% trans user=thread_starter(thread), start=thread.start|reltimesince|low %}by {{ user }} {{ start }}{% endtrans %}
  51. </span>
  52. <ul class="unstyled thread-flags">
  53. {% if thread.replies_reported %}
  54. <li><i class="icon-warning-sign tooltip-top" title="{% trans %}This thread has reported replies{% endtrans %}"></i></li>
  55. {% endif %}
  56. {% if thread.replies_moderated %}
  57. <li><i class="icon-question-sign tooltip-top" title="{% trans %}This thread has unreviewed replies{% endtrans %}"></i></li>
  58. {% endif %}
  59. {% if thread.weight == 2 %}
  60. <li><i class="icon-star tooltip-top" title="{% trans %}This thread is an annoucement{% endtrans %}"></i></li>
  61. {% endif %}
  62. {% if thread.weight == 1 %}
  63. <li><i class="icon-star-empty tooltip-top" title="{% trans %}This thread is sticky{% endtrans %}"></i></li>
  64. {% endif %}
  65. {% if thread.moderated %}
  66. <li><i class="icon-eye-close tooltip-top" title="{% trans %}This thread awaits review{% endtrans %}"></i></li>
  67. {% endif %}
  68. {% if thread.deleted %}
  69. <li><i class="icon-trash tooltip-top" title="{% trans %}This thread is deleted{% endtrans %}"></i></li>
  70. {% endif %}
  71. {% if thread.closed %}
  72. <li><i class="icon-lock tooltip-top" title="{% trans %}This thread is closed{% endtrans %}"></i></li>
  73. {% endif %}
  74. </ul>
  75. </td>
  76. <td>
  77. <div class="thread-rating{% if (thread.upvotes-thread.downvotes) > 0 %} thread-rating-positive{% elif (thread.upvotes-thread.downvotes) < 0 %} thread-rating-negative{% endif %}">
  78. {% if (thread.upvotes-thread.downvotes) > 0 %}+{% elif (thread.upvotes-thread.downvotes) < 0 %}-{% endif %}{{ (thread.upvotes-thread.downvotes)|abs|intcomma }}
  79. </div>
  80. </td>
  81. <td>
  82. <div class="thread-last-reply">
  83. {{ replies(thread.replies) }} - {% trans user=thread_reply(thread), last=thread.last|reldate|low %}last by {{ user }} {{ last }}{% endtrans %}
  84. </div>
  85. </td>
  86. {% if user.is_authenticated() and list_form %}
  87. <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>
  88. {% endif %}
  89. </tr>
  90. {% else %}
  91. <tr>
  92. <td colspan="4" class="threads-list-empty">
  93. {% trans %}There are no threads in this forum.{% endtrans %}
  94. </td>
  95. </tr>
  96. {% endfor %}
  97. </tbody>
  98. </table>
  99. {% if user.is_authenticated() and list_form %}
  100. <div class="threads-actions">
  101. <form id="threads_form" class="form-inline pull-right" action="{% url 'forum' slug=forum.slug, forum=forum.id, page=pagination['page'] %}" method="POST">
  102. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  103. {{ form_theme.input_select(list_form['list_action'],width=3) }}
  104. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  105. </form>
  106. </div>
  107. {% endif %}
  108. </div>
  109. <div class="forum-threads-extra">
  110. {{ pager() }}
  111. {% if user.is_authenticated() and acl.threads.can_start_threads(forum) %}
  112. <a href="{% url 'thread_new' forum=forum.pk, slug=forum.slug %}" class="btn btn-inverse pull-right"><i class="icon-plus"></i> {% trans %}New Thread{% endtrans %}</a>
  113. {% elif not user.is_authenticated() and not user.is_crawler() %}
  114. <p class="lead threads-signin-message"><a href="{% url 'sign_in' %}">{% trans %}Sign in or register to start threads.{% endtrans %}</a></p>
  115. {% endif %}
  116. </div>
  117. </div>
  118. {% endblock %}
  119. {% macro forum_stats(forum) -%}
  120. {% if forum.last_thread_id and not forum.attr('hidethread') -%}
  121. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta), thread=forum_thread(forum) -%}
  122. {{ posts }} post - last in {{ thread }}
  123. {%- pluralize -%}
  124. {{ posts }} posts - last in {{ thread }}
  125. {%- endtrans %}
  126. {%- else -%}
  127. {% trans count=forum.posts, posts=fancy_number(forum.posts, forum.posts_delta) -%}
  128. {{ posts }} post
  129. {%- pluralize -%}
  130. {{ posts }} posts
  131. {%- endtrans %}
  132. {%- endif %}
  133. {%- endmacro %}
  134. {% macro forum_thread(forum) -%}
  135. <a href="{% url 'thread_new' thread=forum.last_thread_id, slug=forum.last_thread_slug %}">{{ forum.last_thread_name }}</a>
  136. {%- endmacro %}
  137. {% macro redirect_stats(forum) -%}
  138. {% trans count=forum.redirects, redirects=fancy_number(forum.redirects, forum.redirects_delta) -%}
  139. {{ redirects }} click
  140. {%- pluralize -%}
  141. {{ redirects }} clicks
  142. {%- endtrans %}
  143. {%- endmacro %}
  144. {% macro fancy_number(number, delta) -%}
  145. <strong{% if delta < number %} class="stat-increment"{% endif %}>{{ number|intcomma }}</strong>
  146. {%- endmacro %}
  147. {% macro replies(thread_replies) -%}
  148. {% trans count=thread_replies, replies=('<strong>' ~ (thread_replies|intcomma) ~ '</strong>')|safe -%}
  149. {{ replies }} reply
  150. {%- pluralize -%}
  151. {{ replies }} replies
  152. {%- endtrans %}
  153. {%- endmacro %}
  154. {% macro thread_starter(thread) -%}
  155. {% 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 %}
  156. {%- endmacro %}
  157. {% macro thread_reply(thread) -%}
  158. {% 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 %}
  159. {%- endmacro %}
  160. {% macro pager() %}
  161. {% if pagination['total'] > 0 %}
  162. <div class="pagination pull-left">
  163. <ul>
  164. <li class="count">{{ macros.pager_label(pagination) }}</li>
  165. {%- 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 -%}
  166. {%- 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 -%}
  167. {%- 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 -%}
  168. </ul>
  169. </div>
  170. {% endif %}
  171. {% endmacro %}
  172. {% block javascripts -%}
  173. {{ super() }}
  174. {%- if user.is_authenticated() and list_form %}
  175. <script type="text/javascript">
  176. $(function () {
  177. $('#threads_form').submit(function() {
  178. if ($('.check-cell[]:checked').length == 0) {
  179. alert("{% trans %}You have to select at least one thread.{% endtrans %}");
  180. return false;
  181. }
  182. if ($('#id_list_action').val() == 'hard') {
  183. var decision = confirm("{% trans %}Are you sure you want to delete selected threads? This action is not reversible!{% endtrans %}");
  184. return decision;
  185. }
  186. return true;
  187. });
  188. });
  189. </script>{% endif %}
  190. {%- endblock %}