diff --git a/README.md b/README.md index d941ac182..2398be5dc 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ You are welcome to contribute, add and extend Diaspora however you see fit. We We need you to fill out a [contributor agreement form](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq) before we can accept your patches. The agreement gives Diaspora joint ownership of the patch so the copyright isn't scattered. You can find it [here](https://spreadsheets.google.com/a/joindiaspora.com/viewform?formkey=dGI2cHA3ZnNHLTJvbm10LUhXRTJjR0E6MQ&theme=0AX42CRMsmRFbUy1iOGYwN2U2Mi1hNWU0LTRlNjEtYWMyOC1lZmU4ODg1ODc1ODI&ifq). -All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec or Test-Unit. +All commits must be tested, and after each commit, all tests should be green before a pull request is sent. Please write your tests in Rspec. GEMS: We would like to keep external dependencies unduplicated. We're using Nokogiri, and Mongomapper, and EM::HttpRequest as much as possible. We have a few gems in the project we'd rather not use, but if you can, use dependencies we already have. @@ -195,9 +195,15 @@ If you installed the OsX package through "brew", MongoDB will need to be started Diaspora will not run unless mongo is running. Mongo will not run by default, and will need to be started every time you wish to use or run the test suite for Diaspora. +### Run the server +`./script/server` will start both thin and the websocket server. If you want to run a different app server, you will have to run them separately. See below for instructions. + ### Run the app server Once mongo is running and bundler has finished, run `bundle exec thin start` from the root Diaspora directory. This will start the app server in development mode[.](http://bit.ly/9mwtUw) +### Run the websocket server +run `bundle exec ruby ./script/websocket_server` to start the websocket server on port 8080. Change the port in config/app_config.yml. + ### Logging in Run `rake db:seed:tom`, then login with user `tom` and password `evankorth`. More details in db/seeds/tom.rb. diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 4a36672bc..72666bc30 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -7,13 +7,6 @@ class UsersController < ApplicationController before_filter :authenticate_user!, :except => [:new, :create] respond_to :html - respond_to :json, :only => :show - - def show - @user = User.find_by_id params[:id] - @user_profile = @user.person.profile - respond_with @user - end def edit @user = current_user @@ -23,7 +16,7 @@ class UsersController < ApplicationController end def update - @user = User.find_by_id params[:id] + @user = current_user prep_image_url(params[:user]) @user.update_profile params[:user] diff --git a/app/models/person.rb b/app/models/person.rb index 48e8b0816..ac4a5dfa7 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -85,7 +85,7 @@ class Person local_person elsif !identifier.include?("localhost") && !opts[:local] begin - puts "begin finger" + Rails.logger.info("Webfingering #{identifier}") f = Redfinger.finger(identifier) rescue SocketError => e raise "Diaspora server for #{identifier} not found" if e.message =~ /Name or service not known/ diff --git a/config/routes.rb b/config/routes.rb index 12dd20ba7..188c4b137 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,7 @@ Diaspora::Application.routes.draw do resources :people, :only => [:index, :show, :destroy] - resources :users, :except => [:create, :new] + resources :users, :except => [:create, :new, :show] resources :status_messages, :only => [:create, :destroy, :show] resources :comments, :except => [:index] resources :requests, :except => [:edit, :update] diff --git a/script/server b/script/server new file mode 100755 index 000000000..0094482b1 --- /dev/null +++ b/script/server @@ -0,0 +1,5 @@ +#!/bin/bash + +mkdir -p -v log/thin/ +bundle exec ruby ./script/websocket_server.rb& +bundle exec thin start $@ diff --git a/script/websocket_server.rb b/script/websocket_server.rb index 8c466ca77..2fbc1370a 100644 --- a/script/websocket_server.rb +++ b/script/websocket_server.rb @@ -19,6 +19,7 @@ def process_message end +begin EM.run { Diaspora::WebSocket.initialize_channels @@ -35,6 +36,13 @@ end ws.onclose { Diaspora::WebSocket.unsubscribe(ws.request['Path'].gsub('/',''), sid) } } end + + puts "Websocket server started." process_message } - +rescue RuntimeError => e + raise e unless e.message.include?("no acceptor") + puts "Are you sure the websocket server isn't already running?" + puts "Just start thin with bundle exec thin start." + Process.exit +end diff --git a/spec/lib/websocket_spec.rb b/spec/lib/websocket_spec.rb index 233f7be48..762a725b5 100644 --- a/spec/lib/websocket_spec.rb +++ b/spec/lib/websocket_spec.rb @@ -17,8 +17,9 @@ describe Diaspora::WebSocket do end it 'The queued job should reach Magent' do - Magent.should_receive(:push) @post.socket_to_uid(@user.id, :aspect_ids => @aspect.id) + channel = Magent::GenericChannel.new('websocket') + channel.message_count.should == 1 end end