Skip to content
Permalink
Browse files
Merge 'master' and add #3041 stuff
  • Loading branch information
Kwpolska committed Apr 15, 2018
2 parents d209432 + 75a1f70 commit da261b7e772d007193dbcee100639357604e81a1
@@ -4,6 +4,10 @@ New in master
Features
--------

* Allowing to customize RSS and Atom feed extensions with
``RSS_EXTENSION``, ``ATOM_EXTENSION`` settings (Issue #3041)
* Allowing to customize filename base appended to RSS_PATH
with ``RSS_FILENAME_BASE`` setting (Issue #3041)
* Use basic ipynb template by default for slightly better appearance
and behavior
* Fixing behavior of RSS_PATH to do what the documentation
@@ -249,7 +249,7 @@ POSTS_SECTIONS = True

# Final locations are:
# output / TRANSLATION[lang] / SECTION_PATH / SECTION_NAME / index.html (list of posts for a section)
# output / TRANSLATION[lang] / SECTION_PATH / SECTION_NAME / rss.xml (RSS feed for a section)
# output / TRANSLATION[lang] / SECTION_PATH / SECTION_NAME / RSS_FILENAME_BASE RSS_EXTENSION (RSS feed for a section)
# (translatable)
# SECTION_PATH = ""

@@ -315,7 +315,7 @@ POSTS_SECTIONS = True
# Final locations are:
# output / TRANSLATION[lang] / TAG_PATH / index.html (list of tags)
# output / TRANSLATION[lang] / TAG_PATH / tag.html (list of posts for a tag)
# output / TRANSLATION[lang] / TAG_PATH / tag.xml (RSS feed for a tag)
# output / TRANSLATION[lang] / TAG_PATH / tag RSS_EXTENSION (RSS feed for a tag)
# (translatable)
# TAG_PATH = "categories"

@@ -373,7 +373,7 @@ HIDDEN_TAGS = ['mathjax']
# Final locations are:
# output / TRANSLATION[lang] / CATEGORY_PATH / index.html (list of categories)
# output / TRANSLATION[lang] / CATEGORY_PATH / CATEGORY_PREFIX category.html (list of posts for a category)
# output / TRANSLATION[lang] / CATEGORY_PATH / CATEGORY_PREFIX category.xml (RSS feed for a category)
# output / TRANSLATION[lang] / CATEGORY_PATH / CATEGORY_PREFIX category RSS_EXTENSION (RSS feed for a category)
# (translatable)
# CATEGORY_PATH = "categories"
# CATEGORY_PREFIX = "cat_"
@@ -440,7 +440,7 @@ HIDDEN_CATEGORIES = []
# Path to author pages. Final locations are:
# output / TRANSLATION[lang] / AUTHOR_PATH / index.html (list of authors)
# output / TRANSLATION[lang] / AUTHOR_PATH / author.html (list of posts by an author)
# output / TRANSLATION[lang] / AUTHOR_PATH / author.xml (RSS feed for an author)
# output / TRANSLATION[lang] / AUTHOR_PATH / author RSS_EXTENSION (RSS feed for an author)
# (translatable)
# AUTHOR_PATH = "authors"

@@ -515,8 +515,15 @@ FRONT_INDEX_HEADER = {
# have mirrors of your site, they will point to SITE_URL everywhere.
USE_BASE_TAG = False

# Extension for RSS feed files
# RSS_EXTENSION = ".xml"

# RSS filename base (without extension); used for indexes, sections and galleries.
# (translatable)
# RSS_FILENAME_BASE = "rss"

# Final location for the blog main RSS feed is:
# output / TRANSLATION[lang] / RSS_PATH / rss.xml
# output / TRANSLATION[lang] / RSS_PATH / RSS_FILENAME_BASE RSS_EXTENSION
# (translatable)
# RSS_PATH = ""

@@ -1059,6 +1066,9 @@ 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
@@ -538,14 +538,17 @@ def __init__(self, **config):
'REDIRECTIONS': [],
'ROBOTS_EXCLUSIONS': [],
'GENERATE_ATOM': False,
'ATOM_EXTENSION': '.atom',
'FEED_TEASERS': True,
'FEED_PLAIN': False,
'FEED_PREVIEWIMAGE': True,
'FEED_READ_MORE_LINK': DEFAULT_FEED_READ_MORE_LINK,
'FEED_LINKS_APPEND_QUERY': False,
'GENERATE_RSS': True,
'RSS_EXTENSION': '.xml',
'RSS_LINK': None,
'RSS_PATH': '',
'RSS_FILENAME_BASE': 'rss',
'SEARCH_FORM': '',
'SHOW_BLOG_TITLE': True,
'SHOW_INDEX_PAGE_NAVIGATION': False,
@@ -656,6 +659,7 @@ def __init__(self, **config):
'SECTION_PATH',
'INDEX_PATH',
'RSS_PATH',
'RSS_FILENAME_BASE',
'AUTHOR_PATH',
'DATE_FORMAT',
'JS_DATE_FORMAT',
@@ -684,6 +688,7 @@ def __init__(self, **config):
)

self._ALL_PAGE_DEPENDENCIES_TRANSLATABLE = ('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.
@@ -1173,7 +1178,10 @@ def _set_all_page_dependencies_from_config(self):
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_DEPENDENCIES['atom_extension'] = self.config.get('ATOM_EXTENSION')
self.ALL_PAGE_DEPENDENCIES['rss_extension'] = self.config.get('RSS_EXTENSION')
self.ALL_PAGE_DEPENDENCIES['rss_path'] = self.config.get('RSS_PATH')
self.ALL_PAGE_DEPENDENCIES['rss_filename_base'] = self.config.get('RSS_FILENAME_BASE')

def _activate_plugins_of_category(self, category):
"""Activate all the plugins of a given category and return them."""
@@ -186,6 +186,7 @@ def analyze(self, fname, find_sources=False, check_remote=False):
self.existing_targets.add(self.site.config['SITE_URL'])
self.existing_targets.add(self.site.config['BASE_URL'])
url_type = self.site.config['URL_TYPE']
atom_extension = self.site.config['ATOM_EXTENSION']

deps = {}
if find_sources:
@@ -219,7 +220,7 @@ def analyze(self, fname, find_sources=False, check_remote=False):
extra_objs.append(lxml.etree.Element('img', src=srcset_item.strip().split(' ')[0]))
link_elements = list(d.iterlinks()) + list(extra_objs.iterlinks())
# Extract links from XML formats to minimal HTML, allowing those to go through the link checks
elif '.atom' == filename[-5:]:
elif atom_extension == filename[-len(atom_extension):]:
d = lxml.etree.parse(filename)
link_elements = lxml.html.fromstring('<html/>')
for elm in d.findall('*//{http://www.w3.org/2005/Atom}link'):
@@ -375,6 +376,7 @@ def scan_links(self, find_sources=False, check_remote=False):
self.logger.debug("===============\n")
self.logger.debug("{0} mode".format(self.site.config['URL_TYPE']))
failure = False
atom_extension = self.site.config['ATOM_EXTENSION']
# Maybe we should just examine all HTML files
output_folder = self.site.config['OUTPUT_FOLDER']

@@ -386,7 +388,7 @@ def scan_links(self, find_sources=False, check_remote=False):
if '.html' == fname[-5:]:
if self.analyze(fname, find_sources, check_remote):
failure = True
if '.atom' == fname[-5:]:
if atom_extension == fname[-len(atom_extension):]:
if self.analyze(fname, find_sources, False):
failure = True
if fname.endswith('sitemap.xml') or fname.endswith('sitemapindex.xml'):
@@ -233,14 +233,14 @@ def _postprocess_path(self, path, lang, append_index='auto', dest_type='page', p
# Forcing extension for Atom feeds and RSS feeds
force_extension = None
if dest_type == 'feed':
force_extension = '.atom'
force_extension = self.site.config['ATOM_EXTENSION']
elif dest_type == 'rss':
force_extension = '.xml'
force_extension = self.site.config['RSS_EXTENSION']
# Determine how to extend path
path = [_f for _f in path if _f]
if force_extension is not None:
if len(path) == 0 and dest_type == 'rss':
path = ['rss']
path = [self.site.config['RSS_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':
@@ -162,7 +162,7 @@ def gallery_rss_path(self, name, lang):
gallery_path = self._find_gallery_path(name)
return [_f for _f in [self.site.config['TRANSLATIONS'][lang]] +
gallery_path.split(os.sep) +
['rss.xml'] if _f]
[self.site.config['RSS_FILENAME_BASE'](lang) + self.site.config['RSS_EXTENSION']] if _f]

def gen_tasks(self):
"""Render image galleries."""
@@ -91,7 +91,10 @@ def get_classification_friendly_name(self, classification, lang, only_last_compo
def get_path(self, classification, lang, dest_type='page'):
"""Return a path for the given classification."""
if dest_type == 'rss':
return [self.site.config['RSS_PATH'](lang), 'rss'], 'auto'
return [
self.site.config['RSS_PATH'](lang),
self.site.config['RSS_FILENAME_BASE'](lang)
], 'auto'
# 'page' (index) or 'feed' (Atom)
page_number = None
if dest_type == 'page':
@@ -100,7 +100,7 @@ def get_path(self, section, lang, dest_type='page'):
"""Return a path for the given classification."""
result = [_f for _f in [self.site.config['SECTION_PATH'](lang), section] if _f]
if dest_type == 'rss':
return result + ['rss.xml'], 'never'
return result + [self.site.config['RSS_FILENAME_BASE'](lang)], 'auto'
return result, 'always'

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

0 comments on commit da261b7

Please sign in to comment.