Commits

David Chambers  committed 48ac190

Added `pubdate` and `pubtime` template filters.

  • Participants
  • Parent commits 95c4664

Comments (0)

Files changed (6)

File templates/archives.dhtml

                     <ol>{% for post in posts %}
                         <li>
                             <a href="{{ post.permalink }}">{{ post.title }}</a>
-                            <time datetime="{{ post.datetime|isoformat }}">{{ post.datetime|display_date }}</time>
+                            <time datetime="{{ post.datetime|isoformat }}">{{ post|pubdate }}</time>
                         </li>{% endfor %}
                     </ol>
                 </li>{% endfor %}

File templates/document.dhtml

                 <article>
                     <header>
                         <h1>{{ document.title }}</h1>{% if document.datetime %}
-                        <time datetime="{{ document.datetime|isoformat }}" pubdate="pubdate">{{ document.datetime|display_date }}</time>{% endif %}
+                        <time datetime="{{ document.datetime|isoformat }}" pubdate="pubdate">{{ document|pubdate }}</time>{% endif %}
                     </header>
                     {{ document.html }}{% with document.shorturl as short %}{% with document.permalink as canon %}{% if document.author or document.tags or short != canon %}
                     <footer class="metadata">{% if document.author or short != canon %}

File templates/excerpt.dhtml

             <article>{% if document.title or document.datetime %}
                 <header>{% if document.title %}
                     <h2><a href="{{ document.permalink }}">{{ document.title }}</a></h2>{% endif %}{% if document.datetime %}
-                    <time datetime="{{ document.datetime|isoformat }}" pubdate="pubdate">{{ document.datetime|display_date }}</time>{% endif %}
+                    <time datetime="{{ document.datetime|isoformat }}" pubdate="pubdate">{{ document|pubdate }}</time>{% endif %}
                 </header>{% endif %}
                 {{ document.excerpt }}
             </article>

File templates/searchresults.dhtml

             </ol>{% endif %}{% if results.posts %}
             <h2>Posts</h2>
             <ol class="searchresults">{% for post in results.posts %}
-                <li><a href="{{ post.permalink }}">{{ post.title }}</a> (<time datetime="{{ post.datetime|isoformat }}">{{ post.datetime|display_date }}</time>)</li>{% endfor %}
+                <li><a href="{{ post.permalink }}">{{ post.title }}</a> (<time datetime="{{ post.datetime|isoformat }}">{{ post|pubdate }}</time>)</li>{% endfor %}
             </ol>{% endif %}{% else %}
             <p>There are currently no documents that match your search term{{ terms|pluralize }}.</p>{% endif %}
 {% endblock %}

File templates/update.dhtml

 <div class="update"><div>{% load mango_extras %}
-<h4>Update{% if update.datetime %} — <time datetime="{{ update.datetime|isoformat }}">{{ update.datetime|display_date }}</time>{% endif %}</h4>
+<h4>Update{% if update.datetime %} — <time datetime="{{ update.datetime|isoformat }}">{{ update|pubdate }}</time>{% endif %}</h4>
 {{ update.html }}
 </div></div>

File templatetags/mango_extras.py

     return calendar.month_name[n]
 
 @register.filter
+def pubdate(document):
+    return display_date(document.datetime)
+
+@register.filter
+def pubtime(document):
+    return display_time(document.datetime)
+
+@register.filter
 def required(documents, kind):
     seen = {}
     urlpaths = []