--- a/deploy-template.py Thu Jan 15 18:06:54 2009 -0500
+++ b/deploy-template.py Thu Jan 15 19:09:43 2009 -0500
@@ -15,3 +15,6 @@
# Make sure it ends in a trailing slash!
BASE_DIR = '/full/path/to/project/directory/'
+
+# This is used for the Mint (http://haveamint.com/) Bird Feeder plugin hack.
+FEEDER_PASSWORD = ''
--- a/feeds.py Thu Jan 15 18:06:54 2009 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-from django.contrib.syndication.feeds import Feed
-from stevelosh.blog.models import Entry, Comment as BlogComment
-from stevelosh.projects.models import Project, Comment as ProjectComment
-from stevelosh.thoughts.models import TextThought, LinkThought
-import operator
-
-class LatestEntries(Feed):
- title = "stevelosh.com blog entries"
- link = "http://stevelosh.com/blog/"
- description = "Latest blog entries on stevelosh.com"
-
- item_author_name = 'Steve Losh'
- item_author_email = 'steve@stevelosh.com'
- item_author_link = 'http://stevelosh.com/'
-
- def items(self):
- return Entry.objects.filter(published=True).order_by('-pub_date')[:10]
-
- def item_pubdate(self, item):
- return item.pub_date
-
-class LatestComments(Feed):
- title = "stevelosh.com blog comments"
- link = "http://stevelosh.com/blog/"
- description = "Latest comments on blog entries from stevelosh.com"
-
- item_author_name = 'Steve Losh'
- item_author_email = 'steve@stevelosh.com'
- item_author_link = 'http://stevelosh.com/'
-
- def items(self):
- comments = list(BlogComment.objects.order_by('-submitted')[:50])
- comments += list(ProjectComment.objects.order_by('-submitted')[:50])
- comments.sort(key=operator.attrgetter('submitted'))
- comments.reverse()
- return comments[:50]
-
- def item_pubdate(self, item):
- return item.submitted
-
-class LatestProjects(Feed):
- title = "stevelosh.com projects"
- link = "http://stevelosh.com/projects/"
- description = "Latest projects on stevelosh.com"
-
- item_author_name = 'Steve Losh'
- item_author_email = 'steve@stevelosh.com'
- item_author_link = 'http://stevelosh.com/'
-
- def items(self):
- return Project.objects.order_by('-posted')[:10]
-
- def item_pubdate(self, item):
- return item.posted
-
-
-class LatestThoughts(Feed):
- title = "stevelosh.com thoughts"
- link = "http://stevelosh.com/thoughts/"
- description = "Latest thoughts from stevelosh.com"
-
- item_author_name = 'Steve Losh'
- item_author_email = 'steve@stevelosh.com'
- item_author_link = 'http://stevelosh.com/'
-
- def items(self):
- thoughts = []
- thoughts += [{'type': 'thought-text', 'item': thought, 'date': thought.posted}
- for thought in
- TextThought.objects.order_by('-posted')[:10]]
- thoughts += [{'type': 'thought-link', 'item': thought, 'date': thought.posted}
- for thought in
- LinkThought.objects.order_by('-posted')[:10]]
- thoughts.sort(key=operator.itemgetter('date'))
- thoughts.reverse()
- return thoughts[:10]
-
- def item_pubdate(self, item):
- return item['date']
-
- def item_link(self, item):
- return item['item'].get_absolute_url()
-
-
-class LatestEverything(Feed):
- title = "stevelosh.com"
- link = "http://stevelosh.com/"
- description = "Latest updates from stevelosh.com"
-
- item_author_name = 'Steve Losh'
- item_author_email = 'steve@stevelosh.com'
- item_author_link = 'http://stevelosh.com/'
-
- def items(self):
- items = []
- items += [{'type': 'blog', 'item': entry, 'date': entry.pub_date}
- for entry in
- Entry.objects.filter(published=True).order_by('-pub_date')[:15]]
- items += [{'type': 'thought-text', 'item': thought, 'date': thought.posted}
- for thought in
- TextThought.objects.order_by('-posted')[:10]]
- items += [{'type': 'thought-link', 'item': thought, 'date': thought.posted}
- for thought in
- LinkThought.objects.order_by('-posted')[:10]]
- items += [{'type': 'project', 'item': project, 'date': project.posted}
- for project in
- Project.objects.order_by('-posted')[:10]]
- items.sort(key=operator.itemgetter('date'))
- items.reverse()
- return items[:10]
-
- def item_pubdate(self, item):
- return item['date']
-
- def item_link(self, item):
- return item['item'].get_absolute_url()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rss/feeds.py Thu Jan 15 19:09:43 2009 -0500
@@ -0,0 +1,116 @@
+from django.contrib.syndication.feeds import Feed
+from stevelosh.blog.models import Entry, Comment as BlogComment
+from stevelosh.projects.models import Project, Comment as ProjectComment
+from stevelosh.thoughts.models import TextThought, LinkThought
+import operator
+
+class LatestEntries(Feed):
+ title = "Steve Losh / RSS / Blog"
+ link = "http://stevelosh.com/blog/"
+ description = "Latest blog entries on stevelosh.com"
+
+ item_author_name = 'Steve Losh'
+ item_author_email = 'steve@stevelosh.com'
+ item_author_link = 'http://stevelosh.com/'
+
+ def items(self):
+ return Entry.objects.filter(published=True).order_by('-pub_date')[:10]
+
+ def item_pubdate(self, item):
+ return item.pub_date
+
+class LatestComments(Feed):
+ title = "Steve Losh / RSS / Comments"
+ link = "http://stevelosh.com/blog/"
+ description = "Latest comments on blog entries from stevelosh.com"
+
+ item_author_name = 'Steve Losh'
+ item_author_email = 'steve@stevelosh.com'
+ item_author_link = 'http://stevelosh.com/'
+
+ def items(self):
+ comments = list(BlogComment.objects.order_by('-submitted')[:50])
+ comments += list(ProjectComment.objects.order_by('-submitted')[:50])
+ comments.sort(key=operator.attrgetter('submitted'))
+ comments.reverse()
+ return comments[:50]
+
+ def item_pubdate(self, item):
+ return item.submitted
+
+class LatestProjects(Feed):
+ title = "Steve Losh / RSS / Projects"
+ link = "http://stevelosh.com/projects/"
+ description = "Latest projects on stevelosh.com"
+
+ item_author_name = 'Steve Losh'
+ item_author_email = 'steve@stevelosh.com'
+ item_author_link = 'http://stevelosh.com/'
+
+ def items(self):
+ return Project.objects.order_by('-posted')[:10]
+
+ def item_pubdate(self, item):
+ return item.posted
+
+
+class LatestThoughts(Feed):
+ title = "Steve Losh / RSS / Thoughts"
+ link = "http://stevelosh.com/thoughts/"
+ description = "Latest thoughts from stevelosh.com"
+
+ item_author_name = 'Steve Losh'
+ item_author_email = 'steve@stevelosh.com'
+ item_author_link = 'http://stevelosh.com/'
+
+ def items(self):
+ thoughts = []
+ thoughts += [{'type': 'thought-text', 'item': thought, 'date': thought.posted}
+ for thought in
+ TextThought.objects.order_by('-posted')[:10]]
+ thoughts += [{'type': 'thought-link', 'item': thought, 'date': thought.posted}
+ for thought in
+ LinkThought.objects.order_by('-posted')[:10]]
+ thoughts.sort(key=operator.itemgetter('date'))
+ thoughts.reverse()
+ return thoughts[:10]
+
+ def item_pubdate(self, item):
+ return item['date']
+
+ def item_link(self, item):
+ return item['item'].get_absolute_url()
+
+
+class LatestEverything(Feed):
+ title = "Steve Losh / RSS / All"
+ link = "http://stevelosh.com/"
+ description = "Latest updates from stevelosh.com"
+
+ item_author_name = 'Steve Losh'
+ item_author_email = 'steve@stevelosh.com'
+ item_author_link = 'http://stevelosh.com/'
+
+ def items(self):
+ items = []
+ items += [{'type': 'blog', 'item': entry, 'date': entry.pub_date}
+ for entry in
+ Entry.objects.filter(published=True).order_by('-pub_date')[:15]]
+ items += [{'type': 'thought-text', 'item': thought, 'date': thought.posted}
+ for thought in
+ TextThought.objects.order_by('-posted')[:10]]
+ items += [{'type': 'thought-link', 'item': thought, 'date': thought.posted}
+ for thought in
+ LinkThought.objects.order_by('-posted')[:10]]
+ items += [{'type': 'project', 'item': project, 'date': project.posted}
+ for project in
+ Project.objects.order_by('-posted')[:10]]
+ items.sort(key=operator.itemgetter('date'))
+ items.reverse()
+ return items[:10]
+
+ def item_pubdate(self, item):
+ return item['date']
+
+ def item_link(self, item):
+ return item['item'].get_absolute_url()
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rss/models.py Thu Jan 15 19:09:43 2009 -0500
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/rss/views.py Thu Jan 15 19:09:43 2009 -0500
@@ -0,0 +1,24 @@
+import deploy
+import urllib2
+
+def feeds(request, url, feed_dict):
+ headers = {'HTTP_HOST':'Host',
+ 'HTTP_USER_AGENT':'User-Agent',
+ 'HTTP_ACCEPT_ENCODING':'Accept-Encoding',
+ 'HTTP_ACCEPT_LANGUAGE':'Accept-Language',
+ 'HTTP_REFERER':'Referer',
+ 'HTTP_COOKIE':'Cookies'}
+
+ feed_name = [p.capitalize() for p in url.split('/') if p.strip() != ''][-1]
+
+ # Call into BirdFeeder with the request headers.
+ o = urllib2.build_opener()
+ o.addheaders = [ (headers[k], request.META.get(k, ''))
+ for k in request.META.keys() if k in headers.keys()]
+ f = o.open( "http://stevelosh.com/feeder/index.php?pw=%s&feed_name=%s" %
+ (deploy.FEEDER_PASSWORD, feed_name) )
+ f.read()
+ f.close()
+
+ return django.contrib.syndication.views.feed(request, url=url,
+ feed_dict=feed_dict)
\ No newline at end of file
--- a/urls.py Thu Jan 15 18:06:54 2009 -0500
+++ b/urls.py Thu Jan 15 19:09:43 2009 -0500
@@ -1,7 +1,7 @@
from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings
-from stevelosh.feeds import *
+from stevelosh.rss.feeds import *
admin.autodiscover()
@@ -25,7 +25,7 @@
url(r'^projects/(.*)/$', 'stevelosh.projects.views.project', name='project-view'),
url(r'^thoughts/$', 'stevelosh.thoughts.views.list', name='thoughts-list-newest'),
url(r'^thoughts/page/(\d+)/$', 'stevelosh.thoughts.views.list', name='thoughts-list-page'),
- url(r'^rss/(?P<url>.+)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),
+ url(r'^rss/(?P<url>.+)/$', 'stevelosh.rss.views.feeds', {'feed_dict': feeds}),
)