posting.html 7.3 KB

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