news: Refactor press release rendering into a partial.
Same rationale as a few commits ago for blog entries.
This commit is contained in:
parent
7f5f98e5db
commit
d5f461d879
7 changed files with 69 additions and 55 deletions
|
@ -26,24 +26,13 @@
|
|||
|
||||
<div class="column">
|
||||
<h2><a href="/feeds/news/" class="feedlink"><img src="/img/feed-icon-14x14.png" alt="[RSS]"/></a> <a href="/news/">Recent News</a></h2>
|
||||
<p class="date">{{ press_releases.0.pub_date|date:"F j, Y" }}</p>
|
||||
<h3><a href="{{ press_releases.0.get_absolute_url }}">{{ press_releases.0.headline|safe }}</a></h3>
|
||||
{{ press_releases.0.summary|safe }}
|
||||
{% if press_releases.0.body %}<p><span class="continued"><a href="{{ press_releases.0.get_absolute_url }}">Read More...</a></span></p>{% endif %}
|
||||
{% if press_releases.1 and press_releases.1.pub_date|date_within_past_days:30 %}
|
||||
<hr/>
|
||||
<p class="date">{{ press_releases.1.pub_date|date:"F j, Y" }}</p>
|
||||
<h3><a href="{{ press_releases.1.get_absolute_url }}">{{ press_releases.1.headline|safe }}</a></h3>
|
||||
{{ press_releases.1.summary|safe }}
|
||||
{% if press_releases.1.body %}<p><span class="continued"><a href="{{ press_releases.1.get_absolute_url }}">Read More...</a></span></p>{% endif %}
|
||||
{% endif %}
|
||||
{% if press_releases.2 and press_releases.2.pub_date|date_within_past_days:30 %}
|
||||
<hr/>
|
||||
<p class="date">{{ press_releases.2.pub_date|date:"F j, Y" }}</p>
|
||||
<h3><a href="{{ press_releases.2.get_absolute_url }}">{{ press_releases.2.headline|safe }}</a></h3>
|
||||
{{ press_releases.2.summary|safe }}
|
||||
{% if press_releases.2.body %}<p><span class="continued"><a href="{{ press_releases.2.get_absolute_url }}">Read More...</a></span></p>{% endif %}
|
||||
{% for pressr in press_releases|slice:":5" %}
|
||||
{% if forloop.first or pressr.pub_date|date_within_past_days:30 %}
|
||||
{% if not forloop.first %}<hr class="clear">{% endif %}
|
||||
{% include "news/pressrelease_partial.html" with pressr=pressr show="summary" only %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
<p><span class="continued"><a href="/news/">Conservancy News Archive…</a></span></p>
|
||||
</div>
|
||||
|
||||
|
|
|
@ -6,13 +6,8 @@
|
|||
|
||||
<h2>Conservancy News Index - {{ day|date:"F j, 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" }}</i></li>
|
||||
{% for pressr in object_list %}
|
||||
{% include "news/pressrelease_partial.html" with pressr=pressr show="dateline" only %}
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -6,13 +6,8 @@
|
|||
|
||||
<h2>Conservancy News Index - {{ month|date:"F 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" }}</i></li>
|
||||
{% for pressr in object_list %}
|
||||
{% include "news/pressrelease_partial.html" with pressr=pressr show="dateline" only %}
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
|
||||
{% endblock %}
|
||||
|
|
|
@ -7,13 +7,9 @@
|
|||
<div id="mainContent">
|
||||
<h2>Conservancy News Index - {{ 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" }}</i></li>
|
||||
{% for pressr in object_list %}
|
||||
{% include "news/pressrelease_partial.html" with pressr=pressr show="dateline" only %}
|
||||
{% endfor %}
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -5,14 +5,6 @@
|
|||
{% block content %}
|
||||
|
||||
<div id="mainContent">
|
||||
<p class="date">{{ object.pub_date|date:"F j, Y" }}</p>
|
||||
<h2>{{ object.headline|safe }}</h2>
|
||||
{% if object.subhead %}
|
||||
<h3>{{ object.subhead|safe }}</h3>
|
||||
{% endif %}
|
||||
|
||||
{{ object.summary|safe }}
|
||||
|
||||
{{ object.body|safe }}
|
||||
{% include "news/pressrelease_partial.html" with pressr=object htag="h2" only %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -15,13 +15,11 @@
|
|||
|
||||
{% ifnotequal news.number 1 %}<p>(Page {{ news.number }} of {{ news.paginator.num_pages }})</p>{% endifnotequal %}
|
||||
|
||||
{% for news_item in news %}
|
||||
<p class="date">{{ news_item.pub_date|date:"F j, Y" }}</p>
|
||||
<h3><a href="{{ news_item.get_absolute_url }}">{{ news_item.headline|safe }}</a></h3>
|
||||
{% if news_item.is_recent %}
|
||||
{% if news_item.subhead %}<h4>{{ news_item.subhead|safe }}</h4>{% endif %}
|
||||
{{ news_item.summary|safe }}
|
||||
{% if news_item.body %}<p><span class="continued"><a href="{{ news_item.get_absolute_url }}">Read More...</a></span></p>{% endif %}
|
||||
{% for pressr in news %}
|
||||
{% if pressr.is_recent %}
|
||||
{% include "news/pressrelease_partial.html" with pressr=pressr show="summary" only %}
|
||||
{% else %}
|
||||
{% include "news/pressrelease_partial.html" with pressr=pressr show="dateline" only %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
|
|
49
www/conservancy/templates/news/pressrelease_partial.html
Normal file
49
www/conservancy/templates/news/pressrelease_partial.html
Normal file
|
@ -0,0 +1,49 @@
|
|||
{% comment %}
|
||||
|
||||
This partial requires these parameters:
|
||||
|
||||
* `pressr`: The PressRelease object to render.
|
||||
|
||||
This partial accepts these optional parameters:
|
||||
|
||||
* `show`: How much of the PressRelease to render. Accepted values are
|
||||
"headline", "dateline", "subhead", "summary", and "body".
|
||||
Every value will render the parts listed before it. Default "body".
|
||||
* `htag`: Name of the HTML tag to render the pressr headline.
|
||||
If you're passing show="subhead" or a greater detail level, this
|
||||
must be a headline tag h1 through h5, inclusive. Default "h3".
|
||||
|
||||
{% endcomment %}
|
||||
|
||||
<div class="press-release">
|
||||
|
||||
<{{ htag|default:"h3" }} class="clear"
|
||||
>{% if show|default:"body" != "body" %}<a href="{{ pressr.get_absolute_url }}"
|
||||
>{% endif %}{{ pressr.headline|safe }}{% if show|default:"body" != "body" %}</a>{% endif %}</{{ htag|default:"h3" }}>
|
||||
|
||||
{% if show != "headline" %}
|
||||
{% if show != "dateline" and pressr.subhead %}
|
||||
{# This filter sequence generates the "next" hN tag from htag #}
|
||||
<h{{ htag|default:"3"|last|get_digit:1|add:1 }}
|
||||
>{{ pressr.subhead|safe }}</h{{ htag|default:"3"|last|get_digit:1|add:1 }}>
|
||||
{% endif %}
|
||||
|
||||
<p class="date">{{ pressr.pub_date|date:"F j, Y" }}</p>
|
||||
|
||||
{% if show != "dateline" and show != "subhead" %}
|
||||
{% if pressr.summary %}
|
||||
{{ pressr.summary|safe }}
|
||||
{% endif %}
|
||||
|
||||
{% if pressr.body %}
|
||||
{% if show == "summary" %}
|
||||
<p><a class="continued" href="{{ pressr.get_absolute_url }}">Read More…</a></p>
|
||||
{% else %}
|
||||
{{ pressr.body|safe }}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}{# show != "headline" #}
|
||||
|
||||
</div>
|
Loading…
Reference in a new issue