Commit 16b54178422b5e84e0ddd61a7a44306d7b164707

Authored by Riyad Preukschas
1 parent 7635afd0

Use image Urls for Emoji in GFM

Fixes #2617
app/helpers/application_helper.rb
@@ -156,4 +156,9 @@ module ApplicationHelper @@ -156,4 +156,9 @@ module ApplicationHelper
156 image_tag("authbuttons/#{file_name}", 156 image_tag("authbuttons/#{file_name}",
157 alt: "Sign in with #{provider.to_s.titleize}") 157 alt: "Sign in with #{provider.to_s.titleize}")
158 end 158 end
  159 +
  160 + def image_url(source)
  161 + root_url + path_to_image(source)
  162 + end
  163 + alias_method :url_to_image, :image_url
159 end 164 end
lib/gitlab/markdown.rb
@@ -119,7 +119,7 @@ module Gitlab @@ -119,7 +119,7 @@ module Gitlab
119 # parse emoji 119 # parse emoji
120 text.gsub!(EMOJI_PATTERN) do |match| 120 text.gsub!(EMOJI_PATTERN) do |match|
121 if valid_emoji?($2) 121 if valid_emoji?($2)
122 - image_tag("emoji/#{$2}.png", class: 'emoji', title: $1, alt: $1, size: "20x20") 122 + image_tag(url_to_image("emoji/#{$2}.png"), class: 'emoji', title: $1, alt: $1, size: "20x20")
123 else 123 else
124 match 124 match
125 end 125 end
spec/helpers/gitlab_markdown_helper_spec.rb
@@ -343,5 +343,9 @@ describe GitlabMarkdownHelper do @@ -343,5 +343,9 @@ describe GitlabMarkdownHelper do
343 it "should generate absolute urls for refs" do 343 it "should generate absolute urls for refs" do
344 markdown("##{issue.id}").should include(project_issue_url(project, issue)) 344 markdown("##{issue.id}").should include(project_issue_url(project, issue))
345 end 345 end
  346 +
  347 + it "should generate absolute urls for emoji" do
  348 + markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}")
  349 + end
346 end 350 end
347 end 351 end