Sha256: 47ca505047244332e05950444b766f02ea63da18b8c2bb3a7254bb1ecfd44a8d

Contents?: true

Size: 1.4 KB

Versions: 1

Compression:

Stored size: 1.4 KB

Contents

class ThemeGenerator < Rails::Generator::Base
  
  default_options :app_name => 'Web App',
                  :layout_type => :administration,
                  :theme => :default,
                  :no_layout => false
    
  def initialize(runtime_args, runtime_options = {})
    super
    @name = @args.first || 'application'
  end
  
  def manifest
    record do |m|            
      m.directory("app/views/layouts")
      m.directory("public/stylesheets/themes/#{options[:theme]}/")      
      m.template("view_layout_#{options[:layout_type]}.html.erb", File.join("app/views/layouts", "#{@name}.html.erb")) unless options[:no_layout]
      m.template("../../../stylesheets/base.css",  File.join("public/stylesheets", "web_app_theme.css"))
      m.template("../../../stylesheets/themes/#{options[:theme]}/style.css",  File.join("public/stylesheets/themes/#{options[:theme]}", "style.css"))      
    end
  end
  
  def banner
    "Usage: #{$0} theme [layout_name] [options]"
  end

protected

  def add_options!(opt)
    opt.separator ''
    opt.separator 'Options:'
    opt.on("--app_name=app_name", String, "") { |v| options[:app_name] = v }
    opt.on("--type=layout_type", String, "Specify the layout type") { |v| options[:layout_type] = v }
    opt.on("--theme=theme", String, "Specify the theme") { |v| options[:theme] = v }
    opt.on("--no-layout", "Don't create layout") { |v| options[:no_layout] = true }
  end
  
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
base_rails_app-0.0.1 lib/vendor/plugins/web-app-theme/rails_generators/theme/theme_generator.rb