summaryrefslogtreecommitdiff
path: root/app/helpers/wiki_page_version_helper.rb
blob: ae20717ad992ef6989d2e88a7ff7104857713485 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# frozen_string_literal: true

module WikiPageVersionHelper
  def wiki_page_version_author_url(wiki_page_version)
    user = wiki_page_version.author
    user.nil? ? "mailto:#{wiki_page_version.author_email}" : Gitlab::UrlBuilder.build(user)
  end

  def wiki_page_version_author_avatar(wiki_page_version)
    image_tag(avatar_icon_for_email(wiki_page_version.author_email, 24), class: "avatar s24 float-none gl-mr-0!")
  end

  def wiki_page_version_author_header(wiki_page_version)
    avatar = wiki_page_version_author_avatar(wiki_page_version)
    name = "<strong>".html_safe + wiki_page_version.author_name + "</strong>".html_safe
    link_start = "<a href='".html_safe + wiki_page_version_author_url(wiki_page_version) + "'>".html_safe

    html_escape(_("Last edited by %{link_start}%{avatar} %{name}%{link_end}")) % { avatar: avatar, name: name, link_start: link_start, link_end: '</a>'.html_safe }
  end
end