diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e22044141..d86938c05 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -15,7 +15,7 @@ class ApplicationController < ActionController::Base end def set_people - @people = Person.all + @people = Person.friends.all end end diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboards_controller.rb similarity index 95% rename from app/controllers/dashboard_controller.rb rename to app/controllers/dashboards_controller.rb index 56696fb84..c5508d51c 100644 --- a/app/controllers/dashboard_controller.rb +++ b/app/controllers/dashboards_controller.rb @@ -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 diff --git a/app/controllers/people_controller.rb b/app/controllers/people_controller.rb index 24c556c46..d8769d448 100644 --- a/app/controllers/people_controller.rb +++ b/app/controllers/people_controller.rb @@ -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 diff --git a/app/controllers/person_requests_controller.rb b/app/controllers/person_requests_controller.rb index 4dba011d0..d6b22f993 100644 --- a/app/controllers/person_requests_controller.rb +++ b/app/controllers/person_requests_controller.rb @@ -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 diff --git a/app/controllers/socket_controller.rb b/app/controllers/sockets_controller.rb similarity index 87% rename from app/controllers/socket_controller.rb rename to app/controllers/sockets_controller.rb index 6046697b7..daea6466a 100644 --- a/app/controllers/socket_controller.rb +++ b/app/controllers/sockets_controller.rb @@ -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! diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb deleted file mode 100644 index 4e26c74d8..000000000 --- a/app/helpers/dashboard_helper.rb +++ /dev/null @@ -1,5 +0,0 @@ -module DashboardHelper - - - -end diff --git a/app/helpers/dashboards_helper.rb b/app/helpers/dashboards_helper.rb new file mode 100644 index 000000000..8673a62e8 --- /dev/null +++ b/app/helpers/dashboards_helper.rb @@ -0,0 +1,5 @@ +module DashboardsHelper + + + +end diff --git a/app/helpers/person_requests_helper.rb b/app/helpers/person_requests_helper.rb new file mode 100644 index 000000000..6dfc0a08e --- /dev/null +++ b/app/helpers/person_requests_helper.rb @@ -0,0 +1,2 @@ +module PersonRequestsHelper +end diff --git a/app/helpers/socket_helper.rb b/app/helpers/sockets_helper.rb similarity index 96% rename from app/helpers/socket_helper.rb rename to app/helpers/sockets_helper.rb index 36124a60d..5b84cbee3 100644 --- a/app/helpers/socket_helper.rb +++ b/app/helpers/sockets_helper.rb @@ -1,4 +1,4 @@ -module SocketHelper +module SocketsHelper include ApplicationHelper def obj_id(object) diff --git a/app/models/comment.rb b/app/models/comment.rb index 55cfe7890..b8a682a94 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -36,6 +36,6 @@ class Comment def send_to_view - SocketController.new.outgoing(self) + SocketsController.new.outgoing(self) end end diff --git a/app/models/person.rb b/app/models/person.rb index 7743f7352..624f9f85a 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -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 diff --git a/app/models/person_request.rb b/app/models/person_request.rb index e27ae670f..3e3027886 100644 --- a/app/models/person_request.rb +++ b/app/models/person_request.rb @@ -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 diff --git a/app/models/post.rb b/app/models/post.rb index 266e16d0b..a0b69e08b 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/views/dashboard/socket.erb b/app/views/dashboard/socket.erb deleted file mode 100644 index ca397440b..000000000 --- a/app/views/dashboard/socket.erb +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - boner -
-
- - diff --git a/app/views/dashboard/index.html.haml b/app/views/dashboards/index.html.haml similarity index 100% rename from app/views/dashboard/index.html.haml rename to app/views/dashboards/index.html.haml diff --git a/app/views/friends/_sidebar.html.haml b/app/views/friends/_sidebar.html.haml deleted file mode 100644 index 6ef5d9073..000000000 --- a/app/views/friends/_sidebar.html.haml +++ /dev/null @@ -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 diff --git a/app/views/friends/index.html.haml b/app/views/friends/index.html.haml deleted file mode 100644 index cda1e225b..000000000 --- a/app/views/friends/index.html.haml +++ /dev/null @@ -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 diff --git a/app/views/friends/new.html.haml b/app/views/friends/new.html.haml deleted file mode 100644 index f18335484..000000000 --- a/app/views/friends/new.html.haml +++ /dev/null @@ -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 diff --git a/app/views/friends/show.html.haml b/app/views/friends/show.html.haml deleted file mode 100644 index 3fdac293b..000000000 --- a/app/views/friends/show.html.haml +++ /dev/null @@ -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! diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 12a4159e7..7365d8b39 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -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? diff --git a/app/views/people/_sidebar.html.haml b/app/views/people/_sidebar.html.haml index 996401ca7..bee8cb4b3 100644 --- a/app/views/people/_sidebar.html.haml +++ b/app/views/people/_sidebar.html.haml @@ -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 diff --git a/app/views/people/index.html.haml b/app/views/people/index.html.haml index 4d1d5a622..4d743a8f4 100644 --- a/app/views/people/index.html.haml +++ b/app/views/people/index.html.haml @@ -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 diff --git a/app/views/people/show.html.haml b/app/views/people/show.html.haml index ca2e88566..ccdabacd3 100644 --- a/app/views/people/show.html.haml +++ b/app/views/people/show.html.haml @@ -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 diff --git a/app/views/person_requests/_form.html.haml b/app/views/person_requests/_form.haml similarity index 72% rename from app/views/person_requests/_form.html.haml rename to app/views/person_requests/_form.haml index 75603f405..8aa4eb008 100644 --- a/app/views/person_requests/_form.html.haml +++ b/app/views/person_requests/_form.haml @@ -1,4 +1,4 @@ -= form_for @person_request do |f| += form_for @person_request do |f| = f.error_messages %p diff --git a/app/views/person_requests/_person_request.html.haml b/app/views/person_requests/_person_request.html.haml index b492c539c..29f16e264 100644 --- a/app/views/person_requests/_person_request.html.haml +++ b/app/views/person_requests/_person_request.html.haml @@ -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 diff --git a/app/views/person_requests/show.html.haml b/app/views/person_requests/show.html.haml index 207d347f1..1c6ce85d7 100644 --- a/app/views/person_requests/show.html.haml +++ b/app/views/person_requests/show.html.haml @@ -1,7 +1,7 @@ - title "Person Request" %p - = person_request.inspect + = @person_request.inspect %p = link_to "Edit", edit_person_request_path(@person_request) diff --git a/app/views/status_messages/_status_message.html.haml b/app/views/status_messages/_status_message.html.haml index 1333640f9..1434ca0d2 100644 --- a/app/views/status_messages/_status_message.html.haml +++ b/app/views/status_messages/_status_message.html.haml @@ -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 diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index bf760d087..fdca7d7b4 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -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 diff --git a/config/initializers/socket.rb b/config/initializers/socket.rb index d1fcfc315..4651335a0 100644 --- a/config/initializers/socket.rb +++ b/config/initializers/socket.rb @@ -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 } diff --git a/config/routes.rb b/config/routes.rb index de1342247..914c5a08b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/lib/common.rb b/lib/common.rb index 48859a9ec..ca270730b 100644 --- a/lib/common.rb +++ b/lib/common.rb @@ -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 diff --git a/lib/message_handler.rb b/lib/message_handler.rb index 5d050eb19..66bc0688a 100644 --- a/lib/message_handler.rb +++ b/lib/message_handler.rb @@ -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 diff --git a/spec/controllers/dashboard_controller_spec.rb b/spec/controllers/dashboards_controller_spec.rb similarity index 85% rename from spec/controllers/dashboard_controller_spec.rb rename to spec/controllers/dashboards_controller_spec.rb index 97656369e..34186d8df 100644 --- a/spec/controllers/dashboard_controller_spec.rb +++ b/spec/controllers/dashboards_controller_spec.rb @@ -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 diff --git a/spec/controllers/socket_controller_spec.rb b/spec/controllers/sockets_controller_spec.rb similarity index 74% rename from spec/controllers/socket_controller_spec.rb rename to spec/controllers/sockets_controller_spec.rb index 5f5a8b70f..a5109e356 100644 --- a/spec/controllers/socket_controller_spec.rb +++ b/spec/controllers/sockets_controller_spec.rb @@ -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 diff --git a/spec/helpers/socket_helper_spec.rb b/spec/helpers/socket_helper_spec.rb deleted file mode 100644 index 45c77f564..000000000 --- a/spec/helpers/socket_helper_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -require File.dirname(__FILE__) + '/../spec_helper' -describe SocketHelper do - -end diff --git a/spec/lib/parser_spec.rb b/spec/lib/parser_spec.rb index fe93b33bb..6499b4c52 100644 --- a/spec/lib/parser_spec.rb +++ b/spec/lib/parser_spec.rb @@ -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 diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index a414acb20..759b3a478 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -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