Skip to content

Commit

Permalink
fix #210 -- implement INDEXES_PAGES support for all pages
Browse files Browse the repository at this point in the history
Signed-off-by: Chris “Kwpolska” Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jan 20, 2014
1 parent da8f087 commit 983600c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
11 changes: 7 additions & 4 deletions nikola/conf.py.in
Expand Up @@ -271,10 +271,13 @@ COMPILERS = ${COMPILERS}
# HTML fragments and diverse things that are used by the templates
# #############################################################################

# Data about post-per-page indexes
# INDEXES_TITLE = "" # If this is empty, the default is BLOG_TITLE
# INDEXES_PAGES = "" # If this is empty, the default is 'old posts page %d'
# translated
# Data about post-per-page indexes.
# INDEXES_PAGES defaults to 'old posts page %d' or 'page %d' (translated),
# depending on the value of INDEXES_PAGES_MAIN.
# INDEXES_TITLE = "" # If this is empty, defaults to BLOG_TITLE
# INDEXES_PAGES = "" # If this is empty, defaults to '[old posts] page %d' (see above)
# INDEXES_PAGES_MAIN = False # If True, INDEXES_PAGES is also displayed on
# the main (the newest) index page (index.html)

# Name of the theme to use.
THEME = "${THEME}"
Expand Down
1 change: 1 addition & 0 deletions nikola/nikola.py
Expand Up @@ -169,6 +169,7 @@ def __init__(self, **config):
'INDEX_TEASERS': False,
'INDEXES_TITLE': "",
'INDEXES_PAGES': "",
'INDEXES_PAGES_MAIN': False,
'INDEX_PATH': '',
'IPYNB_CONFIG': {},
'LESS_COMPILER': 'lessc',
Expand Down
13 changes: 10 additions & 3 deletions nikola/plugins/task/indexes.py
Expand Up @@ -57,6 +57,7 @@ def gen_tasks(self):
"hide_untranslated_posts": self.site.config['HIDE_UNTRANSLATED_POSTS'],
"indexes_title": self.site.config['INDEXES_TITLE'],
"indexes_pages": self.site.config['INDEXES_PAGES'],
"indexes_pages_main": self.site.config['INDEXES_PAGES_MAIN'],
"blog_title": self.site.config["BLOG_TITLE"],
}

Expand All @@ -78,12 +79,18 @@ def gen_tasks(self):
for i, post_list in enumerate(lists):
context = {}
indexes_title = kw['indexes_title'] or kw['blog_title']
if kw["indexes_pages_main"]:
ipages_i = i + 1
ipages_msg = "page %d"
else:
ipages_i = i
ipages_msg = "old posts page %d"
if kw["indexes_pages"]:
indexes_pages = kw["indexes_pages"] % i
indexes_pages = kw["indexes_pages"] % ipages_i
else:
indexes_pages = " (" + \
kw["messages"][lang]["old posts page %d"] % i + ")"
if i > 0:
kw["messages"][lang][ipages_msg] % ipages_i + ")"
if i > 0 or kw["indexes_pages_main"]:
context["title"] = indexes_title + indexes_pages
else:
context["title"] = indexes_title
Expand Down

0 comments on commit 983600c

Please sign in to comment.