summaryrefslogtreecommitdiff
path: root/feedgenerator
diff options
context:
space:
mode:
authorEevee (Lexy Munroe) <eevee.git@veekun.com>2016-01-04 15:30:17 -0800
committerEevee (Lexy Munroe) <eevee.git@veekun.com>2016-01-04 15:30:17 -0800
commit33344f6ec9375c0e279fda1583acbcb97e35bac4 (patch)
treeffc328a0a178809ec28e6ac68b40337eea91e193 /feedgenerator
parent9dcf6e12cd9d26b170a36a513dd06d477635c1bf (diff)
downloadfeedgenerator-33344f6ec9375c0e279fda1583acbcb97e35bac4.tar.gz
Support Atom's <content> element
Adds a `content` kwarg to `add_item`, which will become the <content> of an Atom entry. For RSS, which has no equivalent, the content is silently ignored; this is consistent with how Atom ignores metadata like `ttl` that only exists in RSS.
Diffstat (limited to 'feedgenerator')
-rw-r--r--feedgenerator/django/utils/feedgenerator.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/feedgenerator/django/utils/feedgenerator.py b/feedgenerator/django/utils/feedgenerator.py
index 25b4ba1..eafb736 100644
--- a/feedgenerator/django/utils/feedgenerator.py
+++ b/feedgenerator/django/utils/feedgenerator.py
@@ -114,7 +114,7 @@ class SyndicationFeed(object):
def add_item(self, title, link, description, author_email=None,
author_name=None, author_link=None, pubdate=None, comments=None,
unique_id=None, enclosure=None, categories=(), item_copyright=None,
- ttl=None, **kwargs):
+ ttl=None, content=None, **kwargs):
"""
Adds an item to the feed. All args are expected to be Python Unicode
objects except pubdate, which is a datetime.datetime object, and
@@ -130,6 +130,7 @@ class SyndicationFeed(object):
'title': to_unicode(title),
'link': iri_to_uri(link),
'description': to_unicode(description),
+ 'content': to_unicode(content),
'author_email': to_unicode(author_email),
'author_name': to_unicode(author_name),
'author_link': iri_to_uri(author_link),
@@ -367,6 +368,10 @@ class Atom1Feed(SyndicationFeed):
if item['description'] is not None:
handler.addQuickElement("summary", item['description'], {"type": "html"})
+ # Full content.
+ if item['content'] is not None:
+ handler.addQuickElement("content", item['content'], {"type": "html"})
+
# Enclosure.
if item['enclosure'] is not None:
handler.addQuickElement("link", '',