Reputation: 20538
I am trying to use the HTML5 manifest function using a gem called Manifesto. I am stuck on the instructions for usage. I cannot figure out where those settings are supposed to go.
Any ideas? Perhaps a better gem?
https://github.com/johntopley/manifesto#readme
Thankful for all help!
Upvotes: 0
Views: 609
Reputation: 8945
You can put you settings in a file under config/initializers/
. Use an informational name (like manifesto.rb
). However you don't need a config with the basic usage.
In your Gemfile
file, add:
gem 'manifesto'
then install via bundle:
bundle install
create the file app/controllers/manifest_controller.rb
class ManifestController < ApplicationController
def show
headers['Content-Type'] = 'text/cache-manifest'
render :text => Manifesto.cache, :layout => false
end
end
in config/routes.rb
add:
match '/manifest' => 'manifest#show'
Restart your app and view the result at http://localhost:3000/manifest
You can pass the option directly to Manifesto.cache
like:
# change
render :text => Manifesto.cache, :layout => false
# to
render :text => Manifesto.cache(:directory => './mobile', :compute_hash => false), :layout => false
Or use a YAML file and an initializer.
The config/manifesto.yaml
file:
# directory is relative to Rails root
directory: './mobile'
compute_hash: false
The config/initializers/manifesto.rb
file:
# Load the config file and convert keys from strings in symbols (the manifesto gem need symbolized options).
MANIFESTO_CONFIG = YAML.load_file(Rails.root.join('config', 'manifesto.yml').to_s).inject({}){|config,(k,v)| config[k.to_sym] = v; config}
And pass the loaded config to Manifesto.cache
like:
# change
render :text => Manifesto.cache, :layout => false
# to
render :text => Manifesto.cache(MANIFESTO_CONFIG), :layout => false
Upvotes: 1