Module: Rich

Defined in:
lib/rich.rb,
lib/rich/engine.rb,
lib/rich/version.rb,
app/models/rich/rich_image.rb,
app/helpers/rich/files_helper.rb,
app/helpers/rich/application_helper.rb,
app/controllers/rich/files_controller.rb,
lib/rich/integrations/legacy_formtastic.rb,
lib/rich/integrations/rails_admin_editor.rb,
app/controllers/rich/application_controller.rb,
lib/generators/rich/install/install_generator.rb

Defined Under Namespace

Modules: ApplicationHelper, FilesHelper, Generators, Integrations Classes: ApplicationController, Engine, FilesController, RichImage

Constant Summary collapse

VERSION =
"0.0.7"
@@image_styles =
{
  :thumb => "100x100#"
}
@@allowed_styles =
:all
@@default_style =
:thumb
@@authentication_method =
:none
@@insert_many =
false
@@editor =
{
  :stylesSet  =>  [],
  :extraPlugins => 'stylesheetparser,richimage',
  :removePlugins => 'scayt,menubutton,contextmenu,image,forms',
  :contentsCss => '/assets/rich/editor.css',
  :removeDialogTabs => 'link:advanced;link:target',
  :startupOutlineBlocks => true,
  :forcePasteAsPlainText => true,
  :format_tags => 'h3;p;pre',
  :toolbar => [['Format','Styles'],['Bold', 'Italic', '-','NumberedList', 'BulletedList', 'Blockquote', '-', 'richImage', '-', 'Link', 'Unlink'],['Source', 'ShowBlocks']],
  
  :richBrowserUrl => '/rich/files/',
  
  :uiColor => '#f4f4f4'
}

Class Method Summary collapse

Class Method Details

.getEditorOptions(overrides = {}) ⇒ Object

End configuration defaults



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/rich.rb', line 42

def self.getEditorOptions(overrides={})
  # merge in editor settings configured elsewhere
  
  if(self.allowed_styles == :all)
    # replace :all with a list of the actual styles that are present
    all_styles = Rich.image_styles.keys
    all_styles.push(:original)
    self.allowed_styles = all_styles
  end
  
  base = {
    :allowed_styles => self.allowed_styles,
    :default_style => self.default_style,
    :insert_many => self.insert_many
  }
  editor_options = self.editor.merge(base)
     
  # merge in local overrides
  editor_options.merge!(overrides)
  
  puts editor_options.inspect
  
  editor_options

end

.insertObject



72
73
74
75
76
77
78
79
80
# File 'lib/rich.rb', line 72

def self.insert
  # manually inject into Formtastic 1. V2 is extended autmatically.
  if Object.const_defined?("Formtastic")
    if(Gem.loaded_specs["formtastic"].version.version[0,1] == "1")
      require 'rich/integrations/legacy_formtastic'
      ::Formtastic::SemanticFormBuilder.send :include, Rich::Integrations::FormtasticBuilder
    end
  end
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Rich)

    the object that the method was called on



68
69
70
# File 'lib/rich.rb', line 68

def self.setup
  yield self
end