Skip to content
Permalink
Browse files

POSTS_CATEGORY_TITLES for every preference

  • Loading branch information
da2x committed Aug 27, 2015
1 parent ea8738b commit bd27b766aba34db5d42d8a52a8e23678c2fc99ed
Showing with 19 additions and 4 deletions.
  1. +9 −0 nikola/conf.py.in
  2. +10 −4 nikola/plugins/task/indexes.py
@@ -254,6 +254,15 @@ POSTS_CATEGORY_DESCRIPTIONS = {
# },
# }

# Titles for per-category index pages. Can be either one string where "%s"
# is substituted or the POSTS_CATEGORY_NAME, or a dict of categories. Note
# that the INDEX_PAGES option is also applied to category page titles.
POSTS_CATEGORY_TITLE = {
DEFAULT_LANG: {
'how-to': 'How-to and Tutorials',
},
}

# Paths for different autogenerated bits. These are combined with the
# translation paths.

@@ -102,8 +102,6 @@ def page_path(i, displayed_i, num_pages, force_addition, extension=None):
if self.site.config['POSTS_CATEGORIES']:

kw["posts_category_are_indexes"] = self.site.config['POSTS_CATEGORY_ARE_INDEXES']
kw["posts_category_title"] = self.site.config['POSTS_CATEGORY_TITLE'](lang)

index_len = len(kw['index_file'])

groups = defaultdict(list)
@@ -115,7 +113,6 @@ def page_path(i, displayed_i, num_pages, force_addition, extension=None):
continue

for dirname, post_list in groups.items():

if lang not in self.number_of_pages_cat:
self.number_of_pages_cat[lang] = dict()
self.number_of_pages_cat[lang][dirname] = (len(post_list) + kw['index_display_post_count'] - 1) // kw['index_display_post_count']
@@ -142,7 +139,16 @@ def cat_path(i, displayed_i, num_pages, force_addition, extension=None):

if kw["posts_category_are_indexes"]:
context["pagekind"].append("index")
indexes_title = post_list[0].category_name(lang) # all posts in the list share category name
kw["posts_category_title"] = self.site.config['POSTS_CATEGORY_TITLE'](lang)
if type(kw["posts_category_title"]) is dict:
if dirname in kw["posts_category_title"]:
indexes_title = kw["posts_category_title"][dirname]
elif type(kw["posts_category_title"]) is str:
indexes_title = kw["posts_category_title"]
if not indexes_title:
indexes_title = post_list[0].category_name(lang)
indexes_title = indexes_title.format(post_list[0].category_name(lang))

task = self.site.generic_index_renderer(lang, post_list, indexes_title, "categoryindex.tmpl", context, kw, self.name, cat_link, cat_path)
else:
context["pagekind"].append("list")

0 comments on commit bd27b76

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