Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2017-11-10 12:28:15 +0300
committerOswaldo Ferreira <oswaldo@gitlab.com>2017-11-10 22:31:48 +0300
commit456e45010abef279a4766403dee14e018f8951da (patch)
treeab08665eccf8b42895f89c13ff62217b9e67a1df /app
parent8de703b0162f3270e2407f64ecc8cb3ad52868a3 (diff)
Merge branch 'tz-no-cdn-for-svg-sprites' into 'master'
Icon Sprite URL needs to be local even if asset_host is set See merge request gitlab-org/gitlab-ce!15289 (cherry picked from commit e482a4d59dae6437a64ae4ccbe6976ffced7b9ba) 25eea058 Icon Sprite URL is also local even if asset_host is set 81eaf171 Fixed URL Matching in Tests 687e7dea Put Icons Path in Helper fb1b88de Missing the local url 01240a18 Fixed Function + Test based on MR fce34b4b Removed Brackets
Diffstat (limited to 'app')
-rw-r--r--app/helpers/icons_helper.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb
index ec779c1c447..c6a83f21ceb 100644
--- a/app/helpers/icons_helper.rb
+++ b/app/helpers/icons_helper.rb
@@ -23,10 +23,17 @@ module IconsHelper
render "shared/icons/#{icon_name}.svg", size: size
end
+ def sprite_icon_path
+ # SVG Sprites currently don't work across domains, so in the case of a CDN
+ # we have to set the current path deliberately to prevent addition of asset_host
+ sprite_base_url = Gitlab.config.gitlab.url if ActionController::Base.asset_host
+ ActionController::Base.helpers.image_path('icons.svg', host: sprite_base_url)
+ end
+
def sprite_icon(icon_name, size: nil, css_class: nil)
css_classes = size ? "s#{size}" : ""
css_classes << " #{css_class}" unless css_class.blank?
- content_tag(:svg, content_tag(:use, "", { "xlink:href" => "#{image_path('icons.svg')}##{icon_name}" } ), class: css_classes.empty? ? nil : css_classes)
+ content_tag(:svg, content_tag(:use, "", { "xlink:href" => "#{sprite_icon_path}##{icon_name}" } ), class: css_classes.empty? ? nil : css_classes)
end
def audit_icon(names, options = {})