Skip to content

Commit

Permalink
Allow to ensure that some classifications are always present.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Oct 19, 2016
1 parent 5c7f333 commit 3b457f5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions nikola/plugin_categories.py
Expand Up @@ -527,6 +527,10 @@ def is_enabled(self, lang=None):
"""
return True

def get_implicit_classifications(self, lang):
"""Returns a list of classification strings which should always appear in posts_per_classification."""
return []

def classify(self, post, lang):
"""Classify the given post for the given language.
Expand Down
4 changes: 4 additions & 0 deletions nikola/plugins/misc/taxonomies_classifier.py
Expand Up @@ -125,6 +125,10 @@ def _do_classification(self, site):
site.page_count_per_classification[taxonomy.classification_name] = {}
# Sort post lists
for lang, posts_per_classification in site.posts_per_classification[taxonomy.classification_name].items():
# Ensure implicit classifications are inserted
for classification in taxonomy.get_implicit_classifications(lang):
if classification not in posts_per_classification:
posts_per_classification[classification] = []
site.page_count_per_classification[taxonomy.classification_name][lang] = {}
# Convert sets to lists and sort them
for classification in list(posts_per_classification.keys()):
Expand Down
4 changes: 4 additions & 0 deletions nikola/plugins/task/archive.py
Expand Up @@ -75,6 +75,10 @@ def is_enabled(self, lang=None):
"""Return True if this taxonomy is enabled, or False otherwise."""
return True

def get_implicit_classifications(self, lang):
"""Returns a list of classification strings which should always appear in posts_per_classification."""
return ['']

def classify(self, post, lang):
"""Classify the given post for the given language."""
levels = ['{year:04d}', '{month:02d}', '{day:02d}'][:self.max_levels]
Expand Down
4 changes: 4 additions & 0 deletions nikola/plugins/task/indexes.py
Expand Up @@ -55,6 +55,10 @@ def set_site(self, site):
site.register_path_handler('rss', lambda name, lang: site.path_handlers['index_rss'](name, lang))
return super(Indexes, self).set_site(site)

def get_implicit_classifications(self, lang):
"""Returns a list of classification strings which should always appear in posts_per_classification."""
return [""]

def classify(self, post, lang):
"""Classify the given post for the given language."""
return [""]
Expand Down

0 comments on commit 3b457f5

Please sign in to comment.