diaspora/config/initializers/_load_app_config.rb
Alec Leamas 9cd08bac67 Extended sub-uri support.
Adds new routing in routes.rb based on pod_uri. Assets are handled by a symlink
in public when using sub-uri. Various clean-up, removing thin and socket port
settings from server.sh (these are now taken from pod_uri and socket_port).

Basic functionality when setting a sub_uri like http://example.org/diaspora
now seems OK. Closes .http://joindiaspora.com/issues/737, and partially
http://joindiaspora.com/issues/391. Ports are yet to be defined and handled
in this context.

Conflicts:

	app/views/layouts/application.html.haml
	config/routes.rb
2010-12-21 01:13:15 +01:00

47 lines
1.6 KiB
Ruby

# Copyright (c) 2010, Diaspora Inc. This file is
# licensed under the Affero General Public License version 3 or later. See
# the COPYRIGHT file.
#
# Sets up APP_CONFIG. Unless stated below, each entry is a the string in
# the file app_config.yml, as applicable for current environment.
#
# Specific items
# * pod_url: As in app_config.yml, normalized with a trailing /.
# * pod_uri: An uri object derived from pod_url.
#
if defined? APP_CONFIG
false
else
require 'uri'
def load_config_yaml filename
YAML.load(File.read(filename))
end
if File.exist? "#{Rails.root}/config/app_config.yml"
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml"
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example" unless all_envs
else
puts "WARNING: No config/app_config.yml found! Look at config/app_config.yml.example for help."
all_envs = load_config_yaml "#{Rails.root}/config/app_config.yml.example"
end
if all_envs[Rails.env.to_s]
APP_CONFIG = all_envs['default'].merge(all_envs[Rails.env.to_s]).symbolize_keys
else
APP_CONFIG = all_envs['default'].symbolize_keys
end
begin
APP_CONFIG[:pod_uri] = URI.parse( APP_CONFIG[:pod_url])
rescue
puts "WARNING: pod url " + APP_CONFIG[:pod_url] + " is not a legal URI"
end
APP_CONFIG[:pod_url] = APP_CONFIG[:pod_uri].normalize.to_s
APP_CONFIG[:pod_url].chomp!("/"); APP_CONFIG[:pod_url]+= '/'
if APP_CONFIG[:pod_uri].host == "example.org" && Rails.env != "test"
puts "WARNING: Please modify your app_config.yml to have a proper pod_url!"
end
end