summaryrefslogtreecommitdiff
path: root/blog/feeds.py
diff options
context:
space:
mode:
authorMark Weiman <mark.weiman@markzz.com>2015-10-11 01:00:38 -0400
committerMark Weiman <mark.weiman@markzz.com>2015-10-11 01:00:38 -0400
commit57aa89824a8dabb631c15af986a39e779d0fe3cb (patch)
tree2df3bf79026e1c544e57375566297bcc7634afa5 /blog/feeds.py
downloadwebsite-57aa89824a8dabb631c15af986a39e779d0fe3cb.tar.gz
website-57aa89824a8dabb631c15af986a39e779d0fe3cb.zip
inital
Diffstat (limited to 'blog/feeds.py')
-rw-r--r--blog/feeds.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/blog/feeds.py b/blog/feeds.py
new file mode 100644
index 0000000..e8a3874
--- /dev/null
+++ b/blog/feeds.py
@@ -0,0 +1,27 @@
+from django.contrib.syndication.views import Feed
+from django.core.urlresolvers import reverse
+from django.utils.html import strip_tags as st
+from .models import Post
+
+def truncate_words(content, length=100, suffix='...'):
+ if len(content) <= length:
+ return content
+ else:
+ return content[:length].rsplit(' ',1)[0] + suffix
+
+class PostFeed(Feed):
+ title = "Mark Weiman's Blog"
+ link = "/blog/"
+ description = "Changes on new post"
+
+ def items(self):
+ return Post.objects.order_by('-created')
+
+ def item_title(self, item):
+ return item.title
+
+ def item_description(self, item):
+ return truncate_words(st(item.body))
+
+ def item_link(self, item):
+ return 'https://markzz.com/blog/post/' + str(item.id)