Class: Abqari::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/abqari/manifest.rb

Overview

Web App Manifest writer. Emits _site/manifest.json from site config. Linked from via _head.html.erb. Treated as part of the build, not a static file in public/, so the values stay in sync with site.yml (title, theme color, etc.) without manual duplication.

Override any field via manifest: in config/site.yml; the rest fall back to sensible defaults derived from other config keys.

Constant Summary collapse

DEFAULTS =
{
  'display'          => 'standalone',
  'start_url'        => '/',
  'theme_color'      => '#ffffff',
  'background_color' => '#ffffff'
}.freeze
DEFAULT_ICONS =
[
  { 'src' => '/icon-192.png', 'sizes' => '192x192', 'type' => 'image/png' },
  { 'src' => '/icon-512.png', 'sizes' => '512x512', 'type' => 'image/png' }
].freeze

Instance Method Summary collapse

Constructor Details

#initialize(site) ⇒ Manifest

Returns a new instance of Manifest.



27
28
29
30
# File 'lib/abqari/manifest.rb', line 27

def initialize(site)
  @site = site
  @cfg = site.config['manifest'] || {}
end

Instance Method Details

#writeObject



32
33
34
# File 'lib/abqari/manifest.rb', line 32

def write
  File.write(File.join(@site.output_dir, 'manifest.json'), JSON.pretty_generate(payload))
end