Skip to content
Permalink
Browse files

Allow to ensure that some classifications are always present.

  • Loading branch information
felixfontein committed Oct 19, 2016
1 parent 5c7f333 commit 3b457f512550cf0da49162cdabde0465f9ef0346
@@ -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.
@@ -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()):
@@ -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]
@@ -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 [""]

0 comments on commit 3b457f5

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