diff --git a/.gitignore b/.gitignore index 89b33da60180d91df81c80b1c3b2849b3c7cd5f9..0025a86f53a22fea18824e93fa20865a1f343bb9 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 4e9e968ca689d3673d9364a43d66d656895116ab..a98217b4ec2f3b6d564f6055b3899f9bf5a35fa6 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 5ee07c405656c2bdec681f9d47abadc690c392f6..bd306725ed61e66dcc613616a843a70e15f09646 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 0000000000000000000000000000000000000000..5ee07c405656c2bdec681f9d47abadc690c392f6 --- /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 9ebe1248f9ded80d89e3adfde48d068d2d00d46d..700839f627bb9ac05bd5053173a190a7e9b9dd84 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 ef9dddecff4dc93709439bc25f1bf86e9948f67e..4ffa947e77a7371c4d03454cf48a1c6e7dd2df43 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 c35058bf7892a651c60904e371a3435408f877a3..cf6a1ed0c2530b608f2a5dd4b57c78efd337076c 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