thyone_creator 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/thyone +7 -0
- data/lib/rails_wizard/command.rb +116 -0
- data/lib/rails_wizard/config.rb +88 -0
- data/lib/rails_wizard/recipe.rb +106 -0
- data/lib/rails_wizard/recipes.rb +38 -0
- data/lib/rails_wizard/template.rb +73 -0
- data/lib/rails_wizard.rb +10 -0
- data/recipes/action_mailer.rb +123 -0
- data/recipes/active_admin.rb +44 -0
- data/recipes/activerecord.rb +37 -0
- data/recipes/add_user.rb +129 -0
- data/recipes/airbrake.rb +34 -0
- data/recipes/backbone.rb +23 -0
- data/recipes/capybara.rb +34 -0
- data/recipes/cleanup.rb +40 -0
- data/recipes/cloudfiles.rb +36 -0
- data/recipes/compass.rb +46 -0
- data/recipes/compass_960.rb +48 -0
- data/recipes/cucumber.rb +75 -0
- data/recipes/datamapper.rb +111 -0
- data/recipes/devise.rb +114 -0
- data/recipes/extras.rb +80 -0
- data/recipes/git.rb +40 -0
- data/recipes/guard.rb +99 -0
- data/recipes/haml.rb +23 -0
- data/recipes/heroku.rb +62 -0
- data/recipes/home_page.rb +58 -0
- data/recipes/home_page_users.rb +47 -0
- data/recipes/html5.rb +153 -0
- data/recipes/inherited_resources.rb +23 -0
- data/recipes/less.rb +12 -0
- data/recipes/mongohq.rb +59 -0
- data/recipes/mongoid.rb +39 -0
- data/recipes/mongolab.rb +59 -0
- data/recipes/omniauth.rb +192 -0
- data/recipes/omniauth_email.rb +82 -0
- data/recipes/paperclip.rb +79 -0
- data/recipes/rails_admin.rb +21 -0
- data/recipes/redis.rb +23 -0
- data/recipes/responders.rb +10 -0
- data/recipes/resque.rb +25 -0
- data/recipes/rspec.rb +133 -0
- data/recipes/sass.rb +25 -0
- data/recipes/seed_database.rb +76 -0
- data/recipes/settingslogic.rb +43 -0
- data/recipes/simple_form.rb +54 -0
- data/recipes/slim.rb +46 -0
- data/recipes/static_page.rb +43 -0
- data/recipes/subdomains.rb +121 -0
- data/recipes/users_page.rb +165 -0
- data/spec/rails_wizard/config_spec.rb +108 -0
- data/spec/rails_wizard/recipe_spec.rb +81 -0
- data/spec/rails_wizard/recipes/sanity_spec.rb +30 -0
- data/spec/rails_wizard/recipes_spec.rb +24 -0
- data/spec/rails_wizard/template_spec.rb +78 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/rails_directory.rb +17 -0
- data/spec/support/template_runner.rb +28 -0
- data/templates/helpers.erb +45 -0
- data/templates/layout.erb +83 -0
- data/templates/recipe.erb +10 -0
- data/version.rb +3 -0
- metadata +251 -0
@@ -0,0 +1,79 @@
|
|
1
|
+
if config['paperclip']
|
2
|
+
if recipes.include? 'mongoid'
|
3
|
+
gem 'mongoid-paperclip'
|
4
|
+
else
|
5
|
+
gem 'paperclip'
|
6
|
+
end
|
7
|
+
else
|
8
|
+
recipes.delete('paperclip')
|
9
|
+
end
|
10
|
+
|
11
|
+
if config['paperclip']
|
12
|
+
after_bundler do
|
13
|
+
# Code here is run after Bundler installs all the gems for the project.
|
14
|
+
# You can run generators and rake tasks in this section.
|
15
|
+
if recipes.include? 'mongoid'
|
16
|
+
create_file 'config/initializers/mongoid-paperclip.rb' do
|
17
|
+
<<-RUBY
|
18
|
+
require 'mongoid_paperclip'
|
19
|
+
RUBY
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
if recipes.include? 'cloudfiles'
|
24
|
+
# Add Storage module file for paperclip in lib
|
25
|
+
get 'https://raw.github.com/gist/2476222/986bf7a49556ac549b75768af5dce2e6e4c67b61/Cloudfilesstorage.rb', 'lib/cloud_files_storage.rb'
|
26
|
+
# Add config initialize file
|
27
|
+
create_file 'config/initializers/cloudfiles.rb' do
|
28
|
+
<<-RUBY
|
29
|
+
require 'cloudfiles'
|
30
|
+
require 'cloud_files_storage'
|
31
|
+
RUBY
|
32
|
+
end
|
33
|
+
|
34
|
+
create_file 'config/rackspace_cloudfiles.yml' do
|
35
|
+
<<-YAML
|
36
|
+
DEFAULTS: &DEFAULTS
|
37
|
+
username: [username]
|
38
|
+
api_key: [api_key]
|
39
|
+
|
40
|
+
development:
|
41
|
+
<<: *DEFAULTS
|
42
|
+
container: [container name]
|
43
|
+
|
44
|
+
test:
|
45
|
+
<<: *DEFAULTS
|
46
|
+
container: [container name]
|
47
|
+
|
48
|
+
production:
|
49
|
+
<<: *DEFAULTS
|
50
|
+
container: [container name]
|
51
|
+
YAML
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if config['paperclip']
|
58
|
+
after_everything do
|
59
|
+
# These blocks are run after the bundler blocks and are reserved for
|
60
|
+
# special cases like committing the files to a git repository (something
|
61
|
+
# that depends on everything having been generated).
|
62
|
+
end
|
63
|
+
end
|
64
|
+
# A recipe is two parts: the Ruby code and YAML back-matter that comes
|
65
|
+
# after a blank line with the __END__ keyword.
|
66
|
+
|
67
|
+
__END__
|
68
|
+
|
69
|
+
name: Paperclip
|
70
|
+
description: "Use paperclip for file uploading."
|
71
|
+
author: merlinvn
|
72
|
+
|
73
|
+
category: persistence
|
74
|
+
tags: [storage]
|
75
|
+
|
76
|
+
config:
|
77
|
+
- paperclip:
|
78
|
+
type: boolean
|
79
|
+
prompt: "Would you like to use Paperclip to store your files?"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
gem 'rails_admin', :git => 'git://github.com/sferik/rails_admin.git'
|
2
|
+
|
3
|
+
after_bundler do
|
4
|
+
generate 'rails_admin:install_admin'
|
5
|
+
rake 'admin:copy_assets'
|
6
|
+
rake 'admin:ckeditor_download' if config['ckeditor']
|
7
|
+
end
|
8
|
+
|
9
|
+
__END__
|
10
|
+
|
11
|
+
name: RailsAdmin
|
12
|
+
description: "Install RailsAdmin to manage data in your application"
|
13
|
+
author: alno
|
14
|
+
|
15
|
+
category: other
|
16
|
+
|
17
|
+
config:
|
18
|
+
- ckeditor:
|
19
|
+
type: boolean
|
20
|
+
prompt: Install CKEditor?
|
21
|
+
|
data/recipes/redis.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
if config['redis']
|
2
|
+
gem 'redis'
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
say_wizard "Generating Redis initializer..."
|
6
|
+
|
7
|
+
create_file "config/initializers/redis.rb" do <<-RUBY
|
8
|
+
REDIS = Redis.new
|
9
|
+
RUBY
|
10
|
+
end
|
11
|
+
end
|
12
|
+
else
|
13
|
+
recipes.delete('redis')
|
14
|
+
end
|
15
|
+
__END__
|
16
|
+
|
17
|
+
name: Redis
|
18
|
+
description: "Add Redis as a persistence engine to your application."
|
19
|
+
author: mbleigh
|
20
|
+
|
21
|
+
exclusive: key_value
|
22
|
+
category: persistence
|
23
|
+
tags: [key_value, cache, session_store]
|
data/recipes/resque.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
if config['resque']
|
2
|
+
gem 'resque'
|
3
|
+
|
4
|
+
after_bundler do
|
5
|
+
say_wizard 'Adding resque.rake task to lib/tasks'
|
6
|
+
create_file "lib/tasks/resque.rake" do <<-RUBY
|
7
|
+
require 'resque/tasks'
|
8
|
+
RUBY
|
9
|
+
end
|
10
|
+
end
|
11
|
+
else
|
12
|
+
recipes.delete('resque')
|
13
|
+
end
|
14
|
+
|
15
|
+
__END__
|
16
|
+
|
17
|
+
name: Resque
|
18
|
+
description: "Add Resque to your application."
|
19
|
+
author: porta
|
20
|
+
|
21
|
+
category: worker
|
22
|
+
tags: [background, worker]
|
23
|
+
|
24
|
+
requires: [redis]
|
25
|
+
run_after: [redis]
|
data/recipes/rspec.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/rspec.rb
|
3
|
+
|
4
|
+
if config['rspec']
|
5
|
+
gem 'rspec-rails', '>= 2.10.1', :group => [:development, :test]
|
6
|
+
if recipes.include? 'mongoid'
|
7
|
+
# use the database_cleaner gem to reset the test database
|
8
|
+
gem 'database_cleaner', '>= 0.7.2', :group => :test
|
9
|
+
# include RSpec matchers from the mongoid-rspec gem
|
10
|
+
gem 'mongoid-rspec', '>= 1.4.4', :group => :test
|
11
|
+
end
|
12
|
+
if config['machinist']
|
13
|
+
gem 'machinist', :group => :test
|
14
|
+
end
|
15
|
+
if config['factory_girl']
|
16
|
+
gem 'factory_girl_rails', '>= 3.3.0', :group => [:development, :test]
|
17
|
+
end
|
18
|
+
# add a collection of RSpec matchers and Cucumber steps to make testing email easy
|
19
|
+
gem 'email_spec', '>= 1.2.1', :group => :test
|
20
|
+
create_file 'features/support/email_spec.rb' do <<-RUBY
|
21
|
+
require 'email_spec/cucumber'
|
22
|
+
RUBY
|
23
|
+
end
|
24
|
+
else
|
25
|
+
recipes.delete('rspec')
|
26
|
+
end
|
27
|
+
|
28
|
+
# note: there is no need to specify the RSpec generator in the config/application.rb file
|
29
|
+
|
30
|
+
if config['rspec']
|
31
|
+
after_bundler do
|
32
|
+
say_wizard "RSpec recipe running 'after bundler'"
|
33
|
+
generate 'rspec:install'
|
34
|
+
generate 'email_spec:steps'
|
35
|
+
inject_into_file 'spec/spec_helper.rb', "require 'email_spec'\n", :after => "require 'rspec/rails'\n"
|
36
|
+
inject_into_file 'spec/spec_helper.rb', :after => "RSpec.configure do |config|\n" do <<-RUBY
|
37
|
+
config.include(EmailSpec::Helpers)
|
38
|
+
config.include(EmailSpec::Matchers)
|
39
|
+
RUBY
|
40
|
+
end
|
41
|
+
if config['machinist']
|
42
|
+
say_wizard "Generating blueprints file for Machinist"
|
43
|
+
generate 'machinist:install'
|
44
|
+
end
|
45
|
+
|
46
|
+
say_wizard "Removing test folder (not needed for RSpec)"
|
47
|
+
run 'rm -rf test/'
|
48
|
+
|
49
|
+
inject_into_file 'config/application.rb', :after => "Rails::Application\n" do <<-RUBY
|
50
|
+
|
51
|
+
# don't generate RSpec tests for views and helpers
|
52
|
+
config.generators do |g|
|
53
|
+
g.view_specs false
|
54
|
+
g.helper_specs false
|
55
|
+
#{"g.fixture_replacement :machinist" if config['machinist']}
|
56
|
+
end
|
57
|
+
|
58
|
+
RUBY
|
59
|
+
end
|
60
|
+
|
61
|
+
|
62
|
+
if recipes.include? 'mongoid'
|
63
|
+
|
64
|
+
# remove ActiveRecord artifacts
|
65
|
+
gsub_file 'spec/spec_helper.rb', /config.fixture_path/, '# config.fixture_path'
|
66
|
+
gsub_file 'spec/spec_helper.rb', /config.use_transactional_fixtures/, '# config.use_transactional_fixtures'
|
67
|
+
|
68
|
+
# reset your application database to a pristine state during testing
|
69
|
+
inject_into_file 'spec/spec_helper.rb', :before => "\nend" do
|
70
|
+
<<-RUBY
|
71
|
+
\n
|
72
|
+
# Clean up the database
|
73
|
+
require 'database_cleaner'
|
74
|
+
config.before(:suite) do
|
75
|
+
DatabaseCleaner.strategy = :truncation
|
76
|
+
DatabaseCleaner.orm = "mongoid"
|
77
|
+
end
|
78
|
+
|
79
|
+
config.before(:each) do
|
80
|
+
DatabaseCleaner.clean
|
81
|
+
end
|
82
|
+
RUBY
|
83
|
+
end
|
84
|
+
|
85
|
+
# remove either possible occurrence of "require rails/test_unit/railtie"
|
86
|
+
gsub_file 'config/application.rb', /require 'rails\/test_unit\/railtie'/, '# require "rails/test_unit/railtie"'
|
87
|
+
gsub_file 'config/application.rb', /require "rails\/test_unit\/railtie"/, '# require "rails/test_unit/railtie"'
|
88
|
+
|
89
|
+
# configure RSpec to use matchers from the mongoid-rspec gem
|
90
|
+
create_file 'spec/support/mongoid.rb' do
|
91
|
+
<<-RUBY
|
92
|
+
RSpec.configure do |config|
|
93
|
+
config.include Mongoid::Matchers
|
94
|
+
end
|
95
|
+
RUBY
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
if recipes.include? 'devise'
|
100
|
+
# add Devise test helpers
|
101
|
+
create_file 'spec/support/devise.rb' do
|
102
|
+
<<-RUBY
|
103
|
+
RSpec.configure do |config|
|
104
|
+
config.include Devise::TestHelpers, :type => :controller
|
105
|
+
end
|
106
|
+
RUBY
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
__END__
|
114
|
+
|
115
|
+
name: RSpec
|
116
|
+
description: "Use RSpec instead of TestUnit."
|
117
|
+
author: RailsApps
|
118
|
+
|
119
|
+
exclusive: unit_testing
|
120
|
+
category: testing
|
121
|
+
|
122
|
+
args: ["-T"]
|
123
|
+
|
124
|
+
config:
|
125
|
+
- rspec:
|
126
|
+
type: boolean
|
127
|
+
prompt: Would you like to use RSpec instead of TestUnit?
|
128
|
+
- factory_girl:
|
129
|
+
type: boolean
|
130
|
+
prompt: Would you like to use factory_girl for test fixtures with RSpec?
|
131
|
+
- machinist:
|
132
|
+
type: boolean
|
133
|
+
prompt: Would you like to use machinist for test fixtures with RSpec?
|
data/recipes/sass.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
if config['sass']
|
3
|
+
gem 'sass', '>= 3.1.12'
|
4
|
+
after_bundler do
|
5
|
+
create_file 'config/initializers/sass.rb' do <<-RUBY
|
6
|
+
Rails.application.config.generators.stylesheet_engine = :sass
|
7
|
+
RUBY
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
__END__
|
13
|
+
|
14
|
+
name: SASS
|
15
|
+
description: "Utilize SASS for really awesome stylesheets!"
|
16
|
+
author: mbleigh, mrc2407, & ashley_woodard
|
17
|
+
|
18
|
+
exclusive: css_replacement
|
19
|
+
category: assets
|
20
|
+
tags: [css]
|
21
|
+
|
22
|
+
config:
|
23
|
+
- sass:
|
24
|
+
type: boolean
|
25
|
+
prompt: Would you like to use SASS syntax instead of SCSS?
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/seed_database.rb
|
3
|
+
|
4
|
+
|
5
|
+
after_bundler do
|
6
|
+
|
7
|
+
say_wizard "SeedDatabase recipe running 'after bundler'"
|
8
|
+
|
9
|
+
run 'bundle exec rake db:migrate' unless recipes.include? 'mongoid'
|
10
|
+
|
11
|
+
if recipes.include? 'devise-invitable'
|
12
|
+
generate 'devise_invitable user'
|
13
|
+
unless recipes.include? 'mongoid'
|
14
|
+
run 'bundle exec rake db:migrate'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# clone the schema changes to the test database
|
19
|
+
run 'bundle exec rake db:test:prepare' unless recipes.include? 'mongoid'
|
20
|
+
|
21
|
+
if recipes.include? 'mongoid'
|
22
|
+
append_file 'db/seeds.rb' do <<-FILE
|
23
|
+
puts 'EMPTY THE MONGODB DATABASE'
|
24
|
+
Mongoid.master.collections.reject { |c| c.name =~ /^system/}.each(&:drop)
|
25
|
+
FILE
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
if recipes.include? 'devise'
|
30
|
+
if recipes.include? 'devise-confirmable'
|
31
|
+
append_file 'db/seeds.rb' do <<-FILE
|
32
|
+
puts 'SETTING UP DEFAULT USER LOGIN'
|
33
|
+
user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
|
34
|
+
puts 'New user created: ' << user.name
|
35
|
+
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
|
36
|
+
puts 'New user created: ' << user2.name
|
37
|
+
FILE
|
38
|
+
end
|
39
|
+
else
|
40
|
+
append_file 'db/seeds.rb' do <<-FILE
|
41
|
+
puts 'SETTING UP DEFAULT USER LOGIN'
|
42
|
+
user = User.create! :name => 'First User', :email => 'user@example.com', :password => 'please', :password_confirmation => 'please'
|
43
|
+
puts 'New user created: ' << user.name
|
44
|
+
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please'
|
45
|
+
puts 'New user created: ' << user2.name
|
46
|
+
FILE
|
47
|
+
end
|
48
|
+
end
|
49
|
+
if recipes.include? 'authorization'
|
50
|
+
append_file 'db/seeds.rb' do <<-FILE
|
51
|
+
user.add_role :admin
|
52
|
+
FILE
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
after_everything do
|
62
|
+
|
63
|
+
say_wizard "seeding the database"
|
64
|
+
run 'bundle exec rake db:seed'
|
65
|
+
run 'rake db:mongoid:create_indexes' if recipes.include? 'mongoid'
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
__END__
|
70
|
+
|
71
|
+
name: SeedDatabase
|
72
|
+
description: "Create a database seed file with a default user."
|
73
|
+
author: RailsApps
|
74
|
+
|
75
|
+
category: other
|
76
|
+
tags: [utilities, configuration]
|
@@ -0,0 +1,43 @@
|
|
1
|
+
gem 'settingslogic'
|
2
|
+
|
3
|
+
say_wizard "Generating config/application.yml..."
|
4
|
+
|
5
|
+
append_file "config/application.rb", <<-RUBY
|
6
|
+
|
7
|
+
require 'settings'
|
8
|
+
RUBY
|
9
|
+
|
10
|
+
create_file "lib/settings.rb", <<-RUBY
|
11
|
+
class Settings < Settingslogic
|
12
|
+
source "#\{Rails.root\}/config/application.yml"
|
13
|
+
namespace Rails.env
|
14
|
+
end
|
15
|
+
|
16
|
+
RUBY
|
17
|
+
|
18
|
+
create_file "config/application.yml", <<-YAML
|
19
|
+
defaults: &defaults
|
20
|
+
cool:
|
21
|
+
saweet: nested settings
|
22
|
+
neat_setting: 24
|
23
|
+
awesome_setting: <%= "Did you know 5 + 5 = #{5 + 5}?" %>
|
24
|
+
|
25
|
+
development:
|
26
|
+
<<: *defaults
|
27
|
+
neat_setting: 800
|
28
|
+
|
29
|
+
test:
|
30
|
+
<<: *defaults
|
31
|
+
|
32
|
+
production:
|
33
|
+
<<: *defaults
|
34
|
+
YAML
|
35
|
+
|
36
|
+
__END__
|
37
|
+
|
38
|
+
name: Settingslogic
|
39
|
+
description: "A simple and straightforward settings solution that uses an ERB enabled YAML file and a singleton design pattern."
|
40
|
+
author: elandesign
|
41
|
+
|
42
|
+
category: other
|
43
|
+
tags: [utilities, configuration]
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/gmgp/rails_apps_composer/blob/master/recipes/simple_form.rb
|
3
|
+
|
4
|
+
case config['form_option']
|
5
|
+
when 'no'
|
6
|
+
say_wizard "Form help recipe skipped."
|
7
|
+
when 'simple_form'
|
8
|
+
gem 'simple_form'
|
9
|
+
# for external test
|
10
|
+
recipes << 'simple_form'
|
11
|
+
when 'simple_form_bootstrap'
|
12
|
+
gem 'simple_form'
|
13
|
+
# for external test
|
14
|
+
recipes << 'simple_form'
|
15
|
+
recipes << 'simple_form_bootstrap'
|
16
|
+
else
|
17
|
+
say_wizard "Form help recipe skipped."
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
after_bundler do
|
23
|
+
|
24
|
+
say_wizard "Simple form recipe running 'after bundler'"
|
25
|
+
|
26
|
+
case config['form_option']
|
27
|
+
when 'simple_form'
|
28
|
+
generate 'simple_form:install'
|
29
|
+
when 'simple_form_bootstrap'
|
30
|
+
if recipes.include? 'bootstrap'
|
31
|
+
generate 'simple_form:install --bootstrap'
|
32
|
+
else
|
33
|
+
say_wizard "Bootstrap not found."
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
__END__
|
40
|
+
|
41
|
+
name: SimpleForm
|
42
|
+
description: "Check for 'simple_form'."
|
43
|
+
author: Gmgp
|
44
|
+
|
45
|
+
category: other
|
46
|
+
tags: [utilities, configuration]
|
47
|
+
|
48
|
+
run_after: [html5]
|
49
|
+
|
50
|
+
config:
|
51
|
+
- form_option:
|
52
|
+
type: multiple_choice
|
53
|
+
prompt: "Which form gem would you like?"
|
54
|
+
choices: [["None", no], ["simple form", simple_form], ["simple form (bootstrap)", simple_form_bootstrap]]
|
data/recipes/slim.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Application template recipe for the rails_apps_composer. Check for a newer version here:
|
2
|
+
# https://github.com/RailsApps/rails_apps_composer/blob/master/recipes/slim.rb
|
3
|
+
|
4
|
+
if config['slim']
|
5
|
+
gem 'slim', '~> 1.0'
|
6
|
+
gem 'slim-rails', '~> 1.0.3', :group => :development
|
7
|
+
else
|
8
|
+
recipes.delete('slim')
|
9
|
+
end
|
10
|
+
|
11
|
+
after_bundler do
|
12
|
+
|
13
|
+
say_wizard "Slim recipe running 'after bundler'"
|
14
|
+
|
15
|
+
remove_file 'app/views/layouts/application.html.erb'
|
16
|
+
# There is Slim code in this script. Changing the indentation is perilous between SLIMs.
|
17
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
18
|
+
create_file 'app/views/layouts/application.html.slim' do
|
19
|
+
<<-'SLIM'
|
20
|
+
doctype html
|
21
|
+
html
|
22
|
+
head
|
23
|
+
title App_Name
|
24
|
+
= stylesheet_link_tag "application", :media => "all"
|
25
|
+
= javascript_include_tag "application"
|
26
|
+
= csrf_meta_tags
|
27
|
+
body
|
28
|
+
= yield
|
29
|
+
SLIM
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
__END__
|
35
|
+
|
36
|
+
name: SLIM
|
37
|
+
description: "Utilize Slim instead of ERB."
|
38
|
+
author: claudiob
|
39
|
+
|
40
|
+
category: templating
|
41
|
+
exclusive: templating
|
42
|
+
|
43
|
+
config:
|
44
|
+
- slim:
|
45
|
+
type: boolean
|
46
|
+
prompt: Would you like to use Slim instead of ERB?
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
after_bundler do
|
3
|
+
|
4
|
+
say_wizard "HomePage recipe running 'after bundler'"
|
5
|
+
|
6
|
+
# remove the default home page
|
7
|
+
remove_file 'public/index.html'
|
8
|
+
|
9
|
+
# create a home controller and view
|
10
|
+
generate(:controller, "static home")
|
11
|
+
|
12
|
+
# set up a simple home page (with placeholder content)
|
13
|
+
if recipes.include? 'haml'
|
14
|
+
remove_file 'app/views/static/home.html.haml'
|
15
|
+
# There is Haml code in this script. Changing the indentation is perilous between HAMLs.
|
16
|
+
# We have to use single-quote-style-heredoc to avoid interpolation.
|
17
|
+
create_file 'app/views/static/home.html.haml' do
|
18
|
+
<<-'HAML'
|
19
|
+
%h3 Home
|
20
|
+
HAML
|
21
|
+
end
|
22
|
+
else
|
23
|
+
remove_file 'app/views/static/home.html.erb'
|
24
|
+
create_file 'app/views/static/home.html.erb' do
|
25
|
+
<<-ERB
|
26
|
+
<h3>Home</h3>
|
27
|
+
ERB
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# set routes
|
32
|
+
gsub_file 'config/routes.rb', /get \"static\/home\"/, 'root to: "static#home"'
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
__END__
|
37
|
+
|
38
|
+
name: StaticPage
|
39
|
+
description: "Create a simple home page (creates a static controller and view)."
|
40
|
+
author: RailsApps
|
41
|
+
|
42
|
+
category: other
|
43
|
+
tags: [utilities, configuration]
|