Merging dashboards
This commit is contained in:
commit
122bbf0cd2
37 changed files with 74 additions and 209 deletions
|
|
@ -15,7 +15,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def set_people
|
||||
@people = Person.all
|
||||
@people = Person.friends.all
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
class DashboardController < ApplicationController
|
||||
class DashboardsController < ApplicationController
|
||||
|
||||
before_filter :authenticate_user!, :except => :receive
|
||||
include ApplicationHelper
|
||||
|
|
@ -7,7 +7,6 @@ class DashboardController < ApplicationController
|
|||
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
|
||||
def receive
|
||||
|
||||
puts "SOMEONE JUST SENT ME: #{params[:xml]}"
|
||||
|
|
@ -16,11 +15,6 @@ class DashboardController < ApplicationController
|
|||
render :nothing => true
|
||||
end
|
||||
|
||||
def socket
|
||||
#this is just for me to test teh sockets!
|
||||
render "socket"
|
||||
end
|
||||
|
||||
def warzombie
|
||||
render :nothing => true
|
||||
if User.first.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil
|
||||
|
|
@ -2,7 +2,7 @@ class PeopleController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@people = Person.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@people = Person.friends.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
def show
|
||||
|
|
@ -18,22 +18,4 @@ class PeopleController < ApplicationController
|
|||
redirect_to people_url
|
||||
end
|
||||
|
||||
def new
|
||||
@person = Person.new
|
||||
@profile = Profile.new
|
||||
end
|
||||
|
||||
def create
|
||||
|
||||
puts params.inspect
|
||||
@person = Person.new(params[:person])
|
||||
|
||||
|
||||
if @person.save
|
||||
flash[:notice] = "Successfully created person."
|
||||
redirect_to @person
|
||||
else
|
||||
render :action => 'new'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,14 +1,9 @@
|
|||
class PersonRequestsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
include PersonRequestsHelper
|
||||
def index
|
||||
@person_requests = PersonRequest.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
@person_request = PersonRequest.new
|
||||
@person = Person.new
|
||||
end
|
||||
|
||||
def show
|
||||
@person_request = PersonRequest.where(:id => params[:id]).first
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
|
@ -20,17 +15,18 @@ class PersonRequestsController < ApplicationController
|
|||
|
||||
def new
|
||||
@person_request = PersonRequest.new
|
||||
@recipient = Person.new
|
||||
end
|
||||
|
||||
def create
|
||||
@person_request = PersonRequest.for(params[:person_request][:url])
|
||||
@person_request = PersonRequest.for params[:person_request][:url]
|
||||
|
||||
if true
|
||||
if @person_request
|
||||
flash[:notice] = "Successfully created person request."
|
||||
redirect_to @person_request
|
||||
redirect_to person_requests_url
|
||||
else
|
||||
render :action => 'new'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class SocketController < ApplicationController
|
||||
class SocketsController < ApplicationController
|
||||
include ApplicationHelper
|
||||
include SocketHelper
|
||||
include SocketsHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
before_filter :authenticate_user!
|
||||
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
module DashboardHelper
|
||||
|
||||
|
||||
|
||||
end
|
||||
5
app/helpers/dashboards_helper.rb
Normal file
5
app/helpers/dashboards_helper.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
module DashboardsHelper
|
||||
|
||||
|
||||
|
||||
end
|
||||
2
app/helpers/person_requests_helper.rb
Normal file
2
app/helpers/person_requests_helper.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
module PersonRequestsHelper
|
||||
end
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
module SocketHelper
|
||||
module SocketsHelper
|
||||
include ApplicationHelper
|
||||
|
||||
def obj_id(object)
|
||||
|
|
@ -36,6 +36,6 @@ class Comment
|
|||
|
||||
|
||||
def send_to_view
|
||||
SocketController.new.outgoing(self)
|
||||
SocketsController.new.outgoing(self)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class Person
|
|||
#validates_uniqueness_of :url
|
||||
validates_true_for :url, :logic => lambda { self.url_unique?}
|
||||
|
||||
|
||||
scope :friends, where(:_type => "Person")
|
||||
validates_presence_of :email
|
||||
|
||||
before_validation :clean_url
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ class PersonRequest
|
|||
|
||||
def self.for(url)
|
||||
request = PersonRequest.new(:url => url, :person => User.first)
|
||||
request.push_to_url
|
||||
request.save
|
||||
request.push_to([self])
|
||||
request
|
||||
end
|
||||
|
||||
def check_for_person_requests
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ class Post
|
|||
end
|
||||
|
||||
def send_to_view
|
||||
SocketController.new.outgoing(self)
|
||||
SocketsController.new.outgoing(self)
|
||||
end
|
||||
|
||||
def remove_from_view
|
||||
SocketController.new.outgoing(Retraction.for(self))
|
||||
SocketsController.new.outgoing(Retraction.for(self))
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<script src='javascripts/swfobject.js'></script>
|
||||
<script src='javascripts/FABridge.js'></script>
|
||||
<script src='javascripts/web_socket.js'></script>
|
||||
<script>
|
||||
$(document).ready(function(){
|
||||
function debug(str){ $("#debug").append("<p>" + str); };
|
||||
|
||||
ws = new WebSocket("ws://localhost:8080/");
|
||||
ws.onmessage = function(evt) { $(".msg").prepend("<p>"+evt.data+"</p>"); };
|
||||
ws.onclose = function() { debug("socket closed"); };
|
||||
ws.onopen = function() {
|
||||
debug("connected...");
|
||||
ws.send("hello server");
|
||||
ws.send("hello again");
|
||||
};
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
boner
|
||||
<div id="debug"></div>
|
||||
<div class="msg"></div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
%h3 your friends
|
||||
%ul#friend_stream.nav
|
||||
- for friend in @friends
|
||||
%li= link_to friend.real_name, friend_path(friend)
|
||||
/= link_to "add a new friend", new_friend_path
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
- title "Friends"
|
||||
|
||||
%table
|
||||
%tr
|
||||
%th real name
|
||||
%th email
|
||||
%th url
|
||||
- for friend in @friends
|
||||
%tr
|
||||
%td= friend.real_name
|
||||
%td= friend.email
|
||||
%td= friend.url
|
||||
%td= link_to 'Show', friend
|
||||
%td= link_to 'Destroy', friend, :confirm => 'Are you sure?', :method => :delete
|
||||
|
||||
%p= link_to "New Friend", new_friend_path
|
||||
|
||||
#pagination
|
||||
= will_paginate @friends
|
||||
|
|
@ -1,27 +0,0 @@
|
|||
- title "New Friend"
|
||||
|
||||
= form_for @friend do |f|
|
||||
= f.error_messages
|
||||
%p
|
||||
= f.label :email
|
||||
%br
|
||||
= f.text_field :email
|
||||
%p
|
||||
= f.label :url
|
||||
%br
|
||||
= f.text_field :url
|
||||
|
||||
=f.fields_for :profile do |p|
|
||||
%p
|
||||
= p.label :first_name
|
||||
%br
|
||||
= p.text_field :first_name
|
||||
|
||||
%p
|
||||
= p.label :last_name
|
||||
%br
|
||||
= p.text_field :last_name
|
||||
= f.submit
|
||||
|
||||
|
||||
%p= link_to "Back to List", friends_path
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
.span-18.last
|
||||
%h1= "#{@friend.real_name}"
|
||||
- if @friend_profile
|
||||
%p
|
||||
%b First Name
|
||||
%p
|
||||
= @friend_profile.first_name
|
||||
%p
|
||||
%b Last Name
|
||||
%p
|
||||
= @friend_profile.last_name
|
||||
%p
|
||||
%b url
|
||||
%p
|
||||
= @friend.url
|
||||
|
||||
.span-18
|
||||
- if @friend.posts
|
||||
%h3 stream
|
||||
%ul#stream
|
||||
- for post in @friend_posts
|
||||
= render type_partial(post), :post => post
|
||||
- else
|
||||
%h3 no posts to display!
|
||||
|
|
@ -2,8 +2,8 @@
|
|||
%html
|
||||
%head
|
||||
%title
|
||||
= "diaspora "
|
||||
= "- #{User.first.real_name}" if User.first
|
||||
= User.first.real_name if User.first
|
||||
= " | diaspora"
|
||||
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
||||
|
||||
= stylesheet_link_tag "blueprint/screen", :media => 'screen'
|
||||
|
|
@ -16,8 +16,8 @@
|
|||
= csrf_meta_tag
|
||||
= yield(:head)
|
||||
|
||||
= javascript_include_tag 'satisfaction' , 'satisfaction-display'
|
||||
|
||||
/= javascript_include_tag 'satisfaction' , 'satisfaction-display'
|
||||
%body
|
||||
%header
|
||||
.container
|
||||
|
|
@ -32,6 +32,8 @@
|
|||
- if user_signed_in?
|
||||
=User.first.real_name
|
||||
|
|
||||
= link_to "requests", person_requests_path
|
||||
|
|
||||
= link_to "logout", destroy_user_session_path
|
||||
- else
|
||||
= link_to "login", new_user_session_path
|
||||
|
|
@ -43,7 +45,7 @@
|
|||
#content.span-24.last
|
||||
.span-3.append-1.last
|
||||
= link_to owner_picture, root_path
|
||||
/= render 'friends/sidebar' if user_signed_in?
|
||||
= render 'people/sidebar' if user_signed_in?
|
||||
|
||||
.span-20
|
||||
- if user_signed_in?
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@
|
|||
%ul#friend_stream.nav
|
||||
- for person in @people
|
||||
%li= link_to person.real_name, person_path(person)
|
||||
/= link_to "add a new friend", new_friend_path
|
||||
= link_to "add a new person", new_person_request_path
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
%td= link_to 'Show', person
|
||||
%td= link_to 'Destroy', person, :confirm => 'Are you sure?', :method => :delete
|
||||
|
||||
%p= link_to "New Person", new_person_path
|
||||
%p= link_to "Add a friend", new_person_request_path
|
||||
|
||||
#pagination
|
||||
= will_paginate @people
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
.span-18.last
|
||||
.span-20.last
|
||||
%h1= "#{@person.real_name}"
|
||||
- if @person_profile
|
||||
%p
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
%p
|
||||
= @person.url
|
||||
|
||||
.span-18
|
||||
.span-20
|
||||
- if @person.posts
|
||||
%h3 stream
|
||||
%ul#stream
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
= form_for @person_request do |f|
|
||||
= form_for @person_request do |f|
|
||||
= f.error_messages
|
||||
|
||||
%p
|
||||
|
|
@ -1,2 +1,5 @@
|
|||
%li.message{:id => person_request.id}
|
||||
= person_request.inspect
|
||||
%li.message{:id => person_request.id, :class => "mine"}
|
||||
= person_request.url
|
||||
|
||||
.destroy_link
|
||||
= link_to 'Ignore', person_request_path(person_request), :confirm => 'Are you sure?', :method => :delete, :remote => true
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
- title "Person Request"
|
||||
|
||||
%p
|
||||
= person_request.inspect
|
||||
= @person_request.inspect
|
||||
|
||||
%p
|
||||
= link_to "Edit", edit_person_request_path(@person_request)
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@
|
|||
|
||||
- if mine?(post)
|
||||
.destroy_link
|
||||
= link_to 'Delete', status_message_url(post), :confirm => 'Are you sure?', :method => :delete, :remote => true
|
||||
= link_to 'Delete', status_message_path(post), :confirm => 'Are you sure?', :method => :delete, :remote => true
|
||||
|
|
|
|||
|
|
@ -7,5 +7,4 @@
|
|||
# inflect.singular /^(ox)en/i, '\1'
|
||||
# inflect.irregular 'person', 'people'
|
||||
# inflect.uncountable %w( fish sheep )
|
||||
inflect.uncountable %w(dashboard socket)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,11 +13,11 @@ module WebSocket
|
|||
:debug =>APP_CONFIG[:debug]) do |ws|
|
||||
ws.onopen {
|
||||
@ws = ws
|
||||
sid = SocketController.new.new_subscriber
|
||||
sid = SocketsController.new.new_subscriber
|
||||
|
||||
ws.onmessage { |msg| SocketController.new.incoming(msg) }#@channel.push msg; puts msg}
|
||||
ws.onmessage { |msg| SocketsController.new.incoming(msg) }#@channel.push msg; puts msg}
|
||||
|
||||
ws.onclose { SocketController.new.delete_subscriber(sid) }
|
||||
ws.onclose { SocketsController.new.delete_subscriber(sid) }
|
||||
}
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,8 @@ Diaspora::Application.routes.draw do |map|
|
|||
|
||||
|
||||
resources :users
|
||||
match 'receive', :to => 'dashboard#receive'
|
||||
match "socket", :to => 'dashboard#socket'
|
||||
match 'receive', :to => 'dashboards#receive'
|
||||
|
||||
root :to => 'dashboard#index'
|
||||
root :to => 'dashboards#index'
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@ module Diaspora
|
|||
|
||||
def store_objects_from_xml(xml)
|
||||
objects = parse_objects_from_xml(xml)
|
||||
|
||||
puts xml
|
||||
|
||||
objects.each do |p|
|
||||
if p.is_a? Retraction
|
||||
p.perform
|
||||
|
|
@ -64,7 +61,6 @@ module Diaspora
|
|||
end
|
||||
end
|
||||
|
||||
|
||||
def push_to(recipients)
|
||||
unless recipients.empty?
|
||||
recipients.map!{|x| x = x.url + "receive/"}
|
||||
|
|
@ -74,13 +70,11 @@ module Diaspora
|
|||
end
|
||||
end
|
||||
|
||||
def push_to_url(url)
|
||||
puts "bonedog"
|
||||
if url
|
||||
xml = self.class.build_xml_for([self])
|
||||
@@queue.add_post_request( [url], xml )
|
||||
@@queue.process
|
||||
end
|
||||
def push_to_url
|
||||
hook_url = self.url + "receive/"
|
||||
xml = self.class.build_xml_for([self])
|
||||
@@queue.add_post_request( [hook_url], xml )
|
||||
@@queue.process
|
||||
end
|
||||
|
||||
def prep_webhook
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class MessageHandler
|
|||
|
||||
|
||||
def add_post_request(destinations, body)
|
||||
b = body
|
||||
b = CGI::escape( body )
|
||||
destinations.each{|dest| @queue.push(Message.new(:post, dest, b))}
|
||||
end
|
||||
|
||||
|
|
@ -21,9 +21,8 @@ class MessageHandler
|
|||
@queue.pop{ |query|
|
||||
case query.type
|
||||
when :post
|
||||
puts "sending: #{query.body} to #{query.destination}"
|
||||
http = EventMachine::HttpRequest.new(query.destination).post :timeout => TIMEOUT, :body =>{:xml => query.body}
|
||||
http.callback {puts "success from: to #{query.destination}"; process}
|
||||
http.callback {process}
|
||||
when :get
|
||||
http = EventMachine::HttpRequest.new(query.destination).get :timeout => TIMEOUT
|
||||
http.callback {send_to_seed(query, http.response); process}
|
||||
|
|
@ -32,7 +31,7 @@ class MessageHandler
|
|||
end
|
||||
|
||||
http.errback {
|
||||
puts "fauilure from #{query.destination}, retrying"
|
||||
puts "failure from #{query.destination}, retrying"
|
||||
query.try_count +=1
|
||||
@queue.push query unless query.try_count >= NUM_TRIES
|
||||
process
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe DashboardController do
|
||||
describe DashboardsController do
|
||||
render_views
|
||||
|
||||
before do
|
||||
|
|
@ -16,7 +16,7 @@ describe DashboardController do
|
|||
it "on index sets a person's variable" do
|
||||
Factory.create :person
|
||||
get :index
|
||||
assigns[:people].should == Person.all
|
||||
assigns[:people].should == Person.friends.all
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -1,21 +1,21 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe 'SocketController' do
|
||||
describe 'SocketsController' do
|
||||
render_views
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
SocketController.unstub!(:new)
|
||||
SocketsController.unstub!(:new)
|
||||
#EventMachine::WebSocket.stub!(:start)
|
||||
@controller = SocketController.new
|
||||
stub_socket_controller
|
||||
@controller = SocketsController.new
|
||||
stub_sockets_controller
|
||||
end
|
||||
|
||||
it 'should unstub the websocket' do
|
||||
it 'should unstub the websockets' do
|
||||
WebSocket.initialize_channel
|
||||
@controller.class.should == SocketController
|
||||
@controller.class.should == SocketsController
|
||||
end
|
||||
|
||||
it 'should add a new subscriber to the websocket channel' do
|
||||
it 'should add a new subscriber to the websockets channel' do
|
||||
WebSocket.initialize_channel
|
||||
@controller.new_subscriber.should == 1
|
||||
end
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
describe SocketHelper do
|
||||
|
||||
end
|
||||
|
|
@ -121,7 +121,6 @@ describe "parser in application helper" do
|
|||
Person.count.should be 0
|
||||
store_objects_from_xml(xml)
|
||||
Person.count.should be 1
|
||||
puts Person.first.inspect
|
||||
end
|
||||
|
||||
it "should activate the Person if I initiated a request to that url" do
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ RSpec.configure do |config|
|
|||
|
||||
config.before(:each) do
|
||||
DatabaseCleaner.start
|
||||
stub_socket_controller
|
||||
stub_sockets_controller
|
||||
end
|
||||
|
||||
config.after(:each) do
|
||||
|
|
@ -36,11 +36,11 @@ RSpec.configure do |config|
|
|||
keys.each{|k| ctx.delete_key(k, true)}
|
||||
end
|
||||
end
|
||||
def stub_socket_controller
|
||||
mock_socket_controller = mock('socket mock')
|
||||
mock_socket_controller.stub!(:incoming).and_return(true)
|
||||
mock_socket_controller.stub!(:new_subscriber).and_return(true)
|
||||
mock_socket_controller.stub!(:outgoing).and_return(true)
|
||||
mock_socket_controller.stub!(:delete_subscriber).and_return(true)
|
||||
SocketController.stub!(:new).and_return(mock_socket_controller)
|
||||
def stub_sockets_controller
|
||||
mock_sockets_controller = mock('sockets mock')
|
||||
mock_sockets_controller.stub!(:incoming).and_return(true)
|
||||
mock_sockets_controller.stub!(:new_subscriber).and_return(true)
|
||||
mock_sockets_controller.stub!(:outgoing).and_return(true)
|
||||
mock_sockets_controller.stub!(:delete_subscriber).and_return(true)
|
||||
SocketsController.stub!(:new).and_return(mock_sockets_controller)
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue