posting.html 7.4 KB

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