Sha256: ba36f62cbc1bc46f487e84891661ad2d25423f9d4b711b087eda967e404e9f83

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

require 'rails/generators'
require 'rails/generators/migration'

class PageEngineGenerator < Rails::Generators::Base
  include Rails::Generators::Migration

  source_root File.expand_path('../../../../', __FILE__) 
  
  def self.next_migration_number(path)
    Time.now.utc.strftime("%Y%m%d%H%M%S")
  end
  
  def install
    create_migrations
    copy_stylesheets
    copy_javascripts
    copy_images
    
    copy_file 'app/views/layouts/admin.html.haml', 'app/views/layouts/admin.html.haml'
  end

  private
  
    def create_migrations
      begin
        migration_template 'db/migrate/20110814185929_create_page_engine.rb', 'db/migrate/create_page_engine.rb'
      rescue Exception => e
        puts e
      end  
    end
    
    def copy_stylesheets
      directory 'app/assets/stylesheets', 'public/stylesheets'
      directory 'vendor/assets/stylesheets', 'public/stylesheets'
      
      puts 'Updating image location'
      ['css', 'textile', 'markdown', 'html', 'javascript'].each do |area|
        gsub_file "public/stylesheets/markitup/sets/#{area}/style.css", /\/assets\//, '/images/'
      end
      
      ['markitup', 'simple'].each do |area|
        gsub_file "public/stylesheets/markitup/skins/#{area}/style.css", /\/assets\//, '/images/'
      end
      
      gsub_file "public/stylesheets/jquery-ui.css", /\/assets\//, '/images/'
      gsub_file "public/stylesheets/page_engine.css", /\/assets\//, '/images/'
    end
    
    def copy_javascripts
      directory 'app/assets/javascripts', 'public/javascripts'
      directory 'vendor/assets/javascripts', 'public/javascripts'      
    end
    
    def copy_images
      directory 'app/assets/images', 'public/images'
      directory 'vendor/assets/images', 'public/images'            
    end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
page_engine-0.0.3 lib/generators/page_engine/page_engine_generator.rb
page_engine-0.0.2 lib/generators/page_engine/page_engine_generator.rb