Class: Banzai::Filter::IssuableReferenceExpansionFilter
- Inherits:
-
HTML::Pipeline::Filter
- Object
- HTML::Pipeline::Filter
- Banzai::Filter::IssuableReferenceExpansionFilter
- Includes:
- Concerns::PipelineTimingCheck, Gitlab::Utils::StrongMemoize
- Defined in:
- lib/banzai/filter/issuable_reference_expansion_filter.rb
Overview
HTML filter that appends extra information to issuable links. Runs as a post-process filter as issuable might change while Markdown is in the cache.
This filter supports cross-project references.
Constant Summary collapse
- NUMBER_OF_SUMMARY_ASSIGNEES =
2
- VISIBLE_STATES =
%w[closed merged].freeze
- EXTENDED_FORMAT_XPATH =
Gitlab::Utils::Nokogiri.css_to_xpath('a[data-reference-format="+s"]')
Constants included from Concerns::PipelineTimingCheck
Concerns::PipelineTimingCheck::MAX_PIPELINE_SECONDS
Instance Method Summary collapse
Methods included from Concerns::PipelineTimingCheck
Instance Method Details
#call ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/banzai/filter/issuable_reference_expansion_filter.rb', line 18 def call return doc unless context[:issuable_reference_expansion_enabled] = { extended_preload: doc.xpath(EXTENDED_FORMAT_XPATH).present? } extractor_context = RenderContext.new(project, current_user, options: ) extractor = Banzai::IssuableExtractor.new(extractor_context) issuables = extractor.extract([doc]) issuables.each do |node, issuable| next if !can_read_cross_project? && cross_referenced?(issuable) next unless (node, issuable) case node.attr('data-reference-format') when '+' (node, issuable) when '+s' (node, issuable) (node, issuable) else (node, issuable) end end doc end |