posting.html 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. {% extends "cranefly/layout.html" %}
  2. {% load i18n %}
  3. {% load url from future %}
  4. {% import "_forms.html" as form_theme with context %}
  5. {% import "cranefly/editor.html" as editor with context %}
  6. {% import "cranefly/macros.html" as macros with context %}
  7. {% block title %}{% if thread -%}
  8. {{ macros.page_title(title=_(get_title()), parent=thread.name) }}
  9. {%- else -%}
  10. {{ macros.page_title(title=_(get_title()), parent=forum.name) }}
  11. {%- endif %}{% endblock %}
  12. {% block breadcrumb %}{{ super() }} <span class="divider">/</span></li>
  13. {% for parent in parents %}
  14. <li><a href="{{ parent.type|url(forum=parent.pk, slug=parent.slug) }}">{{ parent.name }}</a> <span class="divider">/</span></li>
  15. {% endfor %}
  16. {% if thread %}<li><a href="{% url 'thread' thread=thread.pk, slug=thread.slug %}">{{ thread.name }}</a> <span class="divider">/</span></li>{% endif %}
  17. <li class="active">{{ get_title() }}
  18. {%- endblock %}
  19. {% block content %}
  20. <div class="page-header">
  21. <ul class="breadcrumb">
  22. {{ self.breadcrumb() }}</li>
  23. </ul>
  24. <h1>{{ get_title() }} <small>{% if thread %}{{ thread.name }}{% else %}{{ forum.name }}{% endif %}</small></h1>
  25. {% if thread %}
  26. <ul class="unstyled thread-info">
  27. {{ get_info() }}
  28. </ul>
  29. {%- endif %}
  30. </div>
  31. {% if message %}{{ macros.draw_message(message, 'alert-form') }}{% endif %}
  32. {% if preview %}
  33. <div class="well" style="margin: 0px; margin-bottom: 32px; padding: 12px;">
  34. <div class="markdown">
  35. {{ preview|markdown_final|safe }}
  36. </div>
  37. </div>
  38. <hr>
  39. {% endif %}
  40. <form action="{{ get_action() }}" method="post">
  41. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  42. {% if 'thread_name' in form.fields %}{{ form_theme.row_widget(form.fields.thread_name) }}{% endif %}
  43. {% if 'edit_reason' in form.fields %}{{ form_theme.row_widget(form.fields.edit_reason) }}{% endif %}
  44. {{ editor.editor(form.fields.post, get_button(), rows=8, extra=get_extra()) }}
  45. </form>
  46. {% endblock %}
  47. {% block stylesheets %}{{ super() }}
  48. <link href="{{ STATIC_URL }}cranefly/highlight/styles/monokai.css" rel="stylesheet">
  49. {% endblock %}
  50. {% block javascripts %}{{ super() }}
  51. <script src="{{ STATIC_URL }}cranefly/highlight/highlight.pack.js"></script>
  52. <script type="text/javascript">
  53. hljs.tabReplace = ' ';
  54. hljs.initHighlightingOnLoad();
  55. </script>
  56. {{ editor.js() }}
  57. {% endblock %}
  58. {% macro get_action() -%}
  59. {% if mode == 'new_thread' -%}
  60. {% url 'thread_new' forum=forum.pk, slug=forum.slug %}
  61. {%- elif mode == 'edit_thread' -%}
  62. {% url 'thread_edit' thread=thread.pk, slug=thread.slug %}
  63. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  64. {%- if quote -%}
  65. {% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=quote.pk %}
  66. {%- else -%}
  67. {% url 'thread_reply' thread=thread.pk, slug=thread.slug %}
  68. {%- endif -%}
  69. {%- elif mode == 'edit_post' -%}
  70. {% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}
  71. {%- endif %}
  72. {%- endmacro %}
  73. {% macro get_title() -%}
  74. {% if mode == 'new_thread' -%}
  75. {% trans %}Post New Thread{% endtrans %}
  76. {%- elif mode == 'edit_thread' -%}
  77. {% trans %}Edit Thread{% endtrans %}
  78. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  79. {% trans %}Post New Reply{% endtrans %}
  80. {%- elif mode == 'edit_post' -%}
  81. {% trans %}Edit Reply{% endtrans %}
  82. {%- endif %}
  83. {%- endmacro %}
  84. {% macro get_info() -%}
  85. {% if mode == 'edit_post' -%}
  86. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  87. <li><i class="icon-time"></i> {{ post.date|reltimesince }}</li>
  88. <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>
  89. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  90. {% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}
  91. {%- else -%}
  92. {% trans %}First edit{% endtrans %}
  93. {%- endif %}</li>
  94. {%- else -%}
  95. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  96. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  97. <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>
  98. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  99. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  100. {%- else -%}
  101. {% trans %}No replies{% endtrans %}
  102. {%- endif %}</li>
  103. {%- endif %}
  104. {%- endmacro %}
  105. {% macro get_button() -%}
  106. {% if mode == 'new_thread' -%}
  107. {% trans %}Post Thread{% endtrans %}
  108. {%- elif mode == 'edit_thread' -%}
  109. {% trans %}Edit Thread{% endtrans %}
  110. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  111. {% trans %}Post Reply{% endtrans %}
  112. {%- elif mode == 'edit_post' -%}
  113. {% trans %}Edit Reply{% endtrans %}
  114. {%- endif %}
  115. {%- endmacro %}
  116. {% macro get_extra() %}
  117. <button id="editor-preview" name="preview" type="submit" class="btn btn-success pull-right">{% trans %}Preview{% endtrans %}</button>
  118. {% endmacro %}