Preserve link/title, map rss source to atom source

This commit is contained in:
Sam Ruby 2010-05-20 16:11:39 -04:00
parent bc72bf572f
commit d2f2f8510b
3 changed files with 16 additions and 17 deletions

View File

@ -103,6 +103,8 @@ def links(xentry, entry):
xlink.setAttribute('type', link.get('type'))
if link.has_key('rel'):
xlink.setAttribute('rel', link.get('rel',None))
if link.has_key('title'):
xlink.setAttribute('title', link.get('title'))
if link.has_key('length'):
xlink.setAttribute('length', link.get('length'))
xentry.appendChild(xlink)
@ -229,15 +231,11 @@ def source(xsource, source, bozo, format):
for contributor in source.get('contributors',[]):
author(xsource, 'contributor', contributor)
links(xsource, source)
if not source.has_key('links') and source.has_key('href'): #rss
xlink = xdoc.createElement('link')
xlink.setAttribute('href', source.get('href'))
xsource.appendChild(xlink)
if source.has_key('title'):
xtitle = xdoc.createElement('title')
xtitle.appendChild(xdoc.createTextNode(source.get('title')))
xsource.appendChild(xtitle)
source['links'] = [{ 'href': source.get('href') }]
if source.has_key('title'):
source['links'][0]['title'] = source.get('title')
links(xsource, source)
content(xsource, 'rights', source.get('rights_detail',None), bozo)
content(xsource, 'subtitle', source.get('subtitle_detail',None), bozo)

View File

@ -59,15 +59,16 @@ def splice():
if data.feed.has_key('id'): sub_ids.append(data.feed.id)
if not data.feed: continue
for link in data.feed.links:
if link.rel == 'self': break
else:
log.warn('missing self link for ' + sub)
if not data.feed.has_key('planet_message'):
for link in data.feed.links:
if link.rel == 'self': break
else:
log.warn('missing self link for ' + sub)
for link in data.feed.links:
if link.rel == 'alternate' and 'html' in link.type: break
else:
log.warn('missing html link for ' + sub)
for link in data.feed.links:
if link.rel == 'alternate' and 'html' in link.type: break
else:
log.warn('missing html link for ' + sub)
xdoc=minidom.parseString('''<planet:source xmlns:planet="%s"
xmlns="http://www.w3.org/2005/Atom"/>\n''' % planet.xmlns)

View File

@ -1,6 +1,6 @@
<!--
Description: source element
Expect: source.title == 'org'
Expect: source.links[0].title == 'org' and source.links[0].href == 'http://www.example.org'
-->
<rss version="2.0">