Class: Banzai::Filter::IssueReferenceFilter

Inherits:
AbstractReferenceFilter show all
Defined in:
lib/banzai/filter/issue_reference_filter.rb

Overview

HTML filter that replaces issue references with links. References to issues that do not exist are ignored.

This filter supports cross-project references.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractReferenceFilter

#call, data_reference, #find_object_cached, #object_class, #object_class_title, object_class_title, #object_link_filter, #object_link_text, #object_link_text_extras, #object_link_title, object_name, #object_sym, object_sym, #project_from_ref_cache, referenced_by, references_in, #references_in, #url_for_object_cached

Methods included from CrossProjectReference

#project_from_ref

Methods inherited from ReferenceFilter

#data_attribute, #each_node, #element_node?, #escape_once, #ignore_ancestor_query, #project, #reference_class, referenced_by, #replace_link_node_with_href, #replace_link_node_with_text, #replace_text_when_pattern_matches, #text_node?, user_can_reference?, #validate, #yield_valid_link

Class Method Details

.object_classObject


8
9
10
# File 'lib/banzai/filter/issue_reference_filter.rb', line 8

def self.object_class
  Issue
end

.user_can_see_reference?(user, node, context) ⇒ Boolean

Returns:

  • (Boolean)

12
13
14
15
# File 'lib/banzai/filter/issue_reference_filter.rb', line 12

def self.user_can_see_reference?(user, node, context)
  issue = Issue.find(node.attr('data-issue')) rescue nil
  Ability.abilities.allowed?(user, :read_issue, issue)
end

Instance Method Details

#find_object(project, id) ⇒ Object


17
18
19
# File 'lib/banzai/filter/issue_reference_filter.rb', line 17

def find_object(project, id)
  project.get_issue(id)
end

#url_for_object(issue, project) ⇒ Object


21
22
23
# File 'lib/banzai/filter/issue_reference_filter.rb', line 21

def url_for_object(issue, project)
  IssuesHelper.url_for_issue(issue.iid, project, only_path: context[:only_path])
end