Changeset - d5f461d87963
[Not reviewed]
0 6 1
Brett Smith (brett) - 4 years ago 2016-12-31 04:12:09
brett@sfconservancy.org
news: Refactor press release rendering into a partial.

Same rationale as a few commits ago for blog entries.
7 files changed with 69 insertions and 55 deletions:
0 comments (0 inline, 0 general)
www/conservancy/templates/frontpage.html
Show inline comments
...
 
@@ -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 %}
 
{% 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&hellip;</a></span></p>
 
</div>
 

	
www/conservancy/templates/news/pressrelease_archive_day.html
Show inline comments
...
 
@@ -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 %}
www/conservancy/templates/news/pressrelease_archive_month.html
Show inline comments
...
 
@@ -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 %}
www/conservancy/templates/news/pressrelease_archive_year.html
Show inline comments
...
 
@@ -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 %}
www/conservancy/templates/news/pressrelease_detail.html
Show inline comments
...
 
@@ -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 %}
www/conservancy/templates/news/pressrelease_list.html
Show inline comments
...
 
@@ -15,14 +15,12 @@
 

	
 
{% 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 %}
 
    {% 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 %}
 

	
 
<p>
www/conservancy/templates/news/pressrelease_partial.html
Show inline comments
 
new file 100644
 
{% 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&hellip;</a></p>
 
    {% else %}
 
      {{ pressr.body|safe }}
 
    {% endif %}
 
  {% endif %}
 
{% endif %}
 

	
 
{% endif %}{# show != "headline" #}
 

	
 
</div>
0 comments (0 inline, 0 general)