Просмотр исходного кода

split behemothic post template into smaller bits

Rafał Pitoń 8 лет назад
Родитель
Сommit
d3d6481c16

+ 5 - 36
misago/templates/misago/thread/posts/event.html → misago/templates/misago/thread/posts/event/index.html

@@ -1,6 +1,7 @@
 {% load i18n misago_capture misago_shorthands %}
 <li id="post-{{ post.pk }}" class="event {{ event.is_hidden|iftrue:'event-hidden' }}">
   <div class="post-border">
+
     <div class="post-avatar">
       <span class="material-icon">
         {% if post.event_type == 'pinned_globally' %}
@@ -26,6 +27,7 @@
         {% endif %}
       </span>
     </div>
+
     <div class="post-body">
       <p class="event-message">
         {% if post.event_type == 'pinned_globally' %}
@@ -60,42 +62,9 @@
           {% trans "Thread has been made hidden." %}
         {% endif %}
       </p>
-      <ul class="list-inline event-info">
-        {% if post.is_hidden %}
-          <li class="event-hidden-message">
-            {% capture trimmed as hidden_by %}
-              {% if post.hidden_by_id %}
-                <a href="{% url 'misago:user' pk=post.hidden_by_id slug=post.hidden_by_slug %}" class="item-title">{{ post.hidden_by_name }}</a>
-              {% else %}
-                <span class="item-title">{{ post.hidden_by_name }}</span>
-              {% endif %}
-            {% endcapture %}
-            {% blocktrans trimmed with hidden_by=hidden_by|safe hidden_on=post.hidden_on|date:'DATETIME_FORMAT' %}
-              Hidden by {{ hidden_by }} on {{ hidden_on }}.
-            {% endblocktrans %}
-          </li>
-        {% endif %}
-        <li class="event-poster">
-          {% capture trimmed as event_by %}
-            {% if post.poster %}
-              <a class="item-title" href="{{ post.poster.get_absolute_url }}">{{ post.poster.username }}</a>
-            {% else %}
-              <strong class="item-title">{{ post.poster_name }}</strong>
-            {% endif %}
-          {% endcapture %}
-          {% capture trimmed as event_on %}
-            <a href="{{ post.get_absolute_url }}">{{ post.posted_on|date:'DATETIME_FORMAT' }}</a>
-          {% endcapture %}
-          {% blocktrans trimmed with event_by=event_by|safe event_on=event_on|safe %}
-            By {{ event_by }} on {{ event_on }}.
-          {% endblocktrans %}
-        </li>
-        {% if user.acl.can_see_users_ips %}
-          <li class="event-ip">
-            <abbr title="{{ post.poster_ip }}">{% trans "IP recorded" %}</abbr>
-          </li>
-        {% endif %}
-      </p>
+
+      {% include "misago/thread/posts/event/info.html" %}
+
     </div>
   </div>
 </li>

+ 37 - 0
misago/templates/misago/thread/posts/event/info.html

@@ -0,0 +1,37 @@
+{% load i18n misago_capture %}
+<ul class="list-inline event-info">
+  {% if post.is_hidden %}
+    <li class="event-hidden-message">
+      {% capture trimmed as hidden_by %}
+        {% if post.hidden_by_id %}
+          <a href="{% url 'misago:user' pk=post.hidden_by_id slug=post.hidden_by_slug %}" class="item-title">{{ post.hidden_by_name }}</a>
+        {% else %}
+          <span class="item-title">{{ post.hidden_by_name }}</span>
+        {% endif %}
+      {% endcapture %}
+      {% blocktrans trimmed with hidden_by=hidden_by|safe hidden_on=post.hidden_on|date:'DATETIME_FORMAT' %}
+        Hidden by {{ hidden_by }} on {{ hidden_on }}.
+      {% endblocktrans %}
+    </li>
+  {% endif %}
+  <li class="event-poster">
+    {% capture trimmed as event_by %}
+      {% if post.poster %}
+        <a class="item-title" href="{{ post.poster.get_absolute_url }}">{{ post.poster.username }}</a>
+      {% else %}
+        <strong class="item-title">{{ post.poster_name }}</strong>
+      {% endif %}
+    {% endcapture %}
+    {% capture trimmed as event_on %}
+      <a href="{{ post.get_absolute_url }}">{{ post.posted_on|date:'DATETIME_FORMAT' }}</a>
+    {% endcapture %}
+    {% blocktrans trimmed with event_by=event_by|safe event_on=event_on|safe %}
+      By {{ event_by }} on {{ event_on }}.
+    {% endblocktrans %}
+  </li>
+  {% if user.acl.can_see_users_ips %}
+    <li class="event-ip">
+      <abbr title="{{ post.poster_ip }}">{% trans "IP recorded" %}</abbr>
+    </li>
+  {% endif %}
+</ul>

