oops forgot to commit this

This commit is contained in:
Sam 2013-12-20 16:38:51 +11:00
parent 4b04ac4c2b
commit 13e1016d73
1 changed files with 6 additions and 28 deletions

View File

@ -1,39 +1,14 @@
class GlobalSetting class GlobalSetting
def self.available_settings(*settings) def self.load_defaults
settings.each do |name, desc, default| provider = FileProvider.from(File.expand_path('../../../config/discourse_defaults.conf', __FILE__))
provider.data.each do |name, default|
define_singleton_method(name) do define_singleton_method(name) do
provider.lookup(name, default) provider.lookup(name, default)
end end
end end
end end
def self.generate_sample_file(file)
end
available_settings(
[:db_pool, "connection pool size", 5],
[:db_timeout, "database timeout in milliseconds", 5000],
[:db_socket, "socket file used to access db", ""],
[:db_host, "host address for db server", "localhost"],
[:db_port, "port running db server", 5432],
[:db_name, "database name running discourse", "discourse"],
[:db_username, "username accessing database", "discourse"],
[:db_password, "password used to access the db", ""],
[:hostname, "hostname running the forum", "www.example.com"],
[:smtp_address, "address of smtp server used to send emails",""],
[:smtp_port, "port of smtp server used to send emails", 25],
[:smtp_domain, "domain passed to smtp server", ""],
[:smtp_user_name, "username for smtp server", ""],
[:smtp_password, "password for smtp server", ""],
[:smtp_enable_start_tls, "enable TLS encryption for smtp connections", true],
[:enable_mini_profiler, "enable MiniProfiler for administrators", true],
[:cdn_url, "recommended, cdn used to access assets", ""],
[:developer_emails, "comma delimited list of emails that have devloper level access", true],
[:redis_host, "redis server address", "localhost"],
[:redis_port, "redis server port", 6379],
[:redis_password, "redis password", ""]
)
class BaseProvider class BaseProvider
def self.coerce(setting) def self.coerce(setting)
@ -55,6 +30,7 @@ class GlobalSetting
end end
class FileProvider < BaseProvider class FileProvider < BaseProvider
attr_reader :data
def self.from(file) def self.from(file)
if File.exists?(file) if File.exists?(file)
parse(file) parse(file)
@ -99,6 +75,8 @@ class GlobalSetting
attr_accessor :provider attr_accessor :provider
end end
load_defaults
@provider = @provider =
FileProvider.from(File.expand_path('../../../config/discourse.conf', __FILE__)) || FileProvider.from(File.expand_path('../../../config/discourse.conf', __FILE__)) ||
EnvProvider.new EnvProvider.new