posting.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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">
  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. </script>
  114. {{ editor.js() }}
  115. {% endblock %}
  116. {% macro get_action() -%}
  117. {% if mode == 'new_thread' -%}
  118. {% url 'thread_new' forum=forum.pk, slug=forum.slug %}
  119. {%- elif mode == 'edit_thread' -%}
  120. {% url 'thread_edit' thread=thread.pk, slug=thread.slug %}
  121. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  122. {%- if quote -%}
  123. {% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=quote.pk %}
  124. {%- else -%}
  125. {% url 'thread_reply' thread=thread.pk, slug=thread.slug %}
  126. {%- endif -%}
  127. {%- elif mode == 'edit_post' -%}
  128. {% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}
  129. {%- endif %}
  130. {%- endmacro %}
  131. {% macro get_title() -%}
  132. {% if mode == 'new_thread' -%}
  133. {% trans %}Post New Thread{% endtrans %}
  134. {%- elif mode == 'edit_thread' -%}
  135. {% trans %}Edit Thread{% endtrans %}
  136. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  137. {% trans %}Post New Reply{% endtrans %}
  138. {%- elif mode == 'edit_post' -%}
  139. {% trans %}Edit Reply{% endtrans %}
  140. {%- endif %}
  141. {%- endmacro %}
  142. {% macro get_info() -%}
  143. {% if mode == 'edit_post' -%}
  144. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  145. <li><i class="icon-time"></i> {{ post.date|reltimesince }}</li>
  146. <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>
  147. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  148. {% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}
  149. {%- else -%}
  150. {% trans %}First edit{% endtrans %}
  151. {%- endif %}</li>
  152. {%- else -%}
  153. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  154. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  155. <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>
  156. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  157. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  158. {%- else -%}
  159. {% trans %}No replies{% endtrans %}
  160. {%- endif %}</li>
  161. {%- endif %}
  162. {%- endmacro %}
  163. {% macro get_button() -%}
  164. {% if mode == 'new_thread' -%}
  165. {% trans %}Post Thread{% endtrans %}
  166. {%- elif mode == 'edit_thread' -%}
  167. {% trans %}Edit Thread{% endtrans %}
  168. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  169. {% trans %}Post Reply{% endtrans %}
  170. {%- elif mode == 'edit_post' -%}
  171. {% trans %}Edit Reply{% endtrans %}
  172. {%- endif %}
  173. {%- endmacro %}
  174. {% macro get_extra() %}
  175. <button id="editor-preview" name="preview" type="submit" class="btn pull-right">{% trans %}Preview{% endtrans %}</button>
  176. {% endmacro %}