Module: Gitlab::Emoji

Extended by:
Emoji
Included in:
Emoji
Defined in:
lib/gitlab/emoji.rb

Constant Summary collapse

EMOJI_VERSION =

When updating emoji assets increase the version below and update the version number in `app/assets/javascripts/emoji/index.js`

2

Instance Method Summary collapse

Instance Method Details

#custom_emoji_tag(name, image_source) ⇒ Object


47
48
49
50
51
52
53
54
55
56
# File 'lib/gitlab/emoji.rb', line 47

def custom_emoji_tag(name, image_source)
  data = {
    name: name,
    fallback_src: image_source,
    unicode_version: 'custom' # Prevents frontend to check for Unicode support
  }
  options = { title: name, data: data }

  ActionController::Base.helpers.('gl-emoji', "", options)
end

#emoji_image_tag(name, src) ⇒ Object


18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/gitlab/emoji.rb', line 18

def emoji_image_tag(name, src)
  image_options = {
    class:  'emoji',
    src:    src,
    title:  ":#{name}:",
    alt:    ":#{name}:",
    height: 20,
    width:  20,
    align:  'absmiddle'
  }

  ActionController::Base.helpers.tag(:img, image_options)
end

#emoji_public_absolute_pathPathname

Return a Pathname to emoji's current versioned folder

Returns:

  • (Pathname)

    Absolute Path to versioned emojis folder in `public`


14
15
16
# File 'lib/gitlab/emoji.rb', line 14

def emoji_public_absolute_path
  Rails.root.join("public/-/emojis/#{EMOJI_VERSION}")
end

#gl_emoji_tag(emoji, options = {}) ⇒ Object

CSS sprite fallback takes precedence over image fallback

Parameters:

  • emoji (TanukiEmoji::Character)
  • options (Hash) (defaults to: {})

35
36
37
38
39
40
41
42
43
44
45
# File 'lib/gitlab/emoji.rb', line 35

def gl_emoji_tag(emoji, options = {})
  return unless emoji

  data = {
    name: emoji.name,
    unicode_version: emoji.unicode_version
  }
  options = { title: emoji.description, data: data }.merge(options)

  ActionController::Base.helpers.('gl-emoji', emoji.codepoints, options)
end