Skip to content

Commit

Permalink
Merge branch 'master' into captioned-images
Browse files Browse the repository at this point in the history
  • Loading branch information
Kwpolska authored Apr 18, 2018
2 parents 739c6f6 + 9e36774 commit da97054
Show file tree
Hide file tree
Showing 10 changed files with 72 additions and 28 deletions.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* `Aru Sahni <https://github.com/arusahni>`_
* `Aurelien Naldi <https://github.com/aurelien-naldi>`_
* `Ben Mather <https://github.com/bwhmather>`_
* `Bendik Knapstad <https://github.com/knapstad>`_
* `Boris Kaul <https://github.com/localvoid>`_
* `Brad Miller <https://github.com/bnmnetp>`_
* `Brandon W. Maister <https://github.com/quodlibetor>`_
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Features
--------

* Support captioned images and image ordering in galleries (Issue #3017)
* 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 Expand Up @@ -58,6 +59,8 @@ Features
Bugfixes
--------

* Renamed ``DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED`` to ``DISABLE_INDEXES``
and ``DISABLE_INDEXES_PLUGIN_RSS_FEED`` to ``DISABLE_MAIN_RSS_FEED`` (Issue #3039)
* Make chart shortcode its own plugin and make the reST directive
depend on it.
* Put post_list shortcode in its own plugin and make the reST
Expand Down
2 changes: 1 addition & 1 deletion docs/creating-a-site.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ configuration file:
INDEX_PATH = "blog"
# Or you can disable blog indexes altogether:
# DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED = True
# DISABLE_INDEXES = True
And now we are ready to create our first page:
Expand Down
3 changes: 2 additions & 1 deletion docs/manual.rst
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ to your configuration:
'author': 'John Doe'
}
Metadata formats
~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -442,6 +441,8 @@ The “traditional” and default meta field format is:
If you are not using reStructuredText, make sure the fields are in a HTML comment in output.

Also, note that this format does not support any multi-line values. Try YAML or reST docinfo if you need those.

Two-file format
```````````````

Expand Down
7 changes: 1 addition & 6 deletions docs/template-variables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ 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
``atom_extension`` str ``ATOM_EXTENSION`` setting
``blog_author`` TranslatableSetting<str> ``BLOG_AUTHOR`` setting
``blog_email`` str ``BLOG_EMAIL`` setting
``blog_description`` TranslatableSetting<str> ``BLOG_DESCRIPTION`` setting
Expand Down Expand Up @@ -88,17 +88,12 @@ Name Type Descript
``posts_section_name`` TranslatableSetting<str> ``POSTS_SECTION_NAME`` setting
``posts_section_title`` TranslatableSetting<str> ``POSTS_SECTION_TITLE`` setting
``rel_link`` function ``Nikola.rel_link`` function
``rss_extension`` str ``RSS_EXTENSION`` setting
``rss_filename_base`` TranslatableSetting<str> ``RSS_FILENAME_BASE`` setting
``rss_link`` str ``RSS_LINK`` setting
``rss_path`` TranslatableSetting<str> ``RSS_PATH`` setting
``search_form`` TranslatableSetting<str> ``SEARCH_FORM`` setting
``set_locale`` function ``LocaleBorg.set_locale`` function (or None if not available)
``show_blog_title`` bool ``SHOW_BLOG_TITLE`` setting
``show_sourcelink`` bool ``SHOW_SOURCELINK`` setting
``site_has_comments`` bool whether or not a comment system is configured
``SLUG_AUTHOR_PATH`` bool ``SLUG_AUTHOR_PATH`` setting
``SLUG_TAG_PATH`` bool ``SLUG_TAG_PATH`` setting
``social_buttons_code`` TranslatableSetting<str> ``SOCIAL_BUTTONS_CODE`` setting
``sort_posts`` function ``utils.sort_posts`` function
``smartjoin`` function ``utils.smartjoin`` function
Expand Down
9 changes: 7 additions & 2 deletions nikola/conf.py.in
Original file line number Diff line number Diff line change
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 Expand Up @@ -1240,8 +1245,8 @@ MARKDOWN_EXTENSIONS = ['markdown.extensions.fenced_code', 'markdown.extensions.c
# Special settings to disable only parts of the indexes plugin (to allow RSS
# but no blog indexes, or to allow blog indexes and Atom but no site-wide RSS).
# Use with care.
# DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED = False
# DISABLE_INDEXES_PLUGIN_RSS_FEED = False
# DISABLE_INDEXES = False
# DISABLE_MAIN_RSS_FEED = False

# Add the absolute paths to directories containing plugins to use them.
# For example, the `plugins` directory of your clone of the Nikola plugins
Expand Down
62 changes: 48 additions & 14 deletions nikola/nikola.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,8 @@ def __init__(self, **config):
'CREATE_FULL_ARCHIVES': False,
'CREATE_DAILY_ARCHIVE': False,
'DATE_FORMAT': '%Y-%m-%d %H:%M',
'DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED': False,
'DISABLE_INDEXES_PLUGIN_RSS_FEED': False,
'DISABLE_INDEXES': False,
'DISABLE_MAIN_RSS_FEED': False,
'JS_DATE_FORMAT': 'YYYY-MM-DD HH:mm',
'DATE_FANCINESS': 0,
'DEFAULT_LANG': "en",
Expand Down 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 @@ -602,6 +603,9 @@ def __init__(self, **config):
# set global_context for template rendering
self._GLOBAL_CONTEXT = {}

# dependencies for all pages, not included in global context
self.ALL_PAGE_DEPS = {}

self.config.update(config)

# __builtins__ contains useless cruft
Expand All @@ -615,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 @@ -655,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 @@ -682,9 +690,12 @@ def __init__(self, **config):
'posts_section_name',
'posts_section_title',
'front_index_header',
'rss_path',
'rss_filename_base',
)

self._ALL_PAGE_DEPS_TRANSLATABLE = ('atom_path',
'rss_path',
'rss_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 @@ -715,6 +726,14 @@ def __init__(self, **config):
utils.LOGGER.warn('The UNSLUGIFY_TITLES setting was renamed to FILE_METADATA_UNSLUGIFY_TITLES.')
self.config['FILE_METADATA_UNSLUGIFY_TITLES'] = self.config['UNSLUGIFY_TITLES']

if 'DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED' in self.config:
utils.LOGGER.warn('The DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED setting was renamed to DISABLE_INDEXES.')
self.config['DISABLE_INDEXES'] = self.config['DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED']

if 'DISABLE_INDEXES_PLUGIN_RSS_FEED' in self.config:
utils.LOGGER.warn('The DISABLE_INDEXES_PLUGIN_RSS_FEED setting was renamed to DISABLE_MAIN_RSS_FEED.')
self.config['DISABLE_MAIN_RSS_FEED'] = self.config['DISABLE_INDEXES_PLUGIN_RSS_FEED']

# Handle CONTENT_FOOTER and RSS_COPYRIGHT* properly.
# We provide the arguments to format in CONTENT_FOOTER_FORMATS and RSS_COPYRIGHT_FORMATS.
self.config['CONTENT_FOOTER'].langformat(self.config['CONTENT_FOOTER_FORMATS'])
Expand Down Expand Up @@ -757,16 +776,16 @@ def __init__(self, **config):
utils.LOGGER.warn('You are disabling the "render_indexes" plugin, as well as disabling the "generate_rss" plugin or setting GENERATE_RSS to False. To achieve the same effect, please disable the "classify_indexes" plugin in the future.')
self.config['DISABLED_PLUGINS'].append('classify_indexes')
else:
if not self.config['DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED']:
utils.LOGGER.warn('You are disabling the "render_indexes" plugin, but not the generation of RSS feeds. Please put "DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED = True" into your configuration instead.')
self.config['DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED'] = True
if not self.config['DISABLE_INDEXES']:
utils.LOGGER.warn('You are disabling the "render_indexes" plugin, but not the generation of RSS feeds. Please put "DISABLE_INDEXES = True" into your configuration instead.')
self.config['DISABLE_INDEXES'] = True

# Disable RSS. For a successful disable, we must have both the option
# false and the plugin disabled through the official means.
if 'generate_rss' in self.config['DISABLED_PLUGINS'] and self.config['GENERATE_RSS'] is True:
utils.LOGGER.warn('Please use GENERATE_RSS to disable RSS feed generation, instead of mentioning generate_rss in DISABLED_PLUGINS.')
self.config['GENERATE_RSS'] = False
self.config['DISABLE_INDEXES_PLUGIN_RSS_FEED'] = True
self.config['DISABLE_MAIN_RSS_FEED'] = True

# PRETTY_URLS defaults to enabling STRIP_INDEXES unless explicitly disabled
if self.config.get('PRETTY_URLS') and 'STRIP_INDEXES' not in config:
Expand Down Expand Up @@ -847,6 +866,7 @@ def __init__(self, **config):
self.register_filter(filter_name_format.format(filter_name), filter_definition)

self._set_global_context_from_config()
self._set_all_page_deps_from_config()
# Read data files only if a site exists (Issue #2708)
if self.configured:
self._set_global_context_from_data()
Expand Down Expand Up @@ -1083,8 +1103,6 @@ def _set_global_context_from_config(self):
self._GLOBAL_CONTEXT['rel_link'] = self.rel_link
self._GLOBAL_CONTEXT['abs_link'] = self.abs_link
self._GLOBAL_CONTEXT['exists'] = self.file_exists
self._GLOBAL_CONTEXT['SLUG_AUTHOR_PATH'] = self.config['SLUG_AUTHOR_PATH']
self._GLOBAL_CONTEXT['SLUG_TAG_PATH'] = self.config['SLUG_TAG_PATH']
self._GLOBAL_CONTEXT['index_display_post_count'] = self.config[
'INDEX_DISPLAY_POST_COUNT']
self._GLOBAL_CONTEXT['index_file'] = self.config['INDEX_FILE']
Expand Down Expand Up @@ -1121,10 +1139,6 @@ def _set_global_context_from_config(self):
'CONTENT_FOOTER')
self._GLOBAL_CONTEXT['generate_atom'] = self.config.get('GENERATE_ATOM')
self._GLOBAL_CONTEXT['generate_rss'] = self.config.get('GENERATE_RSS')
self._GLOBAL_CONTEXT['atom_extension'] = self.config.get('ATOM_EXTENSION')
self._GLOBAL_CONTEXT['rss_extension'] = self.config.get('RSS_EXTENSION')
self._GLOBAL_CONTEXT['rss_path'] = self.config.get('RSS_PATH')
self._GLOBAL_CONTEXT['rss_filename_base'] = self.config.get('RSS_FILENAME_BASE')
self._GLOBAL_CONTEXT['rss_link'] = self.config.get('RSS_LINK')

self._GLOBAL_CONTEXT['navigation_links'] = self.config.get('NAVIGATION_LINKS')
Expand Down Expand Up @@ -1171,6 +1185,20 @@ def _set_global_context_from_data(self):
# Offer global_data as an alias for data (Issue #2488)
self._GLOBAL_CONTEXT['global_data'] = self._GLOBAL_CONTEXT['data']

def _set_all_page_deps_from_config(self):
"""Save dependencies for all pages from configuration.
Changes of values in this dict will force a rebuild of all pages.
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')
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')

def _activate_plugins_of_category(self, category):
"""Activate all the plugins of a given category and return them."""
# this code duplicated in tests/base.py
Expand Down Expand Up @@ -2143,6 +2171,7 @@ def generic_renderer(self, lang, output_name, template_name, filters, file_deps=
deps_dict['OUTPUT_FOLDER'] = self.config['OUTPUT_FOLDER']
deps_dict['TRANSLATIONS'] = self.config['TRANSLATIONS']
deps_dict['global'] = self.GLOBAL_CONTEXT
deps_dict['all_page_deps'] = self.ALL_PAGE_DEPS
if post_deps_dict:
deps_dict.update(post_deps_dict)

Expand All @@ -2151,6 +2180,8 @@ def generic_renderer(self, lang, output_name, template_name, filters, file_deps=

for k in self._GLOBAL_CONTEXT_TRANSLATABLE:
deps_dict[k] = deps_dict['global'][k](lang)
for k in self._ALL_PAGE_DEPS_TRANSLATABLE:
deps_dict[k] = deps_dict['all_page_deps'][k](lang)

deps_dict['navigation_links'] = deps_dict['global']['navigation_links'](lang)

Expand Down Expand Up @@ -2284,9 +2315,12 @@ def atom_link(link_rel, link_type, link_href):
deps_context["posts"] = [(p.meta[lang]['title'], p.permalink(lang)) for p in
posts]
deps_context["global"] = self.GLOBAL_CONTEXT
deps_context["all_page_deps"] = self.ALL_PAGE_DEPS

for k in self._GLOBAL_CONTEXT_TRANSLATABLE:
deps_context[k] = deps_context['global'][k](lang)
for k in self._ALL_PAGE_DEPS_TRANSLATABLE:
deps_context[k] = deps_context['all_page_deps'][k](lang)

deps_context['navigation_links'] = deps_context['global']['navigation_links'](lang)

Expand Down
7 changes: 4 additions & 3 deletions nikola/plugins/task/indexes.py
Original file line number Diff line number Diff line change
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'
page_number = None
if dest_type == 'page':
# Interpret argument as page number
Expand All @@ -119,8 +120,8 @@ def provide_context_and_uptodate(self, classification, lang, node=None):

def should_generate_classification_page(self, classification, post_list, lang):
"""Only generates list of posts for classification if this function returns True."""
return not self.site.config["DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED"]
return not self.site.config["DISABLE_INDEXES"]

def should_generate_rss_for_classification_page(self, classification, post_list, lang):
"""Only generates RSS feed for list of posts for classification if this function returns True."""
return not self.site.config["DISABLE_INDEXES_PLUGIN_RSS_FEED"]
return not self.site.config["DISABLE_MAIN_RSS_FEED"]
2 changes: 1 addition & 1 deletion nikola/plugins/task/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def gen_tasks(self):
index_paths = {}
for lang in kw["translations"]:
index_paths[lang] = False
if not self.site.config["DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED"]:
if not self.site.config["DISABLE_INDEXES"]:
index_paths[lang] = os.path.normpath(os.path.join(self.site.config['OUTPUT_FOLDER'],
self.site.path('index', '', lang=lang)))

Expand Down
4 changes: 4 additions & 0 deletions tests/data/translated_titles/conf.py
Original file line number Diff line number Diff line change
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 = ""

# Number of posts in RSS feeds
# FEED_LENGTH = 10

Expand Down

0 comments on commit da97054

Please sign in to comment.