/alchemy_cms

AlchemyCMS is a Rails 5 CMS engine

Primary LanguageRubyBSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

AlchemyCMS

Gem Version Build Status Maintainability Test Coverage Depfu

Slack Status Reviewed by Hound

Backers on Open Collective Sponsors on Open Collective

Alchemy is an open source CMS engine written in Ruby on Rails.

Read more about Alchemy on the website and in the guidelines.

CAUTION: This master branch is a development branch that can contain bugs. For productive environments you should use the current Ruby gem version, or the latest stable branch (4.2-stable).

โœ… Features

  • Flexible templating that separates content from markup
  • A rich RESTful API
  • Intuitive admin interface with live preview
  • Multi language and multi domain
  • SEO friendly urls
  • User Access Control
  • Build in contact form mailer
  • Attachments and downloads
  • On-the-fly image cropping and resizing
  • Extendable via Rails engines
  • Integrates into existing Rails Apps
  • Resourceful Rails admin
  • Flexible caching
  • Hostable on any Server that supports Ruby on Rails, a SQL Database and ImageMagick

๐ŸŽฎ Demo

Deploy your own free demo on Heroku

Deploy

or visit the existing demo at https://alchemy-demo.herokuapp.com

  • Login: demo
  • Password: demo123

๐Ÿš‚ Rails Version

This version of Alchemy CMS runs with Rails 5 only

๐Ÿ’Ž Ruby Version

Alchemy runs with Ruby >= 2.3.0.

For a Ruby 2.2 compatible version use the 4.1-stable branch.

For a Ruby 2.1 compatible version use the 3.6-stable branch.

For a Ruby 2.0.0 compatible version use the 3.2-stable branch.

For a Ruby 1.9.3 compatible version use the 3.1-stable branch.

For a Ruby 1.8.7 compatible version use the 2.3-stable branch.

โŒจ๏ธ Installation

1. Add the Alchemy gem:

Put this into your Gemfile:

gem 'alchemy_cms', github: 'AlchemyCMS/alchemy_cms', branch: 'master'

NOTE: You normally want to use a stable branch, like 4.1-stable.

2. Update your bundle:

$ bundle install

3. Set the authentication user

Now you have to decide, if you want to use your own user model or if you want to use the Devise based user model that Alchemy provides and was extracted into its own gem.

Use Alchemy user

If you don't have your own user class, you can use the Alchemy user model. Just add the following gem into your Gemfile:

gem 'alchemy-devise', github: 'AlchemyCMS/alchemy-devise', branch: 'master'

NOTE: You normally want to use a stable branch, like 4.1-stable.

Then run:

$ bundle install
$ bin/rake alchemy_devise:install:migrations
Use your User model

In order to use your own user model you need to tell Alchemy about it.

The best practice is to use an initializer:

# config/initializers/alchemy.rb
Alchemy.user_class_name     = 'YourUserClass'       # Defaults to 'User'
Alchemy.current_user_method = 'current_admin_user'  # Defaults to 'current_user'
Alchemy.signup_path         = '/your/signup/path'   # Defaults to '/signup'
Alchemy.login_path          = '/your/login/path'    # Defaults to '/login'
Alchemy.logout_path         = '/your/logout/path'   # Defaults to '/logout'

The only thing Alchemy needs to know from your user class is the alchemy_roles method.

This method has to return an Array (or ActiveRecord::Relation) with at least one of the following roles: member, author, editor, admin.

Example
# app/models/user.rb

def alchemy_roles
  if admin?
    %w(admin)
  end
end

Please follow this guide for further instructions on how to customize your user class even more.

4. Install Alchemy into your app:

After you set the user model you need to run the Alchemy install task:

$ bin/rake alchemy:install

Now everything should be set up and you should be able to visit the Alchemy Dashboard at:

http://localhost:3000/admin

*) Use your custom path if you mounted Alchemy at something else then '/'

๐Ÿ— Customization

Alchemy has very flexible ways to organize and manage content. Please be sure to read the introduction guide in order to understand the basic idea of how Alchemy works.

Custom Controllers

