Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/nikola
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 530179f8c683^
Choose a base ref
...
head repository: getnikola/nikola
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 70d0aec3be60
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Dec 10, 2016

  1. Allowing to enable/disable RSS feed generation completely independent…

    … of index and Atom feed generation.
    felixfontein committed Dec 10, 2016

    Verified

    This commit was signed with the committer’s verified signature.
    darinpope Darin Pope
    Copy the full SHA
    530179f View commit details
  2. Allowing to explicitly disable RSS and index generation for classify_…

    …indexes plugin independently.
    felixfontein committed Dec 10, 2016
    Copy the full SHA
    be6db3e View commit details
  3. Added logic to fix #2591.

    felixfontein committed Dec 10, 2016
    Copy the full SHA
    70d0aec View commit details
Showing with 33 additions and 9 deletions.
  1. +8 −1 nikola/nikola.py
  2. +4 −0 nikola/plugin_categories.py
  3. +8 −0 nikola/plugins/task/indexes.py
  4. +13 −8 nikola/plugins/task/taxonomies.py
9 changes: 8 additions & 1 deletion nikola/nikola.py
Original file line number Diff line number Diff line change
@@ -356,7 +356,7 @@
TAXONOMY_COMPATIBILITY_PLUGIN_NAME_MAP = {
"render_archive": ["classify_archive"],
"render_authors": ["classify_authors"],
"render_indexes": ["classify_indexes", "classify_page_index", "classify_sections"],
"render_indexes": ["classify_page_index", "classify_sections"], # "classify_indexes" removed from list (see #2591 and special-case logic below)
"render_tags": ["classify_categories", "render_tag_cloud", "classify_tags"],
}

@@ -823,12 +823,19 @@ def __init__(self, **config):
utils.LOGGER.warn('You are currently disabling "{}", but not the following new taxonomy plugins: {}'.format(old_plugin_name, ', '.join(missing_plugins)))
utils.LOGGER.warn('Please also disable these new plugins or remove "{}" from the DISABLED_PLUGINS list.'.format(old_plugin_name))
self.config['DISABLED_PLUGINS'].extend(missing_plugins)
# Special-case logic for "render_indexes" to fix #2591
if 'render_indexes' in self.config['DISABLED_PLUGINS']:
if 'generate_rss' in self.config['DISABLED_PLUGINS'] or self.config['GENERATE_RSS'] is False:
self.config['DISABLED_PLUGINS'].append('classify_indexes')
else:
self.config['DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED'] = 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

# PRETTY_URLS defaults to enabling STRIP_INDEXES unless explicitly disabled
if self.config.get('PRETTY_URLS') and 'STRIP_INDEXES' not in config:
4 changes: 4 additions & 0 deletions nikola/plugin_categories.py
Original file line number Diff line number Diff line change
@@ -752,6 +752,10 @@ def should_generate_classification_page(self, classification, post_list, lang):
"""Only generates list of posts for classification if this function returns True."""
return True

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 self.should_generate_classification_page(classification, post_list, lang)

def postprocess_posts_per_classification(self, posts_per_classification_per_language, flat_hierarchy_per_lang=None, hierarchy_lookup_per_lang=None):
"""Rearrange, modify or otherwise use the list of posts per classification and per language.
8 changes: 8 additions & 0 deletions nikola/plugins/task/indexes.py
Original file line number Diff line number Diff line change
@@ -91,3 +91,11 @@ def provide_context_and_uptodate(self, classification, lang, node=None):
}
kw.update(context)
return context, kw

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.get("DISABLE_INDEXES_PLUGIN_INDEX_AND_ATOM_FEED", False)

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.get("DISABLE_INDEXES_PLUGIN_RSS_FEED", False)
21 changes: 13 additions & 8 deletions nikola/plugins/task/taxonomies.py
Original file line number Diff line number Diff line change
@@ -322,7 +322,9 @@ def _generate_classification_page(self, taxonomy, classification, post_list, lan
if len(filtered_posts) == 0 and taxonomy.omit_empty_classifications:
return
# Should we create this list?
if not taxonomy.should_generate_classification_page(classification, filtered_posts, lang):
generate_list = taxonomy.should_generate_classification_page(classification, filtered_posts, lang)
generate_rss = taxonomy.should_generate_rss_for_classification_page(classification, filtered_posts, lang)
if not generate_list and not generate_rss:
return
# Get data
node = None
@@ -353,16 +355,19 @@ def _generate_classification_page(self, taxonomy, classification, post_list, lan
# Are there subclassifications?
if len(node.children) > 0:
# Yes: create list with subclassifications instead of list of posts
yield self._generate_subclassification_page(taxonomy, node, context, kw, lang)
if generate_list:
yield self._generate_subclassification_page(taxonomy, node, context, kw, lang)
return
# Generate RSS feed
if kw["generate_rss"] and not taxonomy.always_disable_rss:
yield self._generate_classification_page_as_rss(taxonomy, classification, filtered_posts, context['title'], context.get("description"), kw, lang)
if generate_rss:
if kw["generate_rss"] and not taxonomy.always_disable_rss:
yield self._generate_classification_page_as_rss(taxonomy, classification, filtered_posts, context['title'], context.get("description"), kw, lang)
# Render HTML
if taxonomy.show_list_as_index:
yield self._generate_classification_page_as_index(taxonomy, classification, filtered_posts, context, kw, lang)
else:
yield self._generate_classification_page_as_list(taxonomy, classification, filtered_posts, context, kw, lang)
if generate_list:
if taxonomy.show_list_as_index:
yield self._generate_classification_page_as_index(taxonomy, classification, filtered_posts, context, kw, lang)
else:
yield self._generate_classification_page_as_list(taxonomy, classification, filtered_posts, context, kw, lang)

def gen_tasks(self):
"""Render the tag pages and feeds."""