Module: Interage::FaviconHelper

Included in:
ApplicationHelper
Defined in:
lib/interage/favicon_helper.rb

Constant Summary collapse

EXTENTION =
ENV.fetch('FAVICON_EXTENTION', 'png')
FILE_NAME =
ENV.fetch('FAVICON_FILE_NAME', 'icons/apple-touch-icon')
FAVICON_SIZES =
[nil, 57, 72, 76, 114, 120, 144, 152, 180].freeze

Instance Method Summary collapse

Instance Method Details



9
10
11
# File 'lib/interage/favicon_helper.rb', line 9

def favicon_link_tags
  safe_join favicon_size_link_tags.push(favicon_link_tag)
end

#favicon_options(size) ⇒ Object



23
24
25
# File 'lib/interage/favicon_helper.rb', line 23

def favicon_options(size)
  { type: 'image/png', rel: 'apple-touch-icon', sizes: handler_size(size) }
end


13
14
15
16
17
# File 'lib/interage/favicon_helper.rb', line 13

def favicon_size_link_tags
  FAVICON_SIZES.map do |s|
    favicon_link_tag(handler_name(s), favicon_options(s))
  end
end

#handler_name(size) ⇒ Object



19
20
21
# File 'lib/interage/favicon_helper.rb', line 19

def handler_name(size)
  "#{FILE_NAME}#{handler_size(size, '-')}.#{EXTENTION}"
end

#handler_size(size, prefix = '') ⇒ Object



27
28
29
# File 'lib/interage/favicon_helper.rb', line 27

def handler_size(size, prefix = '')
  "#{prefix}#{size}x#{size}" if size.present?
end