Class: Editor::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/editor/install/install_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_scripts_into_active_adminObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/generators/editor/install/install_generator.rb', line 17

def add_scripts_into_active_admin
  if defined?(ActiveAdmin)
    content = "//= require editor\n\n$(document).ready(function(){\n\n  editor.init();\n\n});        \n    CONTENT\n    inject_into_file \"app/assets/javascripts/active_admin.js\", :after => \"//= require active_admin/base\\n\" do\n      content\n    end\n  end\nend\n"

#add_styles_into_active_adminObject



34
35
36
37
38
39
40
# File 'lib/generators/editor/install/install_generator.rb', line 34

def add_styles_into_active_admin
  if defined?(ActiveAdmin)
    inject_into_file "app/assets/stylesheets/active_admin.css.scss", :after => "@import \"active_admin/base\";\n" do
      '@import "editor";'
    end
  end
end

#check_active_adminObject



5
6
7
8
9
# File 'lib/generators/editor/install/install_generator.rb', line 5

def check_active_admin
  unless defined?(ActiveAdmin)
    puts "You need installed active admin to use editor gem!"
  end
end

#copy_initializersObject



11
12
13
14
15
# File 'lib/generators/editor/install/install_generator.rb', line 11

def copy_initializers
  if defined?(ActiveAdmin)
    copy_file "editor.rb", "config/initializers/editor.rb"
  end
end

#precompile_assets_on_productionObject



42
43
44
45
46
47
48
# File 'lib/generators/editor/install/install_generator.rb', line 42

def precompile_assets_on_production
  if defined?(ActiveAdmin)
    inject_into_file "config/environments/production.rb", :before => "end\n" do
      "\tconfig.assets.precompile += %w( tinymce/themes/advanced/skins/cirkuit/ui.css tinymce/themes/advanced/skins/cirkuit/content.css tinymce/themes/advanced/skins/cirkuit/dialog.css )\n"
    end
  end
end