Module: SiteIconManager

Extended by:
GlobalPath
Defined in:
lib/site_icon_manager.rb

Constant Summary collapse

SKETCH_LOGO_ID =
-6
ICONS =
{
  digest_logo: {
    width: nil,
    height: nil,
    settings: %i[digest_logo logo],
    fallback_to_sketch: false,
    resize_required: false,
  },
  mobile_logo: {
    width: nil,
    height: nil,
    settings: %i[mobile_logo logo],
    fallback_to_sketch: false,
    resize_required: false,
  },
  large_icon: {
    width: nil,
    height: nil,
    settings: %i[large_icon logo_small],
    fallback_to_sketch: true,
    resize_required: false,
  },
  manifest_icon: {
    width: 512,
    height: 512,
    settings: %i[manifest_icon large_icon logo_small],
    fallback_to_sketch: true,
    resize_required: true,
  },
  favicon: {
    width: 32,
    height: 32,
    settings: %i[favicon large_icon logo_small],
    fallback_to_sketch: true,
    resize_required: false,
  },
  apple_touch_icon: {
    width: 180,
    height: 180,
    settings: %i[apple_touch_icon large_icon logo_small],
    fallback_to_sketch: true,
    resize_required: false,
  },
  opengraph_image: {
    width: nil,
    height: nil,
    settings: %i[opengraph_image large_icon logo_small logo],
    fallback_to_sketch: true,
    resize_required: false,
  },
}
WATCHED_SETTINGS =
ICONS.keys + %i[logo logo_small]

Class Method Summary collapse

Methods included from GlobalPath

cdn_path, cdn_relative_path, full_cdn_url, path, upload_cdn_path

Class Method Details

.clear_cache!Object



64
65
66
# File 'lib/site_icon_manager.rb', line 64

def self.clear_cache!
  @cache.clear
end

.disableObject

Used in test mode



100
101
102
# File 'lib/site_icon_manager.rb', line 100

def self.disable
  @disabled = true
end

.enableObject



104
105
106
# File 'lib/site_icon_manager.rb', line 104

def self.enable
  @disabled = false
end

.ensure_optimized!Object



68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/site_icon_manager.rb', line 68

def self.ensure_optimized!
  unless @disabled
    ICONS.each do |name, info|
      icon = resolve_original(info)

      if info[:height] && info[:width]
        OptimizedImage.create_for(icon, info[:width], info[:height])
      end
    end
  end
  @cache.clear
end