A CMS for developers, built by developers.
This gem handles all of the rote parts of a CMS, but gets out of the way for everything else. In Rails it is easy to build things from scratch, but it is a waste of resources to build again and again. This library is an attempt to get all of the good parts of a CMS without the baggage of a CMS that takes over the entire ecosystem.
rails >= 5.0.5
pg >= 0.21.0; postgres >= 9.5
We hate dependencies, but postgres is just too good. We use it for search and JSONB.
For image processing. Note there is a known vulnerability, please update accordingly: https://imagetragick.com/
We still hate dependencies, but this is a necessity and the best option.
Used for editor fields. Source is included.
bootstrap-sass >= 3.0.0
Required if you want to use editor fields (which utilize summernote).
Hope to be able to remove this, but required for summernote/bootstrap for now.
The recommended dependencies are only required for the admin portions of your application.
Optionally, you can create a separate set of assets for only the admin via standard Rails methods. Or you could not include them and deal with the fallout. ;-)
Pages with Templates
Use application models or assets in CMS pages
Search (coming soon)
Proposed auxilary gems
simplec-vlad: The easiest way to deploy and manage an installation. Database and file syncs between enviroments.
simplec-blog: Don't always need or want a blog bundled in. (You might have your own.)
simplec-admin: Opinionated, prebuilt way of managing pages. Take it or leave it. Or don't mount it and generate scaffold controllers and views for basic functions.
'www' is considered the default subdomain.
'admin' subdomain is reserved for administration functions if you wish.
If you want to modify all pages you should edit ::Page < Simplec::Page, this will be generated in an installer later.
If you want to test a subclass of ::Page, make sure test has ::Page defined.
Create a public layout. The public layout is the default. This will be generated in an installer later.
Put page model definitions in
Put model templates in
app/views/pages/. AND prefix with an underscore (_),
TODO override field types howto
TODO explain using uuids for keys + pgcrypto
TODO explain how to augment model classes (example in
Install simplec in your Rails application.
See installation section.
Build and admin interface with the rest of your application.
Simplec doesn't tell you how to do this. Currently, you should look at the test/dummy application for inspiration.
Then define a model:
# app/models/page/home.rb class Page::Home < ::Page field :tagline end
And the corresponding template:
<!-- app/views/pages/_home.html.erb --> <h1>My Application</h1> <h2><%= @page.tagline %></h2>
Note: You need to call
#html_safeon fields with
And create a page in your admin.
Add this line to your application's Gemfile:
gem 'pg' gem 'simplec' # plus optional gems
At this point it is assumed you are integrating Simplec into an existing application, logically then you have your database already configured. However, Simplec requires some postgres configuration. Please read the section below on Postgres.
Install and run the migrations
rake simplec:install:migrations rake db:migrate
Mount the engine
Rails.application.routes.draw do mount Simplec::Engine => "/" end
Install and configure
rails generate dragonfly
It is recommended to use
rack/cacheor some other HTTP caching solution.
Optional - Install bootstap-sass.
gem 'bootstrap-sass', "~> 3.3.7'
Currenty, we have worked out integration with Bootstrap > 3 and are waiting for the dust to settle on V4. See directions here: https://github.com/twbs/bootstrap-sass
Optional - If you want to use the bundled summernote:
Load the JS in your application's manifest.
//= require simplec/summernote //= require simplec/summernote-config
Please note that this needs to be loaded after jquery and bootstrap.
Please note that this needs to be loaded after bootstrap. And to use
@importstatements, you must use
Note you will need to do this in your production environment as well.
On some operating systems,
pgcrypto is in a separate
be sure to install that as well.
pgcrypto extension is required for the
used to generate uuid primary keys.
Create your application postgres user (matching database.yml)
# -s for superuser in development createuser -s myapp
Create databases and add pgcrypto
# create development/test databases rake db:create # required for gen_random_uuid() function # used for ids in Simplec models # psql myapp_development -c "CREATE EXTENSION pgcrypto;" psql myapp_test -c "CREATE EXTENSION pgcrypto;"
Installation varies per operating system. Image magic is used by dragonfly for on the fly (then cached) image manipulation.
See this page for a good cheat sheet: http://markevans.github.io/dragonfly/imagemagick
- Check doc view helpers - Add config for uuid vs integer ids, maybe check if page is using uuid/id if table exists to determine going forward. Add note in README - Throw clear warning when creating a page without a type - Document `lib/simplec/controller_extensions.rb` - Document why _subdomain in subdomain form in admin. - rails generate simplec:install Install app/models/page.rb, app/models/page/ initializer if needed, with documented - rewrite beginning part of usage - utilize thread local variable for found subdomain in #subdomain - simplec_path/simplec_url caching
rails generater simplec:install
Upgrade summernote from 0.8.2 to 0.8.6
Remove as many dependencies as possible.
- Use it and file create issues. Somethings are core, other things will be relegated to 3rd party extensions.
- Pull requests are welcome. See rule #1.
Running dummy application
Create simplec postgres user
# -s for superuser in development createuser -s simplec
Create databases and add pgcrypto
rake db:create # required for gen_random_uuid() function # used for ids in Simplec models # psql simplec_development -c "CREATE EXTENSION pgcrypto;"
Matt Smith, Near Apogee Consulting (www.nearapogee.com)
@lithxe, @jessedo81 for ongoing feedback, use cases, development support, and the initial project to test the concept.
The gem is available as open source under the terms of the MIT License.