Skip to content

Commit

Permalink
Add ATOM_FILENAME_BASE, use feed.atom instead of index.atom for new s…
Browse files Browse the repository at this point in the history
…ites

Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed May 1, 2018
1 parent c55f840 commit ecedddd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Expand Up @@ -16,6 +16,8 @@ Important compatibility changes
Features
--------

* Add ``ATOM_FILENAME_BASE`` setting (defaults to ``index`` for
existing sites, but ``feed`` for new sites) (Issue #3016)
* Produce a better error message when a template referenced in another
template is missing (Issue #3055)
* Support captioned images and image ordering in galleries (Issue #3017)
Expand Down
12 changes: 8 additions & 4 deletions nikola/conf.py.in
Expand Up @@ -528,10 +528,17 @@ USE_BASE_TAG = False
# RSS_PATH = ""

# Final location for the blog main Atom feed is:
# output / TRANSLATION[lang] / ATOM_PATH / index.atom
# output / TRANSLATION[lang] / ATOM_PATH / ATOM_FILENAME_BASE ATOM_EXTENSION
# (translatable)
# ATOM_PATH = ""

# Atom filename base (without extension); used for indexes.
# (translatable)
ATOM_FILENAME_BASE = "feed"

# Extension for Atom feed files
# ATOM_EXTENSION = ".atom"

# Slug the Tag URL. Easier for users to type, special characters are
# often removed or replaced as well.
# SLUG_TAG_PATH = True
Expand Down Expand Up @@ -1071,9 +1078,6 @@ MARKDOWN_EXTENSIONS = ['markdown.extensions.fenced_code', 'markdown.extensions.c
# between each other. Old Atom feeds with no changes are marked as archived.
# GENERATE_ATOM = False

# Extension for Atom feed files
# ATOM_EXTENSION = ".atom"

# Only include teasers in Atom and RSS feeds. Disabling include the full
# content. Defaults to True.
# FEED_TEASERS = True
Expand Down
4 changes: 4 additions & 0 deletions nikola/nikola.py
Expand Up @@ -540,6 +540,7 @@ def __init__(self, **config):
'GENERATE_ATOM': False,
'ATOM_EXTENSION': '.atom',
'ATOM_PATH': '',
'ATOM_FILENAME_BASE': 'index',
'FEED_TEASERS': True,
'FEED_PLAIN': False,
'FEED_PREVIEWIMAGE': True,
Expand Down Expand Up @@ -665,6 +666,7 @@ def __init__(self, **config):
'ATOM_PATH',
'RSS_PATH',
'RSS_FILENAME_BASE',
'ATOM_FILENAME_BASE',
'AUTHOR_PATH',
'DATE_FORMAT',
'JS_DATE_FORMAT',
Expand Down Expand Up @@ -695,6 +697,7 @@ def __init__(self, **config):
self._ALL_PAGE_DEPS_TRANSLATABLE = ('atom_path',
'rss_path',
'rss_filename_base',
'atom_filename_base',
)
# WARNING: navigation_links SHOULD NOT be added to the list above.
# Themes ask for [lang] there and we should provide it.
Expand Down Expand Up @@ -1196,6 +1199,7 @@ def _set_all_page_deps_from_config(self):
self.ALL_PAGE_DEPS['rss_extension'] = self.config.get('RSS_EXTENSION')
self.ALL_PAGE_DEPS['rss_path'] = self.config.get('RSS_PATH')
self.ALL_PAGE_DEPS['rss_filename_base'] = self.config.get('RSS_FILENAME_BASE')
self.ALL_PAGE_DEPS['atom_filename_base'] = self.config.get('ATOM_FILENAME_BASE')
self.ALL_PAGE_DEPS['slug_author_path'] = self.config.get('SLUG_AUTHOR_PATH')
self.ALL_PAGE_DEPS['slug_tag_path'] = self.config.get('SLUG_TAG_PATH')

Expand Down
2 changes: 2 additions & 0 deletions nikola/plugins/misc/taxonomies_classifier.py
Expand Up @@ -241,6 +241,8 @@ def _postprocess_path(self, path, lang, append_index='auto', dest_type='page', p
if force_extension is not None:
if len(path) == 0 and dest_type == 'rss':
path = [self.site.config['RSS_FILENAME_BASE'](lang)]
elif len(path) == 0 and dest_type == 'feed':
path = [self.site.config['ATOM_FILENAME_BASE'](lang)]
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':
Expand Down
5 changes: 4 additions & 1 deletion nikola/plugins/task/indexes.py
Expand Up @@ -96,7 +96,10 @@ def get_path(self, classification, lang, dest_type='page'):
self.site.config['RSS_FILENAME_BASE'](lang)
], 'auto'
if dest_type == 'feed':
return [self.site.config['ATOM_PATH'](lang)], 'always'
return [
self.site.config['ATOM_PATH'](lang),
self.site.config['ATOM_FILENAME_BASE'](lang)
], 'auto'
page_number = None
if dest_type == 'page':
# Interpret argument as page number
Expand Down
2 changes: 2 additions & 0 deletions nikola/plugins/task/sections.py
Expand Up @@ -101,6 +101,8 @@ def get_path(self, section, lang, dest_type='page'):
result = [_f for _f in [self.site.config['SECTION_PATH'](lang), section] if _f]
if dest_type == 'rss':
return result + [self.site.config['RSS_FILENAME_BASE'](lang)], 'auto'
elif dest_type == 'feed':
return result + [self.site.config['ATOM_FILENAME_BASE'](lang)], 'auto'
return result, 'always'

def provide_context_and_uptodate(self, classification, lang, node=None):
Expand Down

0 comments on commit ecedddd

Please sign in to comment.