Skip to content
Permalink
Browse files
Merge pull request #2652 from getnikola/fix-wrong-behavior-of-never
Preventing .html to be added when it shouldn't be.
  • Loading branch information
Kwpolska committed Feb 2, 2017
2 parents 387e2eb + 590736c commit eebfbfb4f9ef1578b6e7a6a5379dae8b0fcf59e8
@@ -240,10 +240,12 @@ def _postprocess_path(self, path, lang, append_index='auto', dest_type='page', p
path = ['rss']
elif len(path) == 0 or append_index == 'always':
path = path + [os.path.splitext(self.site.config['INDEX_FILE'])[0]]
elif len(path) > 0 and append_index == 'never':
path[-1] = os.path.splitext(path[-1])[0]
path[-1] += force_extension
elif (self.site.config['PRETTY_URLS'] and append_index != 'never') or len(path) == 0 or append_index == 'always':
path = path + [self.site.config['INDEX_FILE']]
else:
elif append_index != 'never':
path[-1] += '.html'
# Create path
result = [_f for _f in [self.site.config['TRANSLATIONS'][lang]] + path if _f]
@@ -26,7 +26,6 @@

"""Classify the posts in archives."""

import os
import natsort
import nikola.utils
import datetime
@@ -139,7 +138,7 @@ def get_path(self, classification, lang, dest_type='page'):
components.extend(classification)
add_index = 'always'
else:
components.append(os.path.splitext(self.site.config['ARCHIVE_FILENAME'])[0])
components.append(self.site.config['ARCHIVE_FILENAME'])
add_index = 'never'
return [_f for _f in components if _f], add_index

@@ -100,7 +100,11 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
def get_overview_path(self, lang, dest_type='page'):
"""A path handler for the list of all classifications."""
if self.site.config['CATEGORIES_INDEX_PATH'](lang):
return [_f for _f in [self.site.config['CATEGORIES_INDEX_PATH'](lang)] if _f], 'never'
path = self.site.config['CATEGORIES_INDEX_PATH'](lang)
if path.endswith('/index'): # TODO: remove in v8
utils.LOGGER.warn("CATEGORIES_INDEX_PATH for language {0} is missing a .html extension. Please update your configuration!".format(lang))
path += '.html'
return [_f for _f in [path] if _f], 'never'
else:
return [_f for _f in [self.site.config['CATEGORY_PATH'](lang)] if _f], 'always'

@@ -100,7 +100,7 @@ def get_path(self, section, lang, dest_type='page'):
"""A path handler for the given classification."""
result = [_f for _f in [section] if _f]
if dest_type == 'rss':
return result + ['rss'], 'never'
return result + ['rss.xml'], 'never'
return result, 'always'

def provide_context_and_uptodate(self, section, lang, node=None):
@@ -104,7 +104,11 @@ def slugify_tag_name(self, name, lang):
def get_overview_path(self, lang, dest_type='page'):
"""A path handler for the list of all classifications."""
if self.site.config['TAGS_INDEX_PATH'](lang):
return [_f for _f in [self.site.config['TAGS_INDEX_PATH'](lang)] if _f], 'never'
path = self.site.config['TAGS_INDEX_PATH'](lang)
if path.endswith('/index'): # TODO: remove in v8
utils.LOGGER.warn("TAGS_INDEX_PATH for language {0} is missing a .html extension. Please update your configuration!".format(lang))
path += '.html'
return [_f for _f in [path] if _f], 'never'
else:
return [_f for _f in [self.site.config['TAG_PATH'](lang)] if _f], 'always'

0 comments on commit eebfbfb

Please sign in to comment.