diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-05-15 09:59:26 +0000 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2015-05-15 09:59:26 +0000 |
commit | 9c6f4a2351e9b5757f4f508388bc099fbeea5788 (patch) | |
tree | ef93864f4b1d3f16ccbdfb1166a8a563fd9aa52c /lib | |
parent | de1aca131e74af8ef77005198d9be99ac2a8091d (diff) | |
parent | cd52cef1c0898230cb684ee294bd7a6c5b2f226a (diff) | |
download | gitlab-ce-9c6f4a2351e9b5757f4f508388bc099fbeea5788.tar.gz |
Merge branch 'dashboard-references' into 'master'
Fix reference links in dashboard activity and ATOM feeds.
References like `@user` were not linked on the dashboard activity feed and in Atom feeds, because the reference parser depends on `@project` which isn't set in those situations.
This MR passes the project in question to the reference parsers in an option.
cc @rspeicher
See merge request !653
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/markdown.rb | 16 | ||||
-rw-r--r-- | lib/redcarpet/render/gitlab_html.rb | 5 |
2 files changed, 13 insertions, 8 deletions
diff --git a/lib/gitlab/markdown.rb b/lib/gitlab/markdown.rb index 89abd521b1e..133010adcaf 100644 --- a/lib/gitlab/markdown.rb +++ b/lib/gitlab/markdown.rb @@ -24,10 +24,10 @@ module Gitlab # Public: Parse the provided text with GitLab-Flavored Markdown # # text - the source text - # project - the project + # options - options # html_options - extra options for the reference links as given to link_to - def gfm(text, project = @project, html_options = {}) - gfm_with_options(text, {}, project, html_options) + def gfm(text, options = {}, html_options = {}) + gfm_with_options(text, options, html_options) end # Public: Parse the provided text with GitLab-Flavored Markdown @@ -38,7 +38,7 @@ module Gitlab # :reference_only_path - Use relative path for reference links # project - the project # html_options - extra options for the reference links as given to link_to - def gfm_with_options(text, options = {}, project = @project, html_options = {}) + def gfm_with_options(text, options = {}, html_options = {}) return text if text.nil? # Duplicate the string so we don't alter the original, then call to_str @@ -48,7 +48,9 @@ module Gitlab options.reverse_merge!( xhtml: false, - reference_only_path: true + reference_only_path: true, + project: @project, + current_user: current_user ) pipeline = HTML::Pipeline.new(filters) @@ -62,9 +64,9 @@ module Gitlab no_header_anchors: options[:no_header_anchors], # ReferenceFilter - current_user: current_user, + current_user: options[:current_user], only_path: options[:reference_only_path], - project: project, + project: options[:project], reference_class: html_options[:class], # RelativeLinkFilter diff --git a/lib/redcarpet/render/gitlab_html.rb b/lib/redcarpet/render/gitlab_html.rb index 15eb6effe08..7dcecc2ecf6 100644 --- a/lib/redcarpet/render/gitlab_html.rb +++ b/lib/redcarpet/render/gitlab_html.rb @@ -7,9 +7,12 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML def initialize(template, color_scheme, options = {}) @template = template @color_scheme = color_scheme - @project = @template.instance_variable_get("@project") @options = options.dup + @options.reverse_merge!( + project: @template.instance_variable_get("@project") + ) + super(options) end |