Sha256: c2d4199e1ccb49b1be5f8f78361de18312297cdfeb804f1864f6d0dd090a933c

Contents?: true

Size: 896 Bytes

Versions: 1

Compression:

Stored size: 896 Bytes

Contents

require "gemoji"

module Middleman
  module Emojifire
    module EmojiExtension
      refine ::Emoji::Character do
        GITHUB_DOT_COM_ASSET_HOST_URL = "https://assets-cdn.github.com".freeze
        ASSET_PATH = "/images/icons/emoji".freeze

        def raw_unicode_character_html
          "<span class=\"emoji\" data-alias=\"#{name}\" " \
            "data-fallback=\"#{fallback_source}\">" \
            "#{raw}</span>"
        end

        def fallback_image_html
          "<span class=\"emoji\" data-alias=\"#{name}\" " \
            "style=\"overflow: hidden; display: inline-block; width: 1em; height: 1em; margin: 0 0.1em; background-size: 100% 100%; " \
            "background-image: url('#{fallback_source}');\"></span>"
        end

        def fallback_source
          File.join(GITHUB_DOT_COM_ASSET_HOST_URL, ASSET_PATH, image_filename)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-emojifire-1.1.0 lib/middleman-emojifire/ext/emoji_extension.rb