Permalink
Browse files

Reorganised files and added README, LICENSE

  • Loading branch information...
1 parent 6a9cf15 commit 82544663d097649ae694cb47f71ac8618bb64c24 @textgoeshere textgoeshere committed Dec 31, 2010
View
@@ -0,0 +1,2 @@
+doc
+.yardoc
View
19 LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010 David Nolan
+
+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.
View
64 README
@@ -0,0 +1,64 @@
+= superfeedr-blather
+
+superfeedr-blather implements a Superfeedr[http://superfeedr.com] PubSub XMPP client in Ruby using the Blather gem.
+
+Starting up a connection and echoing new notifications is as easy as this:
+
+ setup YOUR_SUPERFEEDR_USERNAME, YOUR_SUPERFEEDR_PASSWORD
+
+ pubsub_event do |e|
+ e.items.each do |i|
+ puts "New post from #{i.entry.title}:"
+ puts i.entry.content
+ end
+ end
+
+== About
+
+You get some patches for Blather and some classes that wrap the stuff
+you want from Superfeedr (entries, authors etc.).
+
+Under-the-hood, Blather uses EventMachine and Nokogiri so it's fast
+and convenient. If you want to daemonize your client, daemon-kit[https://github.com/kennethkalmer/daemon-kit/] comes
+ready with a {blather template}[https://github.com/kennethkalmer/daemon-kit/blob/master/lib/daemon_kit/xmpp.rb].
+
+You might want to compare Superfeedr's own
+superfeedr-ruby[https://github.com/superfeedr/superfeedr-ruby] which
+is based on a different XMPP lib, Skates.
+
+== Tips
+
+Take a look in <tt>/examples</tt> for examples of handling notifications,
+(un)subscribing, and fetching the list of subscriptions.
+
+When you're playing around, subscribe to Superfeedr's <tt>dummy.xml</tt> feed and use the button on
+http://www.superfeedr.com/users/kapoq/feeds/xmpp_console to generate a
+new notification on demand ("show console" displays the button).
+
+== Install
+
+ git clone git://github.com/kapoq/superfeedr-blather.git
+
+== Source and latest version
+
+superfeedr-blather lives at
+https://github.com/kapoq/superfeedr-blather.
+
+Stop by and say hi some time (contribs welcome).
+
+== Author
+
+Dave Nolan / Kapoq Ltd / kapoq.com[http://kapoq.com]
+
+== TODO
+
+* apply patches upstream to blather
+ * loading filename conflicts using bundler
+ * multiple namespaces
+
+* improve type-casting
+
+* implement Superfeedr notifications extensions:
+ * stripped
+ * chunks (No mention in the Superfeedr schema docs but is used elsewhere)
+
View
@@ -0,0 +1,20 @@
+# Monkey-patch to add status and fix items lookup
+
+module Blather
+ class Stanza
+ class PubSub
+ class Event < Message
+ def items
+ items_node.find('.//ps:item', :ps => PS).map do |i|
+ PubSubItem.new(nil,nil,self.document).inherit i
+ end
+ end
+
+ def status
+ n = find("ps_event:event/sf:status", :ps_event => PS_EVENT, :sf => SF)
+ Superfeedr::Status.new(n) if n
+ end
+ end
+ end
+ end
+end
@@ -0,0 +1,5 @@
+ATOM = "http://www.w3.org/2005/Atom"
+GEO = "http://www.georss.org/georss"
+PS = "http://jabber.org/protocol/pubsub"
+PS_EVENT = "http://jabber.org/protocol/pubsub#event"
+SF = "http://superfeedr.com/xmpp-pubsub-ext"
View
@@ -0,0 +1,12 @@
+# Adds superfeedr entry to PubSubItem
+
+module Blather
+ class Stanza
+ class PubSubItem < XMPPNode
+ def entry
+ n = find("atom:entry", :atom => ATOM)
+ Superfeedr::Entry.new(n) unless n.nil?
+ end
+ end
+ end
+end
View
@@ -1,22 +0,0 @@
-# # Patch to use correct items namespace
-# module Blather
-# class Stanza::PubSub::Event
-# def items
-# puts "here"
-# items_node.find('//ns:item', :ns => Blather::Stanza::PubSub.registered_ns).map do |i|
-# PubSubItem.new(nil,nil,self.document).inherit i
-# end
-# end
-# end
-
-# class Stanza::PubSubItem
-# def entries
-# puts "there"
-# find("//atom:entry").map { |n| Superfeedr::Entry.new(n) }
-# end
-
-# def status
-# find("//atom:status").map { |n| Superfeedr::Status.new(n) }
-# end
-# end
-# end
@@ -1,54 +1,36 @@
-module Blather
-class Stanza
-class PubSub
-
- # # PubSub Subscriptions Stanza
- #
- # [XEP-0060 Section 5.6 Retrieve Subscriptions](http://xmpp.org/extensions/xep-0060.html#entity-subscriptions)
- #
- # @handler :pubsub_subscriptions
- class Subscriptions < PubSub
+# Monkey-patch to add superfeedr namespace and jid/page attributes
- # Overrides the parent to ensure a subscriptions node is created
- # @private
- def self.new(type, opts = {})
- new_node = super type, nil
- new_node.to = opts.delete(:to) || opts.delete(:host)
- new_node.from = opts.delete(:from)
- new_node.id = opts.delete(:id)
- new_node.pubsub.add_namespace_definition("superfeedr", "http://superfeedr.com/xmpp-pubsub-ext")
- new_node.subscriptions(opts.delete(:page) || 1)
- new_node
- end
-
- # Overrides the parent to ensure the subscriptions node is destroyed
- # @private
- def inherit(node)
- subscriptions.remove
- super
- end
+module Blather
+ class Stanza
+ class PubSub
+ class Subscriptions
+ def self.new(type, opts = {})
+ new_node = super type, nil
+ new_node.to = opts.delete(:to) || opts.delete(:host)
+ new_node.from = opts.delete(:from)
+ new_node.id = opts.delete(:id)
+ new_node.pubsub.add_namespace_definition("sf", SF)
+ new_node.subscriptions(opts.delete(:page) || 1)
+ new_node
+ end
- # Get or create the actual subscriptions node
- #
- # @return [Blather::XMPPNode]
- def subscriptions(page = 1)
- aff = pubsub.find_first('subscriptions', self.class.registered_ns)
- unless aff
- aff = XMPPNode.new('subscriptions', self.document)
- aff["superfeedr:page"] = page.to_s
- aff["jid"] = self.from
- self.pubsub << aff
- end
- aff
- end
+ def subscriptions(page = 1)
+ aff = pubsub.find_first('subscriptions', self.class.registered_ns)
+ unless aff
+ aff = XMPPNode.new('subscriptions', self.document)
+ aff["sf:page"] = page.to_s
+ aff["jid"] = self.from
+ self.pubsub << aff
+ end
+ aff
+ end
- def list
- subscriptions.find('//ns:subscription', :ns => self.class.registered_ns).map do |child|
- Stanza::Superfeedr::Subscription.new(child)
+ def list
+ subscriptions.find('//ns:subscription', :ns => self.class.registered_ns).map do |child|
+ Superfeedr::Subscription.new(child)
+ end
+ end
end
end
- end # Subscriptions
-
-end # PubSub
-end # Stanza
-end # Blather
+ end
+end
Oops, something went wrong.

0 comments on commit 8254466

Please sign in to comment.