posting.html 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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="{{ url(forum.type, 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|short_string(42) }}{% 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. <article>
  48. {{ preview|markdown_final|safe }}
  49. </article>
  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(form.thread_name, attrs={'class': 'span8'}) }}
  57. <hr>
  58. <h4>{% trans %}Message Body{% endtrans %}</h4>
  59. {% endif %}
  60. {{ editor.editor(form.post, get_button(), rows=8, zen=True, extra=get_extra()) }}
  61. {% if 'edit_reason' in form.fields %}
  62. {{ form_theme.row(form.edit_reason, attrs={'class': 'span8'}) }}
  63. {% endif %}
  64. {% if 'poll_question' in form.fields %}
  65. <hr>
  66. <h4>{% trans %}Create Poll{% endtrans %}</h4>
  67. {{ form_theme.row(form.poll_question, attrs={'class': 'span8'}) }}
  68. {{ form_theme.row(form.poll_choices, attrs={'class': 'span8', 'rows': 4}) }}
  69. {{ form_theme.row(form.poll_max_choices, attrs={'class': 'span8'}) }}
  70. {{ form_theme.row(form.poll_length, attrs={'class': 'span8'}) }}
  71. {{ form_theme.row(form.poll_public, attrs={'inline': lang_poll_public()}) }}
  72. {{ form_theme.row(form.poll_changing_votes, attrs={'inline': lang_poll_changing_votes()}) }}
  73. {% endif %}
  74. {% if intersect(form.fields, ('thread_weight', 'close_thread')) %}
  75. <hr>
  76. <div class="control-group">
  77. <label class="control-label">{% trans %}Thread Status{% endtrans %}:</label>
  78. <div class="controls">
  79. {% if 'thread_weight' in form.fields %}
  80. {{ form_theme.field(form.thread_weight, attrs={'class': 'span8'}) }}
  81. {% endif %}
  82. {% if 'close_thread' in form.fields %}
  83. <label class="checkbox">
  84. {{ form_theme.field(form.close_thread) }}
  85. {% if thread.closed %}
  86. {% trans %}Open thread{% endtrans %}
  87. {% else %}
  88. {% trans %}Close thread{% endtrans %}
  89. {% endif %}
  90. </label>
  91. {% endif %}
  92. </div>
  93. </div>
  94. {% endif %}
  95. <div class="form-actions">
  96. <button type="submit" class="btn btn-primary">{{ get_button() }}</button>
  97. <button id="editor-preview" name="preview" type="submit" class="btn">{% trans %}Preview{% endtrans %}</button>
  98. </div>
  99. </form>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. {% endblock %}
  106. {% block stylesheets %}{{ super() }}
  107. <link href="{{ STATIC_URL }}cranefly/highlight/styles/monokai.css" rel="stylesheet">
  108. {% endblock %}
  109. {% block javascripts %}
  110. {{ editor.zen() }}
  111. {{ super() }}
  112. <script src="{{ STATIC_URL }}cranefly/highlight/highlight.pack.js"></script>
  113. <script type="text/javascript">
  114. hljs.tabReplace = ' ';
  115. hljs.initHighlightingOnLoad();
  116. EnhancePostsMD();
  117. </script>
  118. {{ editor.js() }}
  119. {% endblock %}
  120. {% macro get_action() -%}
  121. {% if action == 'new_thread' -%}
  122. {{ url('thread_start', forum=forum.pk, slug=forum.slug) }}
  123. {%- elif action == 'edit_thread' -%}
  124. {{ url('thread_edit', thread=thread.pk, slug=thread.slug) }}
  125. {%- elif action in 'new_reply' -%}
  126. {%- if quote -%}
  127. {{ url('thread_reply', thread=thread.pk, slug=thread.slug, quote=quote.pk) }}
  128. {%- else -%}
  129. {{ url('thread_reply', thread=thread.pk, slug=thread.slug) }}
  130. {%- endif -%}
  131. {%- elif action == 'edit_reply' -%}
  132. {{ url('post_edit', thread=thread.pk, slug=thread.slug, post=post.pk) }}
  133. {%- endif %}
  134. {%- endmacro %}
  135. {% macro get_title() -%}
  136. {% if action == 'new_thread' -%}
  137. {% trans %}Post New Thread{% endtrans %}
  138. {%- elif action == 'edit_thread' -%}
  139. {% trans %}Edit Thread{% endtrans %}
  140. {%- elif action == 'new_reply' -%}
  141. {% trans %}Post New Reply{% endtrans %}
  142. {%- elif action == 'edit_reply' -%}
  143. {% trans %}Edit Reply{% endtrans %}
  144. {%- endif %}
  145. {%- endmacro %}
  146. {% macro get_info() -%}
  147. {% if action == 'edit_reply' -%}
  148. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  149. <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>
  150. <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>
  151. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  152. {% trans edits=post.edits %}One edit{% pluralize %}{{ edits }} edits{% endtrans %}
  153. {%- else -%}
  154. {% trans %}First edit{% endtrans %}
  155. {%- endif %}</li>
  156. {%- else -%}
  157. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  158. {% if action == 'edit_thread' %}
  159. <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>
  160. {% else %}
  161. <li><i class="icon-time"></i> <a href="{{ url('thread_new', thread=thread.pk, slug=thread.slug) }}">{{ thread.last|reltimesince }}</a></li>
  162. {% endif %}
  163. <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>
  164. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  165. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  166. {%- else -%}
  167. {% trans %}No replies{% endtrans %}
  168. {%- endif %}</li>
  169. {%- endif %}
  170. {% if thread.closed %}<li><i class="icon-lock"></i> {% trans %}Locked{% endtrans %}</li>{% endif %}
  171. {%- endmacro %}
  172. {% macro get_button() -%}
  173. {% if action == 'new_thread' -%}
  174. {% trans %}Start Thread{% endtrans %}
  175. {%- elif action == 'new_reply' -%}
  176. {% trans %}Post Reply{% endtrans %}
  177. {%- else -%}
  178. {% trans %}Save Changes{% endtrans %}
  179. {%- endif %}
  180. {%- endmacro %}
  181. {% macro get_extra() %}
  182. <button id="editor-preview" name="preview" type="submit" class="btn pull-right">{% trans %}Preview{% endtrans %}</button>
  183. {% endmacro %}
  184. {% macro lang_poll_public() -%}
  185. {% trans %}Make voting in this poll public.{% endtrans %}
  186. {%- endmacro %}
  187. {% macro lang_poll_changing_votes() -%}
  188. {% trans %}Allow users to change their votes.{% endtrans %}
  189. {%- endmacro %}