Commit b09fd233 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'enabling_markdown_pipelines_from_gitlab' into 'master'

Enabling markdown pipelines from gitlab

Define which markdown pipelines are used in GitLab from application instead from gem.

See merge request !1164
parents f7342ce5 2ea166fc
......@@ -241,9 +241,11 @@ GEM
html-pipeline (1.11.0)
activesupport (>= 2)
nokogiri (~> 1.4)
html-pipeline-gitlab (0.1.0)
gitlab_emoji (~> 0.0.1.1)
html-pipeline-gitlab (0.1.5)
actionpack (~> 4)
gitlab_emoji (~> 0.0.1)
html-pipeline (~> 1.11.0)
sanitize (~> 2.1)
http_parser.rb (0.5.3)
httparty (0.13.0)
json (~> 1.8)
......
......@@ -70,14 +70,22 @@ module Gitlab
insert_piece($1)
end
# Context passed to the markdoqwn pipeline
# Used markdown pipelines in GitLab:
# GitlabEmojiFilter - performs emoji replacement.
#
# see https://gitlab.com/gitlab-org/html-pipeline-gitlab for more filters
filters = [
HTML::Pipeline::Gitlab::GitlabEmojiFilter
]
markdown_context = {
asset_root: File.join(root_url,
Gitlab::Application.config.assets.prefix)
asset_root: Gitlab.config.gitlab.url,
asset_host: Gitlab::Application.config.asset_host
}
result = HTML::Pipeline::Gitlab::MarkdownPipeline.call(text,
markdown_context)
markdown_pipeline = HTML::Pipeline::Gitlab.new(filters).pipeline
result = markdown_pipeline.call(text, markdown_context)
text = result[:output].to_html(save_with: 0)
allowed_attributes = ActionView::Base.sanitized_allowed_attributes
......
......@@ -576,9 +576,21 @@ describe GitlabMarkdownHelper do
end
it "should generate absolute urls for emoji" do
markdown(":smile:").should include("src=\"#{url_helper('emoji/smile')}")
markdown(":smile:").should include("src=\"http://localhost/assets/emoji/smile.png")
end
it "should generate absolute urls for emoji if relative url is present" do
Gitlab.config.gitlab.stub(:url).and_return('http://localhost/gitlab/root')
markdown(":smile:").should include("src=\"http://localhost/gitlab/root/assets/emoji/smile.png")
end
it "should generate absolute urls for emoji if asset_host is present" do
Gitlab::Application.config.stub(:asset_host).and_return("https://cdn.example.com")
ActionView::Base.any_instance.stub_chain(:config, :asset_host).and_return("https://cdn.example.com")
markdown(":smile:").should include("src=\"https://cdn.example.com/assets/emoji/smile.png")
end
it "should handle relative urls for a file in master" do
actual = "[GitLab API doc](doc/api/README.md)\n"
expected = "<p><a href=\"/#{project.path_with_namespace}/blob/#{@ref}/doc/api/README.md\">GitLab API doc</a></p>\n"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment