Skip to content
Permalink
Browse files

Simplifying interface of get_classification_friendly_name.

  • Loading branch information
felixfontein committed Dec 1, 2016
1 parent b542321 commit f55b584765e6a0d9059b1c871e798bd79f317de1
@@ -655,10 +655,6 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
The result of this function is usually displayed to the user, instead
of using the classification string.
For hierarchical taxonomies, the result of extract_hierarchy is provided
as `classification`. For non-hierarchical taxonomies, the classification
string itself is provided as `classification`.
The argument `only_last_component` is only relevant to hierarchical
taxonomies. If it is set, the printable name should only describe the
last component of `classification` if possible.
@@ -74,10 +74,7 @@ def _do_classification(self, site):
else:
post.meta[lang][taxonomy.metadata_name] = classifications[lang][0] if len(classifications[lang]) > 0 else None
if taxonomy.metadata_friendly_name is not None:
if taxonomy.has_hierarchy:
friendly_names = [taxonomy.get_classification_friendly_name(taxonomy.extract_hierarchy(classification), lang) for classification in classifications[lang]]
else:
friendly_names = [taxonomy.get_classification_friendly_name(classification, lang) for classification in classifications[lang]]
friendly_names = [taxonomy.get_classification_friendly_name(classification, lang) for classification in classifications[lang]]
if taxonomy.more_than_one_classifications_per_post:
post.meta[lang][taxonomy.metadata_friendly_name] = friendly_names
else:
@@ -92,6 +92,7 @@ def sort_classifications(self, classifications, lang, level=None):

def get_classification_friendly_name(self, classification, lang, only_last_component=False):
"""Extract a friendly name from the classification."""
classification = self.extract_hierarchy(classification)
if len(classification) == 0:
return ""
elif len(classification) == 1:
@@ -65,9 +65,9 @@ def classify(self, post, lang):
i = destpath.rfind('/')
return destpath[:i] if i >= 0 else ''

def get_classification_friendly_name(self, hierarchy, lang, only_last_component=False):
def get_classification_friendly_name(self, dirname, lang, only_last_component=False):
"""Extract a friendly name from the classification."""
return '/'.join(hierarchy)
return dirname

def get_path(self, hierarchy, lang, type='page'):
"""A path handler for the given classification."""
@@ -247,7 +247,7 @@ def _generate_subclassification_page(self, taxonomy, node, context, kw, lang):
"""Render a list of subclassifications."""
def get_subnode_data(subnode):
return [
taxonomy.get_classification_friendly_name(subnode.classification_path, lang, only_last_component=True),
taxonomy.get_classification_friendly_name(subnode.classification_name, lang, only_last_component=True),
self.site.link(taxonomy.classification_name, subnode.classification_name, lang),
len(self._filter_list(self.site.posts_per_classification[taxonomy.classification_name][lang][subnode.classification_name], lang))
]

0 comments on commit f55b584

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