lib/generators/sushi/sushi_generator.rb in sushifish-0.9.0 vs lib/generators/sushi/sushi_generator.rb in sushifish-0.9.6
- old
+ new
@@ -4,31 +4,22 @@
class SushiGenerator < Rails::Generators::Base
include Rails::Generators::Migration
source_root File.expand_path('../templates', __FILE__)
argument :app_name, :type => :string, :default => "website"
- # http://stackoverflow.com/questions/6199301/global-access-to-rake-dsl-methods-is-deprecated
- # https://github.com/rails/rails/commit/83f257fc4862642af29056cb5b7dfef6e1303754
- # Fixed in Rails 3.1?
- # def rake_dsl_fix
- # gsub_file "Rakefile", "require File.expand_path('../config/application', __FILE__)", "require File.expand_path('../config/application', __FILE__)\nrequire 'rake/dsl_definition'"
- #
- # gsub_file "Rakefile", "require 'rake'", "require 'rake'\ninclude Rake::DSL"
- # end
-
def create_models
generate :model, 'page name:string content:text page_title:string meta_keywords:text meta_description:text sidebar_html:text ancestry:string short_nav:string order_by:integer show_in_nav:boolean'
generate :model, 'stylesheet body:text'
rake 'db:migrate'
- remove_file '/app/models/page.rb'
+ remove_file 'app/models/page.rb'
copy_file 'page.rb', 'app/models/page.rb'
end
def indexes_and_defaults
migration_template 'indexes_and_defaults.rb', 'db/migrate/indexes_and_defaults.rb'
rake 'db:migrate'
- end
+ end
def remove_files
remove_file 'public/index.html' if File.exists?('public/index.html')
remove_file 'app/views/layouts/application.html.erb' if File.exists?('app/views/layouts/application.html.erb')
remove_file 'public/images/rails.png' if File.exists?('public/images/rails.png')
@@ -37,30 +28,33 @@
def add_routes
route "root :to => 'page#show#index', :page => 'index'"
route "match ':section(/:page)' => 'page#show#:page', :as => :link"
route "resources :pages, :module => 'admin'"
route "resources :messages, :module => 'admin'"
- route "resource :stylesheet"
- route "get 'stylesheets/open'"
+ # route "resource :stylesheet"
+ # route "get 'stylesheets/open'"
end
def copy_files
- copy_file 'admin_pages_controller.rb', 'app/controllers/admin/pages_controller.rb'
- copy_file 'application_controller.rb', 'app/controllers/application_controller.rb'
- copy_file 'dashboard_controller.rb', 'app/controllers/dashboard_controller.rb'
- copy_file 'stylesheets_controller.rb', 'app/controllers/stylesheets_controller.rb'
+ # copy_file 'admin_pages_controller.rb', 'app/controllers/admin/pages_controller.rb'
+ # remove_file 'app/controllers/application_controller.rb'
+ # copy_file 'application_controller.rb', 'app/controllers/application_controller.rb'
+ # copy_file 'dashboard_controller.rb', 'app/controllers/dashboard_controller.rb'
+ # copy_file 'stylesheets_controller.rb', 'app/controllers/stylesheets_controller.rb'
copy_file 'page_controller.rb', 'app/controllers/page_controller.rb'
copy_file 'page_helper.rb', 'app/helpers/page_helper.rb'
copy_file 'index.html.haml', 'app/views/page/index.html.haml'
copy_file 'page.html.haml', 'app/views/layouts/page.html.haml'
template 'application.html.haml', 'app/views/layouts/application.html.haml'
# copy_file 'style.sass', 'public/stylesheets/sass/style.sass'
- # copy_file 'reset.sass', 'public/stylesheets/sass/reset.sass'
+ copy_file 'reset.css.scss', 'app/assets/stylesheets/reset.css.scss'
# copy_file 'admin.sass', 'public/stylesheets/sass/admin.sass'
- # copy_file 'layout.sass', 'public/stylesheets/sass/layout.sass'
- # copy_file 'superfish.sass', 'public/stylesheets/sass/superfish.sass'
+ copy_file 'layout.css.scss', 'app/assets/stylesheets/layout.css.scss'
+ copy_file 'superfish.css.scss', 'app/assets/stylesheets/superfish.css.scss'
copy_file 'style.css.scss', 'app/assets/stylesheets/style.css.scss'
+ remove_file 'app/assets/stylesheets/application.css'
+ copy_file 'application.css', 'app/assets/stylesheets/application.css'
copy_file 'show.html.haml', 'app/views/page/show.html.haml'
copy_file '_header.html.haml', 'app/views/page/_header.html.haml'
copy_file '_navigation.html.haml', 'app/views/page/_navigation.html.haml'
copy_file '_sidebar.html.haml', 'app/views/page/_sidebar.html.haml'
copy_file '_footer.html.haml', 'app/views/page/_footer.html.haml'
@@ -78,24 +72,30 @@
run 'git init'
run 'git add .'
run "gc -m 'inital commit'"
end
- # def gems
- # gem 'haml', '2.2.24'
- # gem 'jquery-rails'
- # gem 'ancestry'
- #
- # gsub_file "Gemfile", /#.*\n/, "\n"
- # gsub_file "Gemfile", /\n+/, "\n"
- #
- # run 'bundle'
- # end
-
- # def jquery_setup
- # generate 'jquery:install --ui'
- # end
+ def gems
+ gem 'haml'
+ gem 'ancestry'
+ gem 'activeadmin'
+ gem "meta_search", '>= 1.1.0.pre'
+
+ run 'bundle'
+ end
+ def activeadmin
+ generate "active_admin:install"
+ generate "active_admin:resource Page"
+
+ remove_file 'app/admin/pages.rb'
+ copy_file 'pages.rb', 'app/admin/pages.rb'
+
+ # app/admin/pages
+
+ rake 'db:migrate'
+ end
+
def seed_data
append_file 'db/seeds.rb', "Stylesheet.create! :body => '/* inject style here. */'\n"
append_file 'db/seeds.rb', "Page.create! :name => 'index', :content => 'i am index. i have no data.'"
rake 'db:seed'
end