Navigation Menu

Skip to content

Commit

Permalink
Fix #1949 -- make STORY_INDEXES+PRETTY_URLS work
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Aug 17, 2015
1 parent 1bcf996 commit 1eedcdf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -10,6 +10,7 @@ Features
Bugfixes
--------

* Make STORY_INDEX work together with PRETTY_URLS (Issue #1949)
* Refactor new_post to match lazy plugin loading (Issue #1943)
* Make Nikola startup faster by not loading useless plugins (Issue #1825)
* Ignore sliced multibyte characters when reading metadata for sitemaps
Expand Down
7 changes: 5 additions & 2 deletions nikola/plugins/task/indexes.py
Expand Up @@ -101,13 +101,17 @@ def page_path(i, displayed_i, num_pages, force_addition, extension=None):
"strip_indexes": self.site.config['STRIP_INDEXES'],
}
template_name = "list.tmpl"
index_len = len(kw['index_file'])
for lang in kw["translations"]:
# Need to group by folder to avoid duplicated tasks (Issue #758)
# Group all pages by path prefix
groups = defaultdict(list)
for p in self.site.timeline:
if not p.is_post:
dirname = os.path.dirname(p.destination_path(lang))
destpath = p.destination_path(lang)
if destpath[-(1 + index_len):] == '/' + kw['index_file']:
destpath = destpath[:-(1 + index_len)]
dirname = os.path.dirname(destpath)
groups[dirname].append(p)
for dirname, post_list in groups.items():
context = {}
Expand All @@ -116,7 +120,6 @@ def page_path(i, displayed_i, num_pages, force_addition, extension=None):
output_name = os.path.join(kw['output_folder'], dirname, kw['index_file'])
short_destination = os.path.join(dirname, kw['index_file'])
link = short_destination.replace('\\', '/')
index_len = len(kw['index_file'])
if kw['strip_indexes'] and link[-(1 + index_len):] == '/' + kw['index_file']:
link = link[:-index_len]
context["permalink"] = link
Expand Down

0 comments on commit 1eedcdf

Please sign in to comment.