<commit_before>= Rich

{<img src="https://github.com/bastiaanterhorst/rich/raw/master/app/assets/images/rich/rich.png" />}[https://github.com/bastiaanterhorst/rich/] Rich is an opinionated implementation of CKEditor for Rails 3.1 and up. It includes a stripped down toolbar, simplified dialogs and a custom file manager.

Presently, Rich integrates with Active Admin, Rails Admin and vanilla Formtastic (versions 1 and 2).

== Goals

1. Keep the CKEditor source our of your project.
2. Sensible defaults. We don't want our users to insert tables, smilies or other frivolities that will do nothing but ruin a lovingly crafted design.
3. Make it easy to customize these defaults.
4. Implement a usable (and easily configurable) file manager that serves up images that fit your specific design.
5. A good upload experience (multiple uploads, progress bars, pure html/js).

It should be noted that while a major point of this project was to remove many things from CKEditor, all that stuff is still in there and can be easily re-enabled.

== Dependency Status

{<img src="https://gemnasium.com/bastiaanterhorst/rich.png" />}[https://gemnasium.com/bastiaanterhorst/rich/]

== Quick install

Rich is available as a Ruby Gem, which makes installation very easy.

  # In your Gemfile (Rails >= 3.1)
  gem 'rich'
  # the edge (unstable) version can be had using:
  # gem 'rich', :git => 'https://github.com/bastiaanterhorst/rich.git'
  
After updating your bundle, run the installer.

  $> rails generate rich:install

The installer sets up a route, creates an initializer for configuration and adds a javascript and CSS file. It also creates a migration, so we need to migrate the database.

  $> rake db:migrate
  
As a last step, secure the file manager by setting your authentication method in <tt>/config/initializers/rich.rb</tt>. If you're using Devise with an AdminUser model (incidentally, the Active Admin defaults):
  config.authentication_method = :authenticate_admin_user!
  
You're good to go.

== Usage

=== Vanilla Formtastic

To use Rich, it's javascript file must be loaded. By default, this is already setup for you because Rails loads all Javascript files through the <tt>require_tree .</tt> command in application.js. If you've removed that line, manually load rich by requiring it.

  //= require rich

In your formtastic form, use <tt>:as => :rich</tt> to insert Rich. Like so:

  <%= semantic_form_for @post do |f| %>
     <%= f.inputs do %>
       <%= f.input :name %>
       <%= f.input :title %>
       <%= f.input :body, :as => :rich, :config => { :default_style => "myCrazyPaperclipStyle" } %>
     <% end %>
     <%= f.buttons do %>
       <%= f.commit_button %>
     <% end %>
   <% end %>
   
=== Active Admin

Since Active Admin actually uses Formtastic, you can use it with Rich out of the box. In your model configuration file, set up your form like this. Make sure you add <tt>//= require rich</tt> to your <tt>app/assets/javascripts/active_admin.js</tt>.

  form do |f|
    f.inputs "Basic info" do
      f.input :title
      f.input :body, :as => :rich, :config => { :width => '76%', :height => '400px' }
    end
    f.buttons
  end

If you're annoyed by the fact that the Rich editor overlaps the field label (I was!), add the following to your <tt>/app/assets/stylesheets/active_admin.css.scss</tt>.

  #wrapper .cke_skin_kama {
  	margin-left: 20%;
  }
  
=== Rails Admin

To use Rich in your RA forms, first add the following lines to your <tt>/config/initializers/rails_admin.rb</tt>.

  require 'rich/integrations/rails_admin_editor'
  RailsAdmin::Config::Fields::Types::register(Rich::Integrations::RailsAdmin::RichEditor)
  
This will enable the <tt>rich_editor</tt> field type. You can use this field as follows:

  config.model Post do
    edit do
      field :title
      field :body, :rich_editor do
         config({ 
           :insert_many => true 
         })
      end
    end
  end
  
== Screenshots

This is the editor with default settings.
{<img src="https://github.com/bastiaanterhorst/rich/raw/master/screenshots/rich-editor-default.png" />}[https://github.com/bastiaanterhorst/rich/]

This is the file manager.
{<img src="https://github.com/bastiaanterhorst/rich/raw/master/screenshots/rich-filemanager.png" />}[https://github.com/bastiaanterhorst/rich/]

== Rich in production mode

Rich works just fine in production mode. To accomodate the structure of the CKEditor source, Rich extends the <tt>assets:precompile</tt> task to make sure the full CKEditor source tree is copied to your assets folder. So the following works as you would expect:

  rake assets:precompile

Rich will also clean up these CKEditor files when you clean your assets. Like this:

  rake assets:clean
  
Although generally not necessary, the underlying Rich tasks can be invoked directly.

  rake rich:assetize_ckeditor
  rake rich:clean_ckeditor

== Configuration and overrides

Take a look at the generated <tt>rich.rb</tt> initializer and – if you want to dig deeper – the Rich sourcecode. The initializer guides you through the most important settings and configuration options.

=== Localization

Localization should be automatic. Rich uses the currently set locale (<tt>I18n.locale</tt>) for it's editor and file browser.

=== CKEditor configuration

Rich attempts to provide you with a sensible set of buttons and capabilities. But of course, you might disagree. To that end, you can configure CKEditor through the <tt>config</tt> directive, either globally through the initializer, or per editor instance as an option.

Rich also includes a few settings that manipulate CKEditor settings, but are a bit easier to use. For example, you can set <tt>:allow_embeds</tt> to <tt>true</tt> to load a media embed plugin (think Youtube, Vimeo, etc.)

=== Editor styles

When you run the generator a css file is created for you in <tt>app/assets/stylesheets/rich/editor.css</tt>. Use this stylesheet to define the contents of the Styles drop down in CKEditor.

=== Image configuration

The styles you define in the initializer are passed to Paperclip directly, so the syntax is identical. See https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation for more information.

When you change styles after uploading files, you will need to re-process those old files. To accomplish this, run the following command (avoid the standard Paperclip task!).

  rake rich:refresh_assets

== Planned features

* upload non-image files (almost there)
* scoping assets to other objects
* drag & drop uploading
* separate form control to select/upload images without CKEditor (almost there)

== Inspiration

* Igor Galeta's ckeditor gem - https://github.com/galetahub/ckeditor
* <NAME>' Ckeditor - https://github.com/fesplugas/rails-ckeditor
* <NAME>'s Active Admin - https://github.com/gregbell/active_admin

== Tools used

* Ckeditor - http://ckeditor.com/
* Valum's FileUploader - https://github.com/valums/file-uploader
* Rack Raw Upload - https://github.com/newbamboo/rack-raw-upload
* Paperclip - https://github.com/thoughtbot/paperclip
* Silk icons - http://www.famfamfam.com/lab/icons/silk/
* Iconic icons - http://somerandomdude.com/work/iconic/

== Contributing

Your contributions (small and large) are very welcome! Please fork the project, make your changes and send me a pull request. If you are considering adding new functionality, or if you found a bug, please open an issue on Github first.

== Copyright

Rich was created by <NAME> and is sponsored by Perceptor (http://perceptor.nl).

This project is licenced under the MIT License. See MIT-LICENSE for details.<commit_msg>updated the project status<commit_after>= Rich

{<img src="https://github.com/bastiaanterhorst/rich/raw/master/app/assets/images/rich/rich.png" />}[https://github.com/bastiaanterhorst/rich/] Rich is an opinionated implementation of CKEditor for Rails 3.1 and up. It includes a stripped down toolbar, simplified dialogs and a custom file manager.

Presently, Rich integrates with Active Admin, Rails Admin and vanilla Formtastic (versions 1 and 2).

== Goals

1. Keep the CKEditor source our of your project.
2. Sensible defaults. We don't want our users to insert tables, smilies or other frivolities that will do nothing but ruin a lovingly crafted design.
3. Make it easy to customize these defaults.
4. Implement a usable (and easily configurable) file manager that serves up images that fit your specific design.
5. A good upload experience (multiple uploads, progress bars, pure html/js).

It should be noted that while a major point of this project was to remove many things from CKEditor, all that stuff is still in there and can be easily re-enabled.

== Dependency Status

{<img src="https://gemnasium.com/bastiaanterhorst/rich.png" />}[https://gemnasium.com/bastiaanterhorst/rich/]

== Quick install

Rich is available as a Ruby Gem, which makes installation very easy.

  # In your Gemfile (Rails >= 3.1)
  gem 'rich'
  # the edge (unstable) version can be had using:
  # gem 'rich', :git => 'https://github.com/bastiaanterhorst/rich.git'
  
After updating your bundle, run the installer.

  $> rails generate rich:install

The installer sets up a route, creates an initializer for configuration and adds a javascript and CSS file. It also creates a migration, so we need to migrate the database.

  $> rake db:migrate
  
As a last step, secure the file manager by setting your authentication method in <tt>/config/initializers/rich.rb</tt>. If you're using Devise with an AdminUser model (incidentally, the Active Admin defaults):
  config.authentication_method = :authenticate_admin_user!
  
You're good to go.

== Usage

=== Vanilla Formtastic

To use Rich, it's javascript file must be loaded. By default, this is already setup for you because Rails loads all Javascript files through the <tt>require_tree .</tt> command in application.js. If you've removed that line, manually load rich by requiring it.

  //= require rich

In your formtastic form, use <tt>:as => :rich</tt> to insert Rich. Like so:

  <%= semantic_form_for @post do |f| %>
     <%= f.inputs do %>
       <%= f.input :name %>
       <%= f.input :title %>
       <%= f.input :body, :as => :rich, :config => { :default_style => "myCrazyPaperclipStyle" } %>
     <% end %>
     <%= f.buttons do %>
       <%= f.commit_button %>
     <% end %>
   <% end %>
   
=== Active Admin

Since Active Admin actually uses Formtastic, you can use it with Rich out of the box. In your model configuration file, set up your form like this. Make sure you add <tt>//= require rich</tt> to your <tt>app/assets/javascripts/active_admin.js</tt>.

  form do |f|
    f.inputs "Basic info" do
      f.input :title
      f.input :body, :as => :rich, :config => { :width => '76%', :height => '400px' }
    end
    f.buttons
  end

If you're annoyed by the fact that the Rich editor overlaps the field label (I was!), add the following to your <tt>/app/assets/stylesheets/active_admin.css.scss</tt>.

  #wrapper .cke_skin_kama {
  	margin-left: 20%;
  }
  
=== Rails Admin

To use Rich in your RA forms, first add the following lines to your <tt>/config/initializers/rails_admin.rb</tt>.

  require 'rich/integrations/rails_admin_editor'
  RailsAdmin::Config::Fields::Types::register(Rich::Integrations::RailsAdmin::RichEditor)
  
This will enable the <tt>rich_editor</tt> field type. You can use this field as follows:

  config.model Post do
    edit do
      field :title
      field :body, :rich_editor do
         config({ 
           :insert_many => true 
         })
      end
    end
  end
  
== Screenshots

This is the editor with default settings.
{<img src="https://github.com/bastiaanterhorst/rich/raw/master/screenshots/rich-editor-default.png" />}[https://github.com/bastiaanterhorst/rich/]

This is the file manager.
{<img src="https://github.com/bastiaanterhorst/rich/raw/master/screenshots/rich-filemanager.png" />}[https://github.com/bastiaanterhorst/rich/]

== Rich in production mode

Rich works just fine in production mode. To accomodate the structure of the CKEditor source, Rich extends the <tt>assets:precompile</tt> task to make sure the full CKEditor source tree is copied to your assets folder. So the following works as you would expect:

  rake assets:precompile

Rich will also clean up these CKEditor files when you clean your assets. Like this:

  rake assets:clean
  
Although generally not necessary, the underlying Rich tasks can be invoked directly.

  rake rich:assetize_ckeditor
  rake rich:clean_ckeditor

== Configuration and overrides

Take a look at the generated <tt>rich.rb</tt> initializer and – if you want to dig deeper – the Rich sourcecode. The initializer guides you through the most important settings and configuration options.

=== Localization

Localization should be automatic. Rich uses the currently set locale (<tt>I18n.locale</tt>) for it's editor and file browser.

=== CKEditor configuration

Rich attempts to provide you with a sensible set of buttons and capabilities. But of course, you might disagree. To that end, you can configure CKEditor through the <tt>config</tt> directive, either globally through the initializer, or per editor instance as an option.

Rich also includes a few settings that manipulate CKEditor settings, but are a bit easier to use. For example, you can set <tt>:allow_embeds</tt> to <tt>true</tt> to load a media embed plugin (think Youtube, Vimeo, etc.)

=== Editor styles

When you run the generator a css file is created for you in <tt>app/assets/stylesheets/rich/editor.css</tt>. Use this stylesheet to define the contents of the Styles drop down in CKEditor.

=== Image configuration

The styles you define in the initializer are passed to Paperclip directly, so the syntax is identical. See https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation for more information.

When you change styles after uploading files, you will need to re-process those old files. To accomplish this, run the following command (avoid the standard Paperclip task!).

  rake rich:refresh_assets

== Planned features

* scoping assets to other objects
* drag & drop uploading
* finding/filtering assets
* live image cropping
* live image rotation

== Inspiration

* <NAME>'s ckeditor gem - https://github.com/galetahub/ckeditor
* <NAME>' Ckeditor - https://github.com/fesplugas/rails-ckeditor
* Gregg Bell's Active Admin - https://github.com/gregbell/active_admin

== Tools used

* Ckeditor - http://ckeditor.com/
* Valum's FileUploader - https://github.com/valums/file-uploader
* Rack Raw Upload - https://github.com/newbamboo/rack-raw-upload
* Paperclip - https://github.com/thoughtbot/paperclip
* Silk icons - http://www.famfamfam.com/lab/icons/silk/
* Iconic icons - http://somerandomdude.com/work/iconic/

== Contributing

Your contributions (small and large) are very welcome! Please fork the project, make your changes and send me a pull request. If you are considering adding new functionality, or if you found a bug, please open an issue on Github first.

== Copyright

Rich was created by <NAME> and is sponsored by Perceptor (http://perceptor.nl).

This project is licenced under the MIT License. See MIT-LICENSE for details.
{'fraction_non_alphanumeric': 0.0941222931613243, 'fraction_numerical': 0.00263279141709998, 'mean_word_length': 3.934719064631374, 'pattern_counts': {'":': 0, '<': 97, '<?xml version=': 0, '>': 123, 'https://': 32, 'lorem ipsum': 0, 'www.': 2, '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': '5161382', 'n_tokens_mistral': 4519, 'n_tokens_neox': 4283, 'n_words': 1831}