diff options
author | Alexis Reigel <alexis.reigel.ext@siemens.com> | 2017-12-06 21:04:53 +0100 |
---|---|---|
committer | Alexis Reigel <mail@koffeinfrei.org> | 2018-06-05 16:20:21 +0200 |
commit | 9e14f437b6ed205744d916f5566ee2c11e52b734 (patch) | |
tree | 5c4bf1237cfc4a6cf73f30f942d25e0ab4f0973c /lib | |
parent | 5202c3f0c8da618e2d3821917f6f5d48ae8ae3c2 (diff) | |
download | gitlab-ce-9e14f437b6ed205744d916f5566ee2c11e52b734.tar.gz |
create favicon overlay on the client
the initial reason for this change was that graphicsmagick does not
support writing to ico files. this fact lead to a chain of changes:
1. use png instead of ico (browser support is good enough)
2. render the overlays on the client using the canvas API. this way we
only need to store the original favion and generate the overlay versions
dynamically.
this change also enables (next step) to simplify the handling of the
stock favicons as well, as we don't need to generate all the versions
upfront.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/favicon.rb | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/gitlab/favicon.rb b/lib/gitlab/favicon.rb index 51a25b408ee..e28d4c67661 100644 --- a/lib/gitlab/favicon.rb +++ b/lib/gitlab/favicon.rb @@ -9,18 +9,27 @@ module Gitlab 'favicon.ico' end - def status(status_name) - if appearance_favicon.exists? - custom_favicon_url(appearance_favicon.public_send("#{status_name}").url) # rubocop:disable GitlabSecurity/PublicSend - else - path = File.join( - 'ci_favicons', - Rails.env.development? ? 'dev' : '', - Gitlab::Utils.to_boolean(ENV['CANARY']) ? 'canary' : '', - "#{status_name}.ico" - ) - - ActionController::Base.helpers.image_path(path) + def status_overlay(status_name) + path = File.join( + 'ci_favicons', + 'overlays', + "#{status_name}.png" + ) + + ActionController::Base.helpers.image_path(path) + end + + def available_status_overlays + available_status_names.map do |status_name| + status_overlay(status_name) + end + end + + def available_status_names + @available_status_names ||= begin + Dir.glob(Rails.root.join('app', 'assets', 'images', 'ci_favicons', 'overlays', "*.png")) + .map { |file| File.basename(file, '.png') } + .sort end end |