Skip to content
Permalink
Browse files

Allowing destination_base to be a utils.TranslatableSetting.

  • Loading branch information
felixfontein committed Sep 19, 2016
1 parent 14b33b7 commit ceea3d0266d66be55bb3c4276532d75bfecc40a4
Showing with 11 additions and 5 deletions.
  1. +11 −5 nikola/post.py
@@ -123,12 +123,14 @@ def __init__(
self.metadata_path = self.post_name + ".meta" # posts/blah.meta
self.folder_relative = destination
self.folder_base = destination_base
if self.folder_base is not None:
self.default_lang = self.config['DEFAULT_LANG']
if self.folder_base is None:
self.folder = destination
elif isinstance(self.folder_base, (utils.bytes_str, utils.unicode_str)):
self.folder = os.path.normpath(os.path.join(self.folder_base, self.folder_relative))
else:
self.folder = destination
self.folder = os.path.normpath(os.path.join(self.folder_base(self.default_lang), self.folder_relative))
self.translations = self.config['TRANSLATIONS']
self.default_lang = self.config['DEFAULT_LANG']
self.messages = messages
self.skip_untranslated = not self.config['SHOW_UNTRANSLATED_POSTS']
self._template_name = template_name
@@ -776,8 +778,10 @@ def destination_path(self, lang=None, extension='.html', sep=os.sep, _force_sour
folder = self.folder
else:
folder = self.meta[lang].get('path', self.folder_relative)
if self.folder_base is not None:
if isinstance(self.folder_base, (utils.bytes_str, utils.unicode_str)):
folder = os.path.normpath(os.path.join(self.folder_base, folder))
elif self.folder_base is not None:
folder = os.path.normpath(os.path.join(self.folder_base(lang), folder))
if self._has_pretty_url(lang):
path = os.path.join(self.translations[lang],
folder, self.meta[lang]['slug'], 'index' + extension)
@@ -856,8 +860,10 @@ def permalink(self, lang=None, absolute=False, extension='.html', query=None):

pieces = self.translations[lang].split(os.sep)
folder = self.meta[lang].get('path', self.folder_relative)
if self.folder_base is not None:
if isinstance(self.folder_base, (utils.bytes_str, utils.unicode_str)):
folder = os.path.normpath(os.path.join(self.folder_base, folder))
elif self.folder_base is not None:
folder = os.path.normpath(os.path.join(self.folder_base(lang), folder))
pieces += folder.split(os.sep)
if self._has_pretty_url(lang):
pieces += [self.meta[lang]['slug'], 'index' + extension]

0 comments on commit ceea3d0

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