Skip to content
Permalink
Browse files

Simplifying code.

  • Loading branch information
felixfontein committed Oct 14, 2016
1 parent 10e3094 commit b854621fe46cd31c99dc3be03e0856d3b6c62b81
Showing with 9 additions and 6 deletions.
  1. +9 −6 nikola/post.py
@@ -167,11 +167,15 @@ def __init__(
default_metadata.update(self.meta[lang])

# Compose paths
self.folders = {lang: self.folder_relative for lang in self.config['TRANSLATIONS'].keys()}
if self.folder_base is not None:
# self.folder_base must be a TranslatableSetting whose value
# will be prepended to the folder's path for each language
self.folders = {lang: os.path.normpath(os.path.join(self.folder_base(lang), folder)) for lang, folder in self.folders.items()}
# Use translatable destination folders
self.folders = {}
for lang in self.config['TRANSLATIONS'].keys():
self.folders[lang] = os.path.normpath(os.path.join(
self.folder_base(lang), self.folder_relative))
else:
# Old behavior (non-translatable destination path, normalized by scanner)
self.folders = {lang: self.folder_relative for lang in self.config['TRANSLATIONS'].keys()}
self.folder = self.folders[self.default_lang]

# Load data field from metadata
@@ -859,8 +863,7 @@ def permalink(self, lang=None, absolute=False, extension='.html', query=None):
extension = self.compiler.extension()

pieces = self.translations[lang].split(os.sep)
folder = self.folders[lang]
pieces += folder.split(os.sep)
pieces += self.folders[lang].split(os.sep)
if self._has_pretty_url(lang):
pieces += [self.meta[lang]['slug'], 'index' + extension]
else:

0 comments on commit b854621

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