From 16b54178422b5e84e0ddd61a7a44306d7b164707 Mon Sep 17 00:00:00 2001 From: Riyad Preukschas Date: Wed, 16 Jan 2013 22:39:45 +0100 Subject: [PATCH] Use image Urls for Emoji in GFM Fixes #2617 --- app/helpers/application_helper.rb | 5 +++++ lib/gitlab/markdown.rb | 2 +- spec/helpers/gitlab_markdown_helper_spec.rb | 4 ++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d41f40dc..fe6fe94c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -156,4 +156,9 @@ module ApplicationHelper image_tag("authbuttons/#{file_name}", alt: "Sign in with #{provider.to_s.titleize}") end + + def image_url(source) + root_url + path_to_image(source) + end + alias_method :url_to_image, :image_url end diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 6fffc599..4694c7fc 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -119,7 +119,7 @@ module Gitlab # parse emoji text.gsub!(EMOJI_PATTERN) do |match| if valid_emoji?($2) - image_tag("emoji/#{$2}.png", class: 'emoji', title: $1, alt: $1, size: "20x20") + image_tag(url_to_image("emoji/#{$2}.png"), class: 'emoji', title: $1, alt: $1, size: "20x20") else match end diff --git a/spec/helpers/gitlab_markdown_helper_spec.rb b/spec/helpers/gitlab_markdown_helper_spec.rb index 7b51efdb..b7e16f1e 100644 --- a/spec/helpers/gitlab_markdown_helper_spec.rb +++ b/spec/helpers/gitlab_markdown_helper_spec.rb @@ -343,5 +343,9 @@ describe GitlabMarkdownHelper do it "should generate absolute urls for refs" do markdown("##{issue.id}").should include(project_issue_url(project, issue)) end + + it "should generate absolute urls for emoji" do + markdown(":smile:").should include("src=\"#{url_to_image("emoji/smile")}") + end end end