posting.html 7.3 KB

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