Changeset - e7c1171b6e3d
[Not reviewed]
0 8 1
Brett Smith (brett) - 7 years ago 2016-12-31 04:12:09
brett@sfconservancy.org
blog: Refactor entry rendering into a partial.

This helps ensure that entries are rendered consistently wherever they
appear.
9 files changed with 68 insertions and 76 deletions:
0 comments (0 inline, 0 general)
www/conservancy/static/css/conservancy.css
Show inline comments
...
 
@@ -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;
www/conservancy/templates/blog/entry_archive_day.html
Show inline comments
...
 
@@ -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 %}
www/conservancy/templates/blog/entry_archive_month.html
Show inline comments
...
 
@@ -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 %}
www/conservancy/templates/blog/entry_archive_year.html
Show inline comments
...
 
@@ -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 %}
www/conservancy/templates/blog/entry_detail.html
Show inline comments
...
 
@@ -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&hellip;</a></span></p>
 

	
www/conservancy/templates/blog/entry_list.html
Show inline comments
...
 
@@ -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>
www/conservancy/templates/blog/entry_partial.html
Show inline comments
 
new file 100644
 
{% 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&hellip;</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>
www/conservancy/templates/contractpatch/index.html
Show inline comments
...
 
@@ -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>
www/conservancy/templates/frontpage.html
Show inline comments
...
 
@@ -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&hellip;</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&hellip;</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&hellip;</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&hellip;</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&hellip;</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&hellip;</a></span></p>
 
</div>
0 comments (0 inline, 0 general)