posting.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. {{ get_info() }}
  28. </ul>
  29. {%- endif %}
  30. </div>
  31. {% if message %}{{ macros.draw_message(message, 'alert-form') }}{% endif %}
  32. <form action="{{ get_action() }}" method="post">
  33. <input type="hidden" name="{{ csrf_id }}" value="{{ csrf_token }}">
  34. {% if 'thread_name' in form.fields %}{{ form_theme.row_widget(form.fields.thread_name) }}{% endif %}
  35. {% if 'edit_reason' in form.fields %}{{ form_theme.row_widget(form.fields.edit_reason) }}{% endif %}
  36. {{ editor.editor(form.fields.post, get_button(), rows=8) }}
  37. </form>
  38. <div class="well well-small" id="md-border" style="display: none;">
  39. <div class="markdown" id="md-preview"></div>
  40. </div>
  41. {% endblock %}
  42. {% macro get_action() -%}
  43. {% if mode == 'new_thread' -%}
  44. {% url 'thread_new' forum=forum.pk, slug=forum.slug %}
  45. {%- elif mode == 'edit_thread' -%}
  46. {% url 'thread_edit' thread=thread.pk, slug=thread.slug %}
  47. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  48. {%- if quote -%}
  49. {% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=quote.pk %}
  50. {%- else -%}
  51. {% url 'thread_reply' thread=thread.pk, slug=thread.slug %}
  52. {%- endif -%}
  53. {%- elif mode == 'edit_post' -%}
  54. {% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}
  55. {%- endif %}
  56. {%- endmacro %}
  57. {% macro get_title() -%}
  58. {% if mode == 'new_thread' -%}
  59. {% trans %}Post New Thread{% endtrans %}
  60. {%- elif mode == 'edit_thread' -%}
  61. {% trans %}Edit Thread{% endtrans %}
  62. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  63. {% trans %}Post New Reply{% endtrans %}
  64. {%- elif mode == 'edit_post' -%}
  65. {% trans %}Edit Reply{% endtrans %}
  66. {%- endif %}
  67. {%- endmacro %}
  68. {% macro get_info() -%}
  69. {% if mode == 'edit_post' -%}
  70. {% if post.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  71. <li><i class="icon-time"></i> {{ post.date|reltimesince }}</li>
  72. <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>
  73. <li><i class="icon-pencil"></i> {% if post.edits > 0 -%}
  74. {% trans count=post.edits %}One edit{% pluralize %}{{ count }} edits{% endtrans %}
  75. {%- else -%}
  76. {% trans %}First edit{% endtrans %}
  77. {%- endif %}</li>
  78. {%- else -%}
  79. {% if thread.moderated %}<li><i class="icon-eye-close"></i> {% trans %}Not Reviewed{% endtrans %}</li>{% endif %}
  80. <li><i class="icon-time"></i> {{ thread.last|reltimesince }}</li>
  81. <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>
  82. <li><i class="icon-comment"></i> {% if thread.replies > 0 -%}
  83. {% trans count=thread.replies, replies=thread.replies|intcomma %}One reply{% pluralize %}{{ replies }} replies{% endtrans %}
  84. {%- else -%}
  85. {% trans %}No replies{% endtrans %}
  86. {%- endif %}</li>
  87. {%- endif %}
  88. {%- endmacro %}
  89. {% macro get_button() -%}
  90. {% if mode == 'new_thread' -%}
  91. {% trans %}Post Thread{% endtrans %}
  92. {%- elif mode == 'edit_thread' -%}
  93. {% trans %}Edit Thread{% endtrans %}
  94. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  95. {% trans %}Post Reply{% endtrans %}
  96. {%- elif mode == 'edit_post' -%}
  97. {% trans %}Edit Reply{% endtrans %}
  98. {%- endif %}
  99. {%- endmacro %}
  100. {% block javascripts %}
  101. {{ super() }}
  102. {{ editor.js() }}
  103. {% endblock %}