From bf708e55c2e6035b64861a1cda8bfe3d3b4a2105 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Wed, 18 Jan 2017 18:37:55 -0500 Subject: make mentions working when project not specified --- lib/banzai/filter/reference_filter.rb | 4 ++++ lib/banzai/filter/user_reference_filter.rb | 5 ++--- lib/banzai/renderer.rb | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'lib/banzai') 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 -- cgit v1.2.1 From 0c350b79395d6712c7c4fee649cdbd77aa4052cc Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Fri, 20 Jan 2017 11:28:40 +0100 Subject: address comments --- lib/banzai/filter/user_reference_filter.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/banzai') diff --git a/lib/banzai/filter/user_reference_filter.rb b/lib/banzai/filter/user_reference_filter.rb index 8173f888062..1aa9355b256 100644 --- a/lib/banzai/filter/user_reference_filter.rb +++ b/lib/banzai/filter/user_reference_filter.rb @@ -28,6 +28,7 @@ module Banzai 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| -- cgit v1.2.1