Skip to content

Commit

Permalink
Deprecated RSS_READ_MORE_LINK and RSS_LINKS_APPEND_QUERY
Browse files Browse the repository at this point in the history
Replaced by FEED_READ_MORE_LINK and FEED_LINKS_APPEND_QUERY.
  • Loading branch information
da2x committed Sep 18, 2015
1 parent c4c69c0 commit 4b79e20
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 46 deletions.
6 changes: 4 additions & 2 deletions CHANGES.txt
Expand Up @@ -10,8 +10,10 @@ Features
Bugfixes
--------

* Deprecated ``RSS_TEASERS`` and ``RSS_PLAIN`` in favor of ``FEED_TEASERS``
and ``FEED_PLAIN`` for both RSS and Atom feeds. (Issue #2095)
* Deprecated ``RSS_TEASERS``, ``RSS_PLAIN``, ``RSS_READ_MORE_LINK``, and
``RSS_LINKS_APPEND_QUERY`` in favor of ``FEED_TEASERS``, ``FEED_PLAIN``,
``FEED_READ_MORE_LINK``, and ``FEED_LINKS_APPEND_QUERY`` for both Atom
and RSS feeds. (Issue #2095)
* /robots.txt was never being built (Issue #2098)

New in v7.7.1
Expand Down
4 changes: 2 additions & 2 deletions docs/manual.txt
Expand Up @@ -515,8 +515,8 @@ In Markdown (or basically, the resulting HTML of any format):
By default all your RSS feeds will be shortened (they'll contain only teasers)
whereas your index page will still show complete posts. You can change
this behaviour with your ``conf.py``: ``INDEX_TEASERS`` defines whether index
page should display the whole contents or only teasers. ``RSS_TEASERS``
works the same way for your RSS feeds.
page should display the whole contents or only teasers. ``FEED_TEASERS``
works the same way for your Atom and RSS feeds.

By default, teasers will include a "read more" link at the end. If you want to
change that text, you can use a custom teaser:
Expand Down
17 changes: 9 additions & 8 deletions nikola/conf.py.in
Expand Up @@ -675,17 +675,17 @@ IMAGE_FOLDERS = {'images': 'images'}
# 'Read more...' for the index page, if INDEX_TEASERS is True (translatable)
INDEX_READ_MORE_LINK = ${INDEX_READ_MORE_LINK}
# 'Read more...' for the RSS_FEED, if FEED_TEASERS is True (translatable)
RSS_READ_MORE_LINK = ${RSS_READ_MORE_LINK}
FEED_READ_MORE_LINK = ${FEED_READ_MORE_LINK}

# Append a URL query to the RSS_READ_MORE_LINK in Atom and RSS feeds. Advanced
# Append a URL query to the FEED_READ_MORE_LINK in Atom and RSS feeds. Advanced
# option used for traffic source tracking.
# Minimum example for use with Piwik: "pk_campaign=feed"
# The following tags exist and are replaced for you:
# {feedRelUri} A relative link to the feed.
# {feedFormat} The name of the syndication format.
# Example using replacement for use with Google Analytics:
# "utm_source={feedRelUri}&utm_medium=nikola_feed&utm_campaign={feedFormat}_feed"
RSS_LINKS_APPEND_QUERY = False
FEED_LINKS_APPEND_QUERY = False

# A HTML fragment describing the license, for the sidebar.
# (translatable)
Expand Down Expand Up @@ -889,16 +889,17 @@ MARKDOWN_EXTENSIONS = ['fenced_code', 'codehilite', 'extra']
# them. Generate Atom for tags by setting TAG_PAGES_ARE_INDEXES to True.
# Atom feeds are built based on INDEX_DISPLAY_POST_COUNT and not FEED_LENGTH
# Switch between plain-text summaries and full HTML content using the
# FEED_TEASER option. RSS_LINKS_APPEND_QUERY is also respected. Atom feeds
# FEED_TEASER option. FEED_LINKS_APPEND_QUERY is also respected. Atom feeds
# are generated even for old indexes and have pagination link relations
# between each other. Old Atom feeds with no changes are marked as archived.
# GENERATE_ATOM = False

# Only inlclude teasers in Atom and RSS feeds. Disabling include the full content.
# Only inlclude teasers in Atom and RSS feeds. Disabling include the full
# content. Defaults to True.
# FEED_TEASERS = True

# Strip HTML from Atom annd RSS feed summaries and content.
# FEED_PLAIN = True
# Strip HTML from Atom annd RSS feed summaries and content. Defaults to False.
# FEED_PLAIN = False

# Number of posts in Atom and RSS feeds.
# FEED_LENGTH = 10
Expand All @@ -907,7 +908,7 @@ MARKDOWN_EXTENSIONS = ['fenced_code', 'codehilite', 'extra']
# Requires FEED_PLAIN = False. If the preview image is found in the content,
# it will not be included again. Image will be included as-is, aim to optmize
# the image source for Feedly, Apple News, Flipboard, and other popular clients.
# FEED_PREVIEWIMAGE = False
# FEED_PREVIEWIMAGE = True

# RSS_LINK is a HTML fragment to link the RSS or Atom feeds. If set to None,
# the base.tmpl will use the feed Nikola generates. However, you may want to
Expand Down
53 changes: 35 additions & 18 deletions nikola/nikola.py
Expand Up @@ -80,7 +80,7 @@

# Default "Read more..." link
DEFAULT_INDEX_READ_MORE_LINK = '<p class="more"><a href="{link}">{read_more}…</a></p>'
DEFAULT_RSS_READ_MORE_LINK = '<p><a href="{link}">{read_more}…</a> ({min_remaining_read})</p>'
DEFAULT_FEED_READ_MORE_LINK = '<p><a href="{link}">{read_more}…</a> ({min_remaining_read})</p>'

# Default pattern for translation files' names
DEFAULT_TRANSLATIONS_PATTERN = '{path}.{lang}.{ext}'
Expand Down Expand Up @@ -450,14 +450,14 @@ def __init__(self, **config):
'PRETTY_URLS': False,
'FUTURE_IS_NOW': False,
'INDEX_READ_MORE_LINK': DEFAULT_INDEX_READ_MORE_LINK,
'RSS_READ_MORE_LINK': DEFAULT_RSS_READ_MORE_LINK,
'RSS_LINKS_APPEND_QUERY': False,
'REDIRECTIONS': [],
'ROBOTS_EXCLUSIONS': [],
'GENERATE_ATOM': False,
'FEED_TEASERS': True,
'FEED_PLAIN': True,
'FEED_PREVIEWIMAGE': False,
'FEED_PLAIN': False,
'FEED_PREVIEWIMAGE': True,
'FEED_READ_MORE_LINK': DEFAULT_FEED_READ_MORE_LINK,
'FEED_LINKS_APPEND_QUERY': False,
'GENERATE_RSS': True,
'RSS_LINK': None,
'RSS_PATH': '',
Expand Down Expand Up @@ -544,7 +544,7 @@ def __init__(self, **config):
'EXTRA_HEAD_DATA',
'NAVIGATION_LINKS',
'INDEX_READ_MORE_LINK',
'RSS_READ_MORE_LINK',
'FEED_READ_MORE_LINK',
'INDEXES_TITLE',
'POSTS_SECTION_COLORS',
'POSTS_SECTION_DESCRIPTIONS',
Expand Down Expand Up @@ -619,11 +619,28 @@ def __init__(self, **config):

# RSS_PLAIN has been replaced with FEED_PLAIN
# TODO: remove on v8
if 'RSS_TEASERS' in config:
utils.LOGGER.warn('The RSS_TEASERS option is deprecated, use FEED_TEASERS instead.')
if 'RSS_PLAIN' in config:
utils.LOGGER.warn('The RSS_PLAIN option is deprecated, use FEED_PLAIN instead.')
if 'FEED_PLAIN' in config:
utils.LOGGER.warn('FEED_PLIN conflicts with RSS_PLAIN, ignoring RSS_PLAIN.')
self.config['FEED_PLAIN'] = config['RSS_PLAIN']

# RSS_LINKS_APPEND_QUERY has been replaced with FEED_LINKS_APPEND_QUERY
# TODO: remove on v8
if 'RSS_LINKS_APPEND_QUERY' in config:
utils.LOGGER.warn('The RSS_LINKS_APPEND_QUERY option is deprecated, use FEED_LINKS_APPEND_QUERY instead.')
if 'FEED_TEASERS' in config:
utils.LOGGER.warn('FEED_TEASERS conflicts with RSS_TEASERS, ignoring RSS_TEASERS.')
self.config['FEED_TEASERS'] = config['RSS_TEASERS']
utils.LOGGER.warn('FEED_LINKS_APPEND_QUERY conflicts with RSS_LINKS_APPEND_QUERY, ignoring RSS_LINKS_APPEND_QUERY.')
self.config['FEED_LINKS_APPEND_QUERY'] = utils.TranslatableSetting('FEED_LINKS_APPEND_QUERY', config['RSS_LINKS_APPEND_QUERY'], self.config['TRANSLATIONS'])

# RSS_READ_MORE_LINK has been replaced with FEED_READ_MORE_LINK
# TODO: remove on v8
if 'RSS_READ_MORE_LINK' in config:
utils.LOGGER.warn('The RSS_READ_MORE_LINK option is deprecated, use FEED_READ_MORE_LINK instead.')
if 'FEED_READ_MORE_LINK' in config:
utils.LOGGER.warn('FEED_READ_MORE_LINK conflicts with RSS_READ_MORE_LINK, ignoring RSS_READ_MORE_LINK')
self.config['FEED_READ_MORE_LINK'] = utils.TranslatableSetting('FEED_READ_MORE_LINK', config['RSS_READ_MORE_LINK'], self.config['TRANSLATIONS'])


# DEFAULT_TRANSLATIONS_PATTERN was changed from "p.e.l" to "p.l.e"
# TODO: remove on v8
Expand Down Expand Up @@ -1297,7 +1314,7 @@ def generic_rss_renderer(self, lang, title, link, description, timeline, output_

for post in timeline[:feed_length]:
data = post.text(lang, teaser_only=rss_teasers, strip_html=rss_plain,
rss_read_more_link=True, rss_links_append_query=feed_append_query)
feed_read_more_link=True, feed_links_append_query=feed_append_query)
if feed_url is not None and data:
# Massage the post's HTML (unless plain)
if not rss_plain:
Expand Down Expand Up @@ -1898,8 +1915,8 @@ def atom_link(link_rel, link_type, link_href):
feed_generator.text = "Nikola"

feed_append_query = None
if self.config["RSS_LINKS_APPEND_QUERY"]:
feed_append_query = self.config["RSS_LINKS_APPEND_QUERY"].format(
if self.config["FEED_LINKS_APPEND_QUERY"]:
feed_append_query = self.config["FEED_LINKS_APPEND_QUERY"].format(
feedRelUri=context["feedlink"],
feedFormat="atom")

Expand Down Expand Up @@ -1929,14 +1946,14 @@ def atom_post_text(post, text):
for post in posts:
summary = atom_post_text(post, post.text(lang, teaser_only=True,
strip_html=self.config["FEED_PLAIN"],
rss_read_more_link=True,
rss_links_append_query=feed_append_query))
feed_read_more_link=True,
feed_links_append_query=feed_append_query))
content = None
if not self.config["FEED_TEASERS"]:
content = atom_post_text(post, post.text(lang, teaser_only=self.config["FEED_TEASERS"],
strip_html=self.config["FEED_PLAIN"],
rss_read_more_link=True,
rss_links_append_query=feed_append_query))
feed_read_more_link=True,
feed_links_append_query=feed_append_query))

entry_root = lxml.etree.SubElement(feed_root, "entry")
entry_title = lxml.etree.SubElement(entry_root, "title")
Expand Down Expand Up @@ -2016,7 +2033,7 @@ def generic_index_renderer(self, lang, posts, indexes_title, template_name, cont
kw['indexes_prety_page_url'] = self.config["INDEXES_PRETTY_PAGE_URL"]
kw['demote_headers'] = self.config['DEMOTE_HEADERS']
kw['generate_atom'] = self.config["GENERATE_ATOM"]
kw['feed_link_append_query'] = self.config["RSS_LINKS_APPEND_QUERY"]
kw['feed_link_append_query'] = self.config["FEED_LINKS_APPEND_QUERY"]
kw['currentfeed'] = None

# Split in smaller lists
Expand Down
2 changes: 1 addition & 1 deletion nikola/plugins/command/check.py
Expand Up @@ -227,7 +227,7 @@ def analyze(self, fname, find_sources=False, check_remote=False):
d = lxml.etree.parse(filename)
link_elements = lxml.html.fromstring('<html/>')
for elm in d.findall('*//{http://www.w3.org/2005/Atom}link'):
feed_link = elm.attrib['href'].split('?')[0].strip() # strip RSS_LINKS_APPEND_QUERY
feed_link = elm.attrib['href'].split('?')[0].strip() # strip FEED_LINKS_APPEND_QUERY
link_elements.append(lxml.etree.Element('a', href=feed_link))
link_elements = list(link_elements.iterlinks())
elif filename.endswith('sitemap.xml') or filename.endswith('sitemapindex.xml'):
Expand Down
8 changes: 4 additions & 4 deletions nikola/plugins/command/init.py
Expand Up @@ -41,7 +41,7 @@
import tarfile

import nikola
from nikola.nikola import DEFAULT_TRANSLATIONS_PATTERN, DEFAULT_INDEX_READ_MORE_LINK, DEFAULT_RSS_READ_MORE_LINK, LEGAL_VALUES, urlsplit, urlunsplit
from nikola.nikola import DEFAULT_TRANSLATIONS_PATTERN, DEFAULT_INDEX_READ_MORE_LINK, DEFAULT_FEED_READ_MORE_LINK, LEGAL_VALUES, urlsplit, urlunsplit
from nikola.plugin_categories import Command
from nikola.utils import ask, ask_yesno, get_logger, makedirs, STDERR_HANDLER, load_messages
from nikola.packages.tzlocal import get_localzone
Expand Down Expand Up @@ -71,7 +71,7 @@
'CATEGORY_OUTPUT_FLAT_HIERARCHY': False,
'TRANSLATIONS_PATTERN': DEFAULT_TRANSLATIONS_PATTERN,
'INDEX_READ_MORE_LINK': DEFAULT_INDEX_READ_MORE_LINK,
'RSS_READ_MORE_LINK': DEFAULT_RSS_READ_MORE_LINK,
'FEED_READ_MORE_LINK': DEFAULT_FEED_READ_MORE_LINK,
'POSTS': """(
("posts/*.rst", "posts", "post.tmpl"),
("posts/*.txt", "posts", "post.tmpl"),
Expand Down Expand Up @@ -210,10 +210,10 @@ def prepare_config(config):
"""Parse sample config with JSON."""
p = config.copy()
p.update({k: json.dumps(v, ensure_ascii=False) for k, v in p.items()
if k not in ('POSTS', 'PAGES', 'COMPILERS', 'TRANSLATIONS', 'NAVIGATION_LINKS', '_SUPPORTED_LANGUAGES', '_SUPPORTED_COMMENT_SYSTEMS', 'INDEX_READ_MORE_LINK', 'RSS_READ_MORE_LINK')})
if k not in ('POSTS', 'PAGES', 'COMPILERS', 'TRANSLATIONS', 'NAVIGATION_LINKS', '_SUPPORTED_LANGUAGES', '_SUPPORTED_COMMENT_SYSTEMS', 'INDEX_READ_MORE_LINK', 'FEED_READ_MORE_LINK')})
# READ_MORE_LINKs require some special treatment.
p['INDEX_READ_MORE_LINK'] = "'" + p['INDEX_READ_MORE_LINK'].replace("'", "\\'") + "'"
p['RSS_READ_MORE_LINK'] = "'" + p['RSS_READ_MORE_LINK'].replace("'", "\\'") + "'"
p['FEED_READ_MORE_LINK'] = "'" + p['FEED_READ_MORE_LINK'].replace("'", "\\'") + "'"
# fix booleans and None
p.update({k: str(v) for k, v in config.items() if isinstance(v, bool) or v is None})
return p
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/task/authors.py
Expand Up @@ -70,7 +70,7 @@ def gen_tasks(self):
"generate_rss": self.site.config['GENERATE_RSS'],
"feed_teasers": self.site.config["FEED_TEASERS"],
"feed_plain": self.site.config["FEED_PLAIN"],
"rss_link_append_query": self.site.config["RSS_LINKS_APPEND_QUERY"],
"feed_link_append_query": self.site.config["FEED_LINKS_APPEND_QUERY"],
"show_untranslated_posts": self.site.config['SHOW_UNTRANSLATED_POSTS'],
"feed_length": self.site.config['FEED_LENGTH'],
"tzinfo": self.site.tzinfo,
Expand Down Expand Up @@ -238,7 +238,7 @@ def author_rss(self, author, lang, posts, kw):
(lang, "{0} ({1})".format(kw["blog_title"](lang), self._get_title(author)),
kw["site_url"], None, post_list,
output_name, kw["feed_teasers"], kw["feed_plain"], kw['feed_length'],
feed_url, None, kw["rss_link_append_query"]))],
feed_url, None, kw["feed_link_append_query"]))],
'clean': True,
'uptodate': [utils.config_changed(kw, 'nikola.plugins.task.authors:rss')] + deps_uptodate,
'task_dep': ['render_posts'],
Expand Down
6 changes: 3 additions & 3 deletions nikola/plugins/task/rss.py
Expand Up @@ -64,8 +64,8 @@ def gen_tasks(self):
"feed_length": self.site.config['FEED_LENGTH'],
"feed_previewimage": self.site.config["FEED_PREVIEWIMAGE"],
"tzinfo": self.site.tzinfo,
"rss_read_more_link": self.site.config["RSS_READ_MORE_LINK"],
"rss_links_append_query": self.site.config["RSS_LINKS_APPEND_QUERY"],
"feed_read_more_link": self.site.config["FEED_READ_MORE_LINK"],
"feed_links_append_query": self.site.config["FEED_LINKS_APPEND_QUERY"],
}
self.site.scan_posts()
# Check for any changes in the state of use_in_feeds for any post.
Expand Down Expand Up @@ -98,7 +98,7 @@ def gen_tasks(self):
(lang, kw["blog_title"](lang), kw["site_url"],
kw["blog_description"](lang), posts, output_name,
kw["feed_teasers"], kw["feed_plain"], kw['feed_length'], feed_url,
None, kw["rss_links_append_query"]))],
None, kw["feed_links_append_query"]))],

'task_dep': ['render_posts'],
'clean': True,
Expand Down
4 changes: 2 additions & 2 deletions nikola/plugins/task/tags.py
Expand Up @@ -76,7 +76,7 @@ def gen_tasks(self):
"generate_rss": self.site.config['GENERATE_RSS'],
"feed_teasers": self.site.config["FEED_TEASERS"],
"feed_plain": self.site.config["FEED_PLAIN"],
"rss_link_append_query": self.site.config["RSS_LINKS_APPEND_QUERY"],
"feed_link_append_query": self.site.config["FEED_LINKS_APPEND_QUERY"],
"show_untranslated_posts": self.site.config['SHOW_UNTRANSLATED_POSTS'],
"feed_length": self.site.config['FEED_LENGTH'],
"taglist_minimum_post_count": self.site.config['TAGLIST_MINIMUM_POSTS'],
Expand Down Expand Up @@ -380,7 +380,7 @@ def tag_rss(self, tag, lang, posts, kw, is_category):
(lang, "{0} ({1})".format(kw["blog_title"](lang), self._get_title(tag, is_category)),
kw["site_url"], None, post_list,
output_name, kw["feed_teasers"], kw["feed_plain"], kw['feed_length'],
feed_url, None, kw["rss_link_append_query"]))],
feed_url, None, kw["feed_link_append_query"]))],
'clean': True,
'uptodate': [utils.config_changed(kw, 'nikola.plugins.task.tags:rss')] + deps_uptodate,
'task_dep': ['render_posts'],
Expand Down
8 changes: 4 additions & 4 deletions nikola/post.py
Expand Up @@ -554,13 +554,13 @@ def _translated_file_path(self, lang):
return get_translation_candidate(self.config, self.base_path, sorted(self.translated_to)[0])

def text(self, lang=None, teaser_only=False, strip_html=False, show_read_more_link=True,
rss_read_more_link=False, rss_links_append_query=None):
feed_read_more_link=False, feed_links_append_query=None):
"""Read the post file for that language and return its contents.
teaser_only=True breaks at the teaser marker and returns only the teaser.
strip_html=True removes HTML tags
show_read_more_link=False does not add the Read more... link
rss_read_more_link=True uses RSS_READ_MORE_LINK instead of INDEX_READ_MORE_LINK
feed_read_more_link=True uses FEED_READ_MORE_LINK instead of INDEX_READ_MORE_LINK
lang=None uses the last used to set locale
All links in the returned HTML will be relative.
Expand Down Expand Up @@ -609,9 +609,9 @@ def text(self, lang=None, teaser_only=False, strip_html=False, show_read_more_li
teaser_text = teaser_regexp.search(data).groups()[-1]
else:
teaser_text = self.messages[lang]["Read more"]
l = self.config['RSS_READ_MORE_LINK'](lang) if rss_read_more_link else self.config['INDEX_READ_MORE_LINK'](lang)
l = self.config['FEED_READ_MORE_LINK'](lang) if feed_read_more_link else self.config['INDEX_READ_MORE_LINK'](lang)
teaser += l.format(
link=self.permalink(lang, query=rss_links_append_query),
link=self.permalink(lang, query=feed_links_append_query),
read_more=teaser_text,
min_remaining_read=self.messages[lang]["%d min remaining to read"] % (self.remaining_reading_time),
reading_time=self.reading_time,
Expand Down

0 comments on commit 4b79e20

Please sign in to comment.