mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-30 10:58:31 -05:00
65156bd8f6
(port/force hostname/queue jobs)
37 lines
855 B
Ruby
37 lines
855 B
Ruby
module SiteSettings; end
|
|
|
|
class SiteSettings::YamlLoader
|
|
|
|
def initialize(file)
|
|
@file = file
|
|
end
|
|
|
|
def env_val(value)
|
|
if value.is_a?(Hash)
|
|
value.has_key?(Rails.env) ? value[Rails.env] : value['default']
|
|
else
|
|
value
|
|
end
|
|
end
|
|
|
|
def load
|
|
yaml = YAML.load_file(@file)
|
|
yaml.keys.each do |category|
|
|
yaml[category].each do |setting_name, hash|
|
|
if hash.is_a?(Hash)
|
|
# Get default value for the site setting:
|
|
value = env_val(hash.delete('default'))
|
|
|
|
if hash.key?('hidden')
|
|
hash['hidden'] = env_val(hash.delete('hidden'))
|
|
end
|
|
|
|
yield category, setting_name, value, hash.symbolize_keys!
|
|
else
|
|
# Simplest case. site_setting_name: 'default value'
|
|
yield category, setting_name, hash, {}
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|