+ 2 - 2
misago/templates/misago/thread/posts/index.html

@@ -1,9 +1,9 @@
 <ul class="posts-list ui-ready">
   {% for post in posts %}
     {% if post.is_event %}
-      {% include "misago/thread/posts/event.html" %}
+      {% include "misago/thread/posts/event/index.html" %}
     {% else %}
-      {% include "misago/thread/posts/post.html" %}
+      {% include "misago/thread/posts/post/index.html" %}
     {% endif %}
   {% endfor %}
 </ul>

+ 0 - 119
misago/templates/misago/thread/posts/post.html

@@ -1,119 +0,0 @@
-{% load i18n misago_avatars misago_capture %}
-<li id="post-{{ post.pk }}" class="post {% if post.is_hidden and not post.acl.can_see_hidden %}post-hidden{% endif %}">
-  <div class="post-border">
-    <div class="post-avatar">
-      {% if post.poster %}
-        <a href="{{ post.poster.get_absolute_url }}">
-          <img class="user-avatar" src="{{ post.poster|avatar:100 }}" alt="">
-        </a>
-      {% else %}
-        <img class="user-avatar" src="{% blankavatar 100 %}" alt="">
-      {% endif %}
-    </div>
-    <div class="post-body">
-      <div class="panel panel-default panel-post">
-        <div class="panel-heading post-heading">
-          {% if post.poster %}
-            <a class="item-title" href="{{ post.poster.get_absolute_url }}">{{ post.poster.username }}</a>
-          {% else %}
-            <strong class="item-title">{{ post.poster_name }}</strong>
-          {% endif %}
-          {% if post.poster %}
-            {% if not post.poster.rank.is_default %}
-              {% if post.poster.rank.is_tab %}
-                <a href="{% url 'misago:users-rank' slug=post.poster.rank.slug %}" class="label label-{{ post.poster.rank.css_class|default:'default' }}">
-                  {{ post.poster.short_title }}
-                </a>
-              {% else %}
-                <span class="label label-{{ post.poster.rank.css_class|default:'default' }}">
-                  {{ post.poster.short_title }}
-                </span>
-              {% endif %}
-            {% endif %}
-          {% else %}
-            <span class="rank-name item-title">
-              {% trans "Unregistered" %}
-            </span>
-          {% endif %}
-          <a href="{{ post.get_absolute_url }}" class="posted-on">
-            {% blocktrans trimmed with posted_on=post.posted_on|date:'DATETIME_FORMAT' %}
-              posted on {{ posted_on }}
-            {% endblocktrans %}
-          </a>
-
-          {% if not post.is_read %}
-            <span class="label label-success pull-right">
-              {% trans "New" %}
-            </span>
-          {% endif %}
-        </div>
-        {% if post.is_hidden and not post.acl.can_see_hidden %}
-          <div class="panel-body panel-body-hidden">
-            <p class="lead">{% trans "This post is hidden. You cannot not see its contents." %}</p>
-            {% capture trimmed as hidden_by %}
-              {% if post.hidden_by_id %}
-                <a href="{% url 'misago:user' pk=post.hidden_by_id slug=post.hidden_by_slug %}" class="item-title">{{ post.hidden_by_name }}</a>
-              {% else %}
-                <span class="item-title">{{ post.hidden_by_name }}</span>
-              {% endif %}
-            {% endcapture %}
-            <p class="text-muted">
-              {% blocktrans trimmed with hidden_by=hidden_by|safe hidden_on=post.hidden_on|date:'DATETIME_FORMAT' %}
-                Hidden by {{ hidden_by }} on {{ hidden_on }}.
-              {% endblocktrans %}
-            </p>
-          </div>
-        {% else %}
-          {% if post.is_hidden %}
-            <div class="post-status-message post-status-hidden">
-              <span class="material-icon">visibility_off</span>
-              <p>{% trans "This post is hidden. Only users with permission may see its contents." %}</p>
-            </div>
-          {% endif %}
-          {% if post.is_unapproved %}
-            <div class="post-status-message post-status-unapproved">
-              <span class="material-icon">remove_circle_outline</span>
-              <p>{% trans "This post is unapproved. Only users with permission to approve posts and its author may see its contents." %}</p>
-            </div>
-          {% endif %}
-          {% if post.is_valid %}
-            <div class="panel-body">
-              <article class="misago-markup">
-                {{ post.parsed|safe }}
-              </article>
-            </div>
-          {% else %}
-            <div class="panel-body panel-body-invalid">
-              <p class="lead">{% trans "This post's contents cannot be displayed." %}</p>
-              <p class="text-muted">{% trans "This error is caused by invalid post content manipulation." %}</p>
-            </div>
-          {% endif %}
-          {% if post.acl.can_reply or post.acl.can_edit or post.acl.can_see_likes or post.acl.can_like %}
-            <div class="panel-footer post-footer">
-              {% if post.acl.can_see_likes %}
-                <button type="button" class="btn btn-likes pull-left" disabled="disabled">
-                  Likes
-                </button>
-              {% endif %}
-              {% if post.acl.can_like %}
-                <button type="button" class="btn btn-like pull-left" disabled="disabled">
-                  {% trans "Like" %}
-                </button>
-              {% endif %}
-              {% if post.acl.can_reply %}
-                <button type="button" class="btn btn-reply pull-right" disabled="disabled">
-                  {% trans "Reply" %}
-                </button>
-              {% endif %}
-              {% if post.acl.can_edit %}
-                <button type="button" class="btn btn-edit pull-right" disabled="disabled">
-                  {% trans "Edit" %}
-                </button>
-              {% endif %}
-            </div>
-          {% endif %}
-        {% endif %}
-      </div>
-    </div>
-  </div>
-</li>

