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 /app/helpers | |
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 'app/helpers')
-rw-r--r-- | app/helpers/events_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/gitlab_markdown_helper.rb | 14 |
2 files changed, 10 insertions, 8 deletions
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 18c75a8726b..e55d729fa4f 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -168,8 +168,8 @@ module EventsHelper end end - def event_note(text) - text = first_line_in_markdown(text, 150) + def event_note(text, options = {}) + text = first_line_in_markdown(text, 150, options) sanitize(text, tags: %w(a img b pre code p span)) end diff --git a/app/helpers/gitlab_markdown_helper.rb b/app/helpers/gitlab_markdown_helper.rb index c309f890d96..846aded4bda 100644 --- a/app/helpers/gitlab_markdown_helper.rb +++ b/app/helpers/gitlab_markdown_helper.rb @@ -19,7 +19,7 @@ module GitlabMarkdownHelper escape_once(body) end - gfm_body = gfm(escaped_body, @project, html_options) + gfm_body = gfm(escaped_body, {}, html_options) gfm_body.gsub!(%r{<a.*?>.*?</a>}m) do |match| "</a>#{match}#{link_to("", url, html_options)[0..-5]}" # "</a>".length +1 @@ -32,11 +32,13 @@ module GitlabMarkdownHelper unless @markdown && options == @options @options = options - # see https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderers-for-lunch - rend = Redcarpet::Render::GitlabHTML.new(self, user_color_scheme_class, { + options.merge!( # Handled further down the line by Gitlab::Markdown::SanitizationFilter escape_html: false - }.merge(options)) + ) + + # see https://github.com/vmg/redcarpet#darling-i-packed-you-a-couple-renderers-for-lunch + rend = Redcarpet::Render::GitlabHTML.new(self, user_color_scheme_class, options) # see https://github.com/vmg/redcarpet#and-its-like-really-simple-to-use @markdown = Redcarpet::Markdown.new(rend, @@ -58,8 +60,8 @@ module GitlabMarkdownHelper # as Markdown. HTML tags in the parsed output are not counted toward the # +max_chars+ limit. If the length limit falls within a tag's contents, then # the tag contents are truncated without removing the closing tag. - def first_line_in_markdown(text, max_chars = nil) - md = markdown(text).strip + def first_line_in_markdown(text, max_chars = nil, options = {}) + md = markdown(text, options).strip truncate_visible(md, max_chars || md.length) if md.present? end |