posting.html 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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 intersect(form.fields, ('edit_reason', 'thread_weight', 'close_thread')) %}
  61. <hr>
  62. {% if 'edit_reason' in form.fields %}
  63. {{ form_theme.row_widget(form.fields.edit_reason, width=8) }}
  64. {% endif %}
  65. {% if intersect(form.fields, ('thread_weight', 'close_thread')) %}
  66. <div class="control-group">
  67. <label class="control-label">{% trans %}Thread Status{% endtrans %}:</label>
  68. <div class="controls">
  69. {% if 'thread_weight' in form.fields %}
  70. {{ form_theme.input_radio_select(form.fields.thread_weight, width=8) }}
  71. {% endif %}
  72. {% if 'close_thread' in form.fields %}
  73. {{ form_theme.input_checkbox(form.fields.close_thread, width=8) }}
  74. {% endif %}
  75. </div>
  76. </div>
  77. {% endif %}
  78. <div class="form-actions">
  79. <button type="submit" class="btn btn-primary">{{ get_button() }}</button>
  80. <button id="editor-preview" name="preview" type="submit" class="btn">{% trans %}Preview{% endtrans %}</button>
  81. </div>
  82. {% endif %}
  83. </form>
  84. </div>
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. {% endblock %}
  90. {% block stylesheets %}{{ super() }}
  91. <link href="{{ STATIC_URL }}cranefly/highlight/styles/monokai.css" rel="stylesheet">
  92. {% endblock %}
  93. {% block javascripts %}{{ super() }}
  94. <script src="{{ STATIC_URL }}cranefly/highlight/highlight.pack.js"></script>
  95. <script type="text/javascript">
  96. hljs.tabReplace = ' ';
  97. hljs.initHighlightingOnLoad();
  98. EnhancePostsMD();
  99. </script>
  100. {{ editor.js() }}
  101. {% endblock %}
  102. {% macro get_action() -%}
  103. {% if action == 'new_thread' -%}
  104. {% url 'thread_start' forum=forum.pk, slug=forum.slug %}
  105. {%- elif action == 'edit_thread' -%}
  106. {% url 'thread_edit' thread=thread.pk, slug=thread.slug %}
  107. {%- elif action in 'new_post' -%}
  108. {%- if quote -%}
  109. {% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=quote.pk %}
  110. {%- else -%}
  111. {% url 'thread_reply' thread=thread.pk, slug=thread.slug %}
  112. {%- endif -%}
  113. {%- elif action == 'edit_post' -%}
  114. {% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}
  115. {%- endif %}
  116. {%- endmacro %}
  117. {% macro get_title() -%}
  118. {% if action == 'new_thread' -%}
  119. {% trans %}Post New Thread{% endtrans %}
  120. {%- elif action == 'edit_thread' -%}
  121. {% trans %}Edit Thread{% endtrans %}
  122. {%- elif action in ['new_post', 'new_post_quick'] -%}
  123. {% trans %}Post New Reply{% endtrans %}
  124. {%- elif action == 'edit_post' -%}
  125. {% trans %}Edit Reply{% endtrans %}
  126. {%- endif %}
  127. {%- endmacro %}
  128. {% macro get_info() -%}
  129. {% if mode == 'edit_post' -%}
  130. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  131. <li><i class="icon-time"></i> {{ post.date|reltimesince }}</li>
  132. <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>
  133. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  134. {% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}
  135. {%- else -%}
  136. {% trans %}First edit{% endtrans %}
  137. {%- endif %}</li>
  138. {%- else -%}
  139. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  140. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  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. {%- endmacro %}
  149. {% macro get_button() -%}
  150. {% if mode == 'new_thread' -%}
  151. {% trans %}Post Thread{% endtrans %}
  152. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  153. {% trans %}Post Reply{% endtrans %}
  154. {%- else -%}
  155. {% trans %}Save Changes{% endtrans %}
  156. {%- endif %}
  157. {%- endmacro %}
  158. {% macro get_extra() %}
  159. <button id="editor-preview" name="preview" type="submit" class="btn pull-right">{% trans %}Preview{% endtrans %}</button>
  160. {% endmacro %}