Skip to content

Commit

Permalink
Merge pull request #2652 from getnikola/fix-wrong-behavior-of-never
Browse files Browse the repository at this point in the history
Preventing .html to be added when it shouldn't be.
  • Loading branch information
Kwpolska committed Feb 2, 2017
2 parents 387e2eb + 590736c commit eebfbfb
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 6 deletions.
4 changes: 3 additions & 1 deletion nikola/plugins/misc/taxonomies_classifier.py
Expand Up @@ -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]
Expand Down
3 changes: 1 addition & 2 deletions nikola/plugins/task/archive.py
Expand Up @@ -26,7 +26,6 @@

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

import os
import natsort
import nikola.utils
import datetime
Expand Down Expand Up @@ -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

Expand Down
6 changes: 5 additions & 1 deletion nikola/plugins/task/categories.py
Expand Up @@ -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'

Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/task/sections.py
Expand Up @@ -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):
Expand Down
6 changes: 5 additions & 1 deletion nikola/plugins/task/tags.py
Expand Up @@ -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'

Expand Down

0 comments on commit eebfbfb

Please sign in to comment.