Beginning with Alchemy 3.1 we do not patch the ApplicationController anymore. If you have controllers that loads Alchemy content or uses Alchemy helpers in the views (i.e. render_navigation or render_elements) you can either inherit from Alchemy::BaseController or you include Alchemy::ControllerActions in your controller (that's the recommended way).

Custom admin interface routing

By default, Alchemy Dashboard is accessible at http://example.com/admin. You can change this by setting Alchemy.admin_path and Alchemy.admin_constraints.

For example, these settings:

# config/initializers/alchemy.rb

Alchemy.admin_path = 'backend'
Alchemy.admin_constraints = {subdomain: 'hidden'}

will move the dashboard to http://hidden.example.com/backend.

Picture caching

Alchemy uses the Dragonfly gem to render pictures on-the-fly.

To make this as performant as possible the rendered picture gets stored into public/pictures so the web server can pick up the file and serve it without hitting the Rails process at all.

This may or may not what you want. Especially for multi server setups you eventually want to use something like S3.

Please follow the guidelines about picture caching on the Dragonfly homepage for further instructions:

http://markevans.github.io/dragonfly/cache

We also provide an extension for Cloudinary

๐ŸŒ Localization

Alchemy ships with one default English translation for the admin interface. If you want to use the admin interface in other languages please have a look at the alchemy_i18n project.

โœจ Upgrading

We, the Alchemy team, take upgrades very seriously and we try to make them as smooth as possible. Therefore we have build an upgrade task, that tries to automate the upgrade procedure as much as possible.

That's why after the Alchemy gem has been updated, with explicit call to:

$ bundle update alchemy_cms

you should always run the upgrader:

$ bin/rake alchemy:upgrade

Alchemy will print out useful information after running the automated tasks that help a smooth upgrade path. So please take your time and read them.

Always be sure to keep an eye on the config/alchemy/config.yml.defaults file and update your config/alchemy/config.yml accordingly.

Also, git diff is your friend.

Customize the upgrade preparation

The Alchemy upgrader comes prepared with several rake tasks in a specific order. This is sometimes not what you want or could even break upgrades. In order to customize the upgrade preparation process you can instead run each of the tasks on their own.

$ bin/rake alchemy:install:migrations
$ bin/rake db:migrate
$ bin/rake alchemy:db:seed
$ bin/rake alchemy:upgrade:config
$ bin/rake alchemy:upgrade:run

WARNING: This is only recommended, if you have problems with the default rake alchemy:upgrade task and need to repair your data in between. The upgrader depends on these upgrade tasks running in this specific order, otherwise we can't ensure smooth upgrades for you.

Run an individual upgrade

You can also run an individual upgrade on its own:

$ bin/rake -T alchemy:upgrade

provides you with a list of each upgrade you can run individually.

Example

$ bin/rake alchemy:upgrade:4.1

runs only the Alchemy 4.1 upgrade

๐Ÿš€ Deployment

Alchemy has an official Capistrano extension which takes care of everything you need to deploy an Alchemy site.

Please use capistrano-alchemy, if you want to deploy with Capistrano.

Without Capistrano

If you don't use Capistrano you have to make sure that the uploads, tmp/cache/assets, public/assets and public/pictures folders get shared between deployments, otherwise you will loose data. No, not really, but you know, just keep them in sync.

๐Ÿšง Testing

If you want to contribute to Alchemy (and we encourage you to do so) we have a strong test suite that helps you to not break anything.

Preparation

First of all you need to clone your fork to your local development machine. Then you need to install the dependencies with bundler.

$ bundle install

To prepare the tests of your Alchemy fork please make sure to run the preparation task:

$ bundle exec rake alchemy:spec:prepare

to set up the database for testing.

Run your tests with:

$ bundle exec rspec

Alternatively you can just run*:

$ bundle exec rake

*) This default task executes the database preparations and runs all defined test cases.

Start the dummy app

You can even start the dummy app and use it to manually test your changes with:

$ cd spec/dummy
$ bin/setup
$ bin/rails s

๐Ÿ“ฆ Releasing

Update the changelog

$ export GITHUB_ACCESS_TOKEN=...
$ PREVIOUS_VERSION=4.1.0 bundle exec rake alchemy:changelog:update

Release a new version

$ bundle exec rake release

โ“Getting Help

PLEASE don't use the Github issues for feature requests. If you want to contribute to Alchemy please read the contribution guidelines before doing so.

๐Ÿ”— Resources

โœ๏ธ Authors

๐Ÿ… Contributors

This project exists thanks to all the people who contribute. [Contribute].

๐Ÿ’ต Backers

Thank you to all our backers! ๐Ÿ™ [Become a backer]

๐Ÿ’ฐ Sponsors

Support this project by becoming a sponsor. Your logo will show up here with a link to your website. [Become a sponsor]

๐Ÿ“œ License

BSD-3-Clause

๐Ÿ“ข Spread the love

If you like Alchemy, please help us to spread the word about Alchemy and star this repo on GitHub, upvote it on The Ruby Toolbox, mention us on Twitter.

That will help us to keep Alchemy awesome.

Thank you!

โค๏ธ