+ 16 - 0
misago/templates/misago/thread/posts/post/body-hidden.html

@@ -0,0 +1,16 @@
+{% load i18n misago_capture %}
+<div class="panel-body panel-body-hidden">
+  <p class="lead">{% trans "This post is hidden. You cannot not see its contents." %}</p>
+  {% capture trimmed as hidden_by %}
+    {% if post.hidden_by_id %}
+      <a href="{% url 'misago:user' pk=post.hidden_by_id slug=post.hidden_by_slug %}" class="item-title">{{ post.hidden_by_name }}</a>
+    {% else %}
+      <span class="item-title">{{ post.hidden_by_name }}</span>
+    {% endif %}
+  {% endcapture %}
+  <p class="text-muted">
+    {% blocktrans trimmed with hidden_by=hidden_by|safe hidden_on=post.hidden_on|date:'DATETIME_FORMAT' %}
+      Hidden by {{ hidden_by }} on {{ hidden_on }}.
+    {% endblocktrans %}
+  </p>
+</div>

+ 13 - 0
misago/templates/misago/thread/posts/post/body.html

@@ -0,0 +1,13 @@
+{% load i18n %}
+{% if post.is_valid %}
+  <div class="panel-body">
+    <article class="misago-markup">
+      {{ post.parsed|safe }}
+    </article>
+  </div>
+{% else %}
+  <div class="panel-body panel-body-invalid">
+    <p class="lead">{% trans "This post's contents cannot be displayed." %}</p>
+    <p class="text-muted">{% trans "This error is caused by invalid post content manipulation." %}</p>
+  </div>
+{% endif %}

+ 13 - 0
misago/templates/misago/thread/posts/post/flags.html

@@ -0,0 +1,13 @@
+{% load i18n %}
+{% if post.is_hidden %}
+  <div class="post-status-message post-status-hidden">
+    <span class="material-icon">visibility_off</span>
+    <p>{% trans "This post is hidden. Only users with permission may see its contents." %}</p>
+  </div>
+{% endif %}
+{% if post.is_unapproved %}
+  <div class="post-status-message post-status-unapproved">
+    <span class="material-icon">remove_circle_outline</span>
+    <p>{% trans "This post is unapproved. Only users with permission to approve posts and its author may see its contents." %}</p>
+  </div>
+{% endif %}

