mirror of
https://github.com/mastodon/mastodon
synced 2024-11-28 14:58:21 +09:00
b11fdc3ae3
with YAML-defined defaults. Add admin page for editing global settings. Add "site_description" setting that would show as a paragraph on the frontpage
32 lines
651 B
Ruby
32 lines
651 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Setting < RailsSettings::Base
|
|
source Rails.root.join('config/settings.yml')
|
|
namespace Rails.env
|
|
|
|
def to_param
|
|
var
|
|
end
|
|
|
|
class << self
|
|
def all_as_records
|
|
vars = thing_scoped
|
|
records = vars.map { |r| [r.var, r] }.to_h
|
|
|
|
default_settings.each do |key, default_value|
|
|
next if records.key?(key) || default_value.is_a?(Hash)
|
|
records[key] = Setting.new(var: key, value: default_value)
|
|
end
|
|
|
|
records
|
|
end
|
|
|
|
private
|
|
|
|
def default_settings
|
|
return {} unless RailsSettings::Default.enabled?
|
|
RailsSettings::Default.instance
|
|
end
|
|
end
|
|
end
|