posting.html 7.3 KB

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