From 6544d8235b4276fffb449f624ded40ec4e2406d2 Mon Sep 17 00:00:00 2001 From: zhitomirskiyi Date: Fri, 12 Nov 2010 11:36:34 -0800 Subject: [PATCH 1/3] now running thins through ports since sockets were not working for some reason --- chef/cookbooks/common/files/default/thins.yml | 6 +++--- chef/cookbooks/common/recipes/daemontools.rb | 9 +++++---- chef/cookbooks/common/recipes/nginx.rb | 3 ++- chef/cookbooks/common/templates/default/nginx.conf.erb | 4 ++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/chef/cookbooks/common/files/default/thins.yml b/chef/cookbooks/common/files/default/thins.yml index 31bd3d893..0f660443f 100644 --- a/chef/cookbooks/common/files/default/thins.yml +++ b/chef/cookbooks/common/files/default/thins.yml @@ -1,3 +1,3 @@ -- socket_id: '1' -- socket_id: '2' -- socket_id: '3' +- port: '3001' +- port: '3002' +- port: '3003' diff --git a/chef/cookbooks/common/recipes/daemontools.rb b/chef/cookbooks/common/recipes/daemontools.rb index ed2e6980a..3ce295c3a 100644 --- a/chef/cookbooks/common/recipes/daemontools.rb +++ b/chef/cookbooks/common/recipes/daemontools.rb @@ -16,13 +16,14 @@ end config = YAML.load_file("/usr/local/app/diaspora/chef/cookbooks/common/files/default/thins.yml") config.each do |thin| - id = thin["socket_id"] - socket = "/tmp/thin_#{id}.sock" - dir = "/service/thin_#{id}" + id = thin["port"] + #socket = "/tmp/thin_#{id}.sock" + dir = "/service/thin_#{port}" flags = [] flags << "-c /usr/local/app/diaspora" #directory to run from flags << "-e production" #run in production mode - flags << "-S #{socket}" #use a socket + #flags << "-S #{socket}" #use a socket + flags << "-p #{port}" #use a socket execute "thin run" do command "mkdir -p #{dir} && echo '#!/bin/sh' > #{dir}/run && echo 'exec /usr/local/bin/ruby /usr/local/bin/thin start #{flags.join(" ")}' >> #{dir}/run" end diff --git a/chef/cookbooks/common/recipes/nginx.rb b/chef/cookbooks/common/recipes/nginx.rb index f4719f74b..5ee2a1ba7 100644 --- a/chef/cookbooks/common/recipes/nginx.rb +++ b/chef/cookbooks/common/recipes/nginx.rb @@ -21,5 +21,6 @@ end config = YAML.load_file("/usr/local/app/diaspora/chef/cookbooks/common/files/default/thins.yml") template "/usr/local/nginx/conf/nginx.conf" do source "nginx.conf.erb" - variables :socket_paths => config.map{|thin| "/tmp/thin_#{thin["socket_id"]}.sock"} + #variables :socket_paths => config.map{|thin| "/tmp/thin_#{thin["socket_id"]}.sock"} + variables :ports => config.map{|thin| "thin["port"]"} end diff --git a/chef/cookbooks/common/templates/default/nginx.conf.erb b/chef/cookbooks/common/templates/default/nginx.conf.erb index 8a4f0b888..21ed1e4d1 100644 --- a/chef/cookbooks/common/templates/default/nginx.conf.erb +++ b/chef/cookbooks/common/templates/default/nginx.conf.erb @@ -28,8 +28,8 @@ http { gzip_proxied any; gzip_buffers 16 8k; upstream thin_cluster { - <% @socket_paths.each do |socket_path| %> - server unix:<%=socket_path%>; + <% @ports.each do |port| %> + server <%="localhost:#{port}"%>; <% end %> } From feec6d971ddb5227ba5f3db0aef068d4f6853a8d Mon Sep 17 00:00:00 2001 From: Sarah Mei Date: Fri, 12 Nov 2010 13:40:23 -0600 Subject: [PATCH 2/3] More specs for aspect edit JS --- public/javascripts/aspect-edit.js | 26 ++++++++++++++++---------- spec/javascripts/aspect-edit-spec.js | 24 ++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 10 deletions(-) diff --git a/public/javascripts/aspect-edit.js b/public/javascripts/aspect-edit.js index adcc7fbf9..8edaa1853 100644 --- a/public/javascripts/aspect-edit.js +++ b/public/javascripts/aspect-edit.js @@ -50,29 +50,35 @@ var AspectEdit = { type: "DELETE", url: "/requests/" + person.attr('data-guid'), data: {"accept" : true, "aspect_id" : dropzone.attr('data-aspect_id') }, - success: function(data) { - AspectEdit.decrementRequestsCounter(); - person.removeClass('request'); - } + success: function() { AspectEdit.onDeleteRequestSuccess(person); } }); } if (dropzone.attr('data-aspect_id') != person.attr('data-aspect_id')) { $.ajax({ url: "/aspects/move_friend/", - data: {"friend_id" : person.attr('data-guid'), + data: { + "friend_id" : person.attr('data-guid'), "from" : person.attr('data-aspect_id'), - "to" : { "to" : dropzone.attr('data-aspect_id') }}, - success: function(data) { - person.attr('data-aspect_id', dropzone.attr('data-aspect_id')); - }}); + "to" : { "to" : dropzone.attr('data-aspect_id') } + }, + success: function() { AspectEdit.onMovePersonSuccess(person, dropzone); } + }); } dropzone.closest("ul").append(person); }, + onDeleteRequestSuccess: function(person) { + AspectEdit.decrementRequestsCounter(); + person.removeClass('request'); + }, + + onMovePersonSuccess: function(person, dropzone) { + person.attr('data-aspect_id', dropzone.attr('data-aspect_id')); + }, + deletePersonFromAspect: function(person) { - var person_id = person.attr('data-guid'); if( $(".person[data-guid='"+ person_id +"']").length == 1) { diff --git a/spec/javascripts/aspect-edit-spec.js b/spec/javascripts/aspect-edit-spec.js index 9f0841b1d..d5eea139a 100644 --- a/spec/javascripts/aspect-edit-spec.js +++ b/spec/javascripts/aspect-edit-spec.js @@ -91,6 +91,30 @@ describe("AspectEdit", function() { }); }); + describe("onDropMove", function() { + beforeEach(function() { + $('#jasmine_content').html( + '
  • ' + + ' Alexander Hamiltom' + + '
  • ' + + '' + ); + }); + describe("when dragging a friend request", function() { + it("deletes the request object", function() { + spyOn($, "ajax"); + AspectEdit.initialize(); + $.proxy(AspectEdit.onDropMove, $('.dropzone.ui-droppable'))(null, {draggable: $('.person.ui-draggable')}); + expect($.ajax).toHaveBeenCalled(); + var args = $.ajax.calls[0].args[0]; + expect(args["type"]).toEqual("DELETE"); + expect(args["url"]).toEqual("/requests/4cae42d32367bca44e000003"); + expect(args["data"]).toEqual({"accept" : true, "aspect_id" : "4cdae5ed2367bc30aa000007" }); + }); + }); + }); + describe("decrementRequestsCounter", function() { describe("when there is one request", function() { it("removes the counter from the new requests div", function() { From 4976503c0fdf3be63f286719e4022a91ff2a948f Mon Sep 17 00:00:00 2001 From: danielvincent Date: Fri, 12 Nov 2010 11:43:54 -0800 Subject: [PATCH 3/3] let nginx serve static assets. --- config/environment.rb | 12 ------------ config/environments/production.rb | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/config/environment.rb b/config/environment.rb index 9afe20c52..8270f544d 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -7,18 +7,6 @@ require File.expand_path('../application', __FILE__) Haml::Template.options[:format] = :html5 Haml::Template.options[:escape_html] = true -if File.exists?(File.expand_path("./config/fb_config.yml")) - # Load facebook connection application credentials - fb_config = YAML::load(File.open(File.expand_path("./config/fb_config.yml"))) - FB_API_KEY = fb_config['fb_api_key'] - FB_SECRET = fb_config['fb_secret'] - FB_APP_ID = fb_config['fb_app_id'] - HOST = fb_config['host'] - FACEBOOK = true -else - FACEBOOK = false -end - if File.exists?(File.expand_path("./config/languages.yml")) languages = YAML::load(File.open(File.expand_path("./config/languages.yml"))) AVAILABLE_LANGUAGES = (languages['available'].length > 0) ? languages['available'] : { :en => 'English' } diff --git a/config/environments/production.rb b/config/environments/production.rb index 8c65da341..958f30b6f 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -35,7 +35,7 @@ Diaspora::Application.configure do # Disable Rails's static asset server # In production, Apache or nginx will already do this - #config.serve_static_assets = true + config.serve_static_assets = false # Enable serving of images, stylesheets, and javascripts from an asset server # config.action_controller.asset_host = "http://assets.example.com"