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

View File

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

View File

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

View File

@ -18,13 +18,17 @@ class ConfigTest(unittest.TestCase):
feeds.sort() feeds.sort()
self.assertEqual(['feed1', 'feed2'], feeds) 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 # planet wide configuration
def test_name(self): def test_name(self):
self.assertEqual('Test Configuration', config.name()) self.assertEqual('Test Configuration', config.name())
def test_link(self): def test_link(self):
self.assertEqual('', config.link()) self.assertEqual('http://example.com/', config.link())
# per template configuration # per template configuration