pubsubhubbub
"Sebastian Spaeth" <[email protected]> Mon, 31 May 2010 04:01:30 -0700
| Newsgroups | gmane.comp.web.pyblosxom.devel |
|---|---|
| Message-ID | <[email protected]> |
Hi all, just some FYI and tips. I implemented pubsubhubbub (the
creators of that term deserve a long and slow death BTW :-)) in
pyblosxom and just wanted to document that here for reference.
In short, pubsubhubbub allows you to propagate blog changes in realtime
via RSS feed to other places (facebook, twitter, ...).
This is my setup:
Publishing atom feed at:
http://sspaeth.de/index.atom
in the atom.flav I in included in head:
<link rel="hub" href="$(pubsubhubbub_hub)" />
setting py["pubsubhubbub_hub"]="http://spaetz.superfeedr.com"
I added a small plugin that allows me to to "pyblosxom-cmd pubsubhubbub"
after I posted some new entry and that notifies py["pubsubhubbub_hub"]
about new content. I attached the plugin not sure if someone wants that
in the contributed git repo or so.
Furthermore I registered at superfeedr.com to have my own pubsubhubbub
hub which is notified about new posts and pushes them out whenever I ping
it. I use twitterfeed.com to relay that new content to my identi.ca (and
twitter) accounts. With a setting of 30min, the realtime push works just
fine. Twitterfeed.com doesn't need to be configured to use that
pubsubhubbub hub as it automatically picks it up from the atom line
<link rel="hub" href="http://spaetz.superfeedr.com" /> and uses that.
Hope that helps someone
Sebastian
Below is a manual test setup to see if it works:
I want to test my feed (http://sspaeth.de/index.atom) with the
pubsubhubbub demo subscriber at:
http://pubsubhubbub-subscriber.appspot.com/
I try to subscribe via:
curl -v http://spaetz.superfeedr.com -d hub.callback=http://pubsubhubbub-subscriber.appspot.com/subscriber.spaetz\&hub.topic=http://sspaeth.de/index.atom\&hub.mode=subscribe\&hub.verify=sync
and get a 204 back. (OK)
When I ping spaetz.superfeedr.com for new content via
curl -v http://spaetz.superfeedr.com -d
hub.url=http://sspaeth.de/index.atom\&hub.mode=publish
I also get a 204 back and http://superfeedr.com/stats/user/spaetz says 1 managed
feeds and 1 subscriptions.
New content immediately shows up at the test subscriber at
http://pubsubhubbub-subscriber.appspot.com/
------------------------------------------------------------------------------
_______________________________________________
Pyblosxom-devel mailing list
Pyblosxom-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
https://lists.sourceforge.net/lists/listinfo/pyblosxom-devel
pubsubhubbub.py
(text/x-python, 3.4 KB)
""" This module enables support for pubsubhubbub publishing. Function "publish" is derived from the pubsubhubbub python library and is: Copyright 2009 Google Inc. http://www.apache.org/licenses/LICENSE-2.0 The rest of the program is licensed under the MIT license: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Copyright 2010 Sebastian Spaeth """ __author__ = "Sebastian Spaeth <[email protected]>" __version__ = "0.1" __url__ = "" __description__ = "Enables pubsubhubbub publishing." #TODO: Allow the published feeds to be configured in the config.py file import urllib, urllib2 import os.path import sys from Pyblosxom.commandline import build_pyblosxom, build_parser #def cb_start(args): # """ # Sets the defaults values for the optional configuration properties. # """ # request = args["request"] # config = request.getConfiguration() # # if not config.has_key('disqus_developer'): # config['disqus_developer'] = False def verify_installation(request): """ Verifies the plugin installation checking for the required configuration properties. """ config = request.getConfiguration() retval = 1 if not config.has_key('pubsubhubbub_hub'): print 'The pubsubhubbub hub needs to be configured in "pubsubhubbub_hub".' retval = 0 return retval def pubsub_publish(hub, urls): """Publishes an event to a hub. urls can be a string or a 'list' of urls.""" data = urllib.urlencode( {'hub.url': urls, 'hub.mode': 'publish'}, doseq=True) try: print(str(data)) response = urllib2.urlopen(hub, data) except (IOError, urllib2.HTTPError), e: if hasattr(e, 'code') and e.code == 204: pass error = '' if hasattr(e, 'read'): error = e.read() raise Exception('%s, Response: "%s"' % (e, error)) def pubsubhubbub(command, argv): p = build_pyblosxom() config = p.get_request().config base_url = config.get("base_url") # take off the trailing slash for base_url base_url = base_url.rstrip("/") parser = build_parser("%prog pubsubhubbub") (options, args) = parser.parse_args() if not args: parser.print_help() return 0 atom_url = base_url + '/index.atom' pubsub_publish(config.get("pubsubhubbub_hub"), atom_url) def cb_commandline(args): """Implement the pubsubhubbub command""" args["pubsubhubbub"] = (pubsubhubbub, "pubsubhubbub <FILE>") return args