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
|
||||
include ApplicationHelper
|
||||
|
|
@ -7,20 +7,11 @@ class DashboardController < ApplicationController
|
|||
@posts = Post.paginate :page => params[:page], :order => 'created_at DESC'
|
||||
end
|
||||
|
||||
|
||||
def receive
|
||||
|
||||
puts "SOMEONE JUST SENT ME: #{params[:xml]}"
|
||||
|
||||
store_objects_from_xml CGI::escape( params[:xml] )
|
||||
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
|
||||
|
|
@ -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 @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
|
||||
|
|
|
|||
|
|
@ -20,8 +20,9 @@ class PersonRequest
|
|||
|
||||
def self.for(url)
|
||||
request = PersonRequest.new(:url => url, :person => User.first)
|
||||
request.save
|
||||
request.push_to_url
|
||||
request.save
|
||||
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>
|
||||
|
|
@ -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 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 '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,7 +1,7 @@
|
|||
- title "Person Request"
|
||||
|
||||
%p
|
||||
= person_request.inspect
|
||||
= @person_request.inspect
|
||||
|
||||
%p
|
||||
= link_to "Edit", edit_person_request_path(@person_request)
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe DashboardController do
|
||||
describe DashboardsController do
|
||||
render_views
|
||||
|
||||
before do
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -32,11 +32,11 @@ RSpec.configure do |config|
|
|||
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