posting.html 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {% extends "sora/layout.html" %}
  2. {% load i18n %}
  3. {% load url from future %}
  4. {% import "_forms.html" as form_theme with context %}
  5. {% import "sora/editor.html" as editor with context %}
  6. {% import "sora/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=forum.pk, slug=forum.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. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  28. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  29. <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>
  30. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  31. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  32. {%- else -%}
  33. {% trans %}No replies{% endtrans %}
  34. {%- endif %}</li>
  35. </ul>
  36. {%- endif %}
  37. </div>
  38. {% if message %}{{ macros.draw_message(message, 'alert-form') }}{% endif %}
  39. <form action="{{ get_action() }}" method="post">
  40. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  41. {% if 'thread_name' in form.fields %}
  42. {{ form_theme.row_widget(form.fields.thread_name) }}
  43. {% endif %}
  44. {{ editor.editor(form.fields.post, get_button(), rows=8) }}
  45. </form>
  46. <div class="well well-small" id="md-border" style="display: none;">
  47. <div class="markdown" id="md-preview"></div>
  48. </div>
  49. {% endblock %}
  50. {% block javascripts %}
  51. {{ super() }}
  52. <script type="text/javascript">
  53. $(function($){
  54. var xhr = false;
  55. preview = $('#md-preview')
  56. $('#md-border').fadeIn(200);
  57. $('#id_post').keyup(function() {
  58. if (xhr != false) {
  59. xhr.abort();
  60. }
  61. xhr = $.ajax({
  62. type: "POST",
  63. url: "{% url 'md_preview' %}",
  64. data: { raw: $(this).val() },
  65. success: function(data) {
  66. $(preview).html(data);
  67. }
  68. });
  69. });
  70. });
  71. </script>
  72. {% endblock %}
  73. {% macro get_action() -%}
  74. {% if mode == 'new_thread' -%}
  75. {% url 'thread_new' forum=forum.pk, slug=forum.slug %}
  76. {%- elif mode == 'edit_thread' -%}
  77. NADA!
  78. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  79. {% url 'thread_reply' thread=thread.pk, slug=thread.slug %}
  80. {%- elif mode == 'edit_post' -%}
  81. NADA!
  82. {%- endif %}
  83. {%- endmacro %}
  84. {% macro get_title() -%}
  85. {% if mode == 'new_thread' -%}
  86. {% trans %}Post New Thread{% endtrans %}
  87. {%- elif mode == 'edit_thread' -%}
  88. {% trans %}Edit Thread{% endtrans %}
  89. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  90. {% trans %}Post New Reply{% endtrans %}
  91. {%- elif mode == 'edit_post' -%}
  92. {% trans %}Edit Reply{% endtrans %}
  93. {%- endif %}
  94. {%- endmacro %}
  95. {% macro get_button() -%}
  96. {% if mode == 'new_thread' -%}
  97. {% trans %}Post Thread{% endtrans %}
  98. {%- elif mode == 'edit_thread' -%}
  99. {% trans %}Edit Thread{% endtrans %}
  100. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  101. {% trans %}Post Reply{% endtrans %}
  102. {%- elif mode == 'edit_post' -%}
  103. {% trans %}Edit Reply{% endtrans %}
  104. {%- endif %}
  105. {%- endmacro %}