Skip to content
Permalink
Browse files

Fixing atom feed renderer for empty post lists.

  • Loading branch information
felixfontein committed Sep 6, 2015
1 parent 27dca29 commit d8992df7baaac6b74213ca15143e95c1b3f20740
Showing with 18 additions and 16 deletions.
  1. +1 −1 nikola/nikola.py
  2. +1 −14 nikola/post.py
  3. +16 −1 nikola/utils.py
@@ -1822,7 +1822,7 @@ def atom_link(link_rel, link_type, link_href):
feed_id = lxml.etree.SubElement(feed_root, "id")
feed_id.text = self.abs_link(context["feedlink"])
feed_updated = lxml.etree.SubElement(feed_root, "updated")
feed_updated.text = post.formatted_date('webiso', datetime.datetime.now(tz=dateutil.tz.tzutc()))
feed_updated.text = utils.formatted_date('webiso', datetime.datetime.now(tz=dateutil.tz.tzutc()))
feed_author = lxml.etree.SubElement(feed_root, "author")
feed_author_name = lxml.etree.SubElement(feed_author, "name")
feed_author_name.text = self.config["BLOG_AUTHOR"](lang)
@@ -56,7 +56,6 @@
# for tearDown with _reload we cannot use 'from import' to get forLocaleBorg
import nikola.utils
from .utils import (
bytes_str,
current_time,
Functionary,
LOGGER,
@@ -324,19 +323,7 @@ def template_name(self):

def formatted_date(self, date_format, date=None):
"""Return the formatted date as unicode."""
date = date if date else self.date

if date_format == 'webiso':
# Formatted after RFC 3339 (web ISO 8501 profile) with Zulu
# zone desgignator for times in UTC and no microsecond precision.
fmt_date = date.replace(microsecond=0).isoformat().replace('+00:00', 'Z')
else:
fmt_date = date.strftime(date_format)

# Issue #383, this changes from py2 to py3
if isinstance(fmt_date, bytes_str):
fmt_date = fmt_date.decode('utf8')
return fmt_date
return utils.formatted_date(date_format, date if date else self.date)

def formatted_updated(self, date_format):
"""Return the updated date as unicode."""
@@ -71,7 +71,7 @@
'adjust_name_for_index_path', 'adjust_name_for_index_link',
'NikolaPygmentsHTML', 'create_redirect', 'TreeNode',
'flatten_tree_structure', 'parse_escaped_hierarchical_category_name',
'join_hierarchical_category_path', 'indent')
'join_hierarchical_category_path', 'indent', 'formatted_date')

# Are you looking for 'generic_rss_renderer'?
# It's defined in nikola.nikola.Nikola (the site object).
@@ -1732,3 +1732,18 @@ def prefixed_lines():
for line in text.splitlines(True):
yield (prefix + line if predicate(line) else line)
return ''.join(prefixed_lines())


def formatted_date(date_format, date):
"""Return the formatted date as unicode."""
if date_format == 'webiso':
# Formatted after RFC 3339 (web ISO 8501 profile) with Zulu
# zone desgignator for times in UTC and no microsecond precision.
fmt_date = date.replace(microsecond=0).isoformat().replace('+00:00', 'Z')
else:
fmt_date = date.strftime(date_format)

# Issue #383, this changes from py2 to py3
if isinstance(fmt_date, bytes_str):
fmt_date = fmt_date.decode('utf8')
return fmt_date

0 comments on commit d8992df

Please sign in to comment.
You can’t perform that action at this time.