DG MS; cleaned up views for person. Also, pluralized Dashboard and Socket
This commit is contained in:
parent
1fa2dfd6eb
commit
db1811eb61
25 changed files with 48 additions and 108 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
class DashboardController < ApplicationController
|
class DashboardsController < ApplicationController
|
||||||
|
|
||||||
before_filter :authenticate_user!, :except => :receive
|
before_filter :authenticate_user!, :except => :receive
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
|
|
@ -7,20 +7,11 @@ class DashboardController < ApplicationController
|
||||||
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
|
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
def receive
|
def receive
|
||||||
|
|
||||||
puts "SOMEONE JUST SENT ME: #{params[:xml]}"
|
|
||||||
|
|
||||||
store_objects_from_xml CGI::escape( params[:xml] )
|
store_objects_from_xml CGI::escape( params[:xml] )
|
||||||
render :nothing => true
|
render :nothing => true
|
||||||
end
|
end
|
||||||
|
|
||||||
def socket
|
|
||||||
#this is just for me to test teh sockets!
|
|
||||||
render "socket"
|
|
||||||
end
|
|
||||||
|
|
||||||
def warzombie
|
def warzombie
|
||||||
render :nothing => true
|
render :nothing => true
|
||||||
if User.first.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil
|
if User.first.email == "tom@joindiaspora.com" && StatusMessage.where(:message => "There's a bomb in the lasagna!?").first == nil
|
||||||
|
|
@ -18,22 +18,4 @@ class PeopleController < ApplicationController
|
||||||
redirect_to people_url
|
redirect_to people_url
|
||||||
end
|
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
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,9 @@
|
||||||
class PersonRequestsController < ApplicationController
|
class PersonRequestsController < ApplicationController
|
||||||
before_filter :authenticate_user!
|
before_filter :authenticate_user!
|
||||||
|
include PersonRequestsHelper
|
||||||
def index
|
def index
|
||||||
@person_requests = PersonRequest.paginate :page => params[:page], :order => 'created_at DESC'
|
@person_requests = PersonRequest.paginate :page => params[:page], :order => 'created_at DESC'
|
||||||
@person_request = PersonRequest.new
|
@person_request = PersonRequest.new
|
||||||
@person = Person.new
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
|
||||||
@person_request = PersonRequest.where(:id => params[:id]).first
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
|
@ -20,17 +15,18 @@ class PersonRequestsController < ApplicationController
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@person_request = PersonRequest.new
|
@person_request = PersonRequest.new
|
||||||
@recipient = Person.new
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@person_request = PersonRequest.for(params[:person_request][:url])
|
@person_request = PersonRequest.for params[:person_request][:url]
|
||||||
|
|
||||||
if @person_request
|
if @person_request
|
||||||
flash[:notice] = "Successfully created person request."
|
flash[:notice] = "Successfully created person request."
|
||||||
redirect_to @person_request
|
redirect_to person_requests_url
|
||||||
else
|
else
|
||||||
render :action => 'new'
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
class SocketController < ApplicationController
|
class SocketsController < ApplicationController
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include SocketHelper
|
include SocketsHelper
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
before_filter :authenticate_user!
|
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
|
include ApplicationHelper
|
||||||
|
|
||||||
def obj_id(object)
|
def obj_id(object)
|
||||||
|
|
@ -36,6 +36,6 @@ class Comment
|
||||||
|
|
||||||
|
|
||||||
def send_to_view
|
def send_to_view
|
||||||
SocketController.new.outgoing(self)
|
SocketsController.new.outgoing(self)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -20,8 +20,9 @@ class PersonRequest
|
||||||
|
|
||||||
def self.for(url)
|
def self.for(url)
|
||||||
request = PersonRequest.new(:url => url, :person => User.first)
|
request = PersonRequest.new(:url => url, :person => User.first)
|
||||||
request.save
|
|
||||||
request.push_to_url
|
request.push_to_url
|
||||||
|
request.save
|
||||||
|
request
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_for_person_requests
|
def check_for_person_requests
|
||||||
|
|
|
||||||
|
|
@ -53,11 +53,11 @@ class Post
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_to_view
|
def send_to_view
|
||||||
SocketController.new.outgoing(self)
|
SocketsController.new.outgoing(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
def remove_from_view
|
def remove_from_view
|
||||||
SocketController.new.outgoing(Retraction.for(self))
|
SocketsController.new.outgoing(Retraction.for(self))
|
||||||
end
|
end
|
||||||
|
|
||||||
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>
|
|
||||||
|
|
@ -2,4 +2,4 @@
|
||||||
%ul#friend_stream.nav
|
%ul#friend_stream.nav
|
||||||
- for person in @people
|
- for person in @people
|
||||||
%li= link_to person.real_name, person_path(person)
|
%li= link_to person.real_name, person_path(person)
|
||||||
= link_to "add a new person", new_person_path
|
= link_to "add a new person", new_person_request_path
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
%td= link_to 'Show', person
|
%td= link_to 'Show', person
|
||||||
%td= link_to 'Destroy', person, :confirm => 'Are you sure?', :method => :delete
|
%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
|
#pagination
|
||||||
= will_paginate @people
|
= will_paginate @people
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.span-18.last
|
.span-20.last
|
||||||
%h1= "#{@person.real_name}"
|
%h1= "#{@person.real_name}"
|
||||||
- if @person_profile
|
- if @person_profile
|
||||||
%p
|
%p
|
||||||
|
|
@ -14,7 +14,7 @@
|
||||||
%p
|
%p
|
||||||
= @person.url
|
= @person.url
|
||||||
|
|
||||||
.span-18
|
.span-20
|
||||||
- if @person.posts
|
- if @person.posts
|
||||||
%h3 stream
|
%h3 stream
|
||||||
%ul#stream
|
%ul#stream
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
= form_for @person_request do |f|
|
= form_for @person_request do |f|
|
||||||
= f.error_messages
|
= f.error_messages
|
||||||
|
|
||||||
%p
|
%p
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
- title "Person Request"
|
- title "Person Request"
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= person_request.inspect
|
= @person_request.inspect
|
||||||
|
|
||||||
%p
|
%p
|
||||||
= link_to "Edit", edit_person_request_path(@person_request)
|
= link_to "Edit", edit_person_request_path(@person_request)
|
||||||
|
|
|
||||||
|
|
@ -7,5 +7,4 @@
|
||||||
# inflect.singular /^(ox)en/i, '\1'
|
# inflect.singular /^(ox)en/i, '\1'
|
||||||
# inflect.irregular 'person', 'people'
|
# inflect.irregular 'person', 'people'
|
||||||
# inflect.uncountable %w( fish sheep )
|
# inflect.uncountable %w( fish sheep )
|
||||||
inflect.uncountable %w(dashboard socket)
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -13,11 +13,11 @@ module WebSocket
|
||||||
:debug =>APP_CONFIG[:debug]) do |ws|
|
:debug =>APP_CONFIG[:debug]) do |ws|
|
||||||
ws.onopen {
|
ws.onopen {
|
||||||
@ws = ws
|
@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
|
end
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,8 @@ Diaspora::Application.routes.draw do |map|
|
||||||
|
|
||||||
|
|
||||||
resources :users
|
resources :users
|
||||||
match 'receive', :to => 'dashboard#receive'
|
match 'receive', :to => 'dashboards#receive'
|
||||||
match "socket", :to => 'dashboard#socket'
|
|
||||||
|
|
||||||
root :to => 'dashboard#index'
|
root :to => 'dashboards#index'
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe DashboardController do
|
describe DashboardsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe 'SocketController' do
|
describe 'SocketsController' do
|
||||||
render_views
|
render_views
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
SocketController.unstub!(:new)
|
SocketsController.unstub!(:new)
|
||||||
#EventMachine::WebSocket.stub!(:start)
|
#EventMachine::WebSocket.stub!(:start)
|
||||||
@controller = SocketController.new
|
@controller = SocketsController.new
|
||||||
stub_socket_controller
|
stub_sockets_controller
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should unstub the websocket' do
|
it 'should unstub the websockets' do
|
||||||
WebSocket.initialize_channel
|
WebSocket.initialize_channel
|
||||||
@controller.class.should == SocketController
|
@controller.class.should == SocketsController
|
||||||
end
|
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
|
WebSocket.initialize_channel
|
||||||
@controller.new_subscriber.should == 1
|
@controller.new_subscriber.should == 1
|
||||||
end
|
end
|
||||||
|
|
@ -1,4 +0,0 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
|
||||||
describe SocketHelper do
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
@ -24,7 +24,7 @@ RSpec.configure do |config|
|
||||||
|
|
||||||
config.before(:each) do
|
config.before(:each) do
|
||||||
DatabaseCleaner.start
|
DatabaseCleaner.start
|
||||||
stub_socket_controller
|
stub_sockets_controller
|
||||||
end
|
end
|
||||||
|
|
||||||
config.after(:each) do
|
config.after(:each) do
|
||||||
|
|
@ -32,11 +32,11 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
def stub_socket_controller
|
def stub_sockets_controller
|
||||||
mock_socket_controller = mock('socket mock')
|
mock_sockets_controller = mock('sockets mock')
|
||||||
mock_socket_controller.stub!(:incoming).and_return(true)
|
mock_sockets_controller.stub!(:incoming).and_return(true)
|
||||||
mock_socket_controller.stub!(:new_subscriber).and_return(true)
|
mock_sockets_controller.stub!(:new_subscriber).and_return(true)
|
||||||
mock_socket_controller.stub!(:outgoing).and_return(true)
|
mock_sockets_controller.stub!(:outgoing).and_return(true)
|
||||||
mock_socket_controller.stub!(:delete_subscriber).and_return(true)
|
mock_sockets_controller.stub!(:delete_subscriber).and_return(true)
|
||||||
SocketController.stub!(:new).and_return(mock_socket_controller)
|
SocketsController.stub!(:new).and_return(mock_sockets_controller)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue