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



33
34
35
36
37
38
39
40
41
42
# File 'lib/gitlab/emoji.rb', line 33

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_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: {})


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

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