2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-08 12:06:51 +08:00

FEATURE: Live-update site settings

This commit is contained in:
Kane York 2015-08-27 15:55:19 -07:00
parent b8c3187a94
commit d4c68f2096
3 changed files with 38 additions and 25 deletions

View file

@ -65,6 +65,10 @@ module SiteSettingExtension
@refresh_settings ||= []
end
def client_settings
@client_settings ||= []
end
def previews
@previews ||= {}
end
@ -136,12 +140,7 @@ module SiteSettingExtension
# just like a setting, except that it is available in javascript via DiscourseSession
def client_setting(name, default = nil, opts = {})
setting(name, default, opts)
@client_settings ||= []
@client_settings << name
end
def client_settings
@client_settings ||= []
client_settings << name
end
def settings_hash
@ -312,6 +311,7 @@ module SiteSettingExtension
provider.save(name, val, type)
current[name] = convert(val, type)
notify_clients!(name) if client_settings.include? name
clear_cache!
end
@ -319,6 +319,10 @@ module SiteSettingExtension
MessageBus.publish('/site_settings', {process: process_id})
end
def notify_clients!(name)
MessageBus.publish('/client_settings', {name: name, value: self.send(name)})
end
def has_setting?(name)
defaults.has_key?(name.to_sym) || defaults.has_key?("#{name}?".to_sym)
end