mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +08:00
FEATURE: Theme settings (2) (#5611)
Allows theme authors to specify custom theme settings for the theme. Centralizes the theme/site settings into a single construct
This commit is contained in:
@ -138,6 +138,7 @@ class Admin::ThemesController < Admin::AdminController
|
||||
end
|
||||
|
||||
set_fields
|
||||
update_settings
|
||||
|
||||
save_remote = false
|
||||
if params[:theme][:remote_check]
|
||||
@ -158,7 +159,7 @@ class Admin::ThemesController < Admin::AdminController
|
||||
update_default_theme
|
||||
|
||||
log_theme_change(original_json, @theme)
|
||||
format.json { render json: @theme, status: :created }
|
||||
format.json { render json: @theme, status: :ok }
|
||||
else
|
||||
format.json {
|
||||
|
||||
@ -193,7 +194,7 @@ class Admin::ThemesController < Admin::AdminController
|
||||
|
||||
response.headers['Content-Disposition'] = "attachment; filename=#{@theme.name.parameterize}.dcstyle.json"
|
||||
response.sending_file = true
|
||||
render json: ThemeWithEmbeddedUploadsSerializer.new(@theme, root: 'theme')
|
||||
render json: ::ThemeWithEmbeddedUploadsSerializer.new(@theme, root: 'theme')
|
||||
end
|
||||
end
|
||||
|
||||
@ -223,6 +224,7 @@ class Admin::ThemesController < Admin::AdminController
|
||||
:color_scheme_id,
|
||||
:default,
|
||||
:user_selectable,
|
||||
settings: {},
|
||||
theme_fields: [:name, :target, :value, :upload_id, :type_id],
|
||||
child_theme_ids: []
|
||||
)
|
||||
@ -243,6 +245,14 @@ class Admin::ThemesController < Admin::AdminController
|
||||
end
|
||||
end
|
||||
|
||||
def update_settings
|
||||
return unless target_settings = theme_params[:settings]
|
||||
|
||||
target_settings.each_pair do |setting_name, new_value|
|
||||
@theme.update_setting(setting_name.to_sym, new_value)
|
||||
end
|
||||
end
|
||||
|
||||
def log_theme_change(old_record, new_record)
|
||||
StaffActionLogger.new(current_user).log_theme_change(old_record, new_record)
|
||||
end
|
||||
|
Reference in New Issue
Block a user