1
0
Fork 0
forked from github/pelican

Make it possible to specify custom URLs for feeds.

With this patch, there are new FEED_*_URL configuration options that
allow to specify custom URLs for feeds, which is helpful in case the
feed filename and the actual URL differ a lot -- for example if a feed
is saved to

    blog/feeds/all.atom.xml

but the actual URL from the user PoV is

    http://blog.your.site/feeds/all.atom.xml

This setting currently affects only the generated feed XML. This change
is also fully backwards compatible, so if the FEED_*_URL setting is not
present, the value of FEED_* is used for both file location and URL.
This commit is contained in:
Vladimír Vondruš 2017-10-29 19:58:26 +01:00
commit 343e24a26f
4 changed files with 140 additions and 21 deletions

View file

@ -155,6 +155,7 @@ class TestArticlesGenerator(unittest.TestCase):
writer = MagicMock()
generator.generate_feeds(writer)
writer.write_feed.assert_called_with([], settings,
'feeds/all.atom.xml',
'feeds/all.atom.xml')
generator = ArticlesGenerator(
@ -164,6 +165,20 @@ class TestArticlesGenerator(unittest.TestCase):
generator.generate_feeds(writer)
self.assertFalse(writer.write_feed.called)
@unittest.skipUnless(MagicMock, 'Needs Mock module')
def test_generate_feeds_override_url(self):
settings = get_settings()
settings['CACHE_PATH'] = self.temp_cache
settings['FEED_ALL_ATOM_URL'] = 'feeds/atom/all/'
generator = ArticlesGenerator(
context=settings, settings=settings,
path=None, theme=settings['THEME'], output_path=None)
writer = MagicMock()
generator.generate_feeds(writer)
writer.write_feed.assert_called_with([], settings,
'feeds/all.atom.xml',
'feeds/atom/all/')
def test_generate_context(self):
articles_expected = [
['Article title', 'published', 'Default', 'article'],