3 # Copyright (C) 2012-2013 Gitorious AS
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # Main configuration of the Gitorious application from the config/gitorious.yml
22 # Gitorious configuration used to be a hash (GitoriousConfig) that was mostly
23 # used run-time to look up values in the underlying file. In Gitorious 3.x,
24 # configuration is a boot-time concern, and the underlying key/value data should
25 # rarely be accessed run-time.
27 # This initializer uses Gitorious::ConfigurationLoader to load the contents of
28 # config/gitorious.yml into the Gitorious::Configuration singleton and wire up
29 # other singletons, such as RepositoryRoot.default_base_path.
31 # Settings in config/gitorious.yml are mainly used to build objects exposed via
32 # the Gitorious application module, such as Gitorious.git_daemon (which has
33 # methods like port, host, path, url(path) etc) and configure certain
34 # class-variables, such as ProjectLicense.all. If you ever need to look up
35 # the same key via Gitorious::Configuration.get in more than one place, this
36 # lookup should be protected behind some sort of abstraction.
38 # When this initializer is not run and you need access to Gitorious
39 # configuration data, please look into lib/gitorious/configuration_loader.rb
40 if !defined?(Gitorious::Configuration) || !Gitorious.configured?
41 require "gitorious/configuration_loader"
42 require "gitorious/messaging"
45 loader = Gitorious::ConfigurationLoader.new
48 loader.require_configurable_singletons!
50 loader = Gitorious::ConfigurationLoader.new(Rails.root)
53 # Wire up the global Gitorious::Configuration singleton with settings
54 config = loader.configure_application!(env)
56 config.append("git_version" => `#{Gitorious.git_binary} --version`.chomp)
58 if !Gitorious.public? || Gitorious.private_repositories?
59 require Rails.root + "app/middlewares/dolt_auth_middleware"
60 Gitorious::Application.middleware.use DoltAuthMiddleware
61 require Rails.root + "app/middlewares/dolt_cache_middleware"
62 Gitorious::Application.middleware.use DoltCacheMiddleware