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 156 image_tag("authbuttons/#{file_name}",
157 157 alt: "Sign in with #{provider.to_s.titleize}")
158 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 164 end
... ...
lib/gitlab/markdown.rb
... ... @@ -119,7 +119,7 @@ module Gitlab
119 119 # parse emoji
120 120 text.gsub!(EMOJI_PATTERN) do |match|
121 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 123 else
124 124 match
125 125 end
... ...
spec/helpers/gitlab_markdown_helper_spec.rb
... ... @@ -343,5 +343,9 @@ describe GitlabMarkdownHelper do
343 343 it "should generate absolute urls for refs" do
344 344 markdown("##{issue.id}").should include(project_issue_url(project, issue))
345 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 350 end
347 351 end
... ...