topic.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. {% extends theme("layout.html") %}
  2. {% set page_title = _("%(title)s - Topic", title=topic.title) %}
  3. {% set active_forum_nav=True %}
  4. {% block content %}
  5. {% from theme('macros.html') import render_pagination, form_field, generate_post_id, generate_post_url %}
  6. <div class="topic-view">
  7. <ol class="breadcrumb flaskbb-breadcrumb">
  8. <li><a href="{{ url_for('forum.index') }}">{% trans %}Forum{% endtrans %}</a></li>
  9. <li><a href="{{ topic.forum.category.url }}">{{ topic.forum.category.title }}</a></li>
  10. <li><a href="{{ topic.forum.url }}">{{ topic.forum.title }}</a></li>
  11. <li class="active">{{ topic.title }}</li>
  12. </ol>
  13. {% include theme('forum/topic_controls.html') %}
  14. <div class="panel topic-panel">
  15. <div class="panel-heading topic-head">
  16. <a href="{{ topic.url }}">{{ topic.title }}</a>
  17. </div>
  18. <div class="panel-body topic-body">
  19. {% for post, user in posts.items %}
  20. <div id="{{ post.id }}" class="row post-row clearfix">
  21. <div class="author col-md-2 col-sm-3 col-xs-12">
  22. <!-- Registered User -->
  23. {% if post.user_id %}
  24. <div class="author-name"><h4><a href="{{ user.url }}">{{ user.username }}</a></h4></div>
  25. <!-- check if user is online or not -->
  26. {% if user|is_online %}
  27. <div class="author-online" data-toggle="tooltip" data-placement="top" title="online"></div>
  28. {% else %}
  29. <div class="author-offline" data-toggle="tooltip" data-placement="top" title="offline"></div>
  30. {% endif %}
  31. <div class="author-title"><h5>{{ user.primary_group.name }}</h5></div>
  32. {% if user.avatar %}
  33. <div class="author-avatar"><img src="{{ user.avatar }}" alt="avatar"></div>
  34. {% endif %}
  35. <div class="author-registered">{% trans %}Joined{% endtrans %}: {{ user.date_joined|format_date('%b %d %Y') }}</div>
  36. <div class="author-posts">{% trans %}Posts{% endtrans %}: {{ user.post_count }}</div>
  37. <div class="author-pm">
  38. {% if current_user.is_authenticated() and post.user_id %}
  39. <a href="{{ url_for('message.new_conversation') }}?to_user={{ user.username }}">{% trans %}Message{% endtrans %}</a>
  40. {% endif %}
  41. </div>
  42. {% if user.website %}
  43. <div class="author-website"><a href="{{ user.website }}" rel="nofollow">{% trans %}Website{% endtrans %}</a></div>
  44. {% endif %}
  45. {% else %}
  46. <!-- user deleted or guest -->
  47. <div class="author-name"><h4><a href="{{ user.url }}">{{ post.username }}</a></h4></div>
  48. <div class="author-title"><h5>{% trans %}Guest{% endtrans %}</h5></div>
  49. {% endif %}
  50. </div>
  51. <div class="post-box col-md-10 col-sm-9 col-xs-12">
  52. <div class="post-meta clearfix">
  53. <div class="pull-left">
  54. <!-- Creation date / Date modified -->
  55. <a href="{{ generate_post_url(topic, post, posts.page) }}">
  56. {{ post.date_created|format_date('%d %B %Y - %H:%M') }}
  57. </a>
  58. {% if post.user_id and post.date_modified %}
  59. <small>
  60. (Last modified: {{ post.date_modified|format_date('%d %B %Y - %H:%M') }} by
  61. <a href="{{ url_for('user.profile', username=post.modified_by) }}">{{ post.modified_by }}</a>.)
  62. </small>
  63. {% endif %}
  64. </div>
  65. <!-- Post number -->
  66. <div class="pull-right">
  67. <strong>#{{ generate_post_id(posts, loop.index, flaskbb_config["POSTS_PER_PAGE"]) }}</strong>
  68. </div>
  69. </div>
  70. <div class="post-content clearfix" id="pid{{ post.id }}">
  71. {{ post.content|markup|safe }}
  72. <!-- Signature Begin -->
  73. {% if flaskbb_config["SIGNATURE_ENABLED"] and post.user_id and user.signature %}
  74. <div class="post-signature hidden-xs">
  75. <hr />
  76. {{ user.signature|markup|safe }}
  77. </div>
  78. {% endif %}
  79. <!-- Signature End -->
  80. </div>
  81. <div class="post-footer clearfix">
  82. <!-- Report/Edit/Delete/Quote Post-->
  83. <div class="post-menu pull-right">
  84. {% if current_user|post_reply(topic) %}
  85. <!-- Quick quote -->
  86. <a href="#" class="btn btn-icon icon-reply quote-btn" data-post-id="{{ post.id }}" data-toggle="tooltip" data-placement="top" title="Quote this post"></a>
  87. <!-- Full quote/reply -->
  88. <a href="{{ url_for('forum.reply_post', topic_id=topic.id, post_id=post.id) }}" class="btn btn-icon icon-replyall" data-toggle="tooltip" data-placement="top" title="Full Reply"></a>
  89. {% endif %}
  90. {% if current_user|edit_post(post) %}
  91. <!-- Edit Post -->
  92. <a href="{{ url_for('forum.edit_post', post_id=post.id) }}" class="btn btn-icon icon-edit" data-toggle="tooltip" data-placement="top" title="Edit this post"></a>
  93. {% endif %}
  94. {% if topic.first_post_id == post.id %}
  95. {% if current_user|delete_topic(topic) %}
  96. <form class="inline-form" method="post" action="{{ url_for('forum.delete_topic', topic_id=topic.id, slug=topic.slug) }}">
  97. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
  98. <button class="btn btn-icon icon-delete" data-toggle="tooltip" data-placement="top" title="Delete this topic"></button>
  99. </form>
  100. {% endif %}
  101. {% else %}
  102. {% if current_user|delete_post(post) %}
  103. <!-- Delete Post -->
  104. <form class="inline-form" method="post" action="{{ url_for('forum.delete_post', post_id=post.id) }}">
  105. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
  106. <button class="btn btn-icon icon-delete" data-toggle="tooltip" data-placement="top" title="Delete this post"></button>
  107. </form>
  108. {% endif %}
  109. {% endif %}
  110. {% if current_user.is_authenticated() %}
  111. <!-- Report post -->
  112. <a href="{{ url_for('forum.report_post', post_id=post.id) }}" onclick="window.open(this.href, 'wio_window','width=500,height=500'); return false;" class="btn btn-icon icon-report" data-toggle="tooltip" data-placement="top" title="Report this post"></a>
  113. {% endif %}
  114. </div> <!-- end post-menu -->
  115. </div> <!-- end footer -->
  116. </div>
  117. </div>
  118. {% endfor %}
  119. </div> <!-- end topic-body -->
  120. </div> <!-- end topic-panel -->
  121. {% include theme('forum/topic_controls.html') %}
  122. {% from theme("macros.html") import render_field, render_quickreply, render_submit_field %}
  123. {% if form %}
  124. <form class="form" action="#" method="post">
  125. {{ form.hidden_tag() }}
  126. <div class="row">
  127. <div class="col-md-offset-2 col-sm-offset-3 col-md-10 col-sm-9 col-xs-12">
  128. <div class="editor-box">
  129. <div class="editor quickreply">
  130. {{ render_quickreply(form.content, div_class="new-message", rows=7, cols=75, placeholder="", **{'data-provide': 'markdown', 'data-autofocus': 'false', 'id': 'quickreply-editor'}) }}
  131. </div>
  132. <div class="editor-submit">
  133. <div class="editor-options pull-left">
  134. <span class="label label-info">Markdown</span>
  135. <a href="#" class="label label-success" data-toggle="modal" data-target="#markdown-cheatsheet">
  136. help
  137. </a>
  138. <!-- Modal -->
  139. <div class="modal fade" id="markdown-cheatsheet" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  140. <div class="modal-dialog" role="document">
  141. <div class="modal-content">
  142. <div class="modal-header">
  143. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  144. <h4 class="modal-title" id="myModalLabel">Markdown Cheatsheet</h4>
  145. </div>
  146. <div class="modal-body">
  147. {% include theme("markdown_help.html") %}
  148. </div>
  149. </div>
  150. </div>
  151. </div>
  152. <a class="label label-success" href="#">emojis</a> <!-- TODO: add emoji cheat sheet -->
  153. </div>
  154. {{ render_submit_field(form.submit, input_class="btn btn-success pull-right") }}
  155. </div>
  156. </div>
  157. </div>
  158. </div>
  159. </form>
  160. {% endif %}
  161. </div>
  162. {% endblock %}
  163. {% block scripts %}
  164. <script type="text/javascript" src="{{ url_for('static', filename='js/editor.min.js') }}"></script>
  165. <script>
  166. $(function () {
  167. $('[data-toggle="tooltip"]').tooltip()
  168. })
  169. $('#quickreply-editor').textcomplete([
  170. { // emoji strategy
  171. match: /\B:([\-+\w]*)$/,
  172. search: function (term, callback) {
  173. callback($.map(emojies, function (emoji) {
  174. return emoji.indexOf(term) === 0 ? emoji : null;
  175. }));
  176. },
  177. template: function (value) {
  178. return '<img class="emoji" src="/static/emoji/' + value + '.png"></img>' + value;
  179. },
  180. replace: function (value) {
  181. return ':' + value + ': ';
  182. },
  183. index: 1
  184. },
  185. ], {
  186. onKeydown: function (e, commands) {
  187. if (e.ctrlKey && e.keyCode === 74) { // CTRL-J
  188. return commands.KEY_ENTER;
  189. }
  190. }
  191. });
  192. </script>
  193. {% endblock %}