<commit_before># HancockCMS

#### Inspired by [RocketCMS](https://github.com/rs-pro/rocket_cms)
### Remaded from [EnjoyCMS](https://github.com/red-rocks/enjoy_cms)

# DEVELOPMENT VERSION

Rails + RailsAdmin + Mongoid/PostgreSQL CMS

Very opinionated and tuned for my needs.

**Before 1.0 API and class names should be considered unstable and can change at any time!**

## Installation

Add this line to your application's Gemfile:

    gem 'hancock_cms_mongoid'

or:

    gem 'hancock_cms_activerecord'

*Only PostgreSQL is tested or supported for AR(from root repo). Others will probably work, but untested.*

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install hancock_cms

For activerecord, generate migrations and run them

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

## Usage

### Using app generator

Make sure you have rails 4.2 installed

    rails -v

If not, uninstall rails and install again

    gem uninstall rails
    gem install hancock_cms

Then, for mongoid:

    rails new my_app -T -O -m https://raw.githubusercontent.com/red-rocks/hancock_cms/master/template.rb

for ActiveRecord:

    rails new my_app -T --database=postgresql -m https://raw.githubusercontent.com/red-rocks/hancock_cms/master/template.rb

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](https://github.com/Leadformance/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](https://github.com/glebtv/rails_admin_hstore_translate) or [rails_admin_mongoid_localize_field](https://github.com/sudosu/rails_admin_mongoid_localize_field)

<!-- Wrap your routes with locale scope:

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

Enable localization in HancockCMS:

```ruby
Hancock.configure do |hancock|
  hancock.localize = true
  ...
end
```

Add ```rails_admin_hstore_translate``` or ```hstore_translate``` gem if using PostgreSQL:

```ruby
gem 'rails_admin_hstore_translate'
```

or

```ruby
gem 'hstore_translate'
```

Add ```rails_admin_mongoid_localize_field``` gem if using MongoDB:

```ruby
gem 'rails_admin_mongoid_localize_field'
```<commit_msg>enjoy fixes<commit_after># HancockCMS

#### Inspired by [RocketCMS](https://github.com/rs-pro/rocket_cms)
### Remaded from [EnjoyCMS](https://github.com/enjoycreative/enjoy_cms)

# DEVELOPMENT VERSION

Rails + RailsAdmin + Mongoid/PostgreSQL CMS

Very opinionated and tuned for my needs.

**Before 1.0 API and class names should be considered unstable and can change at any time!**

## Installation

Add this line to your application's Gemfile:

    gem 'hancock_cms_mongoid'

or:

    gem 'hancock_cms_activerecord'

*Only PostgreSQL is tested or supported for AR(from root repo). Others will probably work, but untested.*

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install hancock_cms

For activerecord, generate migrations and run them

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

## Usage

### Using app generator

Make sure you have rails 4.2 installed

    rails -v

If not, uninstall rails and install again

    gem uninstall rails
    gem install hancock_cms

Then, for mongoid:

    rails new my_app -T -O -m https://raw.githubusercontent.com/red-rocks/hancock_cms/master/template.rb

for ActiveRecord:

    rails new my_app -T --database=postgresql -m https://raw.githubusercontent.com/red-rocks/hancock_cms/master/template.rb

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](https://github.com/Leadformance/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](https://github.com/glebtv/rails_admin_hstore_translate) or [rails_admin_mongoid_localize_field](https://github.com/sudosu/rails_admin_mongoid_localize_field)

<!-- Wrap your routes with locale scope:
```ruby
scope "(:locale)", locale: /en|ru/ do
  hancock_cms_routes
end
``` -->

Enable localization in HancockCMS:

```ruby
Hancock.configure do |hancock|
  hancock.localize = true
  ...
end
```

Add ```rails_admin_hstore_translate``` or ```hstore_translate``` gem if using PostgreSQL:

```ruby
gem 'rails_admin_hstore_translate'
```

or

```ruby
gem 'hstore_translate'
```

Add ```rails_admin_mongoid_localize_field``` gem if using MongoDB:

```ruby
gem 'rails_admin_mongoid_localize_field'
```
{'fraction_non_alphanumeric': 0.0988431093971991, 'fraction_numerical': 0.0016237061091942358, 'mean_word_length': 4.632, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 14, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '996925', 'n_tokens_mistral': 1723, 'n_tokens_neox': 1558, 'n_words': 494}