Skip to content
Permalink
Browse files

Improving naming.

  • Loading branch information
felixfontein committed Dec 2, 2016
1 parent 91b1f05 commit e91fe1d74da59cf30364522ba104d4df4f1d7b00
@@ -526,12 +526,12 @@ class Taxonomy(BasePlugin):
Whether the classification has a hierarchy.
include_posts_from_subhierarchies = False:
If True, the list for a classification includes all posts with a
If True, the post list for a classification includes all posts with a
sub-classification (in case has_hierarchy is True).
include_posts_into_hierarchy_root = False:
If True, include_posts_from_subhierarchies == True will also insert
posts into the list for the empty hierarchy [].
posts into the post list for the empty hierarchy [].
show_list_as_subcategories_list = False:
If True, for every classification which has at least one
@@ -673,8 +673,8 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
"""
raise NotImplementedError()

def get_list_path(self, lang, type='page'):
"""A path handler for the list of all classifications.
def get_overview_path(self, lang, type='page'):
"""A path handler for the classification overview.
Must return one or two values (in this order):
* a list or tuple of strings: the path relative to OUTPUT_DIRECTORY;
@@ -735,8 +735,8 @@ def recombine_classification_from_hierarchy(self, hierarchy):
"""
return hierarchy[0]

def provide_list_context_and_uptodate(self, lang):
"""Provide data for the context and the uptodate list for the list of all classifiations.
def provide_overview_context_and_uptodate(self, lang):
"""Provide data for the context and the uptodate list for the classifiation overview.
Must return a tuple of two dicts. The first is merged into the page's context,
the second will be put into the uptodate list of all generated tasks.
@@ -758,7 +758,7 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
"""
raise NotImplementedError()

def should_generate_classification_list(self, classification, post_list, lang):
def should_generate_classification_page(self, classification, post_list, lang):
"""Only generates list of posts for classification if this function returns True."""
return True

@@ -263,7 +263,7 @@ def _postprocess_path(self, path, lang, append_index='auto', type='page', page_i

@staticmethod
def _parse_path_result(result):
"""Interpret the return values of taxonomy.get_path() and taxonomy.get_list_path() as if all three return values were given."""
"""Interpret the return values of taxonomy.get_path() and taxonomy.get_overview_path() as if all three return values were given."""
if not isinstance(result[0], (list, tuple)):
# The result must be a list or tuple of strings. Wrap into a tuple
result = (result, )
@@ -274,7 +274,7 @@ def _parse_path_result(result):

def _taxonomy_index_path(self, lang, taxonomy):
"""Return path to the classification overview."""
result = taxonomy.get_list_path(lang)
result = taxonomy.get_overview_path(lang)
path, append_index, _ = self._parse_path_result(result)
return self._postprocess_path(path, lang, append_index=append_index, type='list')

@@ -161,6 +161,6 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
kw.update(context)
return context, kw

def should_generate_classification_list(self, classification, post_list, lang):
def should_generate_classification_page(self, classification, post_list, lang):
"""Only generates list of posts for classification if this function returns True."""
return len(classification.split('/')) < 3 or len(post_list) > 0
@@ -72,7 +72,7 @@ def get_classification_friendly_name(self, author, lang, only_last_component=Fal
"""Extract a friendly name from the classification."""
return author

def get_list_path(self, lang, type='page'):
def get_overview_path(self, lang, type='page'):
"""A path handler for the list of all classifications."""
return [self.site.config['AUTHOR_PATH']], 'always'

@@ -84,7 +84,7 @@ def get_path(self, author, lang, type='page'):
slug = author
return [self.site.config['AUTHOR_PATH'], slug], 'auto'

def provide_list_context_and_uptodate(self, lang):
def provide_overview_context_and_uptodate(self, lang):
"""Provide data for the context and the uptodate list for the list of all classifiations."""
kw = {
"messages": self.site.MESSAGES,
@@ -81,7 +81,7 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
classification = self.extract_hierarchy(classification)
return classification[-1] if classification else ''

def get_list_path(self, lang, type='page'):
def get_overview_path(self, lang, type='page'):
"""A path handler for the list of all classifications."""
if self.site.config['CATEGORIES_INDEX_PATH'][lang]:
return [_f for _f in [self.site.config['CATEGORIES_INDEX_PATH'][lang]] if _f], 'never'
@@ -123,7 +123,7 @@ def recombine_classification_from_hierarchy(self, hierarchy):
"""Given a list of parts in the hierarchy, return the classification string."""
return utils.join_hierarchical_category_path(hierarchy)

def provide_list_context_and_uptodate(self, lang):
def provide_overview_context_and_uptodate(self, lang):
"""Provide data for the context and the uptodate list for the list of all classifiations."""
kw = {
'category_path': self.site.config['CATEGORY_PATH'],
@@ -94,7 +94,7 @@ def provide_context_and_uptodate(self, dirname, lang, node=None):
kw.update(context)
return context, kw

def should_generate_classification_list(self, dirname, post_list, lang):
def should_generate_classification_page(self, dirname, post_list, lang):
"""Only generates list of posts for classification if this function returns True."""
short_destination = dirname + '/' + self.site.config['INDEX_FILE']
for post in post_list:
@@ -87,7 +87,7 @@ def slugify_tag_name(self, name, lang):
name = utils.slugify(name, lang)
return name

def get_list_path(self, lang, type='page'):
def get_overview_path(self, lang, type='page'):
"""A path handler for the list of all classifications."""
if self.site.config['TAGS_INDEX_PATH'][lang]:
return [_f for _f in [self.site.config['TAGS_INDEX_PATH'][lang]] if _f], 'never'
@@ -100,7 +100,7 @@ def get_path(self, classification, lang, type='page'):
self.site.config['TAG_PATH'][lang],
self.slugify_tag_name(classification, lang)] if _f], 'auto'

def provide_list_context_and_uptodate(self, lang):
def provide_overview_context_and_uptodate(self, lang):
"""Provide data for the context and the uptodate list for the list of all classifiations."""
kw = {
"tag_path": self.site.config['TAG_PATH'],
@@ -73,7 +73,7 @@ class RenderTaxonomies(Task):

def _generate_classification_overview_kw_context(self, taxonomy, lang):
"""Create context and kw for a classification overview page."""
context, kw = taxonomy.provide_list_context_and_uptodate(lang)
context, kw = taxonomy.provide_overview_context_and_uptodate(lang)

context = copy(context)
kw = copy(kw)
@@ -324,7 +324,7 @@ def _generate_classification_page(self, taxonomy, classification, post_list, lan
if len(filtered_posts) == 0 and taxonomy.omit_empty_classifications:
return
# Should we create this list?
if not taxonomy.should_generate_classification_list(classification, filtered_posts, lang):
if not taxonomy.should_generate_classification_page(classification, filtered_posts, lang):
return
# Get data
node = None

0 comments on commit e91fe1d

Please sign in to comment.