diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-18 18:37:55 -0500 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-01-18 18:38:17 -0500 |
commit | bf708e55c2e6035b64861a1cda8bfe3d3b4a2105 (patch) | |
tree | 6eb5f726e0d033a6a69ea1ad900223ef4ef30054 /lib/banzai | |
parent | d6b11dafd37e78c12c982c42f274928293cdfa53 (diff) | |
download | gitlab-ce-bf708e55c2e6035b64861a1cda8bfe3d3b4a2105.tar.gz |
make mentions working when project not specified
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/reference_filter.rb | 4 | ||||
-rw-r--r-- | lib/banzai/filter/user_reference_filter.rb | 5 | ||||
-rw-r--r-- | lib/banzai/renderer.rb | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/lib/banzai/filter/reference_filter.rb b/lib/banzai/filter/reference_filter.rb index ab7af1cad21..6640168bfa2 100644 --- a/lib/banzai/filter/reference_filter.rb +++ b/lib/banzai/filter/reference_filter.rb @@ -53,6 +53,10 @@ module Banzai context[:project] end + def skip_project_check? + context[:skip_project_check] + end + def reference_class(type) "gfm gfm-#{type} has-tooltip" end diff --git a/lib/banzai/filter/user_reference_filter.rb b/lib/banzai/filter/user_reference_filter.rb index f842b1fb779..8173f888062 100644 --- a/lib/banzai/filter/user_reference_filter.rb +++ b/lib/banzai/filter/user_reference_filter.rb @@ -24,11 +24,10 @@ module Banzai end def call - return doc if project.nil? + return doc if project.nil? && !skip_project_check? ref_pattern = User.reference_pattern ref_pattern_start = /\A#{ref_pattern}\z/ - nodes.each do |node| if text_node?(node) replace_text_when_pattern_matches(node, ref_pattern) do |content| @@ -58,7 +57,7 @@ module Banzai # have `gfm` and `gfm-project_member` class names attached for styling. def user_link_filter(text, link_content: nil) self.class.references_in(text) do |match, username| - if username == 'all' + if username == 'all' && !skip_project_check? link_to_all(link_content: link_content) elsif namespace = namespaces[username] link_to_namespace(namespace, link_content: link_content) || match diff --git a/lib/banzai/renderer.rb b/lib/banzai/renderer.rb index f31fb6c3f71..74663556cbb 100644 --- a/lib/banzai/renderer.rb +++ b/lib/banzai/renderer.rb @@ -52,9 +52,9 @@ module Banzai end # Same as +render_field+, but without consulting or updating the cache field - def cacheless_render_field(object, field) + def cacheless_render_field(object, field, options = {}) text = object.__send__(field) - context = object.banzai_render_context(field) + context = object.banzai_render_context(field).merge(options) cacheless_render(text, context) end |