posting.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. {% extends "cranefly/layout.html" %}
  2. {% load i18n %}
  3. {% load url from future %}
  4. {% import "_forms.html" as form_theme with context %}
  5. {% import "cranefly/editor.html" as editor with context %}
  6. {% import "cranefly/macros.html" as macros with context %}
  7. {% block title %}{% if thread -%}
  8. {{ macros.page_title(title=_(get_title()), parent=thread.name) }}
  9. {%- else -%}
  10. {{ macros.page_title(title=_(get_title()), parent=forum.name) }}
  11. {%- endif %}{% endblock %}
  12. {% block breadcrumb %}{{ super() }} <span class="divider"><i class="icon-chevron-right"></i></span></li>
  13. {% for parent in parents %}
  14. <li><a href="{{ parent.type|url(forum=parent.pk, slug=parent.slug) }}">{{ parent.name }}</a> <span class="divider"><i class="icon-chevron-right"></i></span></li>
  15. {% endfor %}
  16. {% if thread %}<li><a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}">{{ thread.name }}</a> <span class="divider"><i class="icon-chevron-right"></i></span></li>{% endif %}
  17. <li class="active">{{ get_title() }}
  18. {%- endblock %}
  19. {% block container %}
  20. <div class="page-header header-primary">
  21. <div class="container">
  22. {{ messages_list(messages) }}
  23. <ul class="breadcrumb">
  24. {{ self.breadcrumb() }}</li>
  25. </ul>
  26. <h1>{{ get_title() }} <small>{% if thread %}{{ thread.name }}{% else %}{{ forum.name }}{% endif %}</small></h1>
  27. {% if thread %}
  28. <ul class="unstyled header-stats">
  29. {{ get_info() }}
  30. </ul>
  31. {% endif %}
  32. </div>
  33. </div>
  34. <div class="container container-primary">
  35. <div class="row">
  36. <div class="span8 offset2">
  37. <div class="posting">
  38. <div class="form-container">
  39. <div class="form-header">
  40. <h1>{{ get_title() }}</h1>
  41. </div>
  42. {% if message %}
  43. <div class="messages-list">
  44. {{ macros.draw_message(message) }}
  45. </div>
  46. {% endif %}
  47. {% if preview %}
  48. <div class="form-preview">
  49. <div class="markdown js-extra">
  50. {{ preview|markdown_final|safe }}
  51. </div>
  52. </div>
  53. {% endif %}
  54. <form action="{{ get_action() }}" method="post">
  55. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  56. {% if 'thread_name' in form.fields %}
  57. {{ form_theme.row_widget(form.fields.thread_name, width=8) }}
  58. <hr>
  59. <h4>Message Body</h4>
  60. {% endif %}
  61. {{ editor.editor(form.fields.post, get_button(), rows=8, extra=get_extra()) }}
  62. {% if 'edit_reason' in form.fields %}
  63. <hr>
  64. {{ form_theme.row_widget(form.fields.edit_reason, width=8) }}
  65. <div class="form-actions">
  66. <button type="submit" class="btn btn-primary">{{ get_button() }}</button>
  67. <button id="editor-preview" name="preview" type="submit" class="btn">{% trans %}Preview{% endtrans %}</button>
  68. </div>
  69. {% endif %}
  70. </form>
  71. </div>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. {% endblock %}
  77. {% block content %}
  78. <div class="page-header">
  79. <ul class="breadcrumb">
  80. {{ self.breadcrumb() }}</li>
  81. </ul>
  82. <h1>{{ get_title() }} <small>{% if thread %}{{ thread.name }}{% else %}{{ forum.name }}{% endif %}</small></h1>
  83. {% if thread %}
  84. <ul class="unstyled thread-info">
  85. {{ get_info() }}
  86. </ul>
  87. {%- endif %}
  88. </div>
  89. {% if message %}{{ macros.draw_message(message, 'alert-form') }}{% endif %}
  90. {% if preview %}
  91. <div class="well" style="margin: 0px; margin-bottom: 32px; padding: 12px;">
  92. <div class="markdown">
  93. {{ preview|markdown_final|safe }}
  94. </div>
  95. </div>
  96. <hr>
  97. {% endif %}
  98. <form action="{{ get_action() }}" method="post">
  99. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  100. {% if 'thread_name' in form.fields %}{{ form_theme.row_widget(form.fields.thread_name) }}{% endif %}
  101. {% if 'edit_reason' in form.fields %}{{ form_theme.row_widget(form.fields.edit_reason) }}{% endif %}
  102. {{ editor.editor(form.fields.post, get_button(), rows=8, extra=get_extra()) }}
  103. </form>
  104. {% endblock %}
  105. {% block stylesheets %}{{ super() }}
  106. <link href="{{ STATIC_URL }}cranefly/highlight/styles/monokai.css" rel="stylesheet">
  107. {% endblock %}
  108. {% block javascripts %}{{ super() }}
  109. <script src="{{ STATIC_URL }}cranefly/highlight/highlight.pack.js"></script>
  110. <script type="text/javascript">
  111. hljs.tabReplace = ' ';
  112. hljs.initHighlightingOnLoad();
  113. EnhancePostsMD();
  114. </script>
  115. {{ editor.js() }}
  116. {% endblock %}
  117. {% macro get_action() -%}
  118. {% if mode == 'new_thread' -%}
  119. {% url 'thread_new' forum=forum.pk, slug=forum.slug %}
  120. {%- elif mode == 'edit_thread' -%}
  121. {% url 'thread_edit' thread=thread.pk, slug=thread.slug %}
  122. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  123. {%- if quote -%}
  124. {% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=quote.pk %}
  125. {%- else -%}
  126. {% url 'thread_reply' thread=thread.pk, slug=thread.slug %}
  127. {%- endif -%}
  128. {%- elif mode == 'edit_post' -%}
  129. {% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}
  130. {%- endif %}
  131. {%- endmacro %}
  132. {% macro get_title() -%}
  133. {% if mode == 'new_thread' -%}
  134. {% trans %}Post New Thread{% endtrans %}
  135. {%- elif mode == 'edit_thread' -%}
  136. {% trans %}Edit Thread{% endtrans %}
  137. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  138. {% trans %}Post New Reply{% endtrans %}
  139. {%- elif mode == 'edit_post' -%}
  140. {% trans %}Edit Reply{% endtrans %}
  141. {%- endif %}
  142. {%- endmacro %}
  143. {% macro get_info() -%}
  144. {% if mode == 'edit_post' -%}
  145. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  146. <li><i class="icon-time"></i> {{ post.date|reltimesince }}</li>
  147. <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>
  148. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  149. {% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}
  150. {%- else -%}
  151. {% trans %}First edit{% endtrans %}
  152. {%- endif %}</li>
  153. {%- else -%}
  154. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  155. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  156. <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>
  157. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  158. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  159. {%- else -%}
  160. {% trans %}No replies{% endtrans %}
  161. {%- endif %}</li>
  162. {%- endif %}
  163. {%- endmacro %}
  164. {% macro get_button() -%}
  165. {% if mode == 'new_thread' -%}
  166. {% trans %}Post Thread{% endtrans %}
  167. {%- elif mode == 'edit_thread' -%}
  168. {% trans %}Edit Thread{% endtrans %}
  169. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  170. {% trans %}Post Reply{% endtrans %}
  171. {%- elif mode == 'edit_post' -%}
  172. {% trans %}Edit Reply{% endtrans %}
  173. {%- endif %}
  174. {%- endmacro %}
  175. {% macro get_extra() %}
  176. <button id="editor-preview" name="preview" type="submit" class="btn pull-right">{% trans %}Preview{% endtrans %}</button>
  177. {% endmacro %}