posting.html 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 %}{{ form_theme.row_widget(form.fields.thread_name) }}{% endif %}
  42. {% if 'edit_reason' in form.fields %}{{ form_theme.row_widget(form.fields.edit_reason) }}{% endif %}
  43. {{ editor.editor(form.fields.post, get_button(), rows=8) }}
  44. </form>
  45. <div class="well well-small" id="md-border" style="display: none;">
  46. <div class="markdown" id="md-preview"></div>
  47. </div>
  48. {% endblock %}
  49. {% macro get_action() -%}
  50. {% if mode == 'new_thread' -%}
  51. {% url 'thread_new' forum=forum.pk, slug=forum.slug %}
  52. {%- elif mode == 'edit_thread' -%}
  53. {% url 'thread_edit' thread=thread.pk, slug=thread.slug %}
  54. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  55. {%- if quote -%}
  56. {% url 'thread_reply' thread=thread.pk, slug=thread.slug, quote=quote.pk %}
  57. {%- else -%}
  58. {% url 'thread_reply' thread=thread.pk, slug=thread.slug %}
  59. {%- endif -%}
  60. {%- elif mode == 'edit_post' -%}
  61. {% url 'post_edit' thread=thread.pk, slug=thread.slug, post=post.pk %}
  62. {%- endif %}
  63. {%- endmacro %}
  64. {% macro get_title() -%}
  65. {% if mode == 'new_thread' -%}
  66. {% trans %}Post New Thread{% endtrans %}
  67. {%- elif mode == 'edit_thread' -%}
  68. {% trans %}Edit Thread{% endtrans %}
  69. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  70. {% trans %}Post New Reply{% endtrans %}
  71. {%- elif mode == 'edit_post' -%}
  72. {% trans %}Edit Reply{% endtrans %}
  73. {%- endif %}
  74. {%- endmacro %}
  75. {% macro get_button() -%}
  76. {% if mode == 'new_thread' -%}
  77. {% trans %}Post Thread{% endtrans %}
  78. {%- elif mode == 'edit_thread' -%}
  79. {% trans %}Edit Thread{% endtrans %}
  80. {%- elif mode in ['new_post', 'new_post_quick'] -%}
  81. {% trans %}Post Reply{% endtrans %}
  82. {%- elif mode == 'edit_post' -%}
  83. {% trans %}Edit Reply{% endtrans %}
  84. {%- endif %}
  85. {%- endmacro %}