Commit 9249b48c authored by andysoiron's avatar andysoiron Committed by Andy Soiron

Cleanup Banzai ExternalIssueReferenceFilter

parent 58ddbc5d
......@@ -54,6 +54,8 @@ module Banzai
doc
end
private
# Replace `JIRA-123` issue references in text with links to the referenced
# issue's details page.
#
......@@ -63,21 +65,14 @@ module Banzai
# Returns a String with `JIRA-123` references replaced with links. All
# links have `gfm` and `gfm-issue` class names attached for styling.
def issue_link_filter(text, link_content: nil)
project = context[:project]
self.class.references_in(text, issue_reference_pattern) do |match, id|
ExternalIssue.new(id, project)
url = url_for_issue(id, project, only_path: context[:only_path])
title = "Issue in #{project.external_issue_tracker.title}"
klass = reference_class(:issue)
data = data_attribute(project: project.id, external_issue: id)
content = link_content || match
%(<a href="#{url}" #{data}
title="#{escape_once(title)}"
title="#{escape_once(issue_title)}"
class="#{klass}">#{content}</a>)
end
end
......@@ -94,7 +89,13 @@ module Banzai
external_issues_cached(:external_issue_reference_pattern)
end
private
def project
context[:project]
end
def issue_title
"Issue in #{project.external_issue_tracker.title}"
end
def external_issues_cached(attribute)
cached_attributes = Gitlab::SafeRequestStore[:banzai_external_issues_tracker_attributes] ||= Hash.new { |h, k| h[k] = {} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment