phoenixbricks 3.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +674 -0
- data/README.md +85 -0
- data/bin/rbricks +5 -0
- data/lib/railsbricks.rb +115 -0
- data/lib/railsbricks/app_generator.rb +352 -0
- data/lib/railsbricks/assets/config/admin_post_routes.rbr +3 -0
- data/lib/railsbricks/assets/config/application.yml +9 -0
- data/lib/railsbricks/assets/config/contact_routes.rbr +2 -0
- data/lib/railsbricks/assets/config/initializers/devise_email/devise.rb +267 -0
- data/lib/railsbricks/assets/config/initializers/devise_username/devise.rb +267 -0
- data/lib/railsbricks/assets/config/post_routes.rbr +2 -0
- data/lib/railsbricks/assets/config/routes.rb +15 -0
- data/lib/railsbricks/assets/config/unicorn.rb +22 -0
- data/lib/railsbricks/assets/controllers/admin/base_controller.rb +10 -0
- data/lib/railsbricks/assets/controllers/admin/devise_email/users_controller.rb +66 -0
- data/lib/railsbricks/assets/controllers/admin/devise_username/users_controller.rb +69 -0
- data/lib/railsbricks/assets/controllers/admin/posts_controller.rb +73 -0
- data/lib/railsbricks/assets/controllers/brick_contact.rbr +23 -0
- data/lib/railsbricks/assets/controllers/devise_email/application_controller.rb +54 -0
- data/lib/railsbricks/assets/controllers/devise_username/application_controller.rb +56 -0
- data/lib/railsbricks/assets/controllers/pages_controller.rb +13 -0
- data/lib/railsbricks/assets/controllers/posts_controller.rbr +10 -0
- data/lib/railsbricks/assets/database/postgresql.yml +12 -0
- data/lib/railsbricks/assets/database/sqlite3.yml +8 -0
- data/lib/railsbricks/assets/gemfile/Gemfile +44 -0
- data/lib/railsbricks/assets/git/gitignore +30 -0
- data/lib/railsbricks/assets/javascripts/analytics.js.coffee +5 -0
- data/lib/railsbricks/assets/lib/markdown_writer.rb +19 -0
- data/lib/railsbricks/assets/mailers/contact_mailer.rb +13 -0
- data/lib/railsbricks/assets/migrations/20141010133702_create_posts.rb +17 -0
- data/lib/railsbricks/assets/migrations/devise_email/20141010133701_devise_create_users.rb +48 -0
- data/lib/railsbricks/assets/migrations/devise_username/20141010133701_devise_create_users.rb +54 -0
- data/lib/railsbricks/assets/models/devise_email/user.rb +41 -0
- data/lib/railsbricks/assets/models/devise_username/user.rb +57 -0
- data/lib/railsbricks/assets/models/post.rb +30 -0
- data/lib/railsbricks/assets/procfile/Procfile +1 -0
- data/lib/railsbricks/assets/seeds/devise_email/seeds_no_test_users.rb +11 -0
- data/lib/railsbricks/assets/seeds/devise_email/seeds_test_users.rb +24 -0
- data/lib/railsbricks/assets/seeds/devise_username/seeds_no_test_users.rb +12 -0
- data/lib/railsbricks/assets/seeds/devise_username/seeds_test_users.rb +26 -0
- data/lib/railsbricks/assets/stylesheets/application.scss +6 -0
- data/lib/railsbricks/assets/stylesheets/railsbricks_custom.scss +562 -0
- data/lib/railsbricks/assets/views/admin/base/admin_posts_link.rbr +1 -0
- data/lib/railsbricks/assets/views/admin/base/devise_email/index.html.erb +41 -0
- data/lib/railsbricks/assets/views/admin/base/devise_username/index.html.erb +41 -0
- data/lib/railsbricks/assets/views/admin/posts/_form.html.erb +54 -0
- data/lib/railsbricks/assets/views/admin/posts/dashboard.html.erb +9 -0
- data/lib/railsbricks/assets/views/admin/posts/drafts.html.erb +23 -0
- data/lib/railsbricks/assets/views/admin/posts/edit.html.erb +10 -0
- data/lib/railsbricks/assets/views/admin/posts/index.html.erb +23 -0
- data/lib/railsbricks/assets/views/admin/posts/new.html.erb +6 -0
- data/lib/railsbricks/assets/views/admin/users/devise_email/edit.html.erb +65 -0
- data/lib/railsbricks/assets/views/admin/users/devise_email/index.html.erb +54 -0
- data/lib/railsbricks/assets/views/admin/users/devise_username/edit.html.erb +74 -0
- data/lib/railsbricks/assets/views/admin/users/devise_username/index.html.erb +56 -0
- data/lib/railsbricks/assets/views/contact_mailer/contact_message.html.erb +5 -0
- data/lib/railsbricks/assets/views/devise/allow_signup_links.rbr +11 -0
- data/lib/railsbricks/assets/views/devise/devise_email/confirmations/new.html.erb +31 -0
- data/lib/railsbricks/assets/views/devise/devise_email/mailer/confirmation_instructions.html.erb +12 -0
- data/lib/railsbricks/assets/views/devise/devise_email/mailer/reset_password_instructions.html.erb +15 -0
- data/lib/railsbricks/assets/views/devise/devise_email/passwords/edit.html.erb +43 -0
- data/lib/railsbricks/assets/views/devise/devise_email/passwords/new.html.erb +31 -0
- data/lib/railsbricks/assets/views/devise/devise_email/registrations/edit.html.erb +63 -0
- data/lib/railsbricks/assets/views/devise/devise_email/registrations/new.html.erb +49 -0
- data/lib/railsbricks/assets/views/devise/devise_email/sessions/new.html.erb +49 -0
- data/lib/railsbricks/assets/views/devise/devise_email/shared/_links.erb +19 -0
- data/lib/railsbricks/assets/views/devise/devise_username/confirmations/new.html.erb +31 -0
- data/lib/railsbricks/assets/views/devise/devise_username/mailer/confirmation_instructions.html.erb +12 -0
- data/lib/railsbricks/assets/views/devise/devise_username/mailer/reset_password_instructions.html.erb +15 -0
- data/lib/railsbricks/assets/views/devise/devise_username/passwords/edit.html.erb +43 -0
- data/lib/railsbricks/assets/views/devise/devise_username/passwords/new.html.erb +31 -0
- data/lib/railsbricks/assets/views/devise/devise_username/registrations/edit.html.erb +63 -0
- data/lib/railsbricks/assets/views/devise/devise_username/registrations/new.html.erb +58 -0
- data/lib/railsbricks/assets/views/devise/devise_username/sessions/new.html.erb +49 -0
- data/lib/railsbricks/assets/views/devise/devise_username/shared/_links.erb +19 -0
- data/lib/railsbricks/assets/views/layouts/_navigation_links.html.erb +15 -0
- data/lib/railsbricks/assets/views/layouts/brick_analytics.rbr +11 -0
- data/lib/railsbricks/assets/views/pages/contact.html.erb +46 -0
- data/lib/railsbricks/assets/views/pages/inside.html.erb +4 -0
- data/lib/railsbricks/assets/views/pages/posts.html.erb +18 -0
- data/lib/railsbricks/assets/views/pages/show_post.html.erb +6 -0
- data/lib/railsbricks/auth_builder.rb +147 -0
- data/lib/railsbricks/config_helpers.rb +27 -0
- data/lib/railsbricks/config_values.rb +14 -0
- data/lib/railsbricks/errors.rb +18 -0
- data/lib/railsbricks/file_helpers.rb +54 -0
- data/lib/railsbricks/foundation/README.md +24 -0
- data/lib/railsbricks/foundation/Rakefile +6 -0
- data/lib/railsbricks/foundation/app/assets/images/.keep +0 -0
- data/lib/railsbricks/foundation/app/assets/images/apple-touch-icon-precomposed.png +0 -0
- data/lib/railsbricks/foundation/app/assets/images/apple-touch-icon.png +0 -0
- data/lib/railsbricks/foundation/app/assets/images/favicon.ico +0 -0
- data/lib/railsbricks/foundation/app/assets/javascripts/application.js +17 -0
- data/lib/railsbricks/foundation/app/assets/javascripts/common.js +7 -0
- data/lib/railsbricks/foundation/app/controllers/application_controller.rb +5 -0
- data/lib/railsbricks/foundation/app/controllers/concerns/.keep +0 -0
- data/lib/railsbricks/foundation/app/controllers/pages_controller.rb +7 -0
- data/lib/railsbricks/foundation/app/helpers/application_helper.rb +7 -0
- data/lib/railsbricks/foundation/app/helpers/email_helper.rb +5 -0
- data/lib/railsbricks/foundation/app/mailers/.keep +0 -0
- data/lib/railsbricks/foundation/app/models/.keep +0 -0
- data/lib/railsbricks/foundation/app/models/concerns/.keep +0 -0
- data/lib/railsbricks/foundation/app/views/layouts/_footer.html.erb +18 -0
- data/lib/railsbricks/foundation/app/views/layouts/_messages.html.erb +9 -0
- data/lib/railsbricks/foundation/app/views/layouts/_navigation.html.erb +18 -0
- data/lib/railsbricks/foundation/app/views/layouts/_navigation_links.html.erb +3 -0
- data/lib/railsbricks/foundation/app/views/layouts/application.html.erb +38 -0
- data/lib/railsbricks/foundation/app/views/pages/home.html.erb +2 -0
- data/lib/railsbricks/foundation/bin/bundle +3 -0
- data/lib/railsbricks/foundation/bin/rails +4 -0
- data/lib/railsbricks/foundation/bin/rake +4 -0
- data/lib/railsbricks/foundation/config.ru +4 -0
- data/lib/railsbricks/foundation/config/application.rb +34 -0
- data/lib/railsbricks/foundation/config/boot.rb +4 -0
- data/lib/railsbricks/foundation/config/environment.rb +5 -0
- data/lib/railsbricks/foundation/config/environments/development.rb +41 -0
- data/lib/railsbricks/foundation/config/environments/production.rb +95 -0
- data/lib/railsbricks/foundation/config/environments/test.rb +51 -0
- data/lib/railsbricks/foundation/config/initializers/backtrace_silencers.rb +7 -0
- data/lib/railsbricks/foundation/config/initializers/date_format.rb +27 -0
- data/lib/railsbricks/foundation/config/initializers/filter_parameter_logging.rb +4 -0
- data/lib/railsbricks/foundation/config/initializers/friendly_id.rb +88 -0
- data/lib/railsbricks/foundation/config/initializers/inflections.rb +16 -0
- data/lib/railsbricks/foundation/config/initializers/kaminari_config.rb +10 -0
- data/lib/railsbricks/foundation/config/initializers/mime_types.rb +5 -0
- data/lib/railsbricks/foundation/config/initializers/secret_token.rb +25 -0
- data/lib/railsbricks/foundation/config/initializers/session_store.rb +3 -0
- data/lib/railsbricks/foundation/config/initializers/wrap_parameters.rb +14 -0
- data/lib/railsbricks/foundation/config/locales/en.yml +23 -0
- data/lib/railsbricks/foundation/config/routes.rb +7 -0
- data/lib/railsbricks/foundation/db/migrate/20131103142222_create_friendly_id_slugs.rb +15 -0
- data/lib/railsbricks/foundation/db/schema.rb +29 -0
- data/lib/railsbricks/foundation/db/seeds.rb +0 -0
- data/lib/railsbricks/foundation/lib/assets/.keep +0 -0
- data/lib/railsbricks/foundation/lib/tasks/.keep +0 -0
- data/lib/railsbricks/foundation/public/404.html +58 -0
- data/lib/railsbricks/foundation/public/422.html +58 -0
- data/lib/railsbricks/foundation/public/500.html +57 -0
- data/lib/railsbricks/foundation/public/favicon.ico +0 -0
- data/lib/railsbricks/foundation/public/robots.txt +5 -0
- data/lib/railsbricks/foundation/vendor/assets/javascripts/.keep +0 -0
- data/lib/railsbricks/foundation/vendor/assets/stylesheets/.keep +0 -0
- data/lib/railsbricks/gemfile_builder.rb +118 -0
- data/lib/railsbricks/menu.rb +533 -0
- data/lib/railsbricks/post_builder.rb +103 -0
- data/lib/railsbricks/string_helpers.rb +39 -0
- data/lib/railsbricks/style_builder.rb +97 -0
- data/lib/railsbricks/ui_helpers.rb +11 -0
- data/lib/railsbricks/validator.rb +68 -0
- data/lib/railsbricks/version.rb +34 -0
- data/railsbricks.gemspec +16 -0
- metadata +198 -0
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/404.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
54
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,58 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/422.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>The change you wanted was rejected.</h1>
|
54
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
55
|
+
</div>
|
56
|
+
<p>If you are the application owner check the logs for more information.</p>
|
57
|
+
</body>
|
58
|
+
</html>
|
@@ -0,0 +1,57 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
5
|
+
<style>
|
6
|
+
body {
|
7
|
+
background-color: #EFEFEF;
|
8
|
+
color: #2E2F30;
|
9
|
+
text-align: center;
|
10
|
+
font-family: arial, sans-serif;
|
11
|
+
}
|
12
|
+
|
13
|
+
div.dialog {
|
14
|
+
width: 25em;
|
15
|
+
margin: 4em auto 0 auto;
|
16
|
+
border: 1px solid #CCC;
|
17
|
+
border-right-color: #999;
|
18
|
+
border-left-color: #999;
|
19
|
+
border-bottom-color: #BBB;
|
20
|
+
border-top: #B00100 solid 4px;
|
21
|
+
border-top-left-radius: 9px;
|
22
|
+
border-top-right-radius: 9px;
|
23
|
+
background-color: white;
|
24
|
+
padding: 7px 4em 0 4em;
|
25
|
+
}
|
26
|
+
|
27
|
+
h1 {
|
28
|
+
font-size: 100%;
|
29
|
+
color: #730E15;
|
30
|
+
line-height: 1.5em;
|
31
|
+
}
|
32
|
+
|
33
|
+
body > p {
|
34
|
+
width: 33em;
|
35
|
+
margin: 0 auto 1em;
|
36
|
+
padding: 1em 0;
|
37
|
+
background-color: #F7F7F7;
|
38
|
+
border: 1px solid #CCC;
|
39
|
+
border-right-color: #999;
|
40
|
+
border-bottom-color: #999;
|
41
|
+
border-bottom-left-radius: 4px;
|
42
|
+
border-bottom-right-radius: 4px;
|
43
|
+
border-top-color: #DADADA;
|
44
|
+
color: #666;
|
45
|
+
box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
|
46
|
+
}
|
47
|
+
</style>
|
48
|
+
</head>
|
49
|
+
|
50
|
+
<body>
|
51
|
+
<!-- This file lives in public/500.html -->
|
52
|
+
<div class="dialog">
|
53
|
+
<h1>We're sorry, but something went wrong.</h1>
|
54
|
+
</div>
|
55
|
+
<p>If you are the application owner check the logs for more information.</p>
|
56
|
+
</body>
|
57
|
+
</html>
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require_relative "ui_helpers"
|
3
|
+
require_relative "version"
|
4
|
+
require_relative "string_helpers"
|
5
|
+
require_relative "file_helpers"
|
6
|
+
require_relative "config_values"
|
7
|
+
|
8
|
+
module GemfileBuilder
|
9
|
+
ANNOTATE = "2.6.10"
|
10
|
+
BCRYPT = "3.1.10"
|
11
|
+
BOOTSTRAP_SASS = "3.3.5.1"
|
12
|
+
BYEBUG = "5.0.0"
|
13
|
+
COFFEE_RAILS = "4.1.0"
|
14
|
+
DEVISE = "3.5.1"
|
15
|
+
FIGARO = "1.1.1"
|
16
|
+
FONT_AWESOME_SASS = "4.3.2.1"
|
17
|
+
FRIENDLY_ID = "5.1.0"
|
18
|
+
JBUILDER = "2.3.0"
|
19
|
+
JQUERY_RAILS = "4.0.4"
|
20
|
+
KAMINARI = "0.16.3"
|
21
|
+
REDCARPET = "3.3.2"
|
22
|
+
SASS_RAILS = "5.0.3"
|
23
|
+
SQLITE3 = "1.3.10"
|
24
|
+
SPRING = "1.3.6"
|
25
|
+
TURBOLINKS = "2.5.3"
|
26
|
+
UGLIFIER = "2.7.1"
|
27
|
+
WEB_CONSOLE = "2.1.3"
|
28
|
+
|
29
|
+
|
30
|
+
def self.build_gemfile(app_dir, options)
|
31
|
+
new_line(2)
|
32
|
+
wputs "----> Generating Gemfile ...", :info
|
33
|
+
|
34
|
+
rbricks_dir = File.dirname(__FILE__)
|
35
|
+
add_gem = ""
|
36
|
+
|
37
|
+
# Copy base Gemfile
|
38
|
+
FileUtils.cp_r(rbricks_dir + "/assets/gemfile/Gemfile", app_dir)
|
39
|
+
|
40
|
+
# Set Ruby version
|
41
|
+
FileHelpers.replace_string(/BRICK_RUBY_VERSION/, options[:ruby_version], app_dir + "/Gemfile")
|
42
|
+
|
43
|
+
# Database
|
44
|
+
if options[:development_db] == "sqlite"
|
45
|
+
add_gem = "# SQLite 3\ngroup :development, :test do\n gem 'sqlite3', 'BRICK_SQLITE3_VERSION'\nend"
|
46
|
+
else
|
47
|
+
add_gem = "# PostgreSQL\ngem 'pg'"
|
48
|
+
end
|
49
|
+
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
|
50
|
+
|
51
|
+
# Devise
|
52
|
+
if options[:devise]
|
53
|
+
add_gem = "# Devise: https://github.com/plataformatec/devise\ngem 'devise', 'BRICK_DEVISE_VERSION'"
|
54
|
+
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
|
55
|
+
end
|
56
|
+
|
57
|
+
# Markdown (needed if Post resources)
|
58
|
+
if options[:post_resources]
|
59
|
+
add_gem = "# Redcarpet: https://github.com/vmg/redcarpet\ngem 'redcarpet', 'BRICK_REDCARPET_VERSION'"
|
60
|
+
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Heroku
|
64
|
+
if options[:production_settings][:target] == "heroku"
|
65
|
+
add_gem = "# Rails 12factor for Heroku: https://github.com/heroku/rails_12factor\ngroup :production do\n gem 'rails_12factor'\nend"
|
66
|
+
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
|
67
|
+
if options[:development_db] == "sqlite"
|
68
|
+
add_gem = "# PostgreSQL gem for Heroku\ngroup :production do\n gem 'pg'\nend"
|
69
|
+
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Unicorn
|
74
|
+
if options[:production_settings][:unicorn]
|
75
|
+
add_gem = "# Unicorn: http://unicorn.bogomips.org\ngroup :production do\n gem 'unicorn'\nend"
|
76
|
+
FileHelpers.add_to_file(app_dir + "/Gemfile", add_gem)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Set gem versions
|
80
|
+
FileHelpers.replace_string(/BRICK_ANNOTATE_VERSION/, ANNOTATE, app_dir + "/Gemfile")
|
81
|
+
FileHelpers.replace_string(/BRICK_BCRYPT_VERSION/, BCRYPT, app_dir + "/Gemfile")
|
82
|
+
FileHelpers.replace_string(/BRICK_BOOTSTRAP_SASS_VERSION/, BOOTSTRAP_SASS, app_dir + "/Gemfile")
|
83
|
+
FileHelpers.replace_string(/BRICK_BYEBUG_VERSION/, BYEBUG, app_dir + "/Gemfile")
|
84
|
+
FileHelpers.replace_string(/BRICK_COFFEE_RAILS_VERSION/, COFFEE_RAILS, app_dir + "/Gemfile")
|
85
|
+
FileHelpers.replace_string(/BRICK_DEVISE_VERSION/, DEVISE, app_dir + "/Gemfile")
|
86
|
+
FileHelpers.replace_string(/BRICK_FIGARO_VERSION/, FIGARO, app_dir + "/Gemfile")
|
87
|
+
FileHelpers.replace_string(/BRICK_FONT_AWESOME_SASS_VERSION/, FONT_AWESOME_SASS, app_dir + "/Gemfile")
|
88
|
+
FileHelpers.replace_string(/BRICK_FRIENDLY_ID_VERSION/, FRIENDLY_ID, app_dir + "/Gemfile")
|
89
|
+
FileHelpers.replace_string(/BRICK_JBUILDER_VERSION/, JBUILDER, app_dir + "/Gemfile")
|
90
|
+
FileHelpers.replace_string(/BRICK_JQUERY_RAILS_VERSION/, JQUERY_RAILS, app_dir + "/Gemfile")
|
91
|
+
FileHelpers.replace_string(/BRICK_KAMINARI_VERSION/, KAMINARI, app_dir + "/Gemfile")
|
92
|
+
FileHelpers.replace_string(/BRICK_RAILS_VERSION/, options[:rails_version], app_dir + "/Gemfile")
|
93
|
+
FileHelpers.replace_string(/BRICK_REDCARPET_VERSION/, REDCARPET, app_dir + "/Gemfile")
|
94
|
+
FileHelpers.replace_string(/BRICK_SASS_RAILS_VERSION/, SASS_RAILS, app_dir + "/Gemfile")
|
95
|
+
FileHelpers.replace_string(/BRICK_SQLITE3_VERSION/, SQLITE3, app_dir + "/Gemfile")
|
96
|
+
FileHelpers.replace_string(/BRICK_SPRING_VERSION/, SPRING, app_dir + "/Gemfile")
|
97
|
+
FileHelpers.replace_string(/BRICK_TURBOLINKS_VERSION/, TURBOLINKS, app_dir + "/Gemfile")
|
98
|
+
FileHelpers.replace_string(/BRICK_UGLIFIER_VERSION/, UGLIFIER, app_dir + "/Gemfile")
|
99
|
+
FileHelpers.replace_string(/BRICK_WEB_CONSOLE_VERSION/, WEB_CONSOLE, app_dir + "/Gemfile")
|
100
|
+
|
101
|
+
new_line
|
102
|
+
wputs "----> Gemfile generated.", :info
|
103
|
+
|
104
|
+
rescue
|
105
|
+
Errors.display_error("Something went wrong and the Gemfile couldn't be generated. Stopping app creation.", true)
|
106
|
+
abort
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
def self.wputs(text, highlight = :none)
|
111
|
+
StringHelpers.wputs(text, highlight)
|
112
|
+
end
|
113
|
+
|
114
|
+
def self.new_line(lines=1)
|
115
|
+
StringHelpers.new_line(lines)
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
@@ -0,0 +1,533 @@
|
|
1
|
+
require_relative "ui_helpers"
|
2
|
+
require_relative "version"
|
3
|
+
require_relative "string_helpers"
|
4
|
+
require_relative "config_values"
|
5
|
+
require "etc"
|
6
|
+
|
7
|
+
class Menu
|
8
|
+
|
9
|
+
attr_accessor :options
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
@options = {railsbricks_version: Version.to_s}
|
13
|
+
end
|
14
|
+
|
15
|
+
def new_app_menu
|
16
|
+
# WELCOME
|
17
|
+
@options[:rails_version] = ConfigValues.rails_version
|
18
|
+
new_line
|
19
|
+
wputs '*****************************'
|
20
|
+
wputs "* *"
|
21
|
+
wputs "* RailsBricks #{Version.to_s} *"
|
22
|
+
wputs '* www.railsbricks.net *'
|
23
|
+
wputs "* *"
|
24
|
+
wputs "* using Rails #{@options[:rails_version]} *"
|
25
|
+
wputs "* *"
|
26
|
+
wputs '*****************************'
|
27
|
+
new_line(2)
|
28
|
+
|
29
|
+
# WIZARD CONFIG
|
30
|
+
wputs "- Do you want me to help you along the way by giving you tips?"
|
31
|
+
wputs "1. Sure, help me make the right choices (default)", :info
|
32
|
+
wputs "2. Nope, I already know how to use RailsBricks", :info
|
33
|
+
hints = answer() == "2" ? false : true
|
34
|
+
new_line(2)
|
35
|
+
|
36
|
+
# APP NAME
|
37
|
+
wputs "1. Your Rails App Name"
|
38
|
+
wputs "----------------------"
|
39
|
+
if hints
|
40
|
+
wputs "First of all, you need to give a name to your new app. I'll create it in #{Dir.pwd}/. Of course, only use a valid Rails app name.", :help
|
41
|
+
end
|
42
|
+
new_line
|
43
|
+
wputs "- What do you want to name your app?"
|
44
|
+
default_name = "railsbricks_#{4.times.map{ 0 + Random.rand(9)}.join}"
|
45
|
+
wputs "(default: #{default_name})"
|
46
|
+
@options[:app_name] = StringHelpers.sanitize(answer("App name:"))
|
47
|
+
@options[:app_name] = default_name if @options[:app_name].length < 1
|
48
|
+
@options[:rails_app_name] = StringHelpers.convert_to_app_name(@options[:app_name])
|
49
|
+
new_line(2)
|
50
|
+
|
51
|
+
# DEVELOPMENT ENVIRONMENT
|
52
|
+
wputs "2. Your Development Environment"
|
53
|
+
wputs "-------------------------------"
|
54
|
+
|
55
|
+
# ruby version
|
56
|
+
if hints
|
57
|
+
wputs "Before I can create your app, I need more information about your current development environment. Note that I don't support versions of Ruby older than 2.0.0.", :help
|
58
|
+
end
|
59
|
+
new_line
|
60
|
+
wputs "- Which version of Ruby do you want to use?"
|
61
|
+
wputs "1. 2.0.0", :info
|
62
|
+
wputs "2. 2.2.1", :info
|
63
|
+
wputs "3. 2.2.2 (default)", :info
|
64
|
+
choice = answer("Your choice (1-3):")
|
65
|
+
case choice
|
66
|
+
when "1"
|
67
|
+
@options[:ruby_version] = "2.0.0"
|
68
|
+
when "2"
|
69
|
+
@options[:ruby_version] = "2.2.1"
|
70
|
+
else
|
71
|
+
@options[:ruby_version] = "2.2.2"
|
72
|
+
end
|
73
|
+
new_line(2)
|
74
|
+
|
75
|
+
# gem command
|
76
|
+
if hints
|
77
|
+
wputs "On some systems, you can't install gems by issuing a simple 'gem install name_of_gem' command but need to prefix it with 'sudo' and issue 'sudo gem install name_of_gem'. If this is the case, you most likely will need to input your password at some point.", :help
|
78
|
+
end
|
79
|
+
new_line
|
80
|
+
wputs "- How do you usually install new gems?"
|
81
|
+
wputs "1. gem install name_of_gem (default)", :info
|
82
|
+
wputs "2. sudo gem install name_of_gem", :info
|
83
|
+
@options[:gem_command] = answer() == "2" ? "sudo gem" : "gem"
|
84
|
+
new_line(2)
|
85
|
+
|
86
|
+
# rake command
|
87
|
+
if hints
|
88
|
+
wputs "Do you usually run rake tasks by prefixing them with 'bundle exec'? I also need to know that.", :help
|
89
|
+
end
|
90
|
+
new_line
|
91
|
+
wputs "- How do you usually run rake tasks?"
|
92
|
+
wputs "1. rake some_task (default)", :info
|
93
|
+
wputs "2. bundle exec rake some_task", :info
|
94
|
+
@options[:rake_command] = answer() == "2" ? "bundle exec rake" : "rake"
|
95
|
+
new_line(2)
|
96
|
+
|
97
|
+
# development database
|
98
|
+
if hints
|
99
|
+
wputs "By default, Rails uses SQLite 3 to store the development database. I can change that to PostgreSQL but you have to make sure that a PostgreSQL server is installed and currently running. If it doesn't, the app creation will fail as I won't be able to create the development database.", :help
|
100
|
+
end
|
101
|
+
new_line
|
102
|
+
wputs "If you are on OS X, I struggle with the Postgres.app as the location of pg_config keeps changing between versions. If you want to use PostgreSQL, you'll have to use a full install which you can get through Homebrew by running 'brew install postgresql'.", :error
|
103
|
+
new_line
|
104
|
+
wputs "- Which database engine do you want to use for development?"
|
105
|
+
wputs "1. SQLite 3 (default)", :info
|
106
|
+
wputs "2. PostgreSQL", :info
|
107
|
+
@options[:development_db] = answer() == "2" ? "postgresql" : "sqlite"
|
108
|
+
@options[:db_config] = {}
|
109
|
+
new_line(2)
|
110
|
+
|
111
|
+
# postgresql config
|
112
|
+
if @options[:development_db] == "postgresql"
|
113
|
+
if hints
|
114
|
+
wputs "Right, you decided to go with PostgreSQL. Note that I will only create a development config. You'll have to manually edit #{@options[:app_name]}/config/database.yml for test and production. I will create the database so make sure it doesn't exist yet.", :help
|
115
|
+
new_line
|
116
|
+
end
|
117
|
+
|
118
|
+
# hostname
|
119
|
+
wputs "- Your database server hostname?"
|
120
|
+
wputs "example: 192.168.1.1, localhost, ...", :help
|
121
|
+
wputs "(default: localhost)"
|
122
|
+
choice = answer("Hostname:")
|
123
|
+
@options[:db_config][:server] = choice == "" ? "localhost" : choice
|
124
|
+
new_line(2)
|
125
|
+
|
126
|
+
# port
|
127
|
+
wputs "- What is the database port number?"
|
128
|
+
wputs "(default: 5432)"
|
129
|
+
choice = answer("Port:")
|
130
|
+
@options[:db_config][:port] = choice == "" ? 5432 : choice.to_i
|
131
|
+
new_line(2)
|
132
|
+
|
133
|
+
# name
|
134
|
+
wputs "- What is the development database name?"
|
135
|
+
wputs "(default #{@options[:app_name].downcase}_development)"
|
136
|
+
choice = StringHelpers.sanitize(answer("Database name:"))
|
137
|
+
@options[:db_config][:name] = choice == "" ? "#{@options[:app_name].downcase}_development" : choice
|
138
|
+
new_line(2)
|
139
|
+
|
140
|
+
# username
|
141
|
+
wputs "- What is your database username?"
|
142
|
+
wputs "(default: #{Etc.getlogin})"
|
143
|
+
choice = answer("Database username:")
|
144
|
+
@options[:db_config][:username] = choice == "" ? "#{Etc.getlogin}" : choice
|
145
|
+
new_line(2)
|
146
|
+
|
147
|
+
# password
|
148
|
+
wputs "- What is your database user password?"
|
149
|
+
wputs "tip: leave blank for none", :help
|
150
|
+
wputs "(default: none)"
|
151
|
+
@options[:db_config][:password] = answer("Database user password:")
|
152
|
+
new_line(2)
|
153
|
+
|
154
|
+
else
|
155
|
+
@options[:db_config][:server] = nil
|
156
|
+
@options[:db_config][:port] = nil
|
157
|
+
@options[:db_config][:name] = nil
|
158
|
+
@options[:db_config][:username] = nil
|
159
|
+
@options[:db_config][:password] = nil
|
160
|
+
end
|
161
|
+
|
162
|
+
# git local
|
163
|
+
if hints
|
164
|
+
wputs "I can create a local and a remote Git repository for you. If you choose to do so, I will also create a specific .gitignore file to make sure your secrets are not distributed with your code.", :help
|
165
|
+
end
|
166
|
+
new_line
|
167
|
+
wputs "- Create a local Git repository?"
|
168
|
+
wputs "1. Yes (default)", :info
|
169
|
+
wputs "2. No", :info
|
170
|
+
answer() == "2" ? @options[:local_git] = false : @options[:local_git] = true
|
171
|
+
new_line(2)
|
172
|
+
|
173
|
+
# git remote
|
174
|
+
if @options[:local_git]
|
175
|
+
wputs "- Add a remote Git repository?"
|
176
|
+
wputs "1. Yes", :info
|
177
|
+
wputs "2. No (default)", :info
|
178
|
+
answer() == "1" ? @options[:remote_git] = true : @options[:remote_git] = false
|
179
|
+
new_line(2)
|
180
|
+
else
|
181
|
+
@options[:remote_git] = false
|
182
|
+
end
|
183
|
+
|
184
|
+
# git remote url
|
185
|
+
if @options[:remote_git]
|
186
|
+
wputs "- What is the URL of your remote Git repository?"
|
187
|
+
wputs "example: https://github.com/yourname/your_app.git", :help
|
188
|
+
@options[:git_url] = answer("Remote URL:")
|
189
|
+
new_line(2)
|
190
|
+
else
|
191
|
+
@options[:git_url] = ""
|
192
|
+
end
|
193
|
+
|
194
|
+
|
195
|
+
# APP INFO
|
196
|
+
wputs "3. About Your App"
|
197
|
+
wputs "-----------------"
|
198
|
+
|
199
|
+
# devise
|
200
|
+
if hints
|
201
|
+
wputs "If your app will have users, I can create an authentication scheme using Devise. If you want me to create resources accessible from an admin zone (blog posts, for example), you will need to have an authentication scheme.", :help
|
202
|
+
end
|
203
|
+
new_line
|
204
|
+
wputs "- Create an authentication scheme?"
|
205
|
+
wputs "1. Yes (default)", :info
|
206
|
+
wputs "2. No", :info
|
207
|
+
@options[:devise] = answer() == "2" ? false : true
|
208
|
+
@options[:devise_config] = {}
|
209
|
+
new_line(2)
|
210
|
+
|
211
|
+
if @options[:devise]
|
212
|
+
# sign in
|
213
|
+
if hints
|
214
|
+
wputs "You can choose what credentials users will need to provide to sign in. Whether with a username and a password or with an email address and a password.", :help
|
215
|
+
new_line
|
216
|
+
end
|
217
|
+
wputs "- How will users sign in?"
|
218
|
+
wputs "1. With a username (default)", :info
|
219
|
+
wputs "2. With an email address", :info
|
220
|
+
@options[:devise_config][:scheme] = answer() == "2" ? "email" : "username"
|
221
|
+
new_line(2)
|
222
|
+
|
223
|
+
# allow sign up
|
224
|
+
if hints
|
225
|
+
wputs "If you don't want to allow new users to register, I can disable the sign up feature.", :help
|
226
|
+
new_line
|
227
|
+
end
|
228
|
+
wputs "- Allow new users to sign up?"
|
229
|
+
wputs "1. Yes, they can click on a 'sign up' button (default)", :info
|
230
|
+
wputs "2. No, I don't want to allow new users to sign up", :info
|
231
|
+
@options[:devise_config][:allow_signup] = answer() == "2" ? false : true
|
232
|
+
new_line(2)
|
233
|
+
|
234
|
+
# test users
|
235
|
+
if hints
|
236
|
+
wputs "I can also create 50 test users for you if you need.", :help
|
237
|
+
new_line
|
238
|
+
end
|
239
|
+
wputs "- Create test users?"
|
240
|
+
wputs "1. No, only create my Admin account (default)", :info
|
241
|
+
wputs "2. Yes, create 50", :info
|
242
|
+
@options[:devise_config][:test_users] = answer() == "2" ? true : false
|
243
|
+
new_line(2)
|
244
|
+
|
245
|
+
# post model
|
246
|
+
if hints
|
247
|
+
wputs "I can create a Post model which is useful if you intend to have a blog, news, articles, etc, in your app. The appropriate model, routes, controllers and views will be created and useable in the admin zone. You will be able to add new posts using the Markdown syntax. To change settings such as how many posts are displayed on a page, refer to the RailsBricks documentation.", :help
|
248
|
+
new_line
|
249
|
+
end
|
250
|
+
wputs "- Create Post resources?"
|
251
|
+
wputs "1. Yes", :info
|
252
|
+
wputs "2. No (default)", :info
|
253
|
+
@options[:post_resources] = answer() == "1" ? true : false
|
254
|
+
new_line(2)
|
255
|
+
else
|
256
|
+
@options[:devise_config][:scheme] = nil
|
257
|
+
@options[:devise_config][:allow_signup] = nil
|
258
|
+
@options[:devise_config][:test_users] = nil
|
259
|
+
@options[:post_resources] = false
|
260
|
+
end
|
261
|
+
|
262
|
+
# contact form
|
263
|
+
if hints
|
264
|
+
wputs "I can create a Contact form for you. Your visitors will be able to fill in their name, email address and their message to you. Note that I won't allow visitors to send you links in order to cut down on spam! To change the contact form settings, refer to the RailsBricks documentation.", :help
|
265
|
+
new_line
|
266
|
+
end
|
267
|
+
wputs "- Create a Contact form?"
|
268
|
+
wputs "1. Yes", :info
|
269
|
+
wputs "2. No (default)", :info
|
270
|
+
@options[:contact_form] = answer() == "1" ? true : false
|
271
|
+
new_line(2)
|
272
|
+
|
273
|
+
# google analytics
|
274
|
+
if hints
|
275
|
+
wputs "I can already generate the necessary bits of code for using Google Analytics. It will work with Turbolinks, don't worry. You will need to provide me with your Google Analytics Tracking ID. It's a string like UA-000000-01. If you don't have one yet, I will use UA-XXXXXX-XX and you can set it later within #{@options[:app_name]}/app/views/layouts/_footer.html.erb.", :help
|
276
|
+
new_line
|
277
|
+
end
|
278
|
+
wputs "- Use Google Analytics?"
|
279
|
+
wputs "1. Yes (default)", :info
|
280
|
+
wputs "2. No", :info
|
281
|
+
@options[:google_analytics] = answer() == "2" ? false : true
|
282
|
+
new_line(2)
|
283
|
+
|
284
|
+
if @options[:google_analytics]
|
285
|
+
wputs "- What is your Google Analytics tracking ID?"
|
286
|
+
wputs "(default: UA-XXXXXX-XX)"
|
287
|
+
choice = answer("Tracking ID:", false)
|
288
|
+
@options[:google_tracking_id] = choice == "" ? "UA-XXXXXX-XX" : choice
|
289
|
+
new_line(2)
|
290
|
+
else
|
291
|
+
@options[:google_tracking_id] = nil
|
292
|
+
end
|
293
|
+
|
294
|
+
# email settings
|
295
|
+
if hints
|
296
|
+
wputs "Your app can send emails. It is even required if you chose to add a contact form or let new users sign up. Let's go through the basic settings I need to know. If you choose not to configure your email settings now, you can do it at a later stage by editing the relevant section within #{@options[:app_name]}/config/application.yml.", :help
|
297
|
+
new_line
|
298
|
+
end
|
299
|
+
wputs "- Configure email settings?"
|
300
|
+
wputs "1. Yes (default)", :info
|
301
|
+
wputs "2. No", :info
|
302
|
+
@options[:email_settings] = answer() == "2" ? false : true
|
303
|
+
@options[:email_config] = {}
|
304
|
+
new_line(2)
|
305
|
+
|
306
|
+
if @options[:email_settings]
|
307
|
+
#sender
|
308
|
+
wputs "- What is the email address you will send emails from?"
|
309
|
+
wputs "example: someone@example.com", :help
|
310
|
+
@options[:email_config][:sender] = answer("Email address:")
|
311
|
+
new_line(2)
|
312
|
+
|
313
|
+
# smtp server
|
314
|
+
wputs "- What is your SMTP server address?"
|
315
|
+
wputs "example: smtp.example.com", :help
|
316
|
+
@options[:email_config][:smtp] = answer("SMTP server:")
|
317
|
+
new_line(2)
|
318
|
+
|
319
|
+
# domain
|
320
|
+
wputs "- What is the domain name of your SMTP server?"
|
321
|
+
wputs "example: 192.168.1.1, example.com, ...", :help
|
322
|
+
@options[:email_config][:domain] = answer("Domain name:")
|
323
|
+
new_line(2)
|
324
|
+
|
325
|
+
# port
|
326
|
+
wputs "- What is the SMTP server port number?"
|
327
|
+
wputs "(default: 587)"
|
328
|
+
choice = answer("SMTP port:")
|
329
|
+
@options[:email_config][:port] = choice == "" ? "587" : choice
|
330
|
+
new_line(2)
|
331
|
+
|
332
|
+
# username
|
333
|
+
wputs "- What is your SMTP username?"
|
334
|
+
@options[:email_config][:username] = answer("SMTP username:")
|
335
|
+
new_line(2)
|
336
|
+
|
337
|
+
# password
|
338
|
+
wputs "- What is your SMTP password?"
|
339
|
+
wputs "tip: it will be stored in #{@options[:app_name]}/config/application.yml but won't be tracked by Git", :help
|
340
|
+
@options[:email_config][:password] = answer("SMTP password:", false)
|
341
|
+
new_line(2)
|
342
|
+
|
343
|
+
else
|
344
|
+
@options[:email_config][:sender] = nil
|
345
|
+
@options[:email_config][:smtp] = nil
|
346
|
+
@options[:email_config][:domain] = nil
|
347
|
+
@options[:email_config][:port] = nil
|
348
|
+
@options[:email_config][:username] = nil
|
349
|
+
@options[:email_config][:password] = nil
|
350
|
+
end
|
351
|
+
|
352
|
+
# UI
|
353
|
+
wputs "4. Your App UI"
|
354
|
+
wputs "--------------"
|
355
|
+
@options[:ui] = {}
|
356
|
+
|
357
|
+
# body theme
|
358
|
+
if hints
|
359
|
+
wputs "I will use Bootstrap 3 to build the UI of your app. You can change Boostrap default values by editing #{@options[:app_name]}/app/assets/railsbricks_custom.scss.", :help
|
360
|
+
end
|
361
|
+
new_line
|
362
|
+
wputs "- Which UI scheme do you want to use for the content area?"
|
363
|
+
wputs "1. Light (default)", :info
|
364
|
+
wputs "2. Dark", :info
|
365
|
+
@options[:ui][:theme_background] = answer() == "2" ? "dark" : "light"
|
366
|
+
new_line(2)
|
367
|
+
|
368
|
+
# navbar theme
|
369
|
+
new_line
|
370
|
+
wputs "- Which UI scheme do you want to use for the navbar?"
|
371
|
+
wputs "1. Light", :info
|
372
|
+
wputs "2. Dark (default)", :info
|
373
|
+
@options[:ui][:theme_navbar] = answer() == "1" ? "light" : "dark"
|
374
|
+
new_line(2)
|
375
|
+
|
376
|
+
# footer theme
|
377
|
+
new_line
|
378
|
+
wputs "- Which UI scheme do you want to use for the footer?"
|
379
|
+
wputs "1. Light", :info
|
380
|
+
wputs "2. Dark (default)", :info
|
381
|
+
@options[:ui][:theme_footer] = answer() == "1" ? "light" : "dark"
|
382
|
+
new_line(2)
|
383
|
+
|
384
|
+
|
385
|
+
# primary color
|
386
|
+
if hints
|
387
|
+
wputs "The primary color is expressed as a hexadecimal value such as #663399 (purple). In #{@options[:app_name]}/app/assets/railsbricks_custom.scss, the primary color is assigned to a variable named '$brand-primary'. It is used as the base color for links, default buttons, etc... .", :help
|
388
|
+
new_line
|
389
|
+
end
|
390
|
+
wputs "- What primary color do you want to use?"
|
391
|
+
wputs "tip: expressed as hexadecimal such as #663399", :help
|
392
|
+
wputs "(default: #428BCA)"
|
393
|
+
choice = answer("Primary color:")
|
394
|
+
@options[:ui][:color] = choice == "" ? "#428bca" : choice.downcase
|
395
|
+
new_line(2)
|
396
|
+
|
397
|
+
# font
|
398
|
+
if hints
|
399
|
+
wputs "Fonts are an important part of you app. You can see what each proposed font looks like by searching for their names on Google Fonts.", :help
|
400
|
+
new_line
|
401
|
+
end
|
402
|
+
wputs "- Which font family and fallback options do you want to use as the main one for the UI?"
|
403
|
+
wputs "1. Open Sans, Helvetica, Arial, sans-serif (default)", :info
|
404
|
+
wputs "2. Arial, Helvetica, sans-serif", :info
|
405
|
+
wputs "3. Gentium Basic, Times New Roman, serif", :info
|
406
|
+
wputs "4. Anonymous Pro, Courier New, monospace", :info
|
407
|
+
choice = answer("Your choice (1-4):")
|
408
|
+
case choice
|
409
|
+
when "2"
|
410
|
+
@options[:ui][:font] = "arial"
|
411
|
+
when "3"
|
412
|
+
@options[:ui][:font] = "gentium"
|
413
|
+
when "4"
|
414
|
+
@options[:ui][:font] = "anonymous"
|
415
|
+
else
|
416
|
+
@options[:ui][:font] = "open"
|
417
|
+
end
|
418
|
+
new_line(2)
|
419
|
+
|
420
|
+
# PRODUCTION
|
421
|
+
wputs "5. Your Production Settings"
|
422
|
+
wputs "---------------------------"
|
423
|
+
|
424
|
+
# production
|
425
|
+
if hints
|
426
|
+
wputs "At some point, you will deploy your app to a production environment. I can already set up some settings for you.", :help
|
427
|
+
end
|
428
|
+
new_line
|
429
|
+
wputs "- Do you want to set up some production settings already?"
|
430
|
+
wputs "1. Yes (default)", :info
|
431
|
+
wputs "2. No", :info
|
432
|
+
@options[:production] = answer() == "2" ? false : true
|
433
|
+
@options[:production_settings] = {}
|
434
|
+
new_line(2)
|
435
|
+
|
436
|
+
if @options[:production]
|
437
|
+
# heroku
|
438
|
+
if hints
|
439
|
+
wputs "If you opt to host your app with Heroku, I can already add the necessary 12 Factor gem to a production group within your Gemfile.", :help
|
440
|
+
new_line
|
441
|
+
end
|
442
|
+
wputs "- Where will you host your app?"
|
443
|
+
wputs "1. Heroku (default)", :info
|
444
|
+
wputs "2. Somewhere else", :info
|
445
|
+
@options[:production_settings][:target] = answer() == "2" ? "else" : "heroku"
|
446
|
+
new_line(2)
|
447
|
+
|
448
|
+
# url
|
449
|
+
wputs "- What will be the URL of your app?"
|
450
|
+
wputs "example: www.my-app.com, blog.my-app.com, ...", :help if hints
|
451
|
+
wputs "tip: don't prefix the URL with http://", :help
|
452
|
+
@options[:production_settings][:url] = answer("URL:")
|
453
|
+
new_line(2)
|
454
|
+
|
455
|
+
# unicorn
|
456
|
+
if hints
|
457
|
+
wputs "By default, Rails apps use WEBrick as a simple HTTP web server. Although it is a good web server for development purpose, it is not really advised to use it in a production environment. I can configure your app to use Unicorn in production. If you choose so, I will add the Unicorn gem to your Gemfile within the :production group, create a unicorn.rb file within #{@options[:app_name]}/config and add a Procfile to your app root. You can edit Unicorn settings in #{@options[:app_name]}/config/unicorn.rb if you need to.", :help
|
458
|
+
new_line
|
459
|
+
end
|
460
|
+
wputs "- Do you want to use Unicorn in production?"
|
461
|
+
wputs "1. Yes (default)", :info
|
462
|
+
wputs "2. No", :info
|
463
|
+
@options[:production_settings][:unicorn] = answer() == "2" ? false : true
|
464
|
+
new_line(2)
|
465
|
+
else
|
466
|
+
@options[:production_settings][:target] = nil
|
467
|
+
@options[:production_settings][:url] = nil
|
468
|
+
@options[:production_settings][:unicorn] = nil
|
469
|
+
end
|
470
|
+
|
471
|
+
# SUMMARY
|
472
|
+
wputs "6. Summary"
|
473
|
+
wputs "----------"
|
474
|
+
# TODO: Offer to save template and/or whole script
|
475
|
+
|
476
|
+
# if hints
|
477
|
+
# wputs "I now have all the details needed to create #{@options[:app_name]}. I can save your settings if you want to generate your application at a later time (for example, if you forgot to start your PostgreSQL server). This will generate a file named #{@options[:app_name]}.rbs in the current directory. You can execute it later by running: rbricks --script #{@options[:app_name]}.rbs", :help
|
478
|
+
|
479
|
+
# new_line
|
480
|
+
|
481
|
+
# wputs "I can also save your chosen settings in a template file if you plan to create similar apps at a later stage. You will only need to fill in unique settings such as the app name. The template will be saved in the current directory as template_#{@options[:app_name]}.rbt. You can execute it later by running: rbricks --template template_#{@options[:app_name]}.rbt", :help
|
482
|
+
# end
|
483
|
+
new_line
|
484
|
+
|
485
|
+
# # save settings
|
486
|
+
# wputs "- Do you want to save the app settings in order to execute them later?"
|
487
|
+
# wputs "tip: rbricks --script #{@options[:app_name]}.rbs", :help
|
488
|
+
# wputs "1. Yes", :info
|
489
|
+
# wputs "2. No (default)", :info
|
490
|
+
# @options[:save_settings] = answer() == "1" ? true : false
|
491
|
+
# new_line(2)
|
492
|
+
|
493
|
+
# # save template
|
494
|
+
# wputs "- Do you want to save common settings as a template?"
|
495
|
+
# wputs "tip: rbricks --template template_#{@options[:app_name]}.rbt", :help
|
496
|
+
# wputs "1. Yes", :info
|
497
|
+
# wputs "2. No (default)", :info
|
498
|
+
# @options[:save_template] = answer() == "1" ? true : false
|
499
|
+
# new_line(2)
|
500
|
+
|
501
|
+
# generate now
|
502
|
+
wputs "- I am ready! Generate #{@options[:app_name]} now?"
|
503
|
+
wputs "1. Do it! (default)", :info
|
504
|
+
wputs "2. No, not now", :info
|
505
|
+
@options[:generate] = answer() == "2" ? false : true
|
506
|
+
new_line
|
507
|
+
|
508
|
+
@options
|
509
|
+
|
510
|
+
end
|
511
|
+
|
512
|
+
# Shortcut/alias methods
|
513
|
+
|
514
|
+
private
|
515
|
+
|
516
|
+
def wputs(text, highlight = :none)
|
517
|
+
StringHelpers.wputs(text, highlight)
|
518
|
+
end
|
519
|
+
|
520
|
+
def new_line(lines=1)
|
521
|
+
StringHelpers.new_line(lines)
|
522
|
+
end
|
523
|
+
|
524
|
+
def answer(choices="Your choice (1-2):", is_downcase = true)
|
525
|
+
print "#{choices} "
|
526
|
+
if is_downcase
|
527
|
+
STDIN.gets.chomp.downcase.strip
|
528
|
+
else
|
529
|
+
STDIN.gets.chomp.strip
|
530
|
+
end
|
531
|
+
end
|
532
|
+
|
533
|
+
end
|