Changeset - d5f461d87963
[Not reviewed]
0 6 1
Brett Smith (brett) - 5 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 67 insertions and 53 deletions:
0 comments (0 inline, 0 general)
www/conservancy/templates/frontpage.html
Show inline comments
...
 
@@ -17,42 +17,31 @@
 
  helps promote, improve, develop, and defend Free, Libre, and Open Source
 
  Software (FLOSS) projects.  Conservancy provides a non-profit home and
 
  infrastructure for FLOSS projects.  This allows FLOSS developers to
 
  focus on what they do best — writing and improving FLOSS for the
 
  general public — while Conservancy takes care of the projects' needs that
 
  do not relate directly to software development and documentation.</p>
 
</div>
 

	
 
<div class="columns">
 

	
 
<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&hellip;</a></span></p>
 
</div>
 

	
 
<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>
 
{% for entry in blog|slice:":5" %}
 
  {% if forloop.first or entry.pub_date|date_within_past_days:30 %}
 
    {% if not forloop.first %}<hr class="clear">{% endif %}
 
    {% include "blog/entry_partial.html" with entry=entry show="summary" only %}
 
  {% endif %}
 
{% endfor %}
 

	
www/conservancy/templates/news/pressrelease_archive_day.html
Show inline comments
 
{% extends "base_news.html" %}
 

	
 
{% block title %}Conservancy News Index - {{ day|date:"F j, Y" }}{% endblock %}
 

	
 
{% block content %}
 

	
 
<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
 
{% extends "base_news.html" %}
 

	
 
{% block title %}Conservancy News Index - {{ month|date:"F Y" }}{% endblock %}
 

	
 
{% block content %}
 

	
 
<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
 
{% extends "base_news.html" %}
 

	
 
{% block title %}Conservancy News Index - {{ year|date:"Y" }}{% endblock %}
 

	
 
{% block content %}
 

	
 
         <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
 
{% extends "base_news.html" %}
 

	
 
{% block subtitle %}{{ object.headline|striptags|safe }} - {% endblock %}
 

	
 
{% 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
...
 
@@ -6,31 +6,29 @@
 
         <div id="sidebar" class="{% block submenuselection %}other{% endblock %}">
 
         <h2>News Index by Year</h2>
 
         <ul>
 
         {% for year in date_list reversed %}<li class="{{ year|date:"Y" }}"><a href="{{ year|date:"Y" }}/">{{ year|date:"Y" }}</a></li>{% endfor %}
 
         </ul>
 
         </div>
 
         <div id="mainContent">
 
         <h1><a href="/feeds/news/" class="feedlink"><img src="/img/feed-icon-14x14.png" alt="[RSS]"/></a> Conservancy News</h1>
 

	
 

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

	
 
<p>
 
{% if news.has_next %}<a class="next_page_button" href="?page={{ news.next_page_number }}">Next page (older) &raquo;</a>{% endif %}
 
{% if news.has_previous %}<a href="?page={{ news.previous_page_number }}">&laquo; Previous page (newer)</a>{% endif %}
 
</p>
 
{% if news.paginator.num_pages > 1 %}<p class="pagination_list"> {% for pagenum in news.paginator.page_range %}{% ifequal pagenum news.number %}[{{ pagenum }}]{% else %}<a href="?page={{ pagenum }}">{{ pagenum }}</a>{% endifequal %} {% endfor %}</p>{% endif %}
 
         </div>
 
 </div>
 
<div class="clear"></div>
 

	
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)