posting.html 7.2 KB

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