thread.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. {% extends "cranefly/layout.html" %}
  2. {% import "forms.html" as form_theme with context %}
  3. {% import "cranefly/editor.html" as editor with context %}
  4. {% import "cranefly/macros.html" as macros with context %}
  5. {% block title %}{{ macros.page_title(title=thread.name,parent=forum.name,page=pagination['page']) }}{% endblock %}
  6. {% block breadcrumb %}{{ super() }} <span class="divider"><i class="icon-chevron-right"></i></span></li>
  7. {{ macros.parents_list(parents) }}
  8. <li class="active">{{ thread.name }}
  9. {%- endblock %}
  10. {% block container %}
  11. <div class="page-header header-primary">
  12. <div class="container">
  13. {{ messages_list(messages) }}
  14. <ul class="breadcrumb" {{ macros.itemprop_bread() }}>
  15. {{ self.breadcrumb() }}</li>
  16. </ul>
  17. <h1>{{ thread.name }}</h1>
  18. <ul class="unstyled header-stats">
  19. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  20. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  21. <li><i class="icon-user"></i> {% if thread.start_poster_id %}<a href="{{ url('user', user=thread.start_poster_id, username=thread.start_poster_slug) }}">{{ thread.start_poster_name }}</a>{% else %}{{ thread.start_poster_name }}{% endif %}</li>
  22. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  23. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  24. {%- else -%}
  25. {% trans %}No replies{% endtrans %}
  26. {%- endif %}</li>
  27. {% if thread.closed %}<li><i class="icon-lock"></i> {% trans %}Locked{% endtrans %}</li>{% endif %}
  28. </ul>
  29. </div>
  30. </div>
  31. <div class="container container-primary">
  32. {% if message %}
  33. <div class="messages-list">
  34. {{ macros.draw_message(message) }}
  35. </div>
  36. {% endif %}
  37. {% if poll %}
  38. <div class="thread-poll-body" id="poll">
  39. {% if poll.message %}
  40. <div class="messages-list">
  41. {{ macros.draw_message(poll.message) }}
  42. </div>
  43. {% endif %}
  44. <h2 class="text-center">{{ poll.question }}</h2>
  45. {% if poll_form %}
  46. <form action="{{ url('thread_poll_vote', slug=thread.slug, thread=thread.pk) }}" method="post">
  47. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  48. <input type="hidden" name="retreat" value="{{ request_path }}">
  49. {% endif %}
  50. <div class="poll-options">
  51. {% if poll_form and not poll.user_votes %}
  52. <ul class="unstyled options-form">
  53. {% for choice in poll.choices_cache %}
  54. <li>
  55. <label class="radio">
  56. <input type="radio" name="options" id="id_options_{{ choice.pk }}" value="{{ choice.pk }}">
  57. {{ choice.name }}
  58. </label>
  59. </li>
  60. {% endfor %}
  61. </ul>
  62. {% else %}
  63. <dl class="dl-horizontal">
  64. {% for choice in poll.choices_cache %}
  65. <dt>{{ choice.name }}</dt>
  66. <dd>
  67. <div class="progress">
  68. <div class="bar" style="width: {% if poll.votes %}{{ (choice.votes * 100 / poll.votes)|int }}{% else %}1{% endif %}%; background: #{{ color_desaturate(color_spin('049cdb', loop.index0 * 265), loop.length, loop.index/3, 20) }};"></div>
  69. </div>
  70. <p class="option-details">
  71. {% if choice.pk in poll.user_votes %}<strong>{% trans %}Your vote{% endtrans %}</strong>{% endif %}
  72. {% trans count=choice.votes, votes=choice.votes, percent=(choice.votes * 100 / poll.votes)|int -%}
  73. {{ votes }} vote, {{ percent }}% of all
  74. {%- pluralize -%}
  75. {{ votes }} votes, {{ percent }}% of all
  76. {%- endtrans %}
  77. </p>
  78. </dd>
  79. {% endfor %}
  80. </dl>
  81. {% endif %}
  82. </div>
  83. <div class="poll-footer">
  84. {% if poll_form %}
  85. <button type="submit" class="btn btn-primary">{% trans %}Vote{% endtrans %}</button>
  86. {% if not poll.user_votes %}
  87. <button type="submit" name="empty_vote" class="btn btn-inverse">{% trans %}Results{% endtrans %}</button>
  88. {% endif %}
  89. {% endif %}
  90. {% if poll.public %}
  91. <a href="" class="btn">{% trans %}Show voters{% endtrans %}</a>
  92. {% endif %}
  93. <p>
  94. {% if poll.public %}
  95. <strong>{% trans %}Voting is public.{% endtrans %}</strong>
  96. {% endif %}
  97. {% if thread.closed or thread.deleted %}
  98. {% trans %}Poll has been closed.{% endtrans %}
  99. {% elif thread.poll.over %}
  100. {% trans end=poll.end_date|date %}Poll ended on {{ end }}{% endtrans %}
  101. {% elif thread.poll.length %}
  102. {% trans end=poll.end_date|date %}Poll ends on {{ end }}{% endtrans %}
  103. {% endif %}
  104. </p>
  105. </div>
  106. {% if poll_form %}
  107. </form>
  108. {% endif %}
  109. </div>
  110. {% endif %}
  111. <div class="thread-buttons">
  112. {{ pager() }}
  113. {% if user.is_authenticated() %}
  114. {% if acl.threads.can_reply(forum, thread) %}
  115. <a href="{{ url('thread_reply', thread=thread.pk, slug=thread.slug) }}" class="btn btn-inverse pull-right"><i class="icon-pencil"></i> {% trans %}Reply{% endtrans %}</a>
  116. {% endif %}
  117. {% if watcher %}
  118. <form action="{{ url('thread_unwatch', thread=thread.pk, slug=thread.slug) }}" class="form-inline pull-right" method="post"><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"><input type="hidden" name="retreat" value="{{ request_path }}"><button type="submit" class="btn btn-icon btn-success tooltip-top" title="{% trans %}Remove thread from watched list{% endtrans %}"><i class="icon-bookmark"></i></button></form>
  119. {% if watcher.email %}
  120. <form action="{{ url('thread_unwatch_email', thread=thread.pk, slug=thread.slug) }}" class="form-inline pull-right" method="post"><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"><input type="hidden" name="retreat" value="{{ request_path }}"><button type="submit" class="btn btn-icon btn-success tooltip-top" title="{% trans %}Don't e-mail me anymore if anyone replies to this thread{% endtrans %}"><i class="icon-envelope"></i></button></form>
  121. {% else %}
  122. <form action="{{ url('thread_watch_email', thread=thread.pk, slug=thread.slug) }}" class="form-inline pull-right" method="post"><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"><input type="hidden" name="retreat" value="{{ request_path }}"><button type="submit" class="btn btn-icon tooltip-top" title="{% trans %}E-mail me if anyone replies{% endtrans %}"><i class="icon-envelope"></i></button></form>
  123. {% endif %}
  124. {% else %}
  125. <form action="{{ url('thread_watch', thread=thread.pk, slug=thread.slug) }}" class="form-inline pull-right" method="post"><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"><input type="hidden" name="retreat" value="{{ request_path }}"><button type="submit" class="btn btn-icon tooltip-top" title="{% trans %}Add thread to watched list{% endtrans %}"><i class="icon-bookmark"></i></button></form>
  126. <form action="{{ url('thread_watch_email', thread=thread.pk, slug=thread.slug) }}" class="form-inline pull-right" method="post"><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"><input type="hidden" name="retreat" value="{{ request_path }}"><button type="submit" class="btn btn-icon tooltip-top" title="{% trans %}Add thread to watched list and e-mail me if anyone replies{% endtrans %}"><i class="icon-envelope"></i></button></form>
  127. {% endif %}
  128. {% if ignored_posts %}
  129. <form action="{{ url('thread_show_hidden', thread=thread.pk, slug=thread.slug) }}" class="form-inline pull-right" method="post"><input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}"><button type="submit" class="btn"><i class="icon-eye-open"></i> {% trans %}Show Hidden Replies{% endtrans %}</button></form>
  130. {% endif %}
  131. {% endif %}
  132. </div>
  133. <div class="thread-body">
  134. {% for post in posts %}
  135. <div id="post-{{ post.pk }}" class="post-wrapper">
  136. {% if post.message %}
  137. <div class="messages-list">
  138. {{ macros.draw_message(post.message) }}
  139. </div>
  140. {% endif %}
  141. {% if post.deleted and not acl.threads.can_see_deleted_posts(forum) %}
  142. <div class="post-body post-muted">
  143. {% if post.user_id %}
  144. <a href="{{ url('user', user=post.user.pk, username=post.user.username_slug) }}"><img src="{{ post.user.get_avatar(50) }}" alt="" class="user-avatar"></a>
  145. {% else %}
  146. <img src="{{ macros.avatar_guest(60) }}" alt="" class="user-avatar">
  147. {% endif %}
  148. <div class="post-content">
  149. <div class="post-header">
  150. <div class="post-header-compact">
  151. {% if post.user_id %}
  152. <a href="{{ url('user', user=post.user.pk, username=post.user.username_slug) }}" class="post-author">{{ post.user.username }}</a>{% if post.user.get_title() %} {{ user_label(post.user) }}{% endif %}
  153. {% else %}
  154. <span class="post-author">{{ post.user_name }}</span> <span class="label post-author-label post-label-guest">{% trans %}Unregistered{% endtrans %}</span>
  155. {% endif %}
  156. <span class="separator">&ndash;</span>
  157. <a href="{{ url('thread_find', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-date">{{ post.date|reltimesince }}</a>
  158. {% if post.edits %}
  159. <span class="separator">&ndash;</span>
  160. {% if acl.threads.can_see_changelog(user, forum, post) %}
  161. <a href="{{ url('thread_changelog', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-changelog tooltip-bottom" title="{% trans %}Show changelog{% endtrans %}">{% trans edits=post.edits %}One edit{% pluralize %}{{ edits }} edits{% endtrans %}</a>
  162. {% else %}
  163. <span class="post-changelog">{% trans edits=post.edits %}One edit{% pluralize %}{{ edits }} edits{% endtrans %}</span>
  164. {% endif %}
  165. {% endif %}
  166. </div>
  167. <a href="{{ url('thread_find', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-perma tooltip-left" title="{% trans %}Direct link to this post{% endtrans %}">#{{ pagination['start'] + loop.index }}</a>
  168. {% if not post.is_read %}
  169. <div class="post-extra">
  170. <span class="label label-warning">
  171. {% trans %}New{% endtrans %}
  172. </span>
  173. </div>
  174. {% endif %}
  175. </div>
  176. <div class="post-message">
  177. {% trans user=edit_user(post), date=post.delete_date|reltimesince|low %}{{ user }} has deleted this reply {{ date }}{% endtrans %}
  178. </div>
  179. </dv>
  180. </div>
  181. {% elif post.ignored %}
  182. <div class="post-body post-muted">
  183. <img src="{{ macros.avatar_guest(60) }}" alt="" class="user-avatar">
  184. <div class="post-arrow"></div>
  185. <div class="post-content">
  186. <div class="post-header">
  187. <div class="post-header-compact">
  188. <a href="{{ url('thread_find', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-date">{{ post.date|reltimesince }}</a>
  189. </div>
  190. <a href="{{ url('thread_find', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-perma tooltip-left" title="{% trans %}Direct link to this post{% endtrans %}">#{{ pagination['start'] + loop.index }}</a>
  191. {% if not post.is_read %}
  192. <div class="post-extra">
  193. <span class="label label-warning">
  194. {% trans %}New{% endtrans %}
  195. </span>
  196. </div>
  197. {% endif %}
  198. </div>
  199. <div class="post-message">
  200. {% trans %}This reply was posted by user that is on your ignored list.{% endtrans %}
  201. </div>
  202. </dv>
  203. </div>
  204. {% else %}
  205. <div class="post-body">
  206. {% if post.user_id %}
  207. <a href="{{ url('user', user=post.user.pk, username=post.user.username_slug) }}"><img src="{{ post.user.get_avatar(100) }}" alt="" class="user-avatar"></a>
  208. {% else %}
  209. <img src="{{ macros.avatar_guest(100) }}" alt="" class="user-avatar">
  210. {% endif %}
  211. <div class="post-arrow"></div>
  212. <div class="post-content">
  213. <div class="post-header">
  214. {% if post.user_id %}
  215. <a href="{{ url('user', user=post.user.pk, username=post.user.username_slug) }}" class="post-author">{{ post.user.username }}</a>{% if post.user.get_title() %} {{ user_label(post.user) }}{% endif %}
  216. {% else %}
  217. <span class="post-author">{{ post.user_name }}</span> <span class="label post-author-label post-label-guest">{% trans %}Unregistered{% endtrans %}</span>
  218. {% endif %}
  219. <span class="separator">&ndash;</span>
  220. <a href="{{ url('thread_find', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-date">{{ post.date|reltimesince }}</a>
  221. {% if post.edits %}
  222. <span class="separator">&ndash;</span>
  223. {% if acl.threads.can_see_changelog(user, forum, post) %}
  224. <a href="{{ url('thread_changelog', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-changelog tooltip-bottom" title="{% trans %}Show changelog{% endtrans %}">{% trans edits=post.edits %}One edit{% pluralize %}{{ edits }} edits{% endtrans %}</a>
  225. {% else %}
  226. <span class="post-changelog">{% trans edits=post.edits %}One edit{% pluralize %}{{ edits }} edits{% endtrans %}</span>
  227. {% endif %}
  228. {% endif %}
  229. {% if user.is_authenticated() and posts_form %}
  230. <label class="checkbox post-checkbox"><input form="posts_form" name="{{ posts_form['list_items']['html_name'] }}" type="checkbox" class="checkbox-member" value="{{ post.pk }}"{% if posts_form['list_items']['has_value'] and ('' ~ post.pk) in posts_form['list_items']['value'] %} checked="checked"{% endif %}></label>
  231. {% endif %}
  232. <a href="{{ url('thread_find', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-perma tooltip-left" title="{% trans %}Direct link to this post{% endtrans %}">#{{ pagination['start'] + loop.index }}</a>
  233. <div class="post-extra">
  234. {% if post.protected and acl.threads.can_protect(forum) %}
  235. <span class="label label-info">
  236. {% trans %}Protected{% endtrans %}
  237. </span>
  238. {% endif %}
  239. {% if post.deleted %}
  240. <span class="label label-inverse">
  241. {% trans %}Deleted{% endtrans %}
  242. </span>
  243. {% endif %}
  244. {% if post.moderated %}
  245. <span class="label label-purple">
  246. {% trans %}Unreviewed{% endtrans %}
  247. </span>
  248. {% endif %}
  249. {% if acl.threads.can_mod_posts(forum) and post.reported %}
  250. <span class="label label-important">
  251. {% trans %}Reported{% endtrans %}
  252. </span>
  253. {% endif %}
  254. {% if not post.is_read %}
  255. <span class="label label-warning">
  256. {% trans %}New{% endtrans %}
  257. </span>
  258. {% endif %}
  259. </div>
  260. </div>
  261. <div class="post-message">
  262. <div class="markdown js-extra">
  263. <article>
  264. {{ post.post_preparsed|markdown_final|safe }}
  265. </article>
  266. </div>
  267. {% if post.user.signature %}
  268. <div class="post-signature">
  269. <div class="markdown">
  270. {{ post.user.signature_preparsed|markdown_final|safe }}
  271. </div>
  272. </div>
  273. {% endif %}
  274. </div>
  275. <div class="post-footer">{% filter trim %}
  276. {% if acl.threads.can_see_post_score(forum) %}
  277. <div{% if user.is_authenticated() and user.pk != post.user_id %} class="post-rating-actions"{% endif %}>
  278. <div class="post-rating">
  279. {% if acl.threads.can_see_post_score(forum) == 1 %}
  280. <span class="post-score post-score-total{% if (post.upvotes - post.downvotes) > 0 %} post-score-good{% elif (post.upvotes - post.downvotes) < 0 %} post-score-bad{% endif %}">{{ post.upvotes - post.downvotes }}</span>
  281. {% elif acl.threads.can_see_post_score(forum) == 2%}
  282. <span class="post-score post-score-upvotes{% if post.upvotes %} post-score-good{% endif %}">{{ post.upvotes }}</span>
  283. {% endif %}
  284. {% if user.is_authenticated() and user.pk != post.user_id and acl.threads.can_upvote_posts(forum) %}
  285. <form action="{{ url('post_upvote', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="form-inline form-upvote" method="post">
  286. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  287. <button type="submit" class="btn btn-link post-like"{% if post.karma_vote and post.karma_vote.score > 0 %} disabled="disabled"{% endif %}>{% trans %}Like{% endtrans %}</button>
  288. </form>
  289. {% else %}
  290. <span class="post-{% if post.upvotes %}like{% else %}neutral{% endif %}">{% trans %}Likes{% endtrans %}</span>
  291. {% endif %}
  292. {% if acl.threads.can_see_post_score(forum) == 2 %}
  293. </div>
  294. <div class="post-rating">
  295. <span class="post-score post-score-downvotes{% if post.downvotes %} post-score-bad{% endif %}">{{ post.downvotes }}</span>
  296. {% endif %}
  297. {% if user.is_authenticated() and user.pk != post.user_id and acl.threads.can_downvote_posts(forum) %}
  298. <form action="{{ url('post_downvote', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="form-inline form-downvote" method="post">
  299. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  300. <button type="submit" class="btn btn-link post-hate"{% if post.karma_vote and post.karma_vote.score < 0 %} disabled="disabled"{% endif %}>{% trans %}Dislike{% endtrans %}</button>
  301. </form>
  302. {% elif acl.threads.can_see_post_score(forum) == 2 %}
  303. <span class="post-{% if post.downvotes %}hate{% else %}neutral{% endif %}">{% trans %}Dislikes{% endtrans %}</span>
  304. {% endif %}
  305. </div>
  306. {% if acl.threads.can_see_post_votes(forum) %}
  307. <div class="post-rating">
  308. <a href="{{ url('post_votes', thread=thread.pk, slug=thread.slug, post=post.pk) }}">{% trans %}Show Votes{% endtrans %}</a>
  309. </div>
  310. {% endif %}
  311. </div>
  312. {% endif %}
  313. {% if user.is_authenticated() %}
  314. <div class="post-actions">
  315. {% if acl.users.can_see_users_trails() -%}
  316. <a href="{{ url('post_info', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-trail">{% trans %}Info{% endtrans %}</a>
  317. {% endif %}
  318. {% if post.reported and acl.reports.can_handle() and acl.threads.can_mod_posts(forum) %}
  319. <a href="{{ url('post_report_show', thread=thread.pk, slug=thread.slug, post=post.pk) }}">{% trans %}Show report{% endtrans %}</a>
  320. {% endif %}
  321. {% if acl.reports.can_report() %}
  322. {% if post.reported_by(user) %}
  323. <a href="{{ url('post_report', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="tooltip-top" title="{% trans %}You have already reported this post.{% endtrans %}" disabled="disabled">{% trans %}Reported{% endtrans %}</a>
  324. {% else %}
  325. <form action="{{ url('post_report', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="form-inline form-report" method="post" autocomplete="off">
  326. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  327. <button type="submit" class="btn btn-link btn-report tooltip-top" title="{% trans %}Bring this post to moderator attention.{% endtrans %}">{% trans %}Report{% endtrans %}</button>
  328. </form>
  329. {% endif %}
  330. {% endif %}
  331. {% if acl.threads.can_edit_thread(user, forum, thread, post) and thread.start_post_id == post.pk %}
  332. <a href="{{ url('thread_edit', thread=thread.pk, slug=thread.slug) }}" class="post-edit">{% trans %}Edit{% endtrans %}</a>
  333. {% elif acl.threads.can_edit_reply(user, forum, thread, post) %}
  334. <a href="{{ url('post_edit', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="post-edit">{% trans %}Edit{% endtrans %}</a>
  335. {%- endif %}
  336. {% if acl.threads.can_reply(forum, thread) %}<a href="{{ url('thread_reply', thread=thread.pk, slug=thread.slug, quote=post.pk) }}" class="post-reply">{% trans %}Reply{% endtrans %}</a>{% endif %}
  337. </div>
  338. {% if post.pk == thread.start_post_id %}
  339. <div class="post-actions">
  340. {% if acl.threads.can_delete_thread(user, forum, thread, post) %}
  341. {% if post.deleted %}
  342. <form action="{{ url('thread_show', thread=thread.pk, slug=thread.slug) }}" class="form-inline" method="post">
  343. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  344. <button type="submit" class="btn btn-link btn-hide tooltip-top" title="{% trans %}Make this thread visible to other users{% endtrans %}">{% trans %}Restore{% endtrans %}</button>
  345. </form>
  346. {% else %}
  347. <form action="{{ url('thread_hide', thread=thread.pk, slug=thread.slug) }}" class="form-inline" method="post">
  348. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  349. <button type="submit" class="btn btn-link btn-hide tooltip-top" title="{% trans %}Hide this thread from other users{% endtrans %}">{% trans %}Hide{% endtrans %}</button>
  350. </form>
  351. {% endif %}
  352. {% endif %}
  353. {% if acl.threads.can_delete_thread(user, forum, thread, post) == 2 %}
  354. <form action="{{ url('thread_delete', thread=thread.pk, slug=thread.slug) }}" class="form-inline prompt-delete-thread" method="post">
  355. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  356. <button type="submit" class="btn btn-link tooltip-top" title="{% trans %}Delete this thread for good{% endtrans %}">{% trans %}Delete{% endtrans %}</button>
  357. </form>
  358. {% endif %}
  359. </div>
  360. {% elif post.pk != thread.start_post_id and acl.threads.can_delete_post(user, forum, thread, post) %}
  361. <div class="post-actions">
  362. {% if acl.threads.can_delete_post(user, forum, thread, post) %}
  363. {% if post.deleted %}
  364. <form action="{{ url('post_show', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="form-inline" method="post">
  365. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  366. <button type="submit" class="btn btn-link btn-hide tooltip-top" title="{% trans %}Make this reply visible to other users{% endtrans %}">{% trans %}Restore{% endtrans %}</button>
  367. </form>
  368. {% else %}
  369. <form action="{{ url('post_hide', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="form-inline" method="post">
  370. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  371. <button type="submit" class="btn btn-link btn-hide tooltip-top" title="{% trans %}Hide this reply from other users{% endtrans %}">{% trans %}Hide{% endtrans %}</button>
  372. </form>
  373. {% endif %}
  374. {% endif %}
  375. {% if acl.threads.can_delete_post(user, forum, thread, post) == 2 -%}
  376. <form action="{{ url('post_delete', thread=thread.pk, slug=thread.slug, post=post.pk) }}" class="form-inline prompt-delete-post" method="post">
  377. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  378. <button type="submit" class="btn btn-link tooltip-top" title="{% trans %}Delete this reply for good{% endtrans %}">{% trans %}Delete{% endtrans %}</button>
  379. </form>
  380. {% endif %}
  381. </div>
  382. {% endif %}
  383. {% endif %}
  384. {% endfilter %}</div>
  385. </div>
  386. </div>
  387. {% endif %}
  388. </div>
  389. {% if post.checkpoints_visible %}
  390. <div class="post-checkpoints">
  391. {% for checkpoint in post.checkpoints_visible %}
  392. <div class="post-checkpoint{% if checkpoint.deleted %} checkpoint-deleted{% endif %}">
  393. <hr>
  394. <span>
  395. {%- if checkpoint.action == 'limit' -%}
  396. <i class="icon-lock"></i> {% trans %}This thread has reached its post limit and has been closed.{% endtrans %}
  397. {%- elif checkpoint.action == 'accepted' -%}
  398. <i class="icon-ok"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} accepted this thread {{ date }}{% endtrans %}
  399. {%- elif checkpoint.action == 'closed' -%}
  400. <i class="icon-lock"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} closed this thread {{ date }}{% endtrans %}
  401. {%- elif checkpoint.action == 'opened' -%}
  402. <i class="icon-lock"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} opened this thread {{ date }}{% endtrans %}
  403. {%- elif checkpoint.action == 'deleted' -%}
  404. <i class="icon-trash"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} deleted this thread {{ date }}{% endtrans %}
  405. {%- elif checkpoint.action == 'undeleted' -%}
  406. <i class="icon-trash"></i> {% trans user=checkpoint_user(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} restored this thread {{ date }}{% endtrans %}
  407. {%- elif checkpoint.action == 'moved' and acl.forums.can_see(checkpoint.old_forum_id) -%}
  408. <i class="icon-arrow-right"></i> {% trans user=checkpoint_user(checkpoint), forum=checkpoint_forum(checkpoint), date=checkpoint.date|reltimesince|low %}{{ user }} moved this thread from {{ forum }} {{ date }}{% endtrans %}
  409. {%- endif -%}
  410. {% if user.is_authenticated() %}
  411. {% if acl.threads.can_delete_checkpoint(forum) %}
  412. {% if checkpoint.deleted %}
  413. <form action="{{ url('post_checkpoint_show', slug=thread.slug, thread=thread.pk, checkpoint=checkpoint.pk) }}" method="post" class="form-inline">
  414. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  415. <input type="hidden" name="retreat" value="{{ request_path }}#post-{{ post.pk }}">
  416. <button type="submit" class="btn btn-link btn-show">{% trans %}Restore{% endtrans %}</button>
  417. </form>
  418. {% else %}
  419. <form action="{{ url('post_checkpoint_hide', slug=thread.slug, thread=thread.pk, checkpoint=checkpoint.pk) }}" method="post" class="form-inline">
  420. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  421. <input type="hidden" name="retreat" value="{{ request_path }}#post-{{ post.pk }}">
  422. <button type="submit" class="btn btn-link btn-hide">{% trans %}Hide{% endtrans %}</button>
  423. </form>
  424. {% endif %}
  425. {% endif %}
  426. {% if acl.threads.can_delete_checkpoint(forum) == 2 %}
  427. <form action="{{ url('post_checkpoint_delete', slug=thread.slug, thread=thread.pk, checkpoint=checkpoint.pk) }}" method="post" class="form-inline prompt-delete-checkpoint">
  428. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  429. <input type="hidden" name="retreat" value="{{ request_path }}#post-{{ post.pk }}">
  430. <button type="submit" class="btn btn-link btn-delete">{% trans %}Delete{% endtrans %}</button>
  431. </form>
  432. {% endif %}
  433. {% endif %}
  434. </span>
  435. </div>
  436. {% endfor %}
  437. </div>
  438. {% endif %}
  439. {% endfor %}
  440. </div>
  441. {% if user.is_authenticated() and (thread_form or posts_form) %}
  442. <div class="thread-moderation">
  443. {% if thread_form %}
  444. <form id="thread_form" class="form-inline pull-left" action="{{ request_path }}" method="POST">
  445. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  446. <input type="hidden" name="origin" value="thread_form">
  447. {{ form_theme.field(thread_form.thread_action, attrs={'class': 'span3'}) }}
  448. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  449. </form>
  450. {% endif %}
  451. {% if posts_form %}
  452. <form id="posts_form" class="form-inline pull-right" action="{{ request_path }}" method="POST">
  453. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  454. <input type="hidden" name="origin" value="posts_form">
  455. {{ form_theme.field(posts_form.list_action, attrs={'class': 'span3'}) }}
  456. <button type="submit" class="btn btn-danger">{% trans %}Go{% endtrans %}</button>
  457. </form>
  458. {% endif %}
  459. </div>
  460. {% endif %}
  461. <div class="thread-buttons">
  462. {{ pager(false) }}
  463. {% if user.is_authenticated() and acl.threads.can_reply(forum, thread) %}
  464. <a href="{{ url('thread_reply', thread=thread.pk, slug=thread.slug) }}" class="btn btn-inverse pull-right"><i class="icon-pencil"></i> {% trans %}Reply{% endtrans %}</a>
  465. {% elif not user.is_authenticated() and not user.is_crawler() %}
  466. <p class="lead thread-signin-message"><a href="{{ url('sign_in') }}">{% trans %}Sign in or register to reply.{% endtrans %}</a></p>
  467. {% endif %}
  468. </div>
  469. {% if user.is_authenticated() and acl.threads.can_reply(forum, thread) %}
  470. <div class="thread-quick-reply">
  471. <form action="{{ url('thread_reply', thread=thread.pk, slug=thread.slug) }}" method="post">
  472. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  473. <input type="hidden" name="quick_reply" value="1">
  474. <img src="{{ user.get_avatar(100) }}" alt="{% trans %}Your Avatar{% endtrans %}" class="user-avatar">
  475. {{ editor.editor(quick_reply.post, _('Post Reply'), zen=True, extra=editor_extra()) }}
  476. </form>
  477. </div>
  478. {% endif %}
  479. </div>
  480. {% endblock %}
  481. {% block stylesheets %}{{ super() }}
  482. <link href="{{ STATIC_URL }}cranefly/highlight/styles/monokai.css" rel="stylesheet">
  483. {% endblock %}
  484. {% block javascripts -%}
  485. {{ editor.zen() }}
  486. {{ super() }}
  487. <script src="{{ STATIC_URL }}cranefly/highlight/highlight.pack.js"></script>
  488. <script type="text/javascript">
  489. var l_post_reported = "{{ _('Reported!') }}";
  490. hljs.tabReplace = ' ';
  491. hljs.initHighlightingOnLoad();
  492. EnhancePostsMD();
  493. {%- if user.is_authenticated() %}
  494. $(function () {
  495. $('#thread_form').submit(function() {
  496. if ($('#id_thread_action').val() == 'hard') {
  497. var decision = confirm("{% trans %}Are you sure you want to delete this thread? This action is not reversible!{% endtrans %}");
  498. return decision;
  499. }
  500. return true;
  501. });
  502. $('#posts_form').submit(function() {
  503. if ($('.post-checkbox[]:checked').length == 0) {
  504. alert("{% trans %}You have to select at least one post.{% endtrans %}");
  505. return false;
  506. }
  507. if ($('#id_list_action').val() == 'merge') {
  508. if ($('.post-checkbox[]:checked').length < 2) {
  509. alert("{% trans %}You have to select at least two posts you want to merge.{% endtrans %}");
  510. return false;
  511. }
  512. var decision = confirm("{% trans %}Are you sure you want to merge selected posts? This action is not reversible!{% endtrans %}");
  513. return decision;
  514. }
  515. if ($('#id_list_action').val() == 'hard') {
  516. var decision = confirm("{% trans %}Are you sure you want to delete selected posts? This action is not reversible!{% endtrans %}");
  517. return decision;
  518. }
  519. return true;
  520. });
  521. $('.prompt-delete-thread').submit(function() {
  522. var decision = confirm("{% trans %}Are you sure you want to delete this thread?{% endtrans %}");
  523. return decision;
  524. });
  525. $('.prompt-delete-post').submit(function() {
  526. var decision = confirm("{% trans %}Are you sure you want to delete this post?{% endtrans %}");
  527. return decision;
  528. });
  529. $('.prompt-delete-checkpoint').submit(function() {
  530. var decision = confirm("{% trans %}Are you sure you want to delete this checkpoint?{% endtrans %}");
  531. return decision;
  532. });
  533. });
  534. {% endif %}
  535. </script>
  536. {% if user.is_authenticated() and acl.threads.can_reply(forum, thread) %}
  537. {{ editor.js() }}
  538. {% endif %}
  539. {%- endblock %}
  540. {% macro user_label(user) -%}
  541. <{% if user.rank and user.rank.as_tab %}a href="{{ url('users', slug=user.rank.slug) }}"{% else %}span{% endif %} class="label post-author-label{% if user.rank and user.rank.style %} post-label-{{ user.rank.style }}{% endif %}">{{ user.get_title() }}</{% if user.rank and user.rank.as_tab%}a{% else %}span{% endif %}>
  542. {%- endmacro %}
  543. {% macro pager(extra=true) %}
  544. <div class="pagination pull-left">
  545. <ul>
  546. {% if pagination['total'] > 0 %}
  547. <li class="count">{{ macros.pager_label(pagination) }}</li>
  548. {%- if pagination['prev'] > 1 %}<li><a href="{{ url('thread', slug=thread.slug, thread=thread.id) }}" class="tooltip-top" title="{% trans %}Go to first page{% endtrans %}"><i class="icon-chevron-left"></i> {% trans %}First{% endtrans %}</a></li>{% endif -%}
  549. {%- if pagination['prev'] > 0 %}<li><a href="{%- if pagination['prev'] > 1 %}{{ url('thread', slug=thread.slug, thread=thread.id, page=pagination['prev']) }}{% else %}{{ url('thread', slug=thread.slug, thread=thread.id) }}{% endif %}" class="tooltip-top" title="{% trans %}Older Posts{% endtrans %}"><i class="icon-chevron-left"></i></a></li>{% endif -%}
  550. {%- if pagination['next'] > 0 %}<li><a href="{{ url('thread', slug=thread.slug, thread=thread.id, page=pagination['next']) }}" class="tooltip-top" title="{% trans %}Newest Posts{% endtrans %}"><i class="icon-chevron-right"></i></a></li>{% endif -%}
  551. {%- if pagination['next'] > 0 and pagination['next'] < pagination['total'] %}<li><a href="{{ url('thread', slug=thread.slug, thread=thread.id, page=pagination['total']) }}" class="tooltip-top" title="{% trans %}Go to last page{% endtrans %}">{% trans %}Last{% endtrans %} <i class="icon-chevron-right"></i></a></li>{% endif -%}
  552. {% endif %}
  553. {% if extra and user.is_authenticated() %}
  554. {% if not is_read %}<li><a href="{{ url('thread_new', slug=thread.slug, thread=thread.id) }}" class="tooltip-top" title="{% trans %}Go to first unread{% endtrans %}"><i class="icon-star"></i> {% trans %}First Unread{% endtrans %}</a></li>{% endif %}
  555. {% if thread.replies_moderated > 0 and acl.threads.can_approve(forum) %}<li><a href="{{ url('thread_moderated', slug=thread.slug, thread=thread.id) }}" class="tooltip-top" title="{% trans %}Go to first post awaiting review{% endtrans %}"><i class="icon-eye-close"></i> {% trans %}First Unreviewed{% endtrans %}</a></li>{% endif %}
  556. {% if thread.replies_reported > 0 and acl.threads.can_mod_posts(forum) %}<li><a href="{{ url('thread_reported', slug=thread.slug, thread=thread.id) }}" class="tooltip-top" title="{% trans %}Go to first reported post{% endtrans %}"><i class="icon-fire"></i> {% trans %}First Reported{% endtrans %}</a></li>{% endif %}
  557. {% endif %}
  558. </ul>
  559. </div>
  560. {% endmacro %}
  561. {% macro checkpoint_user(checkpoint) -%}
  562. {%- if checkpoint.user_id -%}
  563. <a href="{{ url('user', user=checkpoint.user_id, username=checkpoint.user_slug) }}">{{ checkpoint.user_name }}</a>
  564. {%- else -%}
  565. <strong>{{ checkpoint.user_name }}</strong>
  566. {%- endif -%}
  567. {%- endmacro %}
  568. {% macro checkpoint_forum(checkpoint) -%}
  569. {%- if checkpoint.old_forum_id -%}
  570. <a href="{{ url('forum', forum=checkpoint.old_forum_id, slug=checkpoint.old_forum_slug) }}">{{ checkpoint.old_forum_name }}</a>
  571. {%- else -%}
  572. <strong>{{ checkpoint.old_forum_name }}</strong>
  573. {%- endif -%}
  574. {%- endmacro %}
  575. {% macro edit_user(post) -%}
  576. {%- if post.edit_user_id -%}
  577. <a href="{{ url('user', user=post.edit_user_id, username=post.edit_user_slug) }}">{{ post.edit_user_name }}</a>
  578. {%- else -%}
  579. <strong>{{ post.edit_user_name }}</strong>
  580. {%- endif -%}
  581. {%- endmacro %}
  582. {% macro editor_extra() %}
  583. <button id="editor-preview" name="preview" type="submit" class="btn pull-right">{% trans %}Full Editor{% endtrans %}</button>
  584. {% endmacro %}