Skip to content
Browse files

Added pubsubhubbub support

  • Loading branch information...
1 parent dcedaed commit a329f939ad77b049341d4413f408bc984efeb47c @Arachnid Arachnid committed Oct 20, 2009
Showing with 18 additions and 0 deletions.
  1. +3 −0 config.py
  2. +14 −0 generators.py
  3. +1 −0 themes/default/atom.xml
View
3 config.py
@@ -49,3 +49,6 @@
# If you want to use Google Analytics, enter your 'web property id' here
analytics_id = None
+
+# If you want to use PubSubHubbub, supply the hub URL to use here.
+hubbub_hub_url = 'http://pubsubhubbub.appspot.com/'
View
14 generators.py
@@ -1,4 +1,6 @@
import os
+import urllib
+from google.appengine.api import urlfetch
from google.appengine.ext import db
from google.appengine.ext import deferred
@@ -191,4 +193,16 @@ def generate_resource(cls, post, resource):
rendered = utils.render_template("atom.xml", template_vals)
static.set('/feeds/atom.xml', rendered,
'application/atom+xml; charset=utf-8')
+ if config.hubbub_hub_url:
+ cls.send_hubbub_ping(config.hubbub_hub_url)
+
+ @classmethod
+ def send_hubbub_ping(cls, hub_url):
+ data = urllib.urlencode({
+ 'hub.url': 'http://%s/feeds/atom.xml' % (config.host,),
+ 'hub.mode': 'publish',
+ })
+ response = urlfetch.fetch(hub_url, data, urlfetch.POST)
+ if response.status_code / 100 != 2:
+ raise Exception("Hub ping failed", response.status_code, response.content)
generator_list.append(AtomContentGenerator)
View
1 themes/default/atom.xml
@@ -7,6 +7,7 @@
<id>tag:{{config.host}},2009:atom.xml</id>
<link rel="alternate" type="text/html" hreflang="en" href="http://{{config.host}}/" />
<link rel="self" type="application/atom+xml" href="http://{{config.host}}/feeds/atom.xml" />
+ <link rel="hub" href="{{config.hubbub_hub_url}}" />
<rights>Copyright (c) 2009</rights>
<generator uri="http://{{config.host}}/" version="1.0">
Bloggart 1.0

0 comments on commit a329f93

Please sign in to comment.
Something went wrong with that request. Please try again.