diff options
author | Alexis Reigel <mail@koffeinfrei.org> | 2017-09-26 09:54:32 +0200 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2018-06-05 16:20:18 +0200 |
commit | ce6172e863f982c73fedc9f4a73877543c30cb1c (patch) | |
tree | c35bc83d94504d1aa55086d62ff2234d12fe62d4 /app | |
parent | c8a4d202c99c772822a2b9b09fa6da2c90b2ae81 (diff) | |
download | gitlab-ce-ce6172e863f982c73fedc9f4a73877543c30cb1c.tar.gz |
allow uploading favicon in appearance settings
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/admin/appearances_controller.rb | 9 | ||||
-rw-r--r-- | app/controllers/concerns/uploads_actions.rb | 2 | ||||
-rw-r--r-- | app/models/appearance.rb | 1 | ||||
-rw-r--r-- | app/views/admin/appearances/_form.html.haml | 17 |
4 files changed, 28 insertions, 1 deletions
diff --git a/app/controllers/admin/appearances_controller.rb b/app/controllers/admin/appearances_controller.rb index ea302f17d16..9aaec905734 100644 --- a/app/controllers/admin/appearances_controller.rb +++ b/app/controllers/admin/appearances_controller.rb @@ -41,6 +41,13 @@ class Admin::AppearancesController < Admin::ApplicationController redirect_to admin_appearances_path, notice: 'Header logo was succesfully removed.' end + def favicon + @appearance.remove_favicon! + @appearance.save + + redirect_to admin_appearances_path, notice: 'Favicon was succesfully removed.' + end + private # Use callbacks to share common setup or constraints between actions. @@ -61,6 +68,8 @@ class Admin::AppearancesController < Admin::ApplicationController logo_cache header_logo header_logo_cache + favicon + favicon_cache new_project_guidelines updated_by ] diff --git a/app/controllers/concerns/uploads_actions.rb b/app/controllers/concerns/uploads_actions.rb index b9b9b6e4e88..80049044124 100644 --- a/app/controllers/concerns/uploads_actions.rb +++ b/app/controllers/concerns/uploads_actions.rb @@ -2,7 +2,7 @@ module UploadsActions include Gitlab::Utils::StrongMemoize include SendFileUpload - UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo).freeze + UPLOAD_MOUNTS = %w(avatar attachment file logo header_logo favicon).freeze def create link_to_file = UploadService.new(model, params[:file], uploader_class).execute diff --git a/app/models/appearance.rb b/app/models/appearance.rb index 67cc84a9140..b770aadef0e 100644 --- a/app/models/appearance.rb +++ b/app/models/appearance.rb @@ -14,6 +14,7 @@ class Appearance < ActiveRecord::Base mount_uploader :logo, AttachmentUploader mount_uploader :header_logo, AttachmentUploader + mount_uploader :favicon, FaviconUploader # Overrides CacheableAttributes.current_without_cache def self.current_without_cache diff --git a/app/views/admin/appearances/_form.html.haml b/app/views/admin/appearances/_form.html.haml index 5e08837255f..163ce55eb53 100644 --- a/app/views/admin/appearances/_form.html.haml +++ b/app/views/admin/appearances/_form.html.haml @@ -55,6 +55,23 @@ .hint Guidelines parsed with #{link_to "GitLab Flavored Markdown", help_page_path('user/markdown'), target: '_blank'}. + %fieldset.app_logo + %legend + Favicon: + .form-group + = f.label :favicon, 'Favicon', class: 'control-label' + .col-sm-10 + - if @appearance.favicon? + = image_tag @appearance.favicon.default_without_format_conversion.url, class: 'appearance-light-logo-preview' + - if @appearance.persisted? + %br + = link_to 'Remove favicon', favicon_admin_appearances_path, data: { confirm: "Favicon will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-sm remove-logo" + %hr + = f.hidden_field :favicon_cache + = f.file_field :favicon, class: '' + .hint + Maximum file size is 1MB. The resulting favicons will be cropped to be square and scaled down to a size of 32x32 px. + .form-actions = f.submit 'Save', class: 'btn btn-save append-right-10' - if @appearance.persisted? |