posting.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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 javascripts %}
  48. {{ super() }}
  49. {{ editor.js() }}
  50. {% endblock %}
  51. {% macro get_action() -%}
  52. {% if mode == 'new_thread' -%}
  53. {% url 'thread_new' forum=forum.pk, slug=forum.slug %}
  54. {%- elif mode == 'edit_thread' -%}
  55. {% url 'thread_edit' thread=thread.pk, slug=thread.slug %}
  56. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  57. {%- if quote -%}
  58. {% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=quote.pk %}
  59. {%- else -%}
  60. {% url 'thread_reply' thread=thread.pk, slug=thread.slug %}
  61. {%- endif -%}
  62. {%- elif mode == 'edit_post' -%}
  63. {% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}
  64. {%- endif %}
  65. {%- endmacro %}
  66. {% macro get_title() -%}
  67. {% if mode == 'new_thread' -%}
  68. {% trans %}Post New Thread{% endtrans %}
  69. {%- elif mode == 'edit_thread' -%}
  70. {% trans %}Edit Thread{% endtrans %}
  71. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  72. {% trans %}Post New Reply{% endtrans %}
  73. {%- elif mode == 'edit_post' -%}
  74. {% trans %}Edit Reply{% endtrans %}
  75. {%- endif %}
  76. {%- endmacro %}
  77. {% macro get_info() -%}
  78. {% if mode == 'edit_post' -%}
  79. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  80. <li><i class="icon-time"></i> {{ post.date|reltimesince }}</li>
  81. <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>
  82. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  83. {% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}
  84. {%- else -%}
  85. {% trans %}First edit{% endtrans %}
  86. {%- endif %}</li>
  87. {%- else -%}
  88. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  89. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  90. <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>
  91. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  92. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  93. {%- else -%}
  94. {% trans %}No replies{% endtrans %}
  95. {%- endif %}</li>
  96. {%- endif %}
  97. {%- endmacro %}
  98. {% macro get_button() -%}
  99. {% if mode == 'new_thread' -%}
  100. {% trans %}Post Thread{% endtrans %}
  101. {%- elif mode == 'edit_thread' -%}
  102. {% trans %}Edit Thread{% endtrans %}
  103. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  104. {% trans %}Post Reply{% endtrans %}
  105. {%- elif mode == 'edit_post' -%}
  106. {% trans %}Edit Reply{% endtrans %}
  107. {%- endif %}
  108. {%- endmacro %}
  109. {% macro get_extra() %}
  110. <button id="editor-preview" name="preview" type="submit" class="btn btn-success pull-right">{% trans %}Preview{% endtrans %}</button>
  111. {% endmacro %}