-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 48ee8fd
Showing
11 changed files
with
140 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
superfeedr_pshb.tmproj |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2009 [name of plugin creator] | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
SupperfeedrPshb | ||
=============== | ||
|
||
This is a simple PubSubHubbub client that allows you to easily subscribe and | ||
unsubscribe from feeds. It was initially written for Superfeedr.com but should | ||
work with other hubs although this is untested. | ||
|
||
It does not handle the challenge/response part of things but I have included a simple | ||
example of this below. It will not handle recieving updates to your feeds either. | ||
|
||
This plugin requires everyones favorite party: HTTParty | ||
So please make sure you install that. | ||
|
||
Example | ||
======= | ||
Lets create our happy Pshb'er: | ||
pshb = SuperfeedrPshb::SuperfeedrPshb.new("username", "password", | ||
"http://base.url.of.your.site.with.no.trailing.slash", | ||
"http://yourhub.com/defaults/to/superfeedr/but/is/optional") | ||
|
||
Now lets subscribe to a feed: | ||
pshb.subscribe("/your/callback/inc/leading/slash", "http://feed.com/to/subscribe/to", "verify_token") | ||
|
||
Now lets unsubscribe the feed: | ||
pshb.unsubscribe("/your/callback/inc/leading/slash", "http://feed.com/to/subscribe/to", "verify_token") | ||
|
||
Here is an example of a simple controller action to echo back the challenge, you will | ||
also need to handle your feed updates in this action too: | ||
|
||
def pshb | ||
if !params["hub.challenge"].nil? | ||
@challenge = params["hub.challenge"] | ||
render :action => "pshb", :status => 200 | ||
else | ||
@challenge = "uhoh!" | ||
render :action => "pshb", :status => 404 | ||
end | ||
end | ||
|
||
Copyright (c) 2009 Eddy Parris http://www.tech-noir.co.uk, released under the MIT license |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
require 'rake' | ||
require 'rake/testtask' | ||
require 'rake/rdoctask' | ||
|
||
desc 'Default: run unit tests.' | ||
task :default => :test | ||
|
||
desc 'Test the supperfeedr_pshb plugin.' | ||
Rake::TestTask.new(:test) do |t| | ||
t.libs << 'lib' | ||
t.libs << 'test' | ||
t.pattern = 'test/**/*_test.rb' | ||
t.verbose = true | ||
end | ||
|
||
desc 'Generate documentation for the supperfeedr_pshb plugin.' | ||
Rake::RDocTask.new(:rdoc) do |rdoc| | ||
rdoc.rdoc_dir = 'rdoc' | ||
rdoc.title = 'SupperfeedrPshb' | ||
rdoc.options << '--line-numbers' << '--inline-source' | ||
rdoc.rdoc_files.include('README') | ||
rdoc.rdoc_files.include('lib/**/*.rb') | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Install hook code here | ||
puts IO.read(File.join(File.dirname(__FILE__), 'README')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# SupperfeedrPshb | ||
require 'httparty' | ||
|
||
module SuperfeedrPshb | ||
class SuperfeedrPshb | ||
include HTTParty | ||
attr_accessor :hub, :auth, :callback_root | ||
base_uri nil | ||
|
||
def initialize(username, password, callback_root, hub = "http://superfeedr.com/hubbub") | ||
self.class.base_uri hub | ||
self.class.basic_auth username, password | ||
@auth = {:username => username, :password => password} | ||
@callback_root = callback_root | ||
end | ||
|
||
def create_and_send_request(type, mode_options) | ||
options = { :body => { 'hub.mode' => type, 'hub.verify' => "sync" } } | ||
options[:body].merge!(mode_options) | ||
puts options.inspect | ||
self.class.post('/', options) | ||
end | ||
|
||
def subscribe(callback, topic, token) | ||
options = {'hub.callback' => @callback_root + callback, 'hub.topic' => topic, 'hub.verify_token' => token} | ||
create_and_send_request("subscribe", options) | ||
end | ||
|
||
def unsubscribe(callback, topic, token) | ||
options = {'hub.callback' => @callback_root + callback, 'hub.topic' => topic, 'hub.verify_token' => token} | ||
create_and_send_request("unsubscribe", options) | ||
end | ||
|
||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Include hook code here | ||
require 'superfeedr_pshb' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# desc "Explaining what the task does" | ||
# task :supperfeedr_pshb do | ||
# # Task goes here | ||
# end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
require 'test_helper' | ||
|
||
class SupperfeedrPshbTest < ActiveSupport::TestCase | ||
# Replace this with your real tests. | ||
test "the truth" do | ||
assert true | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
require 'rubygems' | ||
require 'active_support' | ||
require 'active_support/test_case' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# Uninstall hook code here |