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/lib
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-07-01 19:51:03 +0300
committerRobert Speicher <rspeicher@gmail.com>2016-07-06 19:45:56 +0300
commit28cd940f227a8cb853a1bd74989765fdecec5685 (patch)
tree15baf0d1c465d881a733e1d733eae31802c7e0b9 /lib
parent6e8864132eeb5582f17ddefb634aae762fcb1611 (diff)
Merge branch 'fix-relative-root-emoji-support' into 'master'
Fix emoji paths in relative root configurations ## What does this MR do? If a site specifies a relative URL root, emoji files would omit the path from the URL, leading to lots of 404s. ## Are there points in the code the reviewer needs to double check? At first, I tried to use `ActionView::Helpers::AssetUrlHelper.asset_url` since this is what it's intended to do. But this helper function is extremely slow, and it took minutes to generate the URLs for the hundreds of links needed for each emoji. ## Why was this MR needed? Because emojis were broken in relative URL installations ## What are the relevant issue numbers? #15642 ## Does this MR meet the acceptance criteria? - [X] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - Tests - [X] Added for this feature/bug - [x] All builds are passing - [X] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [X] Branch has no merge conflicts with `master` (if you do - rebase it please) - [X] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5027 (cherry picked from commit 88dbc4d110507c4c658d45e2b0ec0a2db756d6b9)
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/award_emoji.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/gitlab/award_emoji.rb b/lib/gitlab/award_emoji.rb
index 51b1df9ecbd..c94bfc0e65f 100644
--- a/lib/gitlab/award_emoji.rb
+++ b/lib/gitlab/award_emoji.rb
@@ -66,8 +66,17 @@ module Gitlab
def self.urls
@urls ||= begin
path = File.join(Rails.root, 'fixtures', 'emojis', 'digests.json')
+ # Construct the full asset path ourselves because
+ # ActionView::Helpers::AssetUrlHelper.asset_url is slow for hundreds
+ # of entries since it has to do a lot of extra work (e.g. regexps).
prefix = Gitlab::Application.config.assets.prefix
digest = Gitlab::Application.config.assets.digest
+ base =
+ if defined?(Gitlab::Application.config.relative_url_root) && Gitlab::Application.config.relative_url_root
+ Gitlab::Application.config.relative_url_root
+ else
+ ''
+ end
JSON.parse(File.read(path)).map do |hash|
if digest
@@ -76,7 +85,7 @@ module Gitlab
fname = hash['unicode']
end
- { name: hash['name'], path: "#{prefix}/#{fname}.png" }
+ { name: hash['name'], path: File.join(base, prefix, "#{fname}.png") }
end
end
end