Configuration
During installation, when you invoke rails g push_type:install
an initializer file is generated and saved to config/initializers/push_type.rb
. This file can be used to configure various aspects of your PushType installation.
Root nodes
By default all node types can be placed at the root of the content tree. Instead this can be whitelisted by passing an array of node type symbols to the root_nodes
option.
# Restrict root nodes to HomePage and Page node types
config.root_nodes = [:home_page, :page]
Homepage
By default, when visiting the root URL of your PushType site (the homepage), the NodesFrontEndContoller
will look for a node with the slug home
. This behaviour can be changed by setting a different value for the home_slug
option.
# Set the homepage slug
config.home_slug = 'blog'
Unexposed nodes
By default all node types are exposed to the NodesFrontEndController
when visiting the permalink. Sections of content can be blacklisted (and effectively hidden) from the front end by passing an array of node type symbols to the unexposed_nodes
option.
# Hide node types from the NodesFrontEndController
config.unexposed_nodes = [:testimonial, :author_profile]
It’s also possible to add a node type to the unexposed nodes list by calling Node.unexpose!
on the class itself:
class Testimonial < PushType::Node
unexpose!
end
Media styles
Media styles allow you to configure a collection of reusable geometry strings to be used by the Asset#media
method for resizing images on the fly. The built in WYSIWYG editor makes use of these to allow users to easily scale images to predefined sizes.
# Set predefined geometry strings for resizing image assets
config.media_styles = {
large: '1024x1024>',
medium: '512x512>',
small: '256x256>'
}
# And use them with Asset#media
image.media(:medium)
Dragonfly datastore
PushType uses Dragonfly for managing uploaded images/assets. By default uploads are stored on the filesystem but it’s simple to switch to any datastore.
# Dragonfly datastore configuration
config.dragonfly_datastore = :file
config.dragonfly_datastore_options = {
root_path: Rails.root.join('public/system/dragonfly', Rails.env),
server_root: Rails.root.join('public')
}
# For S3 storage, remember to add to Gemfile:
# gem 'dragonfly-s3_data_store'
config.dragonfly_datastore = :s3
config.dragonfly_datastore_options = {
bucket_name: ENV['S3_BUCKET'],
access_key_id: ENV['S3_ACCESS_KEY_ID'],
secret_access_key: ENV['SECRET_ACCESS_KEY_ID']
}