Class: Umlaut::AssetHooks

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/umlaut/asset_hooks_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_to_javascript_manifestObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/generators/umlaut/asset_hooks_generator.rb', line 42

def add_to_javascript_manifest
  unless IO.read("app/assets/javascripts/application.js").include?('Umlaut')
    prepend_to_file "app/assets/javascripts/application.js" do
      %q{
 // Umlaut javascript required for proper functionality. The 'umlaut' file
 // also forces require of jquery and jquery-ui, dependencies.
 //= require 'umlaut'
      }
    end
  else
    say_status("skipped", "Your application.js already references Umlaut", :yellow)
  end
    
end

#add_to_stylesheet_manifestObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/generators/umlaut/asset_hooks_generator.rb', line 6

def add_to_stylesheet_manifest
  existing = IO.read("app/assets/stylesheets/application.css")
  unless existing.include?('Umlaut')
    after = 
      if existing.include?("require_self")
        "require_self"
      else
        "/*"
      end
      
    insert_into_file "app/assets/stylesheets/application.css", :after => after do
      %q{
 *
 * The base Umlaut styles:
 *= require 'umlaut'
 *}
    end
    append_to_file("app/assets/stylesheets/application.css") do
      %q{

  /*  Umlaut needs a jquery-ui theme CSS. Here's an easy way to get one,
   *  you can replace with another theme. 
   *
   *  Note, CSS @import needs to be the first line in a CSS file. This will
   *  become so if 'require_self' is included above, as the FIRST sprockets
   *  require, and this @import line is the first non-comment line in this
   *  file.
   */
   @import url(//ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css);
      }
    end
  else
    say_status("skipped", "Your application.css already references Umlaut", :yellow)
  end
end