posting.html 10.0 KB

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