From: Michael Hanke Date: Mon, 26 Sep 2011 10:49:56 +0000 (+0200) Subject: Merge branch '3rd-party-pristine' X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=73ad1fff3e6549776cd41142a33b325f5c602d84;p=neurodebian.git Merge branch '3rd-party-pristine' * 3rd-party-pristine: Update the feed extension from sphinxext repo. Conflicts: sphinx/sphinxext/feed/__init__.py --- 73ad1fff3e6549776cd41142a33b325f5c602d84 diff --cc sphinx/sphinxext/feed/__init__.py index 13706a1,ff4fee1..35faeb4 --- a/sphinx/sphinxext/feed/__init__.py +++ b/sphinx/sphinxext/feed/__init__.py @@@ -3,7 -2,7 +3,8 @@@ from fsdict import FSDic import feedgenerator from urllib import quote_plus import os.path +import re + import directives #global feed_entries = None @@@ -18,18 -26,12 +28,18 @@@ def setup(app) """ from sphinx.application import Sphinx if not isinstance(app, Sphinx): return + app.add_config_value('feed_title', '', 'html') app.add_config_value('feed_base_url', '', 'html') app.add_config_value('feed_description', '', 'html') - app.add_config_value('feed_filename', 'rss.xml', 'html') - + app.add_config_value('feed_title', '', 'html') + app.add_config_value('feed_subtitle', '', 'html') + app.add_config_value('feed_author_name', '', 'html') + app.add_config_value('feed_author_email', '', 'html') + app.add_config_value('feed_categories', [], 'html') + app.add_config_value('feed_variants', + {'all': {'filename': 'rss.xml', 'categories': None}}, + 'html') app.connect('html-page-context', create_feed_item) - app.connect('html-page-context', inject_feed_url) app.connect('build-finished', emit_feed) app.connect('builder-inited', create_feed_container) app.connect('env-purge-doc', remove_dead_feed_item) @@@ -43,12 -45,9 +53,14 @@@ def create_feed_container(app) global feed_entries rss_fragment_path = os.path.realpath(os.path.join(app.outdir, '..', 'rss_entry_fragments')) feed_entries = FSDict(work_dir=rss_fragment_path) - app.builder.env.feed_url = app.config.feed_base_url + '/' + 'feed_container' + app.builder.env.feed_url = app.config.feed_base_url + '/' + \ + app.config.feed_filename +def inject_feed_url(app, pagename, templatename, ctx, doctree): + #We like to provide our templates with a way to link to the rss output file + ctx['rss_link'] = app.builder.env.feed_url #app.config.feed_base_url + '/' + app.config.feed_filename + ++ def create_feed_item(app, pagename, templatename, ctx, doctree): """ Here we have access to nice HTML fragments to use in, say, an RSS feed. @@@ -83,21 -79,16 +97,25 @@@ 'title': ctx.get('title'), 'link': link, 'unique_id': link, - 'description': absolutify(ctx.get('body'), link), - 'pubdate': pub_date + 'description': absolutify(body, link), + 'pubdate': pub_date, + 'categories': () } + if 'tags' in metadata: + item['categories'] = metadata['tags'].split(",") if 'author' in metadata: - item['author'] = metadata['author'] - feed_entries[nice_name(pagename, pub_date)] = item + item['author_name'] = metadata['author'] + else: + item['author_name'] = app.config.feed_author_name + if 'author_email' in metadata: + item['author_email'] = metadata['author_email'] + else: + item['author_email'] = app.config.feed_author_email + feed_entries[nice_name(pagename, pub_date)] = item + + #Now, useful variables to keep in context + ctx['rss_link'] = app.builder.env.feed_url + ctx['pub_date'] = pub_date def remove_dead_feed_item(app, env, docname): """ @@@ -114,15 -105,15 +132,19 @@@ def emit_feed(app, exc) global feed_entries import os.path + title = app.config.feed_title + if not title: + title = app.config.project + feed_dict = { - 'title': app.config.feed_title, + 'title': title, + 'subtitle': app.config.feed_subtitle, 'link': app.config.feed_base_url, 'feed_url': app.config.feed_base_url, - 'description': app.config.feed_description + 'description': app.config.feed_description, + 'categories': app.config.feed_categories, + 'author_name': app.config.feed_author_name, + 'author_email': app.config.feed_author_email } if app.config.language: feed_dict['language'] = app.config.language