This is a mountable PubSubHubbub server conforming to the v0.4 of the spec.
In routes.rb
:
mount Pubsubhubbub::Engine, at: 'pubsubhubbub', as: :pubsubhubbub
In feed:
<link rel="hub" href="<%= pubsubhubbub_url %>" />
If you want to override topic verification (which is done before subscribe/unsubscribe events to confirm that the topic is in fact using the hub), you can add a custom initializer, e.g. config/initializers/pubsubhubbub.rb
:
Pubsubhubbub.verify_topic = lambda { |topic_url| topic_url == 'http://mysite.com/my-feed' }
You can also override the fetching of the topic when it is updated, for example if it's generally not publicly accessible or if you generate the feed from the Rails app where you mounted the hub.
Pubsubhubbub.render_topic = lambda { |topic_url| FeedsController.render(:show) }
If you want to notify the subscribers without hitting the /pubsubhubbub
HTTP endpoint, there's a convenience method you can use right from your app:
Pubsubhubbub.publish(pubsubhubbub_url, feed_url(user))
Add this line to your application's Gemfile:
gem 'pubsubhubbub-rails', require: 'pubsubhubbub'
And then execute:
$ bundle
Or install it yourself as:
$ gem install pubsubhubbub-rails
The gem is available as open source under the terms of the MIT License.