blog: Refactor entry rendering into a partial.
This helps ensure that entries are rendered consistently wherever they appear.
This commit is contained in:
parent
9fbc652c7c
commit
e7c1171b6e
9 changed files with 68 additions and 76 deletions
|
@ -268,7 +268,7 @@ h3 { margin-top: .6em; margin-bottom: .4em; }
|
|||
clear: both;
|
||||
}
|
||||
|
||||
span.continued {
|
||||
.continued {
|
||||
display: block;
|
||||
font-size: .9em;
|
||||
font-weight: bold;
|
||||
|
@ -276,7 +276,7 @@ span.continued {
|
|||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
p.date {
|
||||
.date, .blog-tags, .blog-comments {
|
||||
font-style: italic;
|
||||
font-size: .9em;
|
||||
margin-bottom: .3em;
|
||||
|
|
|
@ -6,13 +6,8 @@
|
|||
|
||||
<h2>Conservancy Blog Archive: {{ day|date:"F j, Y" }}</h2>
|
||||
|
||||
{% for object in object_list %}
|
||||
<h3><a href="{{ object.get_absolute_url }}">{{ object.headline|safe }}</a></h3>
|
||||
{{ object.summary|safe }}
|
||||
<p><span class="continued"><a href="{{ object.get_absolute_url }}">Read More...</a></span></p>
|
||||
<p class="date small">Posted by <strong>{{ object.author.formal_name }}</strong> on {{ object.pub_date|date:"F j, Y" }}
|
||||
{% if object.tags.all %}<span class="blog-tags">/ Tags: {% for tag in object.tags.all %}<a href="{{ tag.get_absolute_url }}">{{ tag.label }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</span>{% endif %}
|
||||
</p>
|
||||
{% for entry in object_list %}
|
||||
{% include "blog/entry_partial.html" with entry=entry show="summary+tags" only %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -6,13 +6,8 @@
|
|||
|
||||
<h2>Conservancy Blog Archive: {{ month|date:"F, Y" }}</h2>
|
||||
|
||||
{% for object in object_list %}
|
||||
<h3><a href="{{ object.get_absolute_url }}">{{ object.headline|safe }}</a></h3>
|
||||
{{ object.summary|safe }}
|
||||
<p><span class="continued"><a href="{{ object.get_absolute_url }}">Read More...</a></span></p>
|
||||
<p class="date small">Posted by <strong>{{ object.author.formal_name }}</strong> on {{ object.pub_date|date:"F j, Y" }}
|
||||
{% if object.tags.all %}<span class="blog-tags">/ Tags: {% for tag in object.tags.all %}<a href="{{ tag.get_absolute_url }}">{{ tag.label }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</span>{% endif %}
|
||||
</p>
|
||||
{% for entry in object_list %}
|
||||
{% include "blog/entry_partial.html" with entry=entry show="summary+tags" only %}
|
||||
{% endfor %}
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -6,11 +6,8 @@
|
|||
|
||||
<h2>Conservancy Blog Archive: {{ year|date:"Y" }}</h2>
|
||||
|
||||
<ul>
|
||||
{% for object in object_list %}
|
||||
<li><a href="{{ object.get_absolute_url }}"><b>{{ object.headline|safe }}</b></a><br/>
|
||||
<i>{{ object.pub_date|date:"F j, Y" }} by {{ object.author.formal_name }}</i></li>
|
||||
{% for entry in object_list %}
|
||||
{% include "blog/entry_partial.html" with entry=entry show="dateline" only %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -4,12 +4,10 @@
|
|||
|
||||
{% block content %}
|
||||
|
||||
<p class="date">{{ object.pub_date|date:"F j, Y" }} by {{ object.author.formal_name }}</p>
|
||||
<h2>{{ object.headline|safe }}</h2>
|
||||
{{ object.body|safe }}
|
||||
<p><i>Posted by <strong>{{ object.author.formal_name }}</strong> on {{object.pub_date|date:"F j, Y" }}. Please email any comments on this entry to <a href="mailto:info@sfconservancy.org">info@sfconservancy.org</a>.</i></p>
|
||||
{% include "blog/entry_partial.html" with entry=object htag="h2" only %}
|
||||
|
||||
{% if object.tags.all %}<p class="blog-tags">Tags: {% for tag in object.tags.all %}<a href="{{ tag.get_absolute_url }}">{{ tag.label }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>{% endif %}
|
||||
<p class="blog-comments">Please email any comments on this entry to
|
||||
<a href="mailto:info@sfconservancy.org">info@sfconservancy.org</a>.</p>
|
||||
|
||||
<p><span class="continued"><a href="/blog/">Other Conservancy Blog entries…</a></span></p>
|
||||
|
||||
|
|
|
@ -13,11 +13,7 @@
|
|||
{% endif %}
|
||||
|
||||
{% for entry in blog_entries %}
|
||||
<h3><a href="{{ entry.get_absolute_url }}">{{ entry.headline|safe }}</a></h3>
|
||||
{{ entry.body|safe }}
|
||||
<p class="date small">Posted by <strong>{{ entry.author.formal_name }}</strong> on {{ entry.pub_date|date:"F j, Y" }}
|
||||
{% if entry.tags.all %}<span class="blog-tags">/ Tags: {% for tag in entry.tags.all %}<a href="{{ tag.get_absolute_url }}">{{ tag.label }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</span>{% endif %}
|
||||
</p>
|
||||
{% include "blog/entry_partial.html" with entry=entry only %}
|
||||
{% endfor %}
|
||||
|
||||
<p>
|
||||
|
|
49
www/conservancy/templates/blog/entry_partial.html
Normal file
49
www/conservancy/templates/blog/entry_partial.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
{% comment %}
|
||||
|
||||
This partial requires these parameters:
|
||||
|
||||
* `entry`: The BlogEntry object to render.
|
||||
|
||||
This partial accepts these optional parameters:
|
||||
|
||||
* `show`: How much of the BlogEntry to render. Accepted values are
|
||||
"headline", "dateline", "summary", "summary+tags", and "body".
|
||||
Every value will render the parts listed before it, except "body"
|
||||
doesn't include "summary". Default "body".
|
||||
* `htag`: Name of the HTML tag to render the entry headline. Default "h3".
|
||||
|
||||
{% endcomment %}
|
||||
|
||||
<div class="blog-entry">
|
||||
|
||||
<{{ htag|default:"h3" }}
|
||||
>{% if show|default:"body" != "body" %}<a href="{{ entry.get_absolute_url }}"
|
||||
>{% endif %}{{ entry.headline|safe }}{% if show|default:"body" != "body" %}</a>{% endif %}</{{ htag|default:"h3" }}>
|
||||
|
||||
{% if show != "headline" %}
|
||||
<p class="date">by <span class="author">{{ entry.author.formal_name }}</span>
|
||||
on {{ entry.pub_date|date:"F j, Y" }}
|
||||
</p>
|
||||
|
||||
{% if show != "dateline" %}
|
||||
|
||||
{% if show|default:"body" == "body" %}
|
||||
{{ entry.body|safe }}
|
||||
{% else %}
|
||||
{{ entry.summary|safe }}
|
||||
{% endif %}
|
||||
|
||||
{% if show|default:"body" != "body" %}
|
||||
<p><a class="continued" href="{{ entry.get_absolute_url }}">Read More…</a></p>
|
||||
{% endif %}
|
||||
|
||||
{% if show != "summary" and entry.tags.exists %}
|
||||
<p class="blog-tags">Tags:
|
||||
{% for tag in entry.tags.iterator %}
|
||||
<a href="{{ tag.get_absolute_url }}">{{ tag.label }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</p>
|
||||
{% endif %}
|
||||
|
||||
{% endif %}{# show != "dateline" #}
|
||||
{% endif %}{# show != "headline" #}
|
||||
|
||||
</div>
|
|
@ -33,16 +33,8 @@
|
|||
<div id="contractpatch-blog" class="section">
|
||||
<h2>Blog posts</h2>
|
||||
|
||||
{% comment %}
|
||||
FIXME:
|
||||
This is duplicated from blog/entry_list.html
|
||||
{% endcomment %}
|
||||
{% for entry in blog_entries %}
|
||||
<h3><a href="{{ entry.get_absolute_url }}">{{ entry.headline|safe }}</a></h3>
|
||||
{{ entry.body|safe }}
|
||||
<p class="date small">Posted by <strong>{{ entry.author.formal_name }}</strong> on {{ entry.pub_date|date:"F j, Y" }}
|
||||
{% if entry.tags.all %}<span class="blog-tags">/ Tags: {% for tag in entry.tags.all %}<a href="{{ tag.get_absolute_url }}">{{ tag.label }}</a>{% if not forloop.last %}, {% endif %}{% endfor %}</span>{% endif %}
|
||||
</p>
|
||||
{% include "blog/entry_partial.html" with entry=entry only %}
|
||||
{% endfor %}
|
||||
|
||||
<p><span class="continued"><a href="/blog/?tag=ContractPatch">Read all ContractPatch blog posts…</a></span></p>
|
||||
|
|
|
@ -49,42 +49,12 @@
|
|||
|
||||
<div class="column">
|
||||
<h2><a href="/feeds/blog/" class="feedlink"><img src="/img/feed-icon-14x14.png" alt="[RSS]"/></a> <a href="/blog/">Conservancy Blog</a></h2>
|
||||
<h3><a href="{{ blog.0.get_absolute_url }}">{{ blog.0.headline|safe }}</a></h3>
|
||||
<p class="date">Posted by {{ blog.0.author.formal_name }} on {{ blog.0.pub_date|date:"F j, Y" }}</p>
|
||||
{{ blog.0.summary|safe }}
|
||||
<p><span class="continued"><a href="{{ blog.0.get_absolute_url }}">Read More from {{ blog.0.author.casual_name }} on this…</a></span></p>
|
||||
|
||||
{% if blog.1 and blog.1.pub_date|date_within_past_days:30 %}
|
||||
<hr/>
|
||||
<h3><a href="{{ blog.1.get_absolute_url }}">{{ blog.1.headline|safe }}</a></h3>
|
||||
<p class="date">Posted by {{ blog.1.author.formal_name }} on {{ blog.1.pub_date|date:"F j, Y" }}</p>
|
||||
{{ blog.1.summary|safe }}
|
||||
<p><span class="continued"><a href="{{ blog.1.get_absolute_url }}">Read More from {{ blog.1.author.casual_name }} on this…</a></span></p>
|
||||
{% endif %}
|
||||
|
||||
{% if blog.2 and blog.2.pub_date|date_within_past_days:30 %}
|
||||
<hr/>
|
||||
<h3><a href="{{ blog.2.get_absolute_url }}">{{ blog.2.headline|safe }}</a></h3>
|
||||
<p class="date">Posted by {{ blog.2.author.formal_name }} on {{ blog.2.pub_date|date:"F j, Y" }}</p>
|
||||
{{ blog.2.summary|safe }}
|
||||
<p><span class="continued"><a href="{{ blog.2.get_absolute_url }}">Read More from {{ blog.2.author.casual_name }} on this…</a></span></p>
|
||||
{% endif %}
|
||||
|
||||
{% if blog.3 and blog.3.pub_date|date_within_past_days:30 %}
|
||||
<hr/>
|
||||
<h3><a href="{{ blog.3.get_absolute_url }}">{{ blog.3.headline|safe }}</a></h3>
|
||||
<p class="date">Posted by {{ blog.3.author.formal_name }} on {{ blog.3.pub_date|date:"F j, Y" }}</p>
|
||||
{{ blog.3.summary|safe }}
|
||||
<p><span class="continued"><a href="{{ blog.3.get_absolute_url }}">Read More from {{ blog.3.author.casual_name }} on this…</a></span></p>
|
||||
{% endif %}
|
||||
|
||||
{% if blog.4 and blog.4.pub_date|date_within_past_days:30 %}
|
||||
<hr/>
|
||||
<h3><a href="{{ blog.4.get_absolute_url }}">{{ blog.4.headline|safe }}</a></h3>
|
||||
<p class="date">Posted by {{ blog.4.author.formal_name }} on {{ blog.4.pub_date|date:"F j, Y" }}</p>
|
||||
{{ blog.4.summary|safe }}
|
||||
<p><span class="continued"><a href="{{ blog.4.get_absolute_url }}">Read More from {{ blog.4.author.casual_name }} on this…</a></span></p>
|
||||
{% endif %}
|
||||
{% for entry in blog|slice:":5" %}
|
||||
{% if forloop.first or entry.pub_date|date_within_past_days:30 %}
|
||||
{% if not forloop.first %}<hr>{% endif %}
|
||||
{% include "blog/entry_partial.html" with entry=entry show="summary" only %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<p><span class="continued"><a href="/blog/">Conservancy Blog Archive…</a></span></p>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue