Add Simple GeoRSS support
This commit is contained in:
parent
9ac741ac0e
commit
c0a1acc18c
2 changed files with 37 additions and 0 deletions
15
feedgen/ext/geo.py
Normal file
15
feedgen/ext/geo.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from lxml import etree
|
||||
from feedgen.ext.base import BaseExtension
|
||||
|
||||
class GeoExtension(BaseExtension):
|
||||
def __init__(self):
|
||||
self.__point__ = None
|
||||
|
||||
def extend_ns(self):
|
||||
return { 'georss' : 'http://www.georss.org/georss' }
|
||||
|
||||
def extend_rss(self, rss_feed):
|
||||
return rss_feed
|
||||
|
||||
def extend_atom(self, atom_feed):
|
||||
return atom_feed
|
22
feedgen/ext/geo_entry.py
Normal file
22
feedgen/ext/geo_entry.py
Normal file
|
@ -0,0 +1,22 @@
|
|||
from lxml import etree
|
||||
from feedgen.ext.base import BaseEntryExtension
|
||||
|
||||
class GeoEntryExtension(BaseEntryExtension):
|
||||
def __init__(self):
|
||||
self.__point = None
|
||||
|
||||
def extend_rss(self, entry):
|
||||
GEO_NS = 'http://www.georss.org/georss'
|
||||
|
||||
if self.__point:
|
||||
point = etree.SubElement(entry, '{%s}point' % GEO_NS)
|
||||
point.text = self.__point
|
||||
|
||||
return entry
|
||||
|
||||
def extend_atom(self, entry):
|
||||
return self.extend_rss(self, entry)
|
||||
|
||||
def point(self, point=None):
|
||||
self.__point = point or '0.0 0.0'
|
||||
return self.__point
|
Loading…
Reference in a new issue