OSDN Git Service

Merge pull request #2870 from mikew/relative-url-root-default
[wvm/gitlab.git] / config / initializers / 1_settings.rb
1 class Settings < Settingslogic
2   source "#{Rails.root}/config/gitlab.yml"
3   namespace Rails.env
4
5   class << self
6     def gitlab_on_non_standard_port?
7       ![443, 80].include?(gitlab.port.to_i)
8     end
9
10     private
11
12     def build_gitlab_shell_ssh_path_prefix
13       if gitlab_shell.ssh_port != 22
14         "ssh://#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:#{gitlab_shell.ssh_port}/"
15       else
16         "#{gitlab_shell.ssh_user}@#{gitlab_shell.ssh_host}:"
17       end
18     end
19
20     def build_gitlab_url
21       if gitlab_on_non_standard_port?
22         custom_port = ":#{gitlab.port}"
23       else
24         custom_port = nil
25       end
26       [ gitlab.protocol,
27         "://",
28         gitlab.host,
29         custom_port,
30         gitlab.relative_url_root
31       ].join('')
32     end
33   end
34 end
35
36
37 # Default settings
38 Settings['ldap'] ||= Settingslogic.new({})
39 Settings.ldap['enabled'] = false if Settings.ldap['enabled'].nil?
40
41 Settings['omniauth'] ||= Settingslogic.new({})
42 Settings.omniauth['enabled']      = false if Settings.omniauth['enabled'].nil?
43 Settings.omniauth['providers']  ||= []
44
45 Settings['issues_tracker']  ||= {}
46
47 #
48 # GitLab
49 #
50 Settings['gitlab'] ||= Settingslogic.new({})
51 Settings.gitlab['default_projects_limit'] ||=  10
52 Settings.gitlab['host']       ||= 'localhost'
53 Settings.gitlab['https']        = false if Settings.gitlab['https'].nil?
54 Settings.gitlab['port']       ||= Settings.gitlab.https ? 443 : 80
55 Settings.gitlab['relative_url_root'] ||= ENV['RAILS_RELATIVE_URL_ROOT'] || ''
56 Settings.gitlab['protocol']   ||= Settings.gitlab.https ? "https" : "http"
57 Settings.gitlab['email_from'] ||= "gitlab@#{Settings.gitlab.host}"
58 Settings.gitlab['support_email']  ||= Settings.gitlab.email_from
59 Settings.gitlab['url']        ||= Settings.send(:build_gitlab_url)
60 Settings.gitlab['user']       ||= 'git'
61 Settings.gitlab['signup_enabled'] ||= false
62 Settings.gitlab['username_changing_enabled'] = true if Settings.gitlab['username_changing_enabled'].nil?
63
64 #
65 # Gravatar
66 #
67 Settings['gravatar'] ||= Settingslogic.new({})
68 Settings.gravatar['enabled']      = true if Settings.gravatar['enabled'].nil?
69 Settings.gravatar['plain_url']  ||= 'http://www.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
70 Settings.gravatar['ssl_url']    ||= 'https://secure.gravatar.com/avatar/%{hash}?s=%{size}&d=mm'
71
72 #
73 # GitLab Shell
74 #
75 Settings['gitlab_shell'] ||= Settingslogic.new({})
76 Settings.gitlab_shell['hooks_path']   ||= '/home/git/gitlab-shell/hooks/'
77 Settings.gitlab_shell['receive_pack']   = true if Settings.gitlab_shell['receive_pack'].nil?
78 Settings.gitlab_shell['upload_pack']    = true if Settings.gitlab_shell['upload_pack'].nil?
79 Settings.gitlab_shell['repos_path']   ||= '/home/git/repositories/'
80 Settings.gitlab_shell['ssh_host']     ||= (Settings.gitlab.host || 'localhost')
81 Settings.gitlab_shell['ssh_port']     ||= 22
82 Settings.gitlab_shell['ssh_user']     ||= Settings.gitlab.user
83 Settings.gitlab_shell['owner_group']  ||= Settings.gitlab.user
84 Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.send(:build_gitlab_shell_ssh_path_prefix)
85
86 #
87 # Backup
88 #
89 Settings['backup'] ||= Settingslogic.new({})
90 Settings.backup['keep_time']  ||= 0
91 Settings.backup['path']         = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root)
92
93 #
94 # Git
95 #
96 Settings['git'] ||= Settingslogic.new({})
97 Settings.git['max_size']  ||= 5242880 # 5.megabytes
98 Settings.git['bin_path']  ||= '/usr/bin/git'
99 Settings.git['timeout']   ||= 10
100
101 Settings['satellites'] ||= Settingslogic.new({})
102 Settings.satellites['path'] = File.expand_path(Settings.satellites['path'] || "tmp/repo_satellites/", Rails.root)