Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
section_slug() handling of multi-level directories and translations
Fixes #2023.
  • Loading branch information
da2x committed Sep 6, 2015
1 parent 27dca29 commit d53f162
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/indexes.py
Expand Up @@ -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,
Expand Down
10 changes: 7 additions & 3 deletions nikola/post.py
Expand Up @@ -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."""
Expand Down

0 comments on commit d53f162

Please sign in to comment.