From 1e6fc2170dedc0e584565538f8d484ee8a127ccc Mon Sep 17 00:00:00 2001 From: Bishisht Bhatta Date: Fri, 8 Jan 2016 14:32:18 +0545 Subject: [PATCH 1/2] added administrate --- recipes/admin.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/recipes/admin.rb b/recipes/admin.rb index c09cc64e..0a47e491 100644 --- a/recipes/admin.rb +++ b/recipes/admin.rb @@ -7,6 +7,9 @@ add_gem 'activeadmin', '~> 1.0.0.pre2' elsif prefer :admin, 'rails_admin' add_gem 'rails_admin' +elsif prefer :admin, 'administrate' + add_gem 'administrate', '~> 0.1.2' #Adding administrate + end stage_two do @@ -19,6 +22,9 @@ say_wizard "recipe installing rails_admin" generate 'rails_admin:install' end + if prefer :admin, 'administrate' + say_wizard "recipe installing administrate" + generate 'administrate:install' ### GIT git :add => '-A' if prefer :git, true git :commit => %Q(-qm "rails_apps_composer: installed #{prefs[:admin]}") if prefer :git, true @@ -28,7 +34,7 @@ name: admin description: "Adding rails admin gem to your application" -author: JangoSteve +author: JangoSteve, Bishisht Bhatta category: admin requires: [setup] @@ -39,4 +45,4 @@ - admin: type: multiple_choice prompt: Install admin gem? - choices: [ ["None", "none"], ["ActiveAdmin", "activeadmin"], ["RailsAdmin", "rails_admin"] ] + choices: [ ["None", "none"], ["ActiveAdmin", "activeadmin"], ["RailsAdmin", "rails_admin"], ["Administrate by Thoughtbot", "administrate"] ] From eda03cb2da78ac184c2dced4c18a811240a195c8 Mon Sep 17 00:00:00 2001 From: Bishisht Bhatta Date: Fri, 8 Jan 2016 15:52:10 +0545 Subject: [PATCH 2/2] added some comments --- recipes/admin.rb | 6 ++++++ recipes/analytics.rb | 1 + recipes/roles.rb | 5 +++++ recipes/setup.rb | 13 ++++++++++--- 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/recipes/admin.rb b/recipes/admin.rb index 0a47e491..2e1769e6 100644 --- a/recipes/admin.rb +++ b/recipes/admin.rb @@ -1,12 +1,15 @@ # Application template recipe for the rails_apps_composer. Change the recipe here: # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/admin.rb +# This is the file where you can add other admin backends. prefs[:admin] = config['admin'] unless (config['admin'] == 'none') if prefer :admin, 'activeadmin' add_gem 'activeadmin', '~> 1.0.0.pre2' + elsif prefer :admin, 'rails_admin' add_gem 'rails_admin' + elsif prefer :admin, 'administrate' add_gem 'administrate', '~> 0.1.2' #Adding administrate @@ -14,14 +17,17 @@ stage_two do say_wizard "recipe stage two" + if prefer :admin, 'activeadmin' say_wizard "recipe installing activeadmin" generate 'active_admin:install' end + if prefer :admin, 'rails_admin' say_wizard "recipe installing rails_admin" generate 'rails_admin:install' end + if prefer :admin, 'administrate' say_wizard "recipe installing administrate" generate 'administrate:install' diff --git a/recipes/analytics.rb b/recipes/analytics.rb index 7db83739..f9d92b34 100644 --- a/recipes/analytics.rb +++ b/recipes/analytics.rb @@ -1,5 +1,6 @@ # Application template recipe for the rails_apps_composer. Change the recipe here: # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/analytics.rb +# If you want to use other analytics engine add them here and you are ready to go. prefs[:analytics] = multiple_choice "Install page-view analytics?", [["None", "none"], ["Google Analytics", "ga"], diff --git a/recipes/roles.rb b/recipes/roles.rb index 202a64a7..b5c586ea 100644 --- a/recipes/roles.rb +++ b/recipes/roles.rb @@ -1,8 +1,11 @@ # Application template recipe for the rails_apps_composer. Change the recipe here: # https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/roles.rb +# Helps to assign different kinds of roles to users. Like guest, moderator etc. + stage_two do say_wizard "recipe stage two" + if (prefer :authorization, 'roles') || (prefer :authorization, 'pundit') if prefer :authentication, 'none' generate 'model User email:string' @@ -29,6 +32,8 @@ def set_default_role git :commit => '-qm "rails_apps_composer: add roles to a User model"' if prefer :git, true end +# Normally, ruby scripts are finished when you reach the end of a file; however, this is not always the case. You can end your script sooner by using the __END__ keyword in your script. +# Once added, everything you type after that will not be parsed by ruby. __END__ name: roles diff --git a/recipes/setup.rb b/recipes/setup.rb index 9fff1cbc..3edd98ee 100644 --- a/recipes/setup.rb +++ b/recipes/setup.rb @@ -4,20 +4,26 @@ ## Ruby on Rails HOST_OS = RbConfig::CONFIG['host_os'] say_wizard "Your operating system is #{HOST_OS}." -say_wizard "You are using Ruby version #{RUBY_VERSION}." -say_wizard "You are using Rails version #{Rails::VERSION::STRING}." +say_wizard "You are using Ruby version: #{RUBY_VERSION}." +say_wizard "You are using Rails version: #{Rails::VERSION::STRING}." ## Is sqlite3 in the Gemfile? gemfile = File.read(destination_root() + '/Gemfile') sqlite_detected = gemfile.include? 'sqlite3' -## Web Server +## Web Server ## + +# Select for development prefs[:dev_webserver] = multiple_choice "Web server for development?", [["WEBrick (default)", "webrick"], ["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"], ["Phusion Passenger (Apache/Nginx)", "passenger"], ["Phusion Passenger (Standalone)", "passenger_standalone"]] unless prefs.has_key? :dev_webserver + +# Select for production prefs[:prod_webserver] = multiple_choice "Web server for production?", [["Same as development", "same"], ["Thin", "thin"], ["Unicorn", "unicorn"], ["Puma", "puma"], ["Phusion Passenger (Apache/Nginx)", "passenger"], ["Phusion Passenger (Standalone)", "passenger_standalone"]] unless prefs.has_key? :prod_webserver + +# A cool trick comparing if two arrays are 'same' prefs[:prod_webserver] = prefs[:dev_webserver] if prefs[:prod_webserver] == 'same' ## Database Adapter @@ -66,6 +72,7 @@ prefs[:devise_modules] = multiple_choice "Devise modules?", [["Devise with default modules","default"], ["Devise with Confirmable module","confirmable"], ["Devise with Confirmable and Invitable modules","invitable"]] unless prefs.has_key? :devise_modules + when 'omniauth' prefs[:omniauth_provider] = multiple_choice "OmniAuth provider?", [["Facebook", "facebook"], ["Twitter", "twitter"], ["GitHub", "github"], ["LinkedIn", "linkedin"], ["Google-Oauth-2", "google_oauth2"], ["Tumblr", "tumblr"]] unless prefs.has_key? :omniauth_provider