Skip to content

Commit

Permalink
Allowing to put friendly names into metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Nov 29, 2016
1 parent a4ad4bd commit c37a366
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions nikola/plugin_categories.py
Expand Up @@ -493,6 +493,11 @@ class Taxonomy(BasePlugin):
in the metadata. If set to None, the classification won't be stored
in the metadata.
metadata_friendly_name = None:
The name to be used when storing the friendly names of the classification
in the metadata. If set to None, the friendly names won't be stored
in the metadata.
overview_page_variable_name = "taxonomy":
When rendering the overview page, its template will have a list
of classifications available in a variable by this name.
Expand Down Expand Up @@ -576,6 +581,7 @@ class Taxonomy(BasePlugin):
# Adjust the following values in your plugin!
classification_name = "taxonomy"
metadata_name = "taxonomy"
metadata_friendly_name = None
overview_page_variable_name = "taxonomy"
overview_page_hierarchy_variable_name = "taxonomy_hierarchy"
more_than_one_classifications_per_post = False
Expand Down
6 changes: 6 additions & 0 deletions nikola/plugins/misc/taxonomies_classifier.py
Expand Up @@ -73,6 +73,12 @@ def _do_classification(self, site):
post.meta[lang][taxonomy.metadata_name] = classifications[lang]
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:
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:
post.meta[lang][taxonomy.metadata_friendly_name] = friendly_names[0] if len(friendly_names) > 0 else None
# Add post to sets
for classification in classifications[lang]:
while True:
Expand Down

0 comments on commit c37a366

Please sign in to comment.