Permalink
Browse files

jsonfeed: support untranslated tags/categories

(Adds support for also_create_classifications_from_other_languages)
h/t @felixfontein

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information...
Kwpolska committed May 21, 2017
1 parent 6b3f840 commit 315c88637b6ae4bcefc20258b963af34a2d8457a
Showing with 14 additions and 13 deletions.
  1. +14 −13 v7/jsonfeed/jsonfeed.py
@@ -91,22 +91,23 @@ def gen_tasks(self):
yield self.generate_feed_task(lang, title, link, description,
timeline, feed_url, output_name)
for classification_name, _langs in self.site.posts_per_classification.items():
classification_timelines = _langs[lang]
if classification_name not in self.supported_taxonomies:
print("Unsupported:", classification_name)
continue
else:
print("Supported:", classification_name)
handler = self.supported_taxonomies[classification_name]
for classification_name, path_handler in self.supported_taxonomies.items():
taxonomy = self.site.taxonomy_plugins[classification_name]
classification_timelines = {}
for tlang, posts_per_classification in self.site.posts_per_classification[taxonomy.classification_name].items():
if lang != tlang and not taxonomy.also_create_classifications_from_other_languages:
continue
classification_timelines.update(posts_per_classification)
for classification, timeline in classification_timelines.items():
title = self.kw['blog_title'](lang) # Debatable
link = self.kw['site_url'] # Debatable
description = self.kw['blog_description'](lang) # Debatable
# TODO better values for ↓↓↓
title = self.kw['blog_title'](lang) # Debatable: could also be classification name etc

This comment has been minimized.

@felixfontein

felixfontein May 21, 2017

Contributor

You could ask the taxonomy object to create context and use the title from there. Then it would be the same title as used for the HTML pages or other feeds.

link = self.kw['site_url'] # Debatable: spec unclear
description = self.kw['blog_description'](lang) # Debatable: do classifications have descriptions?

This comment has been minimized.

@felixfontein

felixfontein May 21, 2017

Contributor

Sections can have them, for example. If you call Taxonomy.provide_context_and_uptodate you can extract title and description from there, and fallback to the defaults you used in case they don't provide them.

This comment has been minimized.

@Kwpolska

Kwpolska May 21, 2017

Member

Yeah, I realized that a while ago. Those were kind of placeholders.

timeline = timeline[:self.kw['feed_length']]
output_name = os.path.normpath(os.path.join(self.site.config['OUTPUT_FOLDER'], self.site.path(handler, classification, lang)))
feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(handler, classification, lang).lstrip('/'))
output_name = os.path.normpath(os.path.join(self.site.config['OUTPUT_FOLDER'], self.site.path(path_handler, classification, lang)))
feed_url = urljoin(self.site.config['BASE_URL'], self.site.link(path_handler, classification, lang).lstrip('/'))
# Special handling for author pages
if classification_name == "author":

0 comments on commit 315c886

Please sign in to comment.