Bolton CMS - Padrino
Bolton CMS is a gem that bolts a minimalistic CMS onto your Padrino project.
The Bolton CMS philosophy is that the CMs should only manage content, and that any layout design and templating should be managed by the developer and require deployment. The reasoning behind this is primarily that I'm sick of dealing with content producers and clients who thrash their layouts instead of seeking professional guidance.
Configuration
Only Padrino versions '~>0.11' are supported
Mounting the Bolton CMS apps
Add the following to your Gemfile
:
gem 'bolton-cms-padrino'
There are two apps to mount withinin your apps.rb
: Manage
and Display
.
Padrino.mount('BoltonCms::Manage', :app_file => BoltonCms.root('bolton_cms/manage/app.rb')).to('/cms')
Padrino.mount('BoltonCms::Display', :app_file => BoltonCms.root('bolton_cms/display/app.rb')).to('/')
The mounted paths may be changed to fit your project.
MongoDB and Mongoid
Bolton CMS uses MongoDB via the Mongoid gem. You must configure a Mongo session named
bolton_cms
. A sample mongoid.yml configuration is as follows:
production:
sessions:
bolton_cms:
database: bolton_cms
hosts:
- localhost:27017
options:
raise_not_found_error: false
Bolton CMS Required Configuration
There are three configuration files that you must include in your project at the path
bolton_cms/config
: site.yml
, templates.yml
, and image_sizes.yml
.
site.yml
The site.yml
file maintains simple configuration options, such as the site's display
name, the organization's name, and contact information.
name: My Site
organization: My Company
contact:
name: Person or Department Name
email: [email protected]
phone: 1-310-310-3100
address: "100 Street Rd #200"
city: Los Angeles
state: CA
zip: 90012
country: USA
It is recommended to at least make use of the name and organization parameters.
templates.yml
Custom templates and their layouts are glued together using information in
templates.yml
.
article:
layout:
application
fragments:
- Footnotes
- About the Author
gallery:
layout:
some_other_layout
fragments:
- Artist Bio
- More Like This
Each entry is a template, which must correspond to a file found within
bolton_cms/display/views/templates
. Likewise, the associated layout file must be placed
within bolton_cms/display/views/layouts
.
Fragments are simple page content fields, similar to the default "Body" field, allowing you to break up content within a page, without too much hassle. Currently, all content fields may be configured on the edit screen to contain either markdown (via Redcarpet) or raw HTML.
This system allows you to code your layouts and templates any way you'd like, without being constrained to any CMS-specific methods or tag libraries. However, at this time, templates and layouts are expected to be written using the SLIM templating language.
image_sizes.yml
Asset image processing is configurable within image_sizes.yml
.
default:
resize: limit
width: 1136
height: 1136
large:
resize: fit
width: 1024
height: 1024
medium:
resize: fit
width: 800
height: 800
small:
resize: pad
width: 640
height: 640
background: #99c
thumb:
resize: fill
width: 100
height: 100
Each entry is an image "size" that is generated on upload, to be accessed within layouts
and templates. Available resize options are limit
, fit
, fill
, and pad
.
limit
resizes the image only if it is larger than either of the given dimensionsfit
resizes the image to the closest given dimensionpad
resizes the image to the closest given dimension, but generates an image "padded out" to both given dimensionsfill
resizes the image to match both given dimensions, potentially cropping out portions of the image
If pad
is chosen, an additional option "background" may be added, allowing you to
specify what color the padded potion should be.
Image "gravity" may be specified by the end user for each asset within the edit screen, to further adjust how an image is cropped, if it may be cropped.
Bolton CMS uses Carrierwave to manage uploaded assets, and stores them locally.
User Accounts
To generate the initial Administrator account, run rake db:seed
from the command line,
and follow the prompts.
User accounts may be given a role of Producer, Editor, or Admin. Only the admin can create and delete accounts. At this time, there is no real difference between a producer and an editor.
In the future, the Account screens may be moved into a simple stand-alone Padrino gem app.
Accessing CMS Data in Templates and Layouts
For the time being, the best way to understand all your options is to study this gem. The
models are in lib/bolton_cms/models
, and the default layout and templates are in
bolton_cms/display/views
.
Development
For development, this gem can be run as a standalone Padrino application as you would expect from a normal one:
$ bundle exec padrino start
The Rakefile also works like the normal Padrino one and supports all standard components.
Contributing
Feel free to fork this repo and submit a pull request. Thanks!
Created and maintained by Charles Hudson