diff options
author | Drew Blessing <drew@gitlab.com> | 2015-12-18 01:08:14 +0300 |
---|---|---|
committer | Drew Blessing <drew@gitlab.com> | 2015-12-18 23:19:48 +0300 |
commit | f177aaa5fa789654dc440d6ec4ae3546544c1401 (patch) | |
tree | 709b259ea7903da9ac28e5393cc29d0780a6c63a /lib/banzai | |
parent | 27859f7ed9e1efe98b8386844d0a7e69fd58277a (diff) |
Backport JIRA service
Diffstat (limited to 'lib/banzai')
-rw-r--r-- | lib/banzai/filter/external_issue_reference_filter.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/lib/banzai/filter/external_issue_reference_filter.rb b/lib/banzai/filter/external_issue_reference_filter.rb index f5737a7ac19..f5942740cd6 100644 --- a/lib/banzai/filter/external_issue_reference_filter.rb +++ b/lib/banzai/filter/external_issue_reference_filter.rb @@ -23,6 +23,18 @@ module Banzai end end + def self.referenced_by(node) + project = Project.find(node.attr("data-project")) rescue nil + return unless project + + id = node.attr("data-external-issue") + external_issue = ExternalIssue.new(id, project) + + return unless external_issue + + { external_issue: external_issue } + end + def call # Early return if the project isn't using an external tracker return doc if project.nil? || project.default_issues_tracker? @@ -46,12 +58,14 @@ module Banzai def issue_link_filter(text, link_text: nil) project = context[:project] - self.class.references_in(text) do |match, issue| - url = url_for_issue(issue, project, only_path: context[:only_path]) + self.class.references_in(text) do |match, id| + ExternalIssue.new(id, project) + + url = url_for_issue(id, project, only_path: context[:only_path]) title = escape_once("Issue in #{project.external_issue_tracker.title}") klass = reference_class(:issue) - data = data_attribute(project: project.id) + data = data_attribute(project: project.id, external_issue: id) text = link_text || match |