posting.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 %}{% if thread -%}
  6. {{ macros.page_title(title=_(get_title()), parent=thread.name) }}
  7. {%- else -%}
  8. {{ macros.page_title(title=_(get_title()), parent=_("Private Threads")) }}
  9. {%- endif %}{% endblock %}
  10. {% block breadcrumb %}{{ super() }} <span class="divider"><i class="icon-chevron-right"></i></span></li>
  11. <li><a href="{{ url('private_threads') }}">{% trans %}Private Threads{% endtrans %}</a> <span class="divider"><i class="icon-chevron-right"></i></span></li>
  12. {% if thread %}<li><a href="{{ url('private_thread', thread=thread.pk, slug=thread.slug) }}">{{ thread.name }}</a> <span class="divider"><i class="icon-chevron-right"></i></span></li>{% endif %}
  13. <li class="active">{{ get_title() }}
  14. {%- endblock %}
  15. {% block container %}
  16. <div class="page-header header-primary">
  17. <div class="container">
  18. {{ messages_list(messages) }}
  19. <ul class="breadcrumb">
  20. {{ self.breadcrumb() }}</li>
  21. </ul>
  22. <h1>{{ get_title() }} <small>{% if thread %}{{ thread.name }}{% else %}{% trans %}Private Threads{% endtrans %}{% endif %}</small></h1>
  23. {% if thread %}
  24. <ul class="unstyled header-stats">
  25. {{ get_info() }}
  26. </ul>
  27. {% endif %}
  28. </div>
  29. </div>
  30. <div class="container container-primary">
  31. <div class="row">
  32. <div class="span8 offset2">
  33. <div class="posting">
  34. <div class="form-container">
  35. <div class="form-header">
  36. <h1>{{ get_title() }}</h1>
  37. </div>
  38. {% if message %}
  39. <div class="messages-list">
  40. {{ macros.draw_message(message) }}
  41. </div>
  42. {% endif %}
  43. {% if preview %}
  44. <div class="form-preview">
  45. <div class="markdown js-extra">
  46. <article>
  47. {{ preview|markdown_final|safe }}
  48. </article>
  49. </div>
  50. </div>
  51. {% endif %}
  52. <form action="{{ get_action() }}" method="post">
  53. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  54. {% if 'thread_name' in form.fields %}
  55. {{ form_theme.row_widget(form.fields.thread_name, width=8) }}
  56. {% endif %}
  57. {% if action == 'new_thread' and 'invite_users' in form.fields %}
  58. {{ form_theme.row_widget(form.fields.invite_users, width=8) }}
  59. {% endif %}
  60. {% if 'thread_name' in form.fields or (action == 'new_thread' and 'invite_users' in form.fields) %}
  61. <hr>
  62. <h4>{% trans %}Message Body{% endtrans %}</h4>
  63. {% endif %}
  64. {{ editor.editor(form.fields.post, get_button(), rows=8, extra=get_extra()) }}
  65. {% if 'edit_reason' in form.fields or (action == 'new_reply' and 'invite_users' in form.fields) %}
  66. <hr>
  67. {% if action == 'new_reply' and 'invite_users' in form.fields %}
  68. {{ form_theme.row_widget(form.fields.invite_users, width=8) }}
  69. {% endif %}
  70. {% if 'edit_reason' in form.fields %}
  71. {{ form_theme.row_widget(form.fields.edit_reason, width=8) }}
  72. {% endif %}
  73. <div class="form-actions">
  74. <button type="submit" class="btn btn-primary">{{ get_button() }}</button>
  75. <button id="editor-preview" name="preview" type="submit" class="btn">{% trans %}Preview{% endtrans %}</button>
  76. </div>
  77. {% endif %}
  78. </form>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. {% endblock %}
  85. {% block stylesheets %}{{ super() }}
  86. <link href="{{ STATIC_URL }}cranefly/highlight/styles/monokai.css" rel="stylesheet">
  87. {% endblock %}
  88. {% block javascripts %}{{ super() }}
  89. <script src="{{ STATIC_URL }}cranefly/highlight/highlight.pack.js"></script>
  90. <script type="text/javascript">
  91. hljs.tabReplace = ' ';
  92. hljs.initHighlightingOnLoad();
  93. EnhancePostsMD();
  94. </script>
  95. {{ editor.js() }}
  96. {% endblock %}
  97. {% macro get_action() -%}
  98. {% if action == 'new_thread' -%}
  99. {{ url('private_thread_start') }}
  100. {%- elif action == 'edit_thread' -%}
  101. {{ url('private_thread_edit', thread=thread.pk, slug=thread.slug) }}
  102. {%- elif action in 'new_reply' -%}
  103. {%- if quote -%}
  104. {{ url('private_thread_reply', thread=thread.pk, slug=thread.slug, quote=quote.pk) }}
  105. {%- else -%}
  106. {{ url('private_thread_reply', thread=thread.pk, slug=thread.slug) }}
  107. {%- endif -%}
  108. {%- elif action == 'edit_reply' -%}
  109. {{ url('private_post_edit', thread=thread.pk, slug=thread.slug, post=post.pk) }}
  110. {%- endif %}
  111. {%- endmacro %}
  112. {% macro get_title() -%}
  113. {% if action == 'new_thread' -%}
  114. {% trans %}Post New Thread{% endtrans %}
  115. {%- elif action == 'edit_thread' -%}
  116. {% trans %}Edit Thread{% endtrans %}
  117. {%- elif action == 'new_reply' -%}
  118. {% trans %}Post New Reply{% endtrans %}
  119. {%- elif action == 'edit_reply' -%}
  120. {% trans %}Edit Reply{% endtrans %}
  121. {%- endif %}
  122. {%- endmacro %}
  123. {% macro get_info() -%}
  124. {% if action == 'edit_reply' -%}
  125. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  126. <li><i class="icon-time"></i> <a href="{{ url('private_thread_find', thread=thread.pk, slug=thread.slug, post=post.pk) }}">{{ post.date|reltimesince }}</a></li>
  127. <li><i class="icon-user"></i> {% if post.user %}<a href="{{ url('user', user=post.user.pk, username=post.user.username_slug) }}">{{ post.user.username }}</a>{% else %}{{ post.user_name }}{% endif %}</li>
  128. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  129. {% trans edits=post.edits %}One edit{% pluralize %}{{ edits }} edits{% endtrans %}
  130. {%- else -%}
  131. {% trans %}First edit{% endtrans %}
  132. {%- endif %}</li>
  133. {%- else -%}
  134. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  135. {% if action == 'edit_thread' %}
  136. <li><i class="icon-time"></i> <a href="{{ url('private_thread_find', thread=thread.pk, slug=thread.slug, post=thread.start_post_id) }}">{{ thread.start|reltimesince }}</a></li>
  137. {% else %}
  138. <li><i class="icon-time"></i> <a href="{{ url('private_thread_new', thread=thread.pk, slug=thread.slug) }}">{{ thread.last|reltimesince }}</a></li>
  139. {% endif %}
  140. <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>
  141. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  142. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  143. {%- else -%}
  144. {% trans %}No replies{% endtrans %}
  145. {%- endif %}</li>
  146. {%- endif %}
  147. {% if thread.closed %}<li><i class="icon-lock"></i> {% trans %}Locked{% endtrans %}</li>{% endif %}
  148. {%- endmacro %}
  149. {% macro get_button() -%}
  150. {% if action == 'new_thread' -%}
  151. {% trans %}Post Thread{% endtrans %}
  152. {%- elif action == 'new_reply' -%}
  153. {% trans %}Post Reply{% endtrans %}
  154. {%- else -%}
  155. {% trans %}Save Changes{% endtrans %}
  156. {%- endif %}
  157. {%- endmacro %}
  158. {% macro get_extra() %}
  159. <button id="editor-preview" name="preview" type="submit" class="btn pull-right">{% trans %}Preview{% endtrans %}</button>
  160. {% endmacro %}