Feed fixes

This commit is contained in:
Sam Ruby 2006-09-05 18:11:57 -04:00
parent c8eab0ec66
commit a2be5b6c2a
4 changed files with 15 additions and 4 deletions

View File

@ -97,7 +97,6 @@ def __init__():
define_planet('owner_email', '')
define_planet('output_theme', '')
define_planet('output_dir', 'output')
define_planet('feed', None)
define_planet_list('template_files')
define_planet_list('bill_of_materials')
@ -244,9 +243,9 @@ def cache_lists_directory():
def feed():
if parser.has_option('Planet', 'feed'):
parser.get('Planet', 'feed')
return parser.get('Planet', 'feed')
elif link():
for template_file in template_files:
for template_file in template_files():
name = os.path.splitext(os.path.basename(template_file))[0]
if name.find('atom')>=0 or name.find('rss')>=0:
return urljoin(link(), name)

View File

@ -28,11 +28,18 @@ def splice():
date(feed, 'updated', time.gmtime())
gen = createTextElement(feed, 'generator', config.generator())
gen.setAttribute('uri', config.generator_uri())
author = doc.createElement('author')
createTextElement(author, 'name', config.owner_name())
createTextElement(author, 'email', config.owner_email())
feed.appendChild(author)
createTextElement(feed, 'id', config.feed())
link = doc.createElement('link')
link.setAttribute('rel', 'self')
link.setAttribute('href', config.feed())
feed.appendChild(link)
# insert entry information
for mtime,file in dir[:items]:
try:

View File

@ -1,5 +1,6 @@
[Planet]
name = Test Configuration
link = http://example.com/
template_files = index.html.tmpl atom.xml.tmpl
items_per_page = 50
filters = foo

View File

@ -18,13 +18,17 @@ class ConfigTest(unittest.TestCase):
feeds.sort()
self.assertEqual(['feed1', 'feed2'], feeds)
def test_feed(self):
self.assertEqual('http://example.com/atom.xml', config.feed())
self.assertEqual('atom', config.feedtype())
# planet wide configuration
def test_name(self):
self.assertEqual('Test Configuration', config.name())
def test_link(self):
self.assertEqual('', config.link())
self.assertEqual('http://example.com/', config.link())
# per template configuration