require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb") class HandySetupGenerator < Rails::Generator::Base def initialize(runtime_args, runtime_options = {}) super end def manifest record do |m| m.directory "app/models" m.directory "app/controllers" m.directory "app/controllers/admin" m.directory "app/helpers" m.directory "app/views" #`script/plugin install git://github.com/binarylogic/authlogic.git` #`script/plugin install git://github.com/mbleigh/subdomain-fu.git` m.gem_dependency "Authlogic", "config.gem 'authlogic'" m.gem_dependency "Subdomain-fu", "config.gem 'subdomain-fu'" `rm public/index.html` `script/generate controller home index` m.directory "app/views/users" `rm app/controllers/application_controller.rb` m.template "application_controller.rb", "app/controllers/application_controller.rb" m.template "user.rb", "app/models/user.rb" m.template "authlogic_session.rb", "app/models/user_session.rb" m.template "users_controller.rb", "app/controllers/users_controller.rb" m.template "views/new_user.html.erb", "app/views/users/new.html.erb" m.template "views/edit_user.html.erb", "app/views/users/edit.html.erb" m.template "views/_form_user.html.erb", "app/views/users/_form.html.erb" m.template "views/show_user.html.erb", "app/views/users/show.html.erb" m.directory "app/views/layouts" m.template "layout.html.erb", "app/views/layouts/application.html.erb" m.template "style.css", "public/stylesheets/application.css" m.directory "app/views/user_sessions" m.template "sessions_controller.rb", "app/controllers/user_sessions_controller.rb" m.template "views/login.html.erb", "app/views/user_sessions/new.html.erb" m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_users" m.template "subdomain_fu.rb", "config/initializers/subdomain_fu.rb" m.directory "app/controllers/admin" m.template "admin_controller.rb", "app/controllers/admin_controller.rb" m.template "admin_home_controller.rb", "app/controllers/admin/home_controller.rb" m.directory "app/views/admin" m.directory "app/views/admin/home" m.template "views/admin_home_index.html.erb", "app/views/admin/home/index.html.erb" m.template "admin_sessions_controller.rb", "app/controllers/admin/user_sessions_controller.rb" m.directory "app/views/admin/user_sessions" m.template "views/login.html.erb", "app/views/admin/user_sessions/new.html.erb" m.template "admin_users_controller.rb", "app/controllers/admin/users_controller.rb" m.directory "app/views/admin/users" m.template "views/admin_edit_user.html.erb", "app/views/admin/users/edit.html.erb" m.template "views/admin_new_user.html.erb", "app/views/admin/users/new.html.erb" m.template "views/admin_show_user.html.erb", "app/views/admin/users/show.html.erb" m.template "views/admin_form_user.html.erb", "app/views/admin/users/_form.html.erb" m.template "views/admin_index_users.html.erb", "app/views/admin/users/index.html.erb" `rm db/seeds.rb` m.template "seed.rb", "db/seeds.rb" `rm config/routes.rb` m.template "routes.rb", "config/routes.rb" #m.root_route :controller => :home #m.route_resources :users #m.route_resources :user_sessions #m.named_resource :account, :controller => "users" #m.route_name :login, 'login', :controller => :user_sessions, :action => 'new' #m.route_name :logout, 'logout', :controller => :user_sessions, :action => 'destroy' #m.route_name :signup, 'signup', :controller => :users, :action => 'new' end end def application_controller_name Rails.version >= '2.3.0' ? 'application_controller' : 'application' end protected def banner <<-EOS Creates user model and controllers to handle registration and authentication. USAGE: #{$0} #{spec.name} [user_name] [sessions_controller_name] EOS end end