mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FEATURE: Upload Site Settings. (#6573)
This commit is contained in:
@ -144,26 +144,27 @@ class Wizard
|
||||
end
|
||||
|
||||
@wizard.append_step('logos') do |step|
|
||||
step.add_field(id: 'logo_url', type: 'image', value: SiteSetting.logo_url)
|
||||
step.add_field(id: 'logo_small_url', type: 'image', value: SiteSetting.logo_small_url)
|
||||
step.add_field(id: 'logo', type: 'image', value: SiteSetting.site_logo_url)
|
||||
step.add_field(id: 'logo_small', type: 'image', value: SiteSetting.site_logo_small_url)
|
||||
|
||||
step.on_update do |updater|
|
||||
updater.apply_settings(:logo_url, :logo_small_url)
|
||||
updater.apply_settings(:logo, :logo_small)
|
||||
end
|
||||
end
|
||||
|
||||
@wizard.append_step('icons') do |step|
|
||||
step.add_field(id: 'favicon_url', type: 'image', value: SiteSetting.favicon_url)
|
||||
step.add_field(id: 'apple_touch_icon_url', type: 'image', value: SiteSetting.apple_touch_icon_url)
|
||||
step.add_field(id: 'favicon', type: 'image', value: SiteSetting.favicon)
|
||||
step.add_field(id: 'apple_touch_icon', type: 'image', value: SiteSetting.apple_touch_icon)
|
||||
|
||||
step.on_update do |updater|
|
||||
updater.apply_settings(:favicon_url)
|
||||
updater.apply_settings(:favicon)
|
||||
|
||||
if updater.fields[:apple_touch_icon_url] != SiteSetting.apple_touch_icon_url
|
||||
upload = Upload.find_by_url(updater.fields[:apple_touch_icon_url])
|
||||
if updater.fields[:apple_touch_icon] != SiteSetting.apple_touch_icon
|
||||
upload = Upload.find_by_url(updater.fields[:apple_touch_icon])
|
||||
dimensions = 180 # for apple touch icon
|
||||
|
||||
if upload && upload.width > dimensions && upload.height > dimensions
|
||||
updater.update_setting(:large_icon_url, updater.fields[:apple_touch_icon_url])
|
||||
updater.update_setting(:large_icon, upload)
|
||||
|
||||
apple_touch_icon_optimized = OptimizedImage.create_for(
|
||||
upload,
|
||||
@ -172,13 +173,15 @@ class Wizard
|
||||
)
|
||||
|
||||
original_file = File.new(Discourse.store.path_for(apple_touch_icon_optimized)) rescue nil
|
||||
|
||||
if original_file
|
||||
apple_touch_icon_upload = UploadCreator.new(original_file, upload.original_filename).create_for(@wizard.user.id)
|
||||
updater.update_setting(:apple_touch_icon_url, apple_touch_icon_upload.url)
|
||||
updater.update_setting(:apple_touch_icon, apple_touch_icon_upload)
|
||||
end
|
||||
|
||||
apple_touch_icon_optimized.destroy! if apple_touch_icon_optimized.present?
|
||||
else
|
||||
updater.apply_settings(:apple_touch_icon_url)
|
||||
updater.apply_settings(:apple_touch_icon)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user