Sha256: 4ffad1710ba112e8a237f7fb304426c7f4c8adb8642e694ca6664713b4cdb8b3

Contents?: true

Size: 1.73 KB

Versions: 20

Compression:

Stored size: 1.73 KB

Contents

require 'rails/generators'

module Umlaut
  class AssetHooks < Rails::Generators::Base
    
    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
    
    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
    
    
  end  
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
umlaut-3.1.0.pre2 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.1.0.pre1 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.5 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.4 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.3 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.2 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.1 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0rc1 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta10 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta9 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta8 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta7 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta6 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta5 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta4 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta3 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta2 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0beta1 lib/generators/umlaut/asset_hooks_generator.rb
umlaut-3.0.0alpha15 lib/generators/umlaut/asset_hooks_generator.rb