Skip to content
Permalink
Browse files

section_slug() handling of multi-level directories and translations

Fixes #2023.
  • Loading branch information
da2x committed Sep 6, 2015
1 parent 27dca29 commit d53f162a0cb08c3869b31470983ffeb6b2fa999b
Showing with 10 additions and 4 deletions.
  1. +2 −0 CHANGES.txt
  2. +1 −1 nikola/plugins/task/indexes.py
  3. +7 −3 nikola/post.py
@@ -12,6 +12,8 @@ Features
Bugfixes
--------

* Multi-lingual and multi-level directories confused section slug
detection (Issue #2023)
* Use Unicode strings for WordPress comment headers (Issue #2019)
* Don't add stories to author pages (Issue #2007)

@@ -75,7 +75,7 @@ def gen_tasks(self):
posts = self.site.posts
self.number_of_pages = dict()
self.number_of_pages_section = dict()
for lang in kw["translations"]:
for lang in kw["translations"]:

This comment has been minimized.

Copy link
@Kwpolska

Kwpolska Sep 6, 2015

Member

why the extra whitespace?

This comment has been minimized.

Copy link
@da2x

da2x Sep 6, 2015

Author Contributor

I pressed ctrl+tab (without holding ctrl) after going through changes to verify that everything was as it should … so yeah. Accident. (You’ve probably seen me fix a few dangling "s" and "w"s over the years for the same reason….)

def page_link(i, displayed_i, num_pages, force_addition, extension=None):
feed = "_atom" if extension == ".atom" else ""
return utils.adjust_name_for_index_link(self.site.link("index" + feed, None, lang), i, displayed_i,
@@ -781,12 +781,16 @@ def section_slug(self, lang=None):
if dest[-(1 + len(self.index_file)):] == '/' + self.index_file:
dest = dest[:-(1 + len(self.index_file))]
dirname = os.path.dirname(dest)
slug = dirname
if not dirname or dirname == '.':
slug = dest.split(os.sep)
if not slug or dirname == '.':
slug = self.messages[lang]["Uncategorized"]
elif lang == slug[0]:
slug = slug[1]
else:
slug = slug[0]
else:
slug = self.meta[lang]['section'].split(',')[0] if 'section' in self.meta[lang] else self.messages[lang]["Uncategorized"]
return slug.replace(' ', '-').lower()
return utils.slugify(slug)

def permalink(self, lang=None, absolute=False, extension='.html', query=None):
"""Return permalink for a post."""

0 comments on commit d53f162

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