Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ATOM_PATH setting #3015

Merged
merged 8 commits into from Apr 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -4,6 +4,7 @@ New in master
Features
--------

* New ``ATOM_PATH`` setting (Issue #2971)
* Make ``crumbs`` available to all pages
* Allowing to customize RSS and Atom feed extensions with
``RSS_EXTENSION``, ``ATOM_EXTENSION`` settings (Issue #3041)
Expand Down
1 change: 1 addition & 0 deletions docs/template-variables.rst
Expand Up @@ -39,6 +39,7 @@ Name Type Descript
================================== ================================== ================================================================================
``_link`` function ``Nikola.link`` function
``abs_link`` function ``Nikola.abs_link`` function
``atom_path`` TranslatableSetting<str> ``ATOM_PATH`` setting
``author_pages_generated`` bool False
``blog_author`` TranslatableSetting<str> ``BLOG_AUTHOR`` setting
``blog_email`` str ``BLOG_EMAIL`` setting
Expand Down
5 changes: 5 additions & 0 deletions nikola/conf.py.in
Expand Up @@ -527,6 +527,11 @@ USE_BASE_TAG = False
# (translatable)
# RSS_PATH = ""

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

# Slug the Tag URL. Easier for users to type, special characters are
# often removed or replaced as well.
# SLUG_TAG_PATH = True
Expand Down
9 changes: 8 additions & 1 deletion nikola/nikola.py
Expand Up @@ -539,6 +539,7 @@ def __init__(self, **config):
'ROBOTS_EXCLUSIONS': [],
'GENERATE_ATOM': False,
'ATOM_EXTENSION': '.atom',
'ATOM_PATH': '',
'FEED_TEASERS': True,
'FEED_PLAIN': False,
'FEED_PREVIEWIMAGE': True,
Expand Down Expand Up @@ -618,6 +619,9 @@ def __init__(self, **config):
self.config['__invariant__'] = self.invariant
self.config['__quiet__'] = self.quiet

# Use ATOM_PATH when set
self.config['ATOM_PATH'] = self.config['ATOM_PATH'] or self.config['INDEX_PATH']

# Make sure we have sane NAVIGATION_LINKS.
if not self.config['NAVIGATION_LINKS']:
self.config['NAVIGATION_LINKS'] = {self.config['DEFAULT_LANG']: ()}
Expand Down Expand Up @@ -658,6 +662,7 @@ def __init__(self, **config):
'CATEGORIES_INDEX_PATH',
'SECTION_PATH',
'INDEX_PATH',
'ATOM_PATH',
'RSS_PATH',
'RSS_FILENAME_BASE',
'AUTHOR_PATH',
Expand Down Expand Up @@ -687,7 +692,8 @@ def __init__(self, **config):
'front_index_header',
)

self._ALL_PAGE_DEPS_TRANSLATABLE = ('rss_path',
self._ALL_PAGE_DEPS_TRANSLATABLE = ('atom_path',
'rss_path',
'rss_filename_base',
)
# WARNING: navigation_links SHOULD NOT be added to the list above.
Expand Down Expand Up @@ -1178,6 +1184,7 @@ def _set_all_page_deps_from_config(self):
Unlike global context, contents are NOT available to templates.
"""
self.ALL_PAGE_DEPS['atom_extension'] = self.config.get('ATOM_EXTENSION')
self.ALL_PAGE_DEPS['atom_path'] = self.config.get('ATOM_PATH')
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')
Expand Down
3 changes: 2 additions & 1 deletion nikola/plugins/task/indexes.py
Expand Up @@ -95,7 +95,8 @@ def get_path(self, classification, lang, dest_type='page'):
self.site.config['RSS_PATH'](lang),
self.site.config['RSS_FILENAME_BASE'](lang)
], 'auto'
# 'page' (index) or 'feed' (Atom)
if dest_type == 'feed':
return [self.site.config['ATOM_PATH'](lang)], 'always'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixfontein: why is page number support not implemented for feeds?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, that would be a simple change. But:

  1. nobody asked for it so far (I think);
  2. there's still the big open question why the many .atom feed files are needed after all (multiple atom feed files generated #3016).

I'd like to see an answer to #3016 first.

page_number = None
if dest_type == 'page':
# Interpret argument as page number
Expand Down
4 changes: 4 additions & 0 deletions tests/data/translated_titles/conf.py
Expand Up @@ -225,6 +225,10 @@
# output / TRANSLATION[lang] / RSS_PATH / rss.xml
# RSS_PATH = ""

# Final location for the blog main Atom feed is:
# output / TRANSLATION[lang] / ATOM_PATH / index.atom
# ATOM_PATH = ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(FYI, this file does not need to be updated.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we leave this change anyway?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whatever.


# Number of posts in RSS feeds
# FEED_LENGTH = 10

Expand Down