From 020ff603bdbbea476483a70c0aad764de646893a Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 16:59:06 -0700 Subject: [PATCH 1/3] terse_url in user, db seeds are fixed, config/app_config.yml is now in gitignore, copy over config/app_config_example.yml. --- .gitignore | 1 + app/models/user.rb | 3 +++ config/app_config.yml | 34 ++++++++++++++-------------------- config/app_config_example.yml | 23 +++++++++++++++++++++++ db/seeds/backer.rb | 8 ++++---- db/seeds/dev.rb | 12 ++++++++++++ db/seeds/tom.rb | 8 ++++---- 7 files changed, 61 insertions(+), 28 deletions(-) create mode 100644 config/app_config_example.yml diff --git a/.gitignore b/.gitignore index 89b33da60..0025a86f5 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,4 @@ gpg/diaspora-production/*.gpg gpg/*/random_seed public/uploads/* .rvmrc +config/app_config.yml diff --git a/app/models/user.rb b/app/models/user.rb index 4e9e968ca..a98217b4e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -221,6 +221,9 @@ class User ###Helpers############ def self.instantiate!( opts = {} ) + terse_url = APP_CONFIG[:pod_url].gsub(/(https?:|www\.)\/\//, '') + terse_url.chop! if terse_url[-1, 1] == '/' + opts[:person][:diaspora_handle] = "#{opts[:username]}@#{terse_url}" opts[:person][:url] = APP_CONFIG[:pod_url] opts[:person][:serialized_key] = generate_key diff --git a/config/app_config.yml b/config/app_config.yml index 5ee07c405..bd306725e 100644 --- a/config/app_config.yml +++ b/config/app_config.yml @@ -1,23 +1,17 @@ -# Copyright (c) 2010, Diaspora Inc. This file is -# licensed under the Affero General Public License version 3. See -# the COPYRIGHT file. - - -default: - pod_url: "http://example.org/" - debug: false - socket_debug : false +--- +default: socket_host: 0.0.0.0 - socket_port: 8080 - socket_collection_name: 'websocket' - pubsub_server: 'https://pubsubhubbub.appspot.com/' - mongo_host: 'localhost' + socket_debug: false + pod_url: tom.joindiaspora.com mongo_post: 27017 - -development: - -test: - pod_url: "http://example.org/" + socket_collection_name: websocket + socket_port: 8080 + pubsub_server: https://pubsubhubbub.appspot.com/ + mongo_host: localhost + debug: false +production: +development: + pod_url: tom.joindiaspora.com +test: + pod_url: http://example.org/ socket_port: 8081 - -production: diff --git a/config/app_config_example.yml b/config/app_config_example.yml new file mode 100644 index 000000000..5ee07c405 --- /dev/null +++ b/config/app_config_example.yml @@ -0,0 +1,23 @@ +# Copyright (c) 2010, Diaspora Inc. This file is +# licensed under the Affero General Public License version 3. See +# the COPYRIGHT file. + + +default: + pod_url: "http://example.org/" + debug: false + socket_debug : false + socket_host: 0.0.0.0 + socket_port: 8080 + socket_collection_name: 'websocket' + pubsub_server: 'https://pubsubhubbub.appspot.com/' + mongo_host: 'localhost' + mongo_post: 27017 + +development: + +test: + pod_url: "http://example.org/" + socket_port: 8081 + +production: diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 9ebe1248f..700839f62 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -42,10 +42,10 @@ def create end def set_app_config username - current_config = YAML.load(Rails.root.join('config', 'app_config.yml')).symbolize_keys - current_config[Rails.env] ||= {} - current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com" - current_config[:default][:pod_url] = "#{username}.joindiaspora.com" + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" + current_config['default']['pod_url'] = "#{username}.joindiaspora.com" file = File.new(Rails.root.join('config','app_config.yml'),'w') file.write(current_config.to_yaml) file.close diff --git a/db/seeds/dev.rb b/db/seeds/dev.rb index ef9dddecf..4ffa947e7 100644 --- a/db/seeds/dev.rb +++ b/db/seeds/dev.rb @@ -6,7 +6,19 @@ require 'config/environment' +def set_app_config username + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" + current_config['default']['pod_url'] = "#{username}.joindiaspora.com" + file = File.new(Rails.root.join('config','app_config.yml'),'w') + file.write(current_config.to_yaml) + file.close +end + username = "tom" +set_app_config username + # Create seed user user = User.instantiate!( :email => "tom@tom.joindiaspora.com", :username => "tom", diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index c35058bf7..cf6a1ed0c 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -7,10 +7,10 @@ require 'config/environment' def set_app_config username - current_config = YAML.load(Rails.root.join('config', 'app_config.yml')).symbolize_keys - current_config[Rails.env] ||= {} - current_config[Rails.env][:pod_url] = "#{username}.joindiaspora.com" - current_config[:default][:pod_url] = "#{username}.joindiaspora.com" + current_config = YAML.load(File.read(Rails.root.join('config', 'app_config_example.yml'))) + current_config[Rails.env.to_s] ||= {} + current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" + current_config['default']['pod_url'] = "#{username}.joindiaspora.com" file = File.new(Rails.root.join('config','app_config.yml'),'w') file.write(current_config.to_yaml) file.close From e3d52bb467bd8f45d380a8715c80799065ccb036 Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 17:39:44 -0700 Subject: [PATCH 2/3] putting the config file in a shared directory for in the deploy scripts --- config/deploy.rb | 7 ++++++- db/seeds/backer.rb | 2 +- db/seeds/tom.rb | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/config/deploy.rb b/config/deploy.rb index c84d25556..478736392 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -53,6 +53,11 @@ namespace :deploy do run "ln -s -f #{shared_path}/bundle #{current_path}/vendor/bundle" end + task :symlink_config do + run "touch #{shared_path}/app_config.yml" + run "ln -s -f #{shared_path}/app_config.yml #{current_path}/config/app_config.yml" + end + task :start do start_mongo start_thin @@ -150,4 +155,4 @@ namespace :db do end -after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle" +after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config" diff --git a/db/seeds/backer.rb b/db/seeds/backer.rb index 700839f62..1730ee202 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -46,7 +46,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" - file = File.new(Rails.root.join('config','app_config.yml'),'w') + file = File.new(Rails.root.join('..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end diff --git a/db/seeds/tom.rb b/db/seeds/tom.rb index cf6a1ed0c..d8152a33b 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -11,7 +11,7 @@ def set_app_config username current_config[Rails.env.to_s] ||= {} current_config[Rails.env.to_s]['pod_url'] = "#{username}.joindiaspora.com" current_config['default']['pod_url'] = "#{username}.joindiaspora.com" - file = File.new(Rails.root.join('config','app_config.yml'),'w') + file = File.new(Rails.root.join('..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end From 74a92a26374cebd9adbf236c47f148d85dd307ce Mon Sep 17 00:00:00 2001 From: ilya Date: Tue, 21 Sep 2010 17:40:43 -0700 Subject: [PATCH 3/3] tiny typo --- config/deploy.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/deploy.rb b/config/deploy.rb index 478736392..2f8065134 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -155,4 +155,4 @@ namespace :db do end -after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config" +after "deploy:symlink", "deploy:symlink_images", "deploy:symlink_bundle", 'deploy:symlink_config'