RocketCMS

What's in the box when you generate a new app:

  • Rails 5.1
  • ActiveRecord + PostgreSQL or Mongoid 6
  • Elasticsearch (optional)
  • RailsAdmin
  • Webpack via webpack-rails with fully customizeable webpack.config.js
  • JS packages via package.json
  • Capistrano deploy (including puma and webpack)
  • Puma in production and in development
  • Windows support
  • Basic CMS models and controllers (Pages + SEO, News, Contact form with mailer, menu)
  • Menu via SimpleNavigation
  • Ckeditor with image upload support
  • L10n and i18n support

Installation (existing app)

Add this line to your application's Gemfile:

gem 'rocket_cms_mongoid'

or:

gem 'rocket_cms_activerecord'

Or, if you don't need CKeditor, GeoCoder, mongoid-audit\paper_trail:

gem 'rocket_cms_mongoid_light'
gem 'rocket_cms_activerecord_light'

Only PostgreSQL is tested or supported for AR. Others will probably work, but untested.

And then execute:

$ bundle

Or install it yourself as:

$ gem install rocket_cms

For activerecord, generate migrations and run them

rails g rails_admin_settings:migration
rails g rocket_cms:migration
rake db:migrate

Generating a new app

Make sure you have rails 4.1/4.2/5.0 installed

rails -v

If not, uninstall rails and install again

gem uninstall rails
gem install rocket_cms

Then, for mongoid:

rails new my_app -T -O -m https://raw.githubusercontent.com/rs-pro/rocket_cms/master/template.rb --yarn --skip-spring

for ActiveRecord:

rails new my_app -T --database=postgresql -m https://raw.githubusercontent.com/rs-pro/rocket_cms/master/template.rb --yarn --skip-spring

generator creates a new RVM gemset, so after cd'ing to app dir, you should run bundle install again if you use rvm.

Localization

All models included in the gem support localization via either hstore_translate or built-in Mongoid localize: true option.

You can get a nice admin UI for editing locales by adding rails_admin_hstore_translate or rails_admin_mongoid_localize_field

Add to: app/models/page.rb

class Page < ActiveRecord::Base
  include RocketCMS::Models::Page
  RocketCMS.apply_patches self
  rails_admin &RocketCMS.page_config

  def regexp_prefix
    "(?:\/ru|\/en)?"
  end
end

Wrap your routes with locale scope:

scope "(:locale)", locale: /en|ru/ do
  get 'contacts' => 'contacts#new', as: :contacts
  post 'contacts' => 'contacts#create', as: :create_contacts
end

Add to application_controller.rb:

class ApplicationController < ActionController::Base
  include RocketCMS::Controller
  include RsLocalizeable
end

Enable localization in RocketCMS:

RocketCMS.configure do |rc|
  rc.news_image_styles = {small: '107x126#'}
  rc.contacts_captcha = true
  rc.contacts_message_required = true
  ...
  rc.localize = true
end

Add rails_admin_hstore_translate or hstore_translate gem if using PostgreSQL:

gem 'rails_admin_hstore_translate'

or

gem 'hstore_translate'

or

gem 'jsonb_translate' # requires postgresql 9.4

Add rails_admin_mongoid_localize_field gem if using MongoDB:

gem 'rails_admin_mongoid_localize_field'

Capistrano generator

rails g rocket_cms:capify data unicorn_port domain_name
# (path /data/:user/app/ - rocket science default)

rails g rocket_cms:capify home unicorn_port domain_name
# (path /home/:user/:app_name/)

designed to be used together with our ansible app setup script.

Documentation

It's basically Rails Admin + some of our common models and controllers, capistrano config, etc.

See their documentation for more info

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request