Skip to content
Permalink
Browse files

Atom for tag lists

Fixes #1686.
  • Loading branch information
da2x committed Aug 31, 2015
1 parent 86aa454 commit 9a07634edf97d0295e6053988f5f95ff9f208bb1
Showing with 28 additions and 4 deletions.
  1. +1 −0 CHANGES.txt
  2. +4 −4 nikola/nikola.py
  3. +23 −0 nikola/plugins/task/tags.py
@@ -4,6 +4,7 @@ New in master
Features
--------

* Atom feeds for tag lists (Issue #1686)
* New ``THEME_COLOR`` option for customizing themes from a primary color
(Issue #1980)
* New ``color_hsl_adjust_hex`` and ``colorize_str_from_base_color``
@@ -1778,7 +1778,7 @@ def atom_link(link_rel, link_type, link_href):
deps_context['navigation_links'] = deps_context['global']['navigation_links'](lang)

nslist = {}
if context["is_feed_stale"] or (not context["feedpagenum"] == context["feedpagecount"] - 1 and not context["feedpagenum"] == 0):
if context["is_feed_stale"] or "feedpagenum" in context and (not context["feedpagenum"] == context["feedpagecount"] - 1 and not context["feedpagenum"] == 0):
nslist["fh"] = "http://purl.org/syndication/history/1.0"
if not self.config["RSS_TEASERS"]:
nslist["xh"] = "http://www.w3.org/1999/xhtml"
@@ -1807,17 +1807,17 @@ def atom_link(link_rel, link_type, link_href):
if "prevfeedlink" in context:
feed_root.append(atom_link("previous", "application/atom+xml",
self.abs_link(context["prevfeedlink"])))
if context["is_feed_stale"] or not context["feedpagenum"] == 0:
if context["is_feed_stale"] or "feedpagenum" in context and not context["feedpagenum"] == 0:
feed_root.append(atom_link("current", "application/atom+xml",
self.abs_link(context["currentfeedlink"])))
# Older is "prev-archive" and newer is "next-archive" in archived feeds (opposite of paginated)
if "prevfeedlink" in context and (context["is_feed_stale"] or not context["feedpagenum"] == context["feedpagecount"] - 1):
if "prevfeedlink" in context and (context["is_feed_stale"] or "feedpagenum" in context and not context["feedpagenum"] == context["feedpagecount"] - 1):
feed_root.append(atom_link("next-archive", "application/atom+xml",
self.abs_link(context["prevfeedlink"])))
if "nextfeedlink" in context:
feed_root.append(atom_link("prev-archive", "application/atom+xml",
self.abs_link(context["nextfeedlink"])))
if context["is_feed_stale"] or not context["feedpagenum"] == context["feedpagecount"] - 1:
if context["is_feed_stale"] or "feedpagenum" and not context["feedpagenum"] == context["feedpagecount"] - 1:
lxml.etree.SubElement(feed_root, "{http://purl.org/syndication/history/1.0}archive")
feed_root.append(atom_link("alternate", "text/html",
self.abs_link(context["permalink"])))
@@ -333,6 +333,29 @@ def tag_page_as_list(self, tag, lang, post_list, kw, is_category):
task['basename'] = str(self.name)
yield task

if self.site.config['GENERATE_ATOM']:
self.atom_feed_list(kind, lang, post_list, context)


def atom_feed_list(self, kind, lang, post_list, context):
if kind == 'tag':
context['feedlink'] = self.site.abs_link(self.site.path('tag_atom', tag, lang))
feed_path = os.path.join(kw['output_folder'], self.site.path('tag_atom', tag, lang))
elif kind == 'category':
context['feedlink'] = self.site.abs_link(self.site.path('category_atom', tag, lang))
feed_path = os.path.join(kw['output_folder'], self.site.path('category_atom', tag, lang))

task = {
'basename': str(self.name),
'name': feed_path,
'targets': [feed_path],
'actions': [(self.site.atom_feed_renderer, (lang, post_list, feed_path, kw['filters'], context))],
'clean': True,
'uptodate': [utils.config_changed(kw, 'nikola.plugins.task.tags:atom')],
'task_dep': ['render_posts'],
}
yield task

def tag_rss(self, tag, lang, posts, kw, is_category):
"""Create a RSS feed for a single tag in a given language."""
kind = "category" if is_category else "tag"

0 comments on commit 9a07634

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