Class: Banzai::Filter::InlineMetricsFilter

Inherits:
InlineEmbedsFilter show all
Defined in:
lib/banzai/filter/inline_metrics_filter.rb

Overview

HTML filter that inserts a placeholder element for each reference to a metrics dashboard.

Instance Method Summary collapse

Methods inherited from InlineEmbedsFilter

#call, #create_element, #element_to_embed, #embed_params, #gitlab_domain, #query_params

Instance Method Details

Regular expression matching metrics urls


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

def link_pattern
  Gitlab::Metrics::Dashboard::Url.metrics_regex
end

#xpath_searchObject

Search params for selecting metrics links. A few simple checks is enough to boost performance without the cost of doing a full regex match.


11
12
13
14
# File 'lib/banzai/filter/inline_metrics_filter.rb', line 11

def xpath_search
  "descendant-or-self::a[contains(@href,'metrics') and \
    starts-with(@href, '#{gitlab_domain}')]"
end