posting.html 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. <hr>
  55. <h4>Message Body</h4>
  56. {% endif %}
  57. {{ editor.editor(form.fields.post, get_button(), rows=8, extra=get_extra()) }}
  58. {% if 'edit_reason' in form.fields %}
  59. <hr>
  60. {{ form_theme.row_widget(form.fields.edit_reason, width=8) }}
  61. <div class="form-actions">
  62. <button type="submit" class="btn btn-primary">{{ get_button() }}</button>
  63. <button id="editor-preview" name="preview" type="submit" class="btn">{% trans %}Preview{% endtrans %}</button>
  64. </div>
  65. {% endif %}
  66. </form>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. {% endblock %}
  73. {% block stylesheets %}{{ super() }}
  74. <link href="{{ STATIC_URL }}cranefly/highlight/styles/monokai.css" rel="stylesheet">
  75. {% endblock %}
  76. {% block javascripts %}{{ super() }}
  77. <script src="{{ STATIC_URL }}cranefly/highlight/highlight.pack.js"></script>
  78. <script type="text/javascript">
  79. hljs.tabReplace = ' ';
  80. hljs.initHighlightingOnLoad();
  81. EnhancePostsMD();
  82. </script>
  83. {{ editor.js() }}
  84. {% endblock %}
  85. {% macro get_action() -%}
  86. {% if action == 'new_thread' -%}
  87. {% url 'private_thread_start' %}
  88. {%- elif action == 'edit_thread' -%}
  89. {% url 'private_thread_edit' thread=thread.pk, slug=thread.slug %}
  90. {%- elif action in 'new_reply' -%}
  91. {%- if quote -%}
  92. {% url 'private_thread_reply' thread=thread.pk, slug=thread.slug, quote=quote.pk %}
  93. {%- else -%}
  94. {% url 'private_thread_reply' thread=thread.pk, slug=thread.slug %}
  95. {%- endif -%}
  96. {%- elif action == 'edit_reply' -%}
  97. {% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}
  98. {%- endif %}
  99. {%- endmacro %}
  100. {% macro get_title() -%}
  101. {% if action == 'new_thread' -%}
  102. {% trans %}Post New Thread{% endtrans %}
  103. {%- elif action == 'edit_thread' -%}
  104. {% trans %}Edit Thread{% endtrans %}
  105. {%- elif action == 'new_reply' -%}
  106. {% trans %}Post New Reply{% endtrans %}
  107. {%- elif action == 'edit_reply' -%}
  108. {% trans %}Edit Reply{% endtrans %}
  109. {%- endif %}
  110. {%- endmacro %}
  111. {% macro get_info() -%}
  112. {% if action == 'edit_reply' -%}
  113. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  114. <li><i class="icon-time"></i> {{ post.date|reltimesince }}</li>
  115. <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>
  116. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  117. {% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}
  118. {%- else -%}
  119. {% trans %}First edit{% endtrans %}
  120. {%- endif %}</li>
  121. {%- else -%}
  122. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  123. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  124. <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>
  125. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  126. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  127. {%- else -%}
  128. {% trans %}No replies{% endtrans %}
  129. {%- endif %}</li>
  130. {%- endif %}
  131. {%- endmacro %}
  132. {% macro get_button() -%}
  133. {% if action == 'new_thread' -%}
  134. {% trans %}Post Thread{% endtrans %}
  135. {%- elif action == 'new_reply' -%}
  136. {% trans %}Post Reply{% endtrans %}
  137. {%- else -%}
  138. {% trans %}Save Changes{% endtrans %}
  139. {%- endif %}
  140. {%- endmacro %}
  141. {% macro get_extra() %}
  142. <button id="editor-preview" name="preview" type="submit" class="btn pull-right">{% trans %}Preview{% endtrans %}</button>
  143. {% endmacro %}