posting.html 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  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('private_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|short_string(42) }}{% 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. <article>
  47. {{ preview|markdown_final|safe }}
  48. </article>
  49. </div>
  50. </div>
  51. {% endif %}
  52. <form action="{{ get_action() }}" method="post"{% if acl.threads.can_upload_attachments(forum) %} enctype="multipart/form-data"{% endif %}>
  53. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  54. {% if 'thread_name' in form.fields %}
  55. {{ form_theme.row(form.thread_name, attrs={'class': 'span8'}) }}
  56. {% endif %}
  57. {% if action == 'new_thread' and 'invite_users' in form.fields %}
  58. {{ form_theme.row(form.invite_users, attrs={'class': 'span8', 'placeholder': lang_user1_user2_user3()}) }}
  59. {% endif %}
  60. {% if 'thread_name' in form.fields or (action == 'new_thread' and 'invite_users' in form.fields) %}
  61. <hr>
  62. <h4>{% trans %}Message Body{% endtrans %}</h4>
  63. {% endif %}
  64. {{ editor.editor(form.post, get_button(), rows=8, zen=True, extra=get_extra()) }}
  65. {% if 'edit_reason' in form.fields or (action == 'new_reply' and 'invite_users' in form.fields) %}
  66. <hr>
  67. {% if action == 'new_reply' and 'invite_users' in form.fields %}
  68. {{ form_theme.row(form.invite_users, attrs={'class': 'span8', 'placeholder': lang_user1_user2_user3()}) }}
  69. {% endif %}
  70. {% if 'edit_reason' in form.fields %}
  71. {{ form_theme.row(form.edit_reason, attrs={'class': 'span8'}) }}
  72. {% endif %}
  73. <div class="form-actions">
  74. <button type="submit" class="btn btn-primary">{{ get_button() }}</button>
  75. <button id="editor-preview" name="preview" type="submit" class="btn">{% trans %}Preview{% endtrans %}</button>
  76. </div>
  77. {% endif %}
  78. </form>
  79. </div>
  80. </div>
  81. </div>
  82. </div>
  83. </div>
  84. {% endblock %}
  85. {% block stylesheets %}{{ super() }}
  86. <link href="{{ STATIC_URL }}cranefly/highlight/styles/monokai.css" rel="stylesheet">
  87. {% endblock %}
  88. {% block javascripts %}
  89. {{ editor.zen() }}
  90. {{ super() }}
  91. <script src="{{ STATIC_URL }}cranefly/highlight/highlight.pack.js"></script>
  92. <script type="text/javascript">
  93. hljs.tabReplace = ' ';
  94. hljs.initHighlightingOnLoad();
  95. EnhancePostsMD();
  96. </script>
  97. {{ editor.js() }}
  98. {% endblock %}
  99. {# Language strings macros #}
  100. {% macro lang_user1_user2_user3() -%}
  101. {% trans %}user1, user2, user3...{% endtrans %}
  102. {%- endmacro %}
  103. {# Template Macros #}
  104. {% macro get_action() -%}
  105. {% if action == 'new_thread' -%}
  106. {{ url('private_thread_start') }}
  107. {%- elif action == 'edit_thread' -%}
  108. {{ url('private_thread_edit', thread=thread.pk, slug=thread.slug) }}
  109. {%- elif action in 'new_reply' -%}
  110. {%- if quote -%}
  111. {{ url('private_thread_reply', thread=thread.pk, slug=thread.slug, quote=quote.pk) }}
  112. {%- else -%}
  113. {{ url('private_thread_reply', thread=thread.pk, slug=thread.slug) }}
  114. {%- endif -%}
  115. {%- elif action == 'edit_reply' -%}
  116. {{ url('private_post_edit', thread=thread.pk, slug=thread.slug, post=post.pk) }}
  117. {%- endif %}
  118. {%- endmacro %}
  119. {% macro get_title() -%}
  120. {% if action == 'new_thread' -%}
  121. {% trans %}Post New Thread{% endtrans %}
  122. {%- elif action == 'edit_thread' -%}
  123. {% trans %}Edit Thread{% endtrans %}
  124. {%- elif action == 'new_reply' -%}
  125. {% trans %}Post New Reply{% endtrans %}
  126. {%- elif action == 'edit_reply' -%}
  127. {% trans %}Edit Reply{% endtrans %}
  128. {%- endif %}
  129. {%- endmacro %}
  130. {% macro get_info() -%}
  131. {% if action == 'edit_reply' -%}
  132. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  133. <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>
  134. <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>
  135. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  136. {% trans edits=post.edits %}One edit{% pluralize %}{{ edits }} edits{% endtrans %}
  137. {%- else -%}
  138. {% trans %}First edit{% endtrans %}
  139. {%- endif %}</li>
  140. {%- else -%}
  141. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  142. {% if action == 'edit_thread' %}
  143. <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>
  144. {% else %}
  145. <li><i class="icon-time"></i> <a href="{{ url('private_thread_new', thread=thread.pk, slug=thread.slug) }}">{{ thread.last|reltimesince }}</a></li>
  146. {% endif %}
  147. <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>
  148. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  149. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  150. {%- else -%}
  151. {% trans %}No replies{% endtrans %}
  152. {%- endif %}</li>
  153. {%- endif %}
  154. {% if thread.closed %}<li><i class="icon-lock"></i> {% trans %}Locked{% endtrans %}</li>{% endif %}
  155. {%- endmacro %}
  156. {% macro get_button() -%}
  157. {% if action == 'new_thread' -%}
  158. {% trans %}Start Thread{% endtrans %}
  159. {%- elif action == 'new_reply' -%}
  160. {% trans %}Post Reply{% endtrans %}
  161. {%- else -%}
  162. {% trans %}Save Changes{% endtrans %}
  163. {%- endif %}
  164. {%- endmacro %}
  165. {% macro get_extra() %}
  166. <button id="editor-preview" name="preview" type="submit" class="btn pull-right">{% trans %}Preview{% endtrans %}</button>
  167. {% endmacro %}