Skip to content

Commit eebfbfb

Browse files
authoredFeb 2, 2017
Merge pull request #2652 from getnikola/fix-wrong-behavior-of-never
Preventing .html to be added when it shouldn't be.
2 parents 387e2eb + 590736c commit eebfbfb

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed
 

‎nikola/plugins/misc/taxonomies_classifier.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,12 @@ def _postprocess_path(self, path, lang, append_index='auto', dest_type='page', p
240240
path = ['rss']
241241
elif len(path) == 0 or append_index == 'always':
242242
path = path + [os.path.splitext(self.site.config['INDEX_FILE'])[0]]
243+
elif len(path) > 0 and append_index == 'never':
244+
path[-1] = os.path.splitext(path[-1])[0]
243245
path[-1] += force_extension
244246
elif (self.site.config['PRETTY_URLS'] and append_index != 'never') or len(path) == 0 or append_index == 'always':
245247
path = path + [self.site.config['INDEX_FILE']]
246-
else:
248+
elif append_index != 'never':
247249
path[-1] += '.html'
248250
# Create path
249251
result = [_f for _f in [self.site.config['TRANSLATIONS'][lang]] + path if _f]

‎nikola/plugins/task/archive.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
"""Classify the posts in archives."""
2828

29-
import os
3029
import natsort
3130
import nikola.utils
3231
import datetime
@@ -139,7 +138,7 @@ def get_path(self, classification, lang, dest_type='page'):
139138
components.extend(classification)
140139
add_index = 'always'
141140
else:
142-
components.append(os.path.splitext(self.site.config['ARCHIVE_FILENAME'])[0])
141+
components.append(self.site.config['ARCHIVE_FILENAME'])
143142
add_index = 'never'
144143
return [_f for _f in components if _f], add_index
145144

‎nikola/plugins/task/categories.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
100100
def get_overview_path(self, lang, dest_type='page'):
101101
"""A path handler for the list of all classifications."""
102102
if self.site.config['CATEGORIES_INDEX_PATH'](lang):
103-
return [_f for _f in [self.site.config['CATEGORIES_INDEX_PATH'](lang)] if _f], 'never'
103+
path = self.site.config['CATEGORIES_INDEX_PATH'](lang)
104+
if path.endswith('/index'): # TODO: remove in v8
105+
utils.LOGGER.warn("CATEGORIES_INDEX_PATH for language {0} is missing a .html extension. Please update your configuration!".format(lang))
106+
path += '.html'
107+
return [_f for _f in [path] if _f], 'never'
104108
else:
105109
return [_f for _f in [self.site.config['CATEGORY_PATH'](lang)] if _f], 'always'
106110

‎nikola/plugins/task/sections.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ def get_path(self, section, lang, dest_type='page'):
100100
"""A path handler for the given classification."""
101101
result = [_f for _f in [section] if _f]
102102
if dest_type == 'rss':
103-
return result + ['rss'], 'never'
103+
return result + ['rss.xml'], 'never'
104104
return result, 'always'
105105

106106
def provide_context_and_uptodate(self, section, lang, node=None):

‎nikola/plugins/task/tags.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,11 @@ def slugify_tag_name(self, name, lang):
104104
def get_overview_path(self, lang, dest_type='page'):
105105
"""A path handler for the list of all classifications."""
106106
if self.site.config['TAGS_INDEX_PATH'](lang):
107-
return [_f for _f in [self.site.config['TAGS_INDEX_PATH'](lang)] if _f], 'never'
107+
path = self.site.config['TAGS_INDEX_PATH'](lang)
108+
if path.endswith('/index'): # TODO: remove in v8
109+
utils.LOGGER.warn("TAGS_INDEX_PATH for language {0} is missing a .html extension. Please update your configuration!".format(lang))
110+
path += '.html'
111+
return [_f for _f in [path] if _f], 'never'
108112
else:
109113
return [_f for _f in [self.site.config['TAG_PATH'](lang)] if _f], 'always'
110114

0 commit comments

Comments
 (0)
Please sign in to comment.