Skip to content

Instantly share code, notes, and snippets.

@superfeedr
Created September 20, 2009 02:23
Show Gist options
  • Save superfeedr/189675 to your computer and use it in GitHub Desktop.
Save superfeedr/189675 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'sinatra'
require 'atom'
require 'ruby-growl'
g = Growl.new "localhost", "Superfeedr", ["Superfeedr Notification"]
g.notify "Superfeedr Notification", "We're connected!",
"You should soon see notifications coming over."
##
# When checking subscription. See Section 6.2 of PubSubHubbub Spec.
get '/' do
# We confirm all subscriptions... Ideally in a "real-world" case, you'd want to make sure you actually want to receive notification for the hub.topic feed :)
status 200
params["hub.challenge"]
end
##
# Upon new Notification, just parse the ATOM and use the resul in your app. In this case, we just send a Growl Notification
# Make sure you allowed "Network notification" in thr growl settings.
post '/' do
feed = Atom::Feed.new(request.body.string)
feed.entries.each { |entry|
g.notify "Superfeedr Notification", "#{entry.title}", "#{entry.content.value}"
}
status 204
"Thanks!"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment