Class: Banzai::Filter::CommitTrailersFilter

Inherits:
HTML::Pipeline::Filter
  • Object
show all
Includes:
ActionView::Helpers::TagHelper, AvatarsHelper
Defined in:
lib/banzai/filter/commit_trailers_filter.rb

Overview

HTML filter that replaces users’ names and emails in commit trailers with links to their GitLab accounts or mailto links to their mentioned emails.

Commit trailers are special labels in the form of ‘*-by:` and fall on a single line, ex:

Reported-By: John S. Doe <[email protected]>

More info about this can be found here:

Constant Summary

Constants included from AvatarsHelper

AvatarsHelper::DEFAULT_AVATAR_PATH

Instance Method Summary collapse

Methods included from AvatarsHelper

#author_avatar, #avatar_icon_for, #avatar_icon_for_email, #avatar_icon_for_user, #avatar_without_link, #default_avatar, #gravatar_icon, #group_icon, #project_icon, #topic_icon, #user_avatar, #user_avatar_without_link

Instance Method Details

#callObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/banzai/filter/commit_trailers_filter.rb', line 20

def call
  doc.xpath('descendant-or-self::text()').each do |node|
    content = node.to_html

    html = trailer_filter(content)

    next if html == content

    node.replace("\n\n#{html}")
  end

  doc
end