+ 25 - 0
misago/templates/misago/thread/posts/post/footer.html

@@ -0,0 +1,25 @@
+{% load i18n %}
+{% if post.acl.can_reply or post.acl.can_edit or post.acl.can_see_likes or post.acl.can_like %}
+  <div class="panel-footer post-footer">
+    {% if post.acl.can_see_likes %}
+      <button type="button" class="btn btn-likes pull-left" disabled="disabled">
+        Likes
+      </button>
+    {% endif %}
+    {% if post.acl.can_like %}
+      <button type="button" class="btn btn-like pull-left" disabled="disabled">
+        {% trans "Like" %}
+      </button>
+    {% endif %}
+    {% if post.acl.can_reply %}
+      <button type="button" class="btn btn-reply pull-right" disabled="disabled">
+        {% trans "Reply" %}
+      </button>
+    {% endif %}
+    {% if post.acl.can_edit %}
+      <button type="button" class="btn btn-edit pull-right" disabled="disabled">
+        {% trans "Edit" %}
+      </button>
+    {% endif %}
+  </div>
+{% endif %}

+ 38 - 0
misago/templates/misago/thread/posts/post/header.html

@@ -0,0 +1,38 @@
+{% load i18n %}
+<div class="panel-heading post-heading">
+  {% if post.poster %}
+    <a class="item-title" href="{{ post.poster.get_absolute_url }}">{{ post.poster.username }}</a>
+  {% else %}
+    <strong class="item-title">{{ post.poster_name }}</strong>
+  {% endif %}
+
+  {% if post.poster %}
+    {% if not post.poster.rank.is_default %}
+      {% if post.poster.rank.is_tab %}
+        <a href="{% url 'misago:users-rank' slug=post.poster.rank.slug %}" class="label label-{{ post.poster.rank.css_class|default:'default' }}">
+          {{ post.poster.short_title }}
+        </a>
+      {% else %}
+        <span class="label label-{{ post.poster.rank.css_class|default:'default' }}">
+          {{ post.poster.short_title }}
+        </span>
+      {% endif %}
+    {% endif %}
+  {% else %}
+    <span class="rank-name item-title">
+      {% trans "Unregistered" %}
+    </span>
+  {% endif %}
+
+  <a href="{{ post.get_absolute_url }}" class="posted-on">
+    {% blocktrans trimmed with posted_on=post.posted_on|date:'DATETIME_FORMAT' %}
+      posted on {{ posted_on }}
+    {% endblocktrans %}
+  </a>
+
+  {% if not post.is_read %}
+    <span class="label label-success pull-right">
+      {% trans "New" %}
+    </span>
+  {% endif %}
+</div>

+ 26 - 0
misago/templates/misago/thread/posts/post/index.html

@@ -0,0 +1,26 @@
+{% load misago_avatars %}
+<li id="post-{{ post.pk }}" class="post {% if post.is_hidden and not post.acl.can_see_hidden %}post-hidden{% endif %}">
+  <div class="post-border">
+    <div class="post-avatar">
+      {% if post.poster %}
+        <a href="{{ post.poster.get_absolute_url }}">
+          <img class="user-avatar" src="{{ post.poster|avatar:100 }}" alt="">
+        </a>
+      {% else %}
+        <img class="user-avatar" src="{% blankavatar 100 %}" alt="">
+      {% endif %}
+    </div>
+    <div class="post-body">
+      <div class="panel panel-default panel-post">
+        {% include "misago/thread/posts/post/header.html" %}
+        {% if post.is_hidden and not post.acl.can_see_hidden %}
+          {% include "misago/thread/posts/post/body-hidden.html" %}
+        {% else %}
+          {% include "misago/thread/posts/post/flags.html" %}
+          {% include "misago/thread/posts/post/body.html" %}
+          {% include "misago/thread/posts/post/footer.html" %}
+        {% endif %}
+      </div>
+    </div>
+  </div>
+</li>