diff --git a/app/controllers/dashboards_controller.rb b/app/controllers/dashboards_controller.rb
index 654f9af6f..10d0b8fd0 100644
--- a/app/controllers/dashboards_controller.rb
+++ b/app/controllers/dashboards_controller.rb
@@ -1,31 +1,18 @@
class DashboardsController < ApplicationController
- before_filter :authenticate_user!, :except => [:receive, :hub]
+ before_filter :authenticate_user!, :except => :receive
include ApplicationHelper
- include DashboardsHelper
def index
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
end
def receive
-
puts "SOMEONE JUST SENT ME: #{params[:xml]}"
-
store_objects_from_xml params[:xml]
render :nothing => true
end
- def hub
- if params[:mode] == "subscribe"
- response.status = subscribe(params)
- end
-
- render :nothing => true
- end
-
-
-
def warzombie
render :nothing => true
diff --git a/app/controllers/publics_controller.rb b/app/controllers/publics_controller.rb
new file mode 100644
index 000000000..f86411e6a
--- /dev/null
+++ b/app/controllers/publics_controller.rb
@@ -0,0 +1,23 @@
+class PublicsController < ApplicationController
+ include ApplicationHelper
+ include PublicsHelper
+
+ def hcard
+ end
+
+ def host_meta
+ @user = User.owner
+ render 'host_meta', :layout => false, :content_type => 'application/xrd+xml'
+ end
+
+ def webfinger
+ @user = Person.first(:email => params[:q])
+ render 'webfinger', :layout => false, :content_type => 'application/xrd+xml'
+ end
+
+ def hubbub
+ if params['hub.mode'] == 'subscribe' || params['hub.mode'] == 'unsubscribe'
+ render :text => params['hub.challenge'], :status => 202
+ end
+ end
+end
diff --git a/app/helpers/dashboards_helper.rb b/app/helpers/dashboards_helper.rb
index dc181652a..28cd48d0e 100644
--- a/app/helpers/dashboards_helper.rb
+++ b/app/helpers/dashboards_helper.rb
@@ -1,19 +1,2 @@
module DashboardsHelper
-
- def subscribe(opts = {})
- subscriber = Subscriber.first(:url => opts[:callback], :topic => opts[:topic])
- subscriber ||= Subscriber.new(:url => opts[:callback], :topic => opts[:topic])
-
- if subscriber.save
-
- if opts[:verify] == 'sync'
- 204
- elsif opts[:verify] == 'async'
- 202
- end
- else
- 400
- end
- end
-
end
diff --git a/app/helpers/publics_helper.rb b/app/helpers/publics_helper.rb
new file mode 100644
index 000000000..e694adef9
--- /dev/null
+++ b/app/helpers/publics_helper.rb
@@ -0,0 +1,17 @@
+module PublicsHelper
+ def subscribe(opts = {})
+ subscriber = Subscriber.first(:url => opts[:callback], :topic => opts[:topic])
+ subscriber ||= Subscriber.new(:url => opts[:callback], :topic => opts[:topic])
+
+ if subscriber.save
+
+ if opts[:verify] == 'sync'
+ 204
+ elsif opts[:verify] == 'async'
+ 202
+ end
+ else
+ 400
+ end
+ end
+end
\ No newline at end of file
diff --git a/app/models/subscriber.rb b/app/models/subscriber.rb
deleted file mode 100644
index 19d234d24..000000000
--- a/app/models/subscriber.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-class Subscriber
- include MongoMapper::Document
-
- key :url
- key :topic
-
- validates_presence_of :url, :topic
-
-end
diff --git a/app/views/publics/host_meta.erb b/app/views/publics/host_meta.erb
new file mode 100644
index 000000000..88ea0ffd7
--- /dev/null
+++ b/app/views/publics/host_meta.erb
@@ -0,0 +1,9 @@
+
+
+ <%=@user.url%>
+
+ Resource Descriptor
+
+
\ No newline at end of file
diff --git a/app/views/publics/webfinger.erb b/app/views/publics/webfinger.erb
new file mode 100644
index 000000000..ebc8cbf02
--- /dev/null
+++ b/app/views/publics/webfinger.erb
@@ -0,0 +1,13 @@
+
+
+ acct:<%=@user.email%>
+ <%=@user.url%>
+
+
+
+ //
+ //
+ //
+
+
+
diff --git a/app/views/status_messages/_status_message.haml b/app/views/status_messages/_status_message.haml
new file mode 100644
index 000000000..1434ca0d2
--- /dev/null
+++ b/app/views/status_messages/_status_message.haml
@@ -0,0 +1,14 @@
+%li.message{:id => post.id, :class => ("mine" if mine?(post))}
+ %span.from
+ = link_to post.person.real_name, post.person
+ = auto_link post.message
+
+ %div.time
+ = link_to(how_long_ago(post), status_message_path(post))
+ \--
+ = link_to "show comments (#{post.comments.count})", '#', :class => "show_post_comments"
+ = render "comments/comments", :post => post
+
+ - if mine?(post)
+ .destroy_link
+ = link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true
diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb
index 4651335a0..aebf023f3 100644
--- a/config/initializers/socket.rb
+++ b/config/initializers/socket.rb
@@ -1,8 +1,6 @@
require 'em-websocket'
require 'eventmachine'
-
-
module WebSocket
EM.next_tick {
initialize_channel
@@ -13,7 +11,7 @@ module WebSocket
:debug =>APP_CONFIG[:debug]) do |ws|
ws.onopen {
@ws = ws
- sid = SocketsController.new.new_subscriber
+ sid = @channel.subscribe{ |msg| ws.send msg }#SocketsController.new.new_subscriber
ws.onmessage { |msg| SocketsController.new.incoming(msg) }#@channel.push msg; puts msg}
@@ -36,7 +34,7 @@ module WebSocket
def self.subscribe
- @channel.subscribe{ |msg| @ws.send msg }
+ @channel.subscribe{ |msg| ws.send msg }
end
end
diff --git a/config/routes.rb b/config/routes.rb
index 27c49a43d..45e1942e0 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -18,7 +18,9 @@ Diaspora::Application.routes.draw do |map|
resources :users
match 'receive', :to => 'dashboards#receive'
- match 'hub', :to => 'dashboards#hub'
+ match 'hubbub', :to => 'publics#hubbub'
+ match '.well-known/host-meta', :to => 'publics#host_meta'
+ match 'webfinger', :to => 'publics#webfinger'
root :to => 'dashboards#index'
end
diff --git a/spec/controllers/dashboards_controller_spec.rb b/spec/controllers/dashboards_controller_spec.rb
index 84c25f6fe..d8749727e 100644
--- a/spec/controllers/dashboards_controller_spec.rb
+++ b/spec/controllers/dashboards_controller_spec.rb
@@ -15,45 +15,4 @@ describe DashboardsController do
assigns[:friends].should == Person.friends.all
end
- describe 'PubSubHubBuB intergration' do
-
- describe 'incoming subscriptions' do
- it 'should register a friend' do
- Subscriber.all.count.should == 0
-
- post :hub, {:callback => "http://example.com/",
- :mode => 'subscribe',
- :topic => '/status_messages',
- :verify => 'async'}
- response.status.should == 202
-
- Subscriber.all.count.should == 1
- end
-
- it 'should keep track of what topic a subscriber wants' do
- post :hub, {:callback => "http://example.com/",
- :mode => 'subscribe',
- :topic => '/status_messages',
- :verify => 'async'}
- Subscriber.first.topic.should == '/status_messages'
- end
- end
-
- it 'should return a 204 for a sync request' do
- post :hub, {:callback => "http://example.com/",
- :mode => 'subscribe',
- :topic => '/status_messages',
- :verify => 'sync'}
- response.status.should == 204
- end
-
- it 'should confirm subscription of a sync request' do
- post :hub, {:callback => "http://example.com/",
- :mode => 'subscribe',
- :topic => '/status_messages',
- :verify => 'sync'}
-
- end
-
- end
end
diff --git a/spec/controllers/publics_controller_spec.rb b/spec/controllers/publics_controller_spec.rb
new file mode 100644
index 000000000..e9539b464
--- /dev/null
+++ b/spec/controllers/publics_controller_spec.rb
@@ -0,0 +1,26 @@
+require File.dirname(__FILE__) + '/../spec_helper'
+
+describe PublicsController do
+ render_views
+
+ before do
+ @user = Factory.create(:user, :profile => Profile.create( :first_name => "bob", :last_name => "smith"))
+ request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
+ end
+
+ describe 'PubSubHubBuB intergration' do
+
+ describe 'incoming subscriptions' do
+ it 'should respond to a incoming subscription request' do
+
+ get :hubbub, {'hub.callback' => "http://example.com/",
+ 'hub.mode' => 'subscribe',
+ 'hub.topic' => '/status_messages',
+ 'hub.verify' => 'sync',
+ 'hub.challenge' => 'foobar'}
+ response.status.should == 202
+ response.body.should == 'foobar'
+ end
+ end
+ end
+end
diff --git a/spec/models/subscriber_spec.rb b/spec/models/subscriber_spec.rb
deleted file mode 100644
index 4cfad9bbe..000000000
--- a/spec/models/subscriber_spec.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-require File.dirname(__FILE__) + '/../spec_helper'
-
-describe Subscriber do
- it 'should require a url' do
- n = Subscriber.new
- n.valid?.should be false
-
- n.topic = '/status_messages'
- n.valid?.should be false
-
- n.url = "http://clown.com/"
-
- n.valid?.should be true
- end
-end