watched.html 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. {% extends "cranefly/layout.html" %}
  2. {% import "cranefly/macros.html" as macros with context %}
  3. {% block title %}{{ macros.page_title(title=_('Threads you are watching')) }}{% endblock %}
  4. {% block container %}
  5. <div class="page-header header-primary">
  6. <div class="container">
  7. {{ messages_list(messages) }}
  8. <h1>{% trans %}Threads you are watching{% endtrans %}</h1>
  9. <ul class="nav nav-tabs header-tabs">
  10. <li class="{% if not new %}active{% endif %}"><a href="{% url 'watched_threads' %}">{% trans %}All Threads{% endtrans %}</a></li>
  11. <li class="{% if new %}active{% endif %}"><a href="{% url 'watched_threads_new' %}">{% trans %}Unread Threads{% endtrans %}</a></li>
  12. </ul>
  13. </div>
  14. </div>
  15. <div class="container container-primary">
  16. {% if message %}
  17. <div class="messages-list">
  18. {{ macros.draw_message(message) }}
  19. </div>
  20. {% endif %}
  21. {% if threads %}
  22. <div class="forum-threads-list watched-threads">
  23. {{ pager() }}
  24. <table class="table">
  25. <thead>
  26. <tr>
  27. <th>{% trans %}Thread{% endtrans %}</th>
  28. <th colspan="2" class="span5">{% trans %}Activity{% endtrans %}</th>
  29. </tr>
  30. </thead>
  31. <tbody>
  32. {% for thread in threads %}
  33. <tr id="watch-{{ loop.index }}">
  34. <td>
  35. <a href="{{ thread_new(thread) }}" class="thread-icon{% if not thread.is_read %} thread-new{% endif %} tooltip-top" title="{% if not thread.is_read -%}
  36. {% trans %}Click to see first unread post{% endtrans %}
  37. {%- else -%}
  38. {% trans %}Click to see last post{% endtrans %}
  39. {%- endif %}"><i class="icon-comment"></i></a>
  40. <a href="{{ thread_start(thread) }}" class="thread-name">{{ thread.name }}</a>
  41. <span class="thread-details">
  42. {% trans user=thread_starter(thread), forum=thread_forum(thread), start=thread.start|reltimesince|low %}by {{ user }} in {{ forum }} {{ start }}{% endtrans %}
  43. </span>
  44. </td>
  45. <td>
  46. <div class="thread-last-reply">
  47. {{ replies(thread.replies) }} - {% trans user=thread_reply(thread), last=thread.last|reltimesince|low %}last by {{ user }} {{ last }}{% endtrans %}
  48. </div>
  49. </td>
  50. <td class="watched-thread-flags">
  51. <form action="{% url 'thread_unwatch' thread=thread.pk, slug=thread.slug %}" method="post">
  52. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  53. <input type="hidden" name="retreat" value="{{ delete_retreat(loop) }}">
  54. <button type="submit" class="btn btn-danger tooltip-top" title="{% trans %}Unwatch{% endtrans %}"><i class="icon-remove"></i></button>
  55. </form>
  56. <form action="{% if thread.send_email %}{% url 'thread_unwatch_email' thread=thread.pk, slug=thread.slug %}{% else %}{% url 'thread_watch_email' thread=thread.pk, slug=thread.slug %}{% endif %}" method="post">
  57. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  58. <input type="hidden" name="retreat" value="{{ request_path }}#watch-{{ loop.index }}">
  59. <button type="submit" class="btn btn-{% if thread.send_email %}success{% else %}inverse{% endif %} tooltip-top" title="{% if thread.send_email %}{% trans %}Don't notify with e-mail{% endtrans %}{% else %}{% trans %}Notify with e-mail{% endtrans %}{% endif %}"><i class="icon-envelope"></i></button>
  60. </form>
  61. </td>
  62. </tr>
  63. {% endfor %}
  64. </tbody>
  65. </table>
  66. {{ pager() }}
  67. </div>
  68. {% else %}
  69. <p class="lead">{% if new -%}
  70. {% trans %}There are no unread threads that you are watching.{% endtrans %}
  71. {%- else -%}
  72. {% trans %}You are not watching any threads.{% endtrans %}
  73. {%- endif %}</p>
  74. {% endif %}
  75. </div>
  76. {% endblock %}
  77. {% macro thread_new(thread) -%}
  78. {% if thread.forum_id == private_threads.pk %}
  79. {% url 'private_thread_new' thread=thread.pk, slug=thread.slug %}
  80. {% elif thread.forum_id == reports.pk %}
  81. TODO!
  82. {% else %}
  83. {% url 'thread_new' thread=thread.pk, slug=thread.slug %}
  84. {% endif%}
  85. {%- endmacro%}
  86. {% macro thread_start(thread) -%}
  87. {% if thread.forum_id == private_threads.pk %}
  88. {% url 'private_thread' thread=thread.pk, slug=thread.slug %}
  89. {% elif thread.forum_id == reports.pk %}
  90. TODO!
  91. {% else %}
  92. {% url 'thread' thread=thread.pk, slug=thread.slug %}
  93. {% endif%}
  94. {%- endmacro%}
  95. {% macro replies(thread_replies) -%}
  96. {% trans count=thread_replies, replies=('<strong>' ~ (thread_replies|intcomma) ~ '</strong>')|safe -%}
  97. {{ replies }} reply
  98. {%- pluralize -%}
  99. {{ replies }} replies
  100. {%- endtrans %}
  101. {%- endmacro %}
  102. {% macro thread_starter(thread) -%}
  103. {% 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 %}
  104. {%- endmacro %}
  105. {% macro thread_forum(thread) -%}{% filter trim %}
  106. {% if thread.forum_id == private_threads.pk %}
  107. <a href="{% url 'private_threads' %}" class="forum-link">{% trans %}Private Threads{% endtrans %}</a>
  108. {% elif thread.forum_id == reports.pk %}
  109. TODO!
  110. {% else %}
  111. <a href="{% url 'forum' forum=thread.forum_id, slug=thread.forum.slug %}" class="forum-link">{{ thread.forum.name }}</a>
  112. {% endif%}
  113. {% endfilter %}{%- endmacro %}
  114. {% macro thread_reply(thread) -%}
  115. {% 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 %}
  116. {%- endmacro %}
  117. {% macro pager() -%}
  118. {% if pagination['total'] > 1 %}
  119. <div class="pagination">
  120. <ul>
  121. <li class="count">{{ macros.pager_label(pagination) }}</li>
  122. {% if new %}
  123. {%- if pagination['prev'] > 1 %}<li><a href="{% url 'watched_threads_new' %}" class="tooltip-top" title="{% trans %}Latest Threads{% endtrans %}"><i class="icon-chevron-left"></i> {% trans %}Latest{% endtrans %}</a></li>{% endif -%}
  124. {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{% url 'watched_threads_new' page=pagination['prev'] %}{% else %}{% url 'watched_threads_new' %}{% endif %}" class="tooltip-top" title="{% trans %}Newer Threads{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  125. {%- if pagination['next'] > 0 %}<li><a href="{% url 'watched_threads_new' page=pagination['next'] %}" class="tooltip-top" title="{% trans %}Older Threads{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  126. {% else %}
  127. {%- if pagination['prev'] > 1 %}<li><a href="{% url 'watched_threads' %}" class="tooltip-top" title="{% trans %}Latest Threads{% endtrans %}"><i class="icon-chevron-left"></i> {% trans %}Latest{% endtrans %}</a></li>{% endif -%}
  128. {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{% url 'watched_threads' page=pagination['prev'] %}{% else %}{% url 'watched_threads' %}{% endif %}" class="tooltip-top" title="{% trans %}Newer Threads{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  129. {%- if pagination['next'] > 0 %}<li><a href="{% url 'watched_threads' page=pagination['next'] %}" class="tooltip-top" title="{% trans %}Older Threads{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  130. {% endif %}
  131. </ul>
  132. </div>
  133. {% endif %}
  134. {%- endmacro %}
  135. {% macro delete_retreat(loop) -%}
  136. {%- if pagination['page'] == 1 -%}
  137. {{ request_path }}{% if not (loop.first and loop.last) %}#watch-{{ loop.index }}{% endif %}
  138. {%- else -%}
  139. {%- if loop.first and loop.last -%}
  140. {%- if new -%}
  141. {%- if pagination['prev'] > 1 %}{% url 'watched_threads_new' page=pagination['prev'] %}{% else %}{% url 'watched_threads_new' %}{% endif %}
  142. {%- else -%}
  143. {%- if pagination['prev'] > 1 %}{% url 'watched_threads' page=pagination['prev'] %}{% else %}{% url 'watched_threads' %}{% endif %}
  144. {%- endif -%}#watch-{{ settings.threads_per_page }}
  145. {%- else -%}
  146. {{ request_path }}#watch-{{ loop.index }}
  147. {%- endif -%}
  148. {%- endif -%}
  149. {%- endmacro %}