Skip to content

Commit

Permalink
Removing option add_postcount_in_overview (always enabled).
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Dec 3, 2016
1 parent d5d9c8e commit b5bfd49
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 31 deletions.
22 changes: 12 additions & 10 deletions nikola/plugin_categories.py
Expand Up @@ -504,6 +504,11 @@ class Taxonomy(BasePlugin):
(friendly_name, link)
for the classifications available in a variable by this name.
The template will also have a list
(friendly_name, link, post_count)
for the classifications available in a variable by the name
`overview_page_items_variable_name + '_with_postcount'`.
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 All @@ -516,6 +521,13 @@ class Taxonomy(BasePlugin):
available in a variable by this name. These tuples can be used
to render the hierarchy as a tree.
The template will also have a list
(friendly_name, classification, classification_path, link,
indent_levels, indent_change_before, indent_change_after,
number_of_children, post_count)
available in the variable by the name
`overview_page_hierarchy_variable_name + '_with_postcount'`.
more_than_one_classifications_per_post = False:
If True, there can be more than one classification per post; in that case,
the classification data in the metadata is stored as a list. If False,
Expand Down Expand Up @@ -559,15 +571,6 @@ class Taxonomy(BasePlugin):
The template to use for the classification overview page.
Set to None to avoid generating overviews.
add_postcount_in_overview = False:
If set to True, two more variables `'items_with_postcount'` and
`overview_page_hierarchy_variable_name + '_with_postcount'` (for
hierarchical taxonomies) besides the `'items'` and
`overview_page_hierarchy_variable_name` will be available in the
overview page's template. These new variables will contain the post
count for every classification, and in case of the hierarchy, also
the number of children for every node.
always_disable_rss = False:
Whether to always disable RSS feed generation
Expand Down Expand Up @@ -610,7 +613,6 @@ class Taxonomy(BasePlugin):
generate_atom_feeds_for_post_lists = False
template_for_single_list = "tagindex.tmpl"
template_for_classification_overview = "list.tmpl"
add_postcount_in_overview = False
always_disable_rss = False
apply_to_posts = True
apply_to_pages = False
Expand Down
1 change: 0 additions & 1 deletion nikola/plugins/task/categories.py
Expand Up @@ -53,7 +53,6 @@ class ClassifyCategories(Taxonomy):
show_list_as_subcategories_list = False
generate_atom_feeds_for_post_lists = True
template_for_classification_overview = "tags.tmpl"
add_postcount_in_overview = True
always_disable_rss = False
apply_to_posts = True
apply_to_pages = False
Expand Down
1 change: 0 additions & 1 deletion nikola/plugins/task/tags.py
Expand Up @@ -50,7 +50,6 @@ class ClassifyTags(Taxonomy):
show_list_as_subcategories_list = False
generate_atom_feeds_for_post_lists = True
template_for_classification_overview = "tags.tmpl"
add_postcount_in_overview = True
always_disable_rss = False
apply_to_posts = True
apply_to_pages = False
Expand Down
36 changes: 17 additions & 19 deletions nikola/plugins/task/taxonomies.py
Expand Up @@ -109,15 +109,14 @@ def acceptor(node):
items = [(classification,
self.site.link(taxonomy.classification_name, classification, lang))
for classification in classifications]
items_with_postcount = [
(classification,
self.site.link(taxonomy.classification_name, classification, lang),
len(self._filter_list(self.site.posts_per_classification[taxonomy.classification_name][lang][classification], lang)))
for classification in classifications
]
context[taxonomy.overview_page_items_variable_name] = items
if taxonomy.add_postcount_in_overview:
items_with_postcount = [
(classification,
self.site.link(taxonomy.classification_name, classification, lang),
len(self._filter_list(self.site.posts_per_classification[taxonomy.classification_name][lang][classification], lang)))
for classification in classifications
]
context[taxonomy.overview_page_items_variable_name + "_with_postcount"] = items_with_postcount
context[taxonomy.overview_page_items_variable_name + "_with_postcount"] = items_with_postcount
if taxonomy.has_hierarchy and taxonomy.overview_page_hierarchy_variable_name:
hier_items = [
(node.name, node.classification_name, node.classification_path,
Expand All @@ -126,18 +125,17 @@ def acceptor(node):
node.indent_change_after)
for node in clipped_flat_hierarchy
]
hier_items_with_postcount = [
(node.name, node.classification_name, node.classification_path,
self.site.link(taxonomy.classification_name, node.classification_name, lang),
node.indent_levels, node.indent_change_before,
node.indent_change_after,
len(node.children),
len(self._filter_list(self.site.posts_per_classification[taxonomy.classification_name][lang][node.classification_name], lang)))
for node in clipped_flat_hierarchy
]
context[taxonomy.overview_page_hierarchy_variable_name] = hier_items
if taxonomy.add_postcount_in_overview:
hier_items_with_postcount = [
(node.name, node.classification_name, node.classification_path,
self.site.link(taxonomy.classification_name, node.classification_name, lang),
node.indent_levels, node.indent_change_before,
node.indent_change_after,
len(node.children),
len(self._filter_list(self.site.posts_per_classification[taxonomy.classification_name][lang][node.classification_name], lang)))
for node in clipped_flat_hierarchy
]
context[taxonomy.overview_page_hierarchy_variable_name + '_with_postcount'] = hier_items_with_postcount
context[taxonomy.overview_page_hierarchy_variable_name + '_with_postcount'] = hier_items_with_postcount
return context, kw

def _render_classification_overview(self, classification_name, template, lang, context, kw):
Expand Down

0 comments on commit b5bfd49

Please sign in to comment.