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 87f11fc29..928a02173 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -239,6 +239,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/config/deploy.rb b/config/deploy.rb index c84d25556..2f8065134 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 9ebe1248f..1730ee202 100644 --- a/db/seeds/backer.rb +++ b/db/seeds/backer.rb @@ -42,11 +42,11 @@ 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" - file = File.new(Rails.root.join('config','app_config.yml'),'w') + 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('..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end 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..d8152a33b 100644 --- a/db/seeds/tom.rb +++ b/db/seeds/tom.rb @@ -7,11 +7,11 @@ 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" - file = File.new(Rails.root.join('config','app_config.yml'),'w') + 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('..','shared','app_config.yml'),'w') file.write(current_config.to_yaml) file.close end