railsbricks 3.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +9 -0
  3. data/Gemfile +7 -0
  4. data/LICENSE.txt +674 -0
  5. data/README.md +81 -0
  6. data/bin/rbricks +5 -0
  7. data/lib/railsbricks.rb +112 -0
  8. data/lib/railsbricks/app_generator.rb +338 -0
  9. data/lib/railsbricks/assets/config/admin_post_routes.rbr +3 -0
  10. data/lib/railsbricks/assets/config/application.yml +9 -0
  11. data/lib/railsbricks/assets/config/contact_routes.rbr +2 -0
  12. data/lib/railsbricks/assets/config/initializers/devise_email/devise.rb +267 -0
  13. data/lib/railsbricks/assets/config/initializers/devise_username/devise.rb +267 -0
  14. data/lib/railsbricks/assets/config/post_routes.rbr +2 -0
  15. data/lib/railsbricks/assets/config/routes.rb +15 -0
  16. data/lib/railsbricks/assets/config/unicorn.rb +22 -0
  17. data/lib/railsbricks/assets/controllers/admin/base_controller.rb +10 -0
  18. data/lib/railsbricks/assets/controllers/admin/devise_email/users_controller.rb +66 -0
  19. data/lib/railsbricks/assets/controllers/admin/devise_username/users_controller.rb +69 -0
  20. data/lib/railsbricks/assets/controllers/admin/posts_controller.rb +73 -0
  21. data/lib/railsbricks/assets/controllers/brick_contact.rbr +23 -0
  22. data/lib/railsbricks/assets/controllers/devise_email/application_controller.rb +54 -0
  23. data/lib/railsbricks/assets/controllers/devise_username/application_controller.rb +56 -0
  24. data/lib/railsbricks/assets/controllers/pages_controller.rb +13 -0
  25. data/lib/railsbricks/assets/controllers/posts_controller.rbr +10 -0
  26. data/lib/railsbricks/assets/database/postgresql.yml +12 -0
  27. data/lib/railsbricks/assets/database/sqlite3.yml +8 -0
  28. data/lib/railsbricks/assets/gemfile/Gemfile +41 -0
  29. data/lib/railsbricks/assets/git/gitignore +30 -0
  30. data/lib/railsbricks/assets/javascripts/analytics.js.coffee +5 -0
  31. data/lib/railsbricks/assets/lib/markdown_writer.rb +19 -0
  32. data/lib/railsbricks/assets/mailers/contact_mailer.rb +13 -0
  33. data/lib/railsbricks/assets/migrations/20141010133702_create_posts.rb +17 -0
  34. data/lib/railsbricks/assets/migrations/devise_email/20141010133701_devise_create_users.rb +48 -0
  35. data/lib/railsbricks/assets/migrations/devise_username/20141010133701_devise_create_users.rb +54 -0
  36. data/lib/railsbricks/assets/models/devise_email/user.rb +41 -0
  37. data/lib/railsbricks/assets/models/devise_username/user.rb +57 -0
  38. data/lib/railsbricks/assets/models/post.rb +30 -0
  39. data/lib/railsbricks/assets/procfile/Procfile +1 -0
  40. data/lib/railsbricks/assets/seeds/devise_email/seeds_no_test_users.rb +11 -0
  41. data/lib/railsbricks/assets/seeds/devise_email/seeds_test_users.rb +24 -0
  42. data/lib/railsbricks/assets/seeds/devise_username/seeds_no_test_users.rb +12 -0
  43. data/lib/railsbricks/assets/seeds/devise_username/seeds_test_users.rb +26 -0
  44. data/lib/railsbricks/assets/stylesheets/application.scss +6 -0
  45. data/lib/railsbricks/assets/stylesheets/railsbricks_custom.scss +562 -0
  46. data/lib/railsbricks/assets/views/admin/base/admin_posts_link.rbr +1 -0
  47. data/lib/railsbricks/assets/views/admin/base/devise_email/index.html.erb +41 -0
  48. data/lib/railsbricks/assets/views/admin/base/devise_username/index.html.erb +41 -0
  49. data/lib/railsbricks/assets/views/admin/posts/_form.html.erb +54 -0
  50. data/lib/railsbricks/assets/views/admin/posts/dashboard.html.erb +9 -0
  51. data/lib/railsbricks/assets/views/admin/posts/drafts.html.erb +23 -0
  52. data/lib/railsbricks/assets/views/admin/posts/edit.html.erb +10 -0
  53. data/lib/railsbricks/assets/views/admin/posts/index.html.erb +23 -0
  54. data/lib/railsbricks/assets/views/admin/posts/new.html.erb +6 -0
  55. data/lib/railsbricks/assets/views/admin/users/devise_email/edit.html.erb +65 -0
  56. data/lib/railsbricks/assets/views/admin/users/devise_email/index.html.erb +54 -0
  57. data/lib/railsbricks/assets/views/admin/users/devise_username/edit.html.erb +74 -0
  58. data/lib/railsbricks/assets/views/admin/users/devise_username/index.html.erb +56 -0
  59. data/lib/railsbricks/assets/views/contact_mailer/contact_message.html.erb +5 -0
  60. data/lib/railsbricks/assets/views/devise/allow_signup_links.rbr +11 -0
  61. data/lib/railsbricks/assets/views/devise/devise_email/confirmations/new.html.erb +31 -0
  62. data/lib/railsbricks/assets/views/devise/devise_email/mailer/confirmation_instructions.html.erb +12 -0
  63. data/lib/railsbricks/assets/views/devise/devise_email/mailer/reset_password_instructions.html.erb +15 -0
  64. data/lib/railsbricks/assets/views/devise/devise_email/passwords/edit.html.erb +43 -0
  65. data/lib/railsbricks/assets/views/devise/devise_email/passwords/new.html.erb +31 -0
  66. data/lib/railsbricks/assets/views/devise/devise_email/registrations/edit.html.erb +63 -0
  67. data/lib/railsbricks/assets/views/devise/devise_email/registrations/new.html.erb +49 -0
  68. data/lib/railsbricks/assets/views/devise/devise_email/sessions/new.html.erb +49 -0
  69. data/lib/railsbricks/assets/views/devise/devise_email/shared/_links.erb +19 -0
  70. data/lib/railsbricks/assets/views/devise/devise_username/confirmations/new.html.erb +31 -0
  71. data/lib/railsbricks/assets/views/devise/devise_username/mailer/confirmation_instructions.html.erb +12 -0
  72. data/lib/railsbricks/assets/views/devise/devise_username/mailer/reset_password_instructions.html.erb +15 -0
  73. data/lib/railsbricks/assets/views/devise/devise_username/passwords/edit.html.erb +43 -0
  74. data/lib/railsbricks/assets/views/devise/devise_username/passwords/new.html.erb +31 -0
  75. data/lib/railsbricks/assets/views/devise/devise_username/registrations/edit.html.erb +63 -0
  76. data/lib/railsbricks/assets/views/devise/devise_username/registrations/new.html.erb +58 -0
  77. data/lib/railsbricks/assets/views/devise/devise_username/sessions/new.html.erb +49 -0
  78. data/lib/railsbricks/assets/views/devise/devise_username/shared/_links.erb +19 -0
  79. data/lib/railsbricks/assets/views/layouts/_navigation_links.html.erb +15 -0
  80. data/lib/railsbricks/assets/views/layouts/brick_analytics.rbr +11 -0
  81. data/lib/railsbricks/assets/views/pages/contact.html.erb +46 -0
  82. data/lib/railsbricks/assets/views/pages/inside.html.erb +4 -0
  83. data/lib/railsbricks/assets/views/pages/posts.html.erb +18 -0
  84. data/lib/railsbricks/assets/views/pages/show_post.html.erb +6 -0
  85. data/lib/railsbricks/auth_builder.rb +147 -0
  86. data/lib/railsbricks/config_helpers.rb +27 -0
  87. data/lib/railsbricks/config_values.rb +14 -0
  88. data/lib/railsbricks/errors.rb +18 -0
  89. data/lib/railsbricks/file_helpers.rb +54 -0
  90. data/lib/railsbricks/foundation/README.md +24 -0
  91. data/lib/railsbricks/foundation/Rakefile +6 -0
  92. data/lib/railsbricks/foundation/app/assets/images/.keep +0 -0
  93. data/lib/railsbricks/foundation/app/assets/images/apple-touch-icon-precomposed.png +0 -0
  94. data/lib/railsbricks/foundation/app/assets/images/apple-touch-icon.png +0 -0
  95. data/lib/railsbricks/foundation/app/assets/images/favicon.ico +0 -0
  96. data/lib/railsbricks/foundation/app/assets/javascripts/application.js +17 -0
  97. data/lib/railsbricks/foundation/app/assets/javascripts/common.js +7 -0
  98. data/lib/railsbricks/foundation/app/controllers/application_controller.rb +5 -0
  99. data/lib/railsbricks/foundation/app/controllers/concerns/.keep +0 -0
  100. data/lib/railsbricks/foundation/app/controllers/pages_controller.rb +7 -0
  101. data/lib/railsbricks/foundation/app/helpers/application_helper.rb +7 -0
  102. data/lib/railsbricks/foundation/app/helpers/email_helper.rb +5 -0
  103. data/lib/railsbricks/foundation/app/mailers/.keep +0 -0
  104. data/lib/railsbricks/foundation/app/models/.keep +0 -0
  105. data/lib/railsbricks/foundation/app/models/concerns/.keep +0 -0
  106. data/lib/railsbricks/foundation/app/views/layouts/_footer.html.erb +18 -0
  107. data/lib/railsbricks/foundation/app/views/layouts/_messages.html.erb +9 -0
  108. data/lib/railsbricks/foundation/app/views/layouts/_navigation.html.erb +18 -0
  109. data/lib/railsbricks/foundation/app/views/layouts/_navigation_links.html.erb +3 -0
  110. data/lib/railsbricks/foundation/app/views/layouts/application.html.erb +38 -0
  111. data/lib/railsbricks/foundation/app/views/pages/home.html.erb +2 -0
  112. data/lib/railsbricks/foundation/bin/bundle +3 -0
  113. data/lib/railsbricks/foundation/bin/rails +4 -0
  114. data/lib/railsbricks/foundation/bin/rake +4 -0
  115. data/lib/railsbricks/foundation/config.ru +4 -0
  116. data/lib/railsbricks/foundation/config/application.rb +34 -0
  117. data/lib/railsbricks/foundation/config/boot.rb +4 -0
  118. data/lib/railsbricks/foundation/config/environment.rb +5 -0
  119. data/lib/railsbricks/foundation/config/environments/development.rb +41 -0
  120. data/lib/railsbricks/foundation/config/environments/production.rb +95 -0
  121. data/lib/railsbricks/foundation/config/environments/test.rb +51 -0
  122. data/lib/railsbricks/foundation/config/initializers/backtrace_silencers.rb +7 -0
  123. data/lib/railsbricks/foundation/config/initializers/date_format.rb +27 -0
  124. data/lib/railsbricks/foundation/config/initializers/filter_parameter_logging.rb +4 -0
  125. data/lib/railsbricks/foundation/config/initializers/friendly_id.rb +88 -0
  126. data/lib/railsbricks/foundation/config/initializers/inflections.rb +16 -0
  127. data/lib/railsbricks/foundation/config/initializers/kaminari_config.rb +10 -0
  128. data/lib/railsbricks/foundation/config/initializers/mime_types.rb +5 -0
  129. data/lib/railsbricks/foundation/config/initializers/secret_token.rb +25 -0
  130. data/lib/railsbricks/foundation/config/initializers/session_store.rb +3 -0
  131. data/lib/railsbricks/foundation/config/initializers/wrap_parameters.rb +14 -0
  132. data/lib/railsbricks/foundation/config/locales/en.yml +23 -0
  133. data/lib/railsbricks/foundation/config/routes.rb +7 -0
  134. data/lib/railsbricks/foundation/db/migrate/20131103142222_create_friendly_id_slugs.rb +15 -0
  135. data/lib/railsbricks/foundation/db/schema.rb +29 -0
  136. data/lib/railsbricks/foundation/db/seeds.rb +0 -0
  137. data/lib/railsbricks/foundation/lib/assets/.keep +0 -0
  138. data/lib/railsbricks/foundation/lib/tasks/.keep +0 -0
  139. data/lib/railsbricks/foundation/public/404.html +58 -0
  140. data/lib/railsbricks/foundation/public/422.html +58 -0
  141. data/lib/railsbricks/foundation/public/500.html +57 -0
  142. data/lib/railsbricks/foundation/public/favicon.ico +0 -0
  143. data/lib/railsbricks/foundation/public/robots.txt +5 -0
  144. data/lib/railsbricks/foundation/vendor/assets/javascripts/.keep +0 -0
  145. data/lib/railsbricks/foundation/vendor/assets/stylesheets/.keep +0 -0
  146. data/lib/railsbricks/gemfile_builder.rb +118 -0
  147. data/lib/railsbricks/menu.rb +524 -0
  148. data/lib/railsbricks/post_builder.rb +103 -0
  149. data/lib/railsbricks/string_helpers.rb +39 -0
  150. data/lib/railsbricks/style_builder.rb +97 -0
  151. data/lib/railsbricks/ui_helpers.rb +11 -0
  152. data/lib/railsbricks/validator.rb +68 -0
  153. data/lib/railsbricks/version.rb +34 -0
  154. data/railsbricks.gemspec +16 -0
  155. 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
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -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.7.1"
10
+ BCRYPT = "3.1.11"
11
+ BOOTSTRAP_SASS = "3.3.7"
12
+ BYEBUG = "9.0.6"
13
+ COFFEE_RAILS = "4.2.1"
14
+ DEVISE = "3.5.3"
15
+ FIGARO = "1.1.1"
16
+ FONT_AWESOME_SASS = "4.7.0"
17
+ FRIENDLY_ID = "5.2.0"
18
+ JBUILDER = "2.6.3"
19
+ JQUERY_RAILS = "4.2.2"
20
+ KAMINARI = "1.0.1"
21
+ REDCARPET = "3.3.3"
22
+ SASS_RAILS = "5.0.6"
23
+ SQLITE3 = "1.3.11"
24
+ SPRING = "2.0.1"
25
+ TURBOLINKS = "5.0.1"
26
+ UGLIFIER = "3.1.6"
27
+ WEB_CONSOLE = "3.3.0"
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,524 @@
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 "* *"
23
+ wputs "* using Rails #{@options[:rails_version]} *"
24
+ wputs "* *"
25
+ wputs '*****************************'
26
+ new_line(2)
27
+
28
+ # WIZARD CONFIG
29
+ wputs "- Do you want me to help you along the way by giving you tips?"
30
+ wputs "1. Sure, help me make the right choices (default)", :info
31
+ wputs "2. Nope, I already know how to use RailsBricks", :info
32
+ hints = answer() == "2" ? false : true
33
+ new_line(2)
34
+
35
+ # APP NAME
36
+ wputs "1. Your Rails App Name"
37
+ wputs "----------------------"
38
+ if hints
39
+ 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
40
+ end
41
+ new_line
42
+ wputs "- What do you want to name your app?"
43
+ default_name = "railsbricks_#{4.times.map{ 0 + Random.rand(9)}.join}"
44
+ wputs "(default: #{default_name})"
45
+ @options[:app_name] = StringHelpers.sanitize(answer("App name:"))
46
+ @options[:app_name] = default_name if @options[:app_name].length < 1
47
+ @options[:rails_app_name] = StringHelpers.convert_to_app_name(@options[:app_name])
48
+ new_line(2)
49
+
50
+ # DEVELOPMENT ENVIRONMENT
51
+ wputs "2. Your Development Environment"
52
+ wputs "-------------------------------"
53
+
54
+ # ruby version
55
+ if hints
56
+ 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
57
+ end
58
+ new_line
59
+ wputs "- Which version of Ruby do you want to use?"
60
+ wputs "1. 2.0.0", :info
61
+ wputs "2. 2.3.3", :info
62
+ wputs "3. 2.4.0 (default)", :info
63
+ choice = answer("Your choice (1-3):")
64
+ case choice
65
+ when "1"
66
+ @options[:ruby_version] = "2.0.0"
67
+ when "2"
68
+ @options[:ruby_version] = "2.3.3"
69
+ else
70
+ @options[:ruby_version] = "2.4.0"
71
+ end
72
+ new_line(2)
73
+
74
+ # gem command
75
+ if hints
76
+ 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
77
+ end
78
+ new_line
79
+ wputs "- How do you usually install new gems?"
80
+ wputs "1. gem install name_of_gem (default)", :info
81
+ wputs "2. sudo gem install name_of_gem", :info
82
+ @options[:gem_command] = answer() == "2" ? "sudo gem" : "gem"
83
+ new_line(2)
84
+
85
+ # rake command
86
+ @options[:rake_command] = "bundle exec rake"
87
+
88
+ # development database
89
+ if hints
90
+ 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
91
+ end
92
+ new_line
93
+ 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
94
+ new_line
95
+ wputs "- Which database engine do you want to use for development?"
96
+ wputs "1. SQLite 3 (default)", :info
97
+ wputs "2. PostgreSQL", :info
98
+ @options[:development_db] = answer() == "2" ? "postgresql" : "sqlite"
99
+ @options[:db_config] = {}
100
+ new_line(2)
101
+
102
+ # postgresql config
103
+ if @options[:development_db] == "postgresql"
104
+ if hints
105
+ 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
106
+ new_line
107
+ end
108
+
109
+ # hostname
110
+ wputs "- Your database server hostname?"
111
+ wputs "example: 192.168.1.1, localhost, ...", :help
112
+ wputs "(default: localhost)"
113
+ choice = answer("Hostname:")
114
+ @options[:db_config][:server] = choice == "" ? "localhost" : choice
115
+ new_line(2)
116
+
117
+ # port
118
+ wputs "- What is the database port number?"
119
+ wputs "(default: 5432)"
120
+ choice = answer("Port:")
121
+ @options[:db_config][:port] = choice == "" ? 5432 : choice.to_i
122
+ new_line(2)
123
+
124
+ # name
125
+ wputs "- What is the development database name?"
126
+ wputs "(default #{@options[:app_name].downcase}_development)"
127
+ choice = StringHelpers.sanitize(answer("Database name:"))
128
+ @options[:db_config][:name] = choice == "" ? "#{@options[:app_name].downcase}_development" : choice
129
+ new_line(2)
130
+
131
+ # username
132
+ wputs "- What is your database username?"
133
+ wputs "(default: #{Etc.getlogin})"
134
+ choice = answer("Database username:")
135
+ @options[:db_config][:username] = choice == "" ? "#{Etc.getlogin}" : choice
136
+ new_line(2)
137
+
138
+ # password
139
+ wputs "- What is your database user password?"
140
+ wputs "tip: leave blank for none", :help
141
+ wputs "(default: none)"
142
+ @options[:db_config][:password] = answer("Database user password:")
143
+ new_line(2)
144
+
145
+ else
146
+ @options[:db_config][:server] = nil
147
+ @options[:db_config][:port] = nil
148
+ @options[:db_config][:name] = nil
149
+ @options[:db_config][:username] = nil
150
+ @options[:db_config][:password] = nil
151
+ end
152
+
153
+ # git local
154
+ if hints
155
+ 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
156
+ end
157
+ new_line
158
+ wputs "- Create a local Git repository?"
159
+ wputs "1. Yes (default)", :info
160
+ wputs "2. No", :info
161
+ answer() == "2" ? @options[:local_git] = false : @options[:local_git] = true
162
+ new_line(2)
163
+
164
+ # git remote
165
+ if @options[:local_git]
166
+ wputs "- Add a remote Git repository?"
167
+ wputs "1. Yes", :info
168
+ wputs "2. No (default)", :info
169
+ answer() == "1" ? @options[:remote_git] = true : @options[:remote_git] = false
170
+ new_line(2)
171
+ else
172
+ @options[:remote_git] = false
173
+ end
174
+
175
+ # git remote url
176
+ if @options[:remote_git]
177
+ wputs "- What is the URL of your remote Git repository?"
178
+ wputs "example: https://github.com/yourname/your_app.git", :help
179
+ @options[:git_url] = answer("Remote URL:")
180
+ new_line(2)
181
+ else
182
+ @options[:git_url] = ""
183
+ end
184
+
185
+
186
+ # APP INFO
187
+ wputs "3. About Your App"
188
+ wputs "-----------------"
189
+
190
+ # devise
191
+ if hints
192
+ 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
193
+ end
194
+ new_line
195
+ wputs "- Create an authentication scheme?"
196
+ wputs "1. Yes (default)", :info
197
+ wputs "2. No", :info
198
+ @options[:devise] = answer() == "2" ? false : true
199
+ @options[:devise_config] = {}
200
+ new_line(2)
201
+
202
+ if @options[:devise]
203
+ # sign in
204
+ if hints
205
+ 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
206
+ new_line
207
+ end
208
+ wputs "- How will users sign in?"
209
+ wputs "1. With a username (default)", :info
210
+ wputs "2. With an email address", :info
211
+ @options[:devise_config][:scheme] = answer() == "2" ? "email" : "username"
212
+ new_line(2)
213
+
214
+ # allow sign up
215
+ if hints
216
+ wputs "If you don't want to allow new users to register, I can disable the sign up feature.", :help
217
+ new_line
218
+ end
219
+ wputs "- Allow new users to sign up?"
220
+ wputs "1. Yes, they can click on a 'sign up' button (default)", :info
221
+ wputs "2. No, I don't want to allow new users to sign up", :info
222
+ @options[:devise_config][:allow_signup] = answer() == "2" ? false : true
223
+ new_line(2)
224
+
225
+ # test users
226
+ if hints
227
+ wputs "I can also create 50 test users for you if you need.", :help
228
+ new_line
229
+ end
230
+ wputs "- Create test users?"
231
+ wputs "1. No, only create my Admin account (default)", :info
232
+ wputs "2. Yes, create 50", :info
233
+ @options[:devise_config][:test_users] = answer() == "2" ? true : false
234
+ new_line(2)
235
+
236
+ # post model
237
+ if hints
238
+ 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
239
+ new_line
240
+ end
241
+ wputs "- Create Post resources?"
242
+ wputs "1. Yes", :info
243
+ wputs "2. No (default)", :info
244
+ @options[:post_resources] = answer() == "1" ? true : false
245
+ new_line(2)
246
+ else
247
+ @options[:devise_config][:scheme] = nil
248
+ @options[:devise_config][:allow_signup] = nil
249
+ @options[:devise_config][:test_users] = nil
250
+ @options[:post_resources] = false
251
+ end
252
+
253
+ # contact form
254
+ if hints
255
+ 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
256
+ new_line
257
+ end
258
+ wputs "- Create a Contact form?"
259
+ wputs "1. Yes", :info
260
+ wputs "2. No (default)", :info
261
+ @options[:contact_form] = answer() == "1" ? true : false
262
+ new_line(2)
263
+
264
+ # google analytics
265
+ if hints
266
+ 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
267
+ new_line
268
+ end
269
+ wputs "- Use Google Analytics?"
270
+ wputs "1. Yes (default)", :info
271
+ wputs "2. No", :info
272
+ @options[:google_analytics] = answer() == "2" ? false : true
273
+ new_line(2)
274
+
275
+ if @options[:google_analytics]
276
+ wputs "- What is your Google Analytics tracking ID?"
277
+ wputs "(default: UA-XXXXXX-XX)"
278
+ choice = answer("Tracking ID:", false)
279
+ @options[:google_tracking_id] = choice == "" ? "UA-XXXXXX-XX" : choice
280
+ new_line(2)
281
+ else
282
+ @options[:google_tracking_id] = nil
283
+ end
284
+
285
+ # email settings
286
+ if hints
287
+ 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
288
+ new_line
289
+ end
290
+ wputs "- Configure email settings?"
291
+ wputs "1. Yes (default)", :info
292
+ wputs "2. No", :info
293
+ @options[:email_settings] = answer() == "2" ? false : true
294
+ @options[:email_config] = {}
295
+ new_line(2)
296
+
297
+ if @options[:email_settings]
298
+ #sender
299
+ wputs "- What is the email address you will send emails from?"
300
+ wputs "example: someone@example.com", :help
301
+ @options[:email_config][:sender] = answer("Email address:")
302
+ new_line(2)
303
+
304
+ # smtp server
305
+ wputs "- What is your SMTP server address?"
306
+ wputs "example: smtp.example.com", :help
307
+ @options[:email_config][:smtp] = answer("SMTP server:")
308
+ new_line(2)
309
+
310
+ # domain
311
+ wputs "- What is the domain name of your SMTP server?"
312
+ wputs "example: 192.168.1.1, example.com, ...", :help
313
+ @options[:email_config][:domain] = answer("Domain name:")
314
+ new_line(2)
315
+
316
+ # port
317
+ wputs "- What is the SMTP server port number?"
318
+ wputs "(default: 587)"
319
+ choice = answer("SMTP port:")
320
+ @options[:email_config][:port] = choice == "" ? "587" : choice
321
+ new_line(2)
322
+
323
+ # username
324
+ wputs "- What is your SMTP username?"
325
+ @options[:email_config][:username] = answer("SMTP username:")
326
+ new_line(2)
327
+
328
+ # password
329
+ wputs "- What is your SMTP password?"
330
+ wputs "tip: it will be stored in #{@options[:app_name]}/config/application.yml but won't be tracked by Git", :help
331
+ @options[:email_config][:password] = answer("SMTP password:", false)
332
+ new_line(2)
333
+
334
+ else
335
+ @options[:email_config][:sender] = nil
336
+ @options[:email_config][:smtp] = nil
337
+ @options[:email_config][:domain] = nil
338
+ @options[:email_config][:port] = nil
339
+ @options[:email_config][:username] = nil
340
+ @options[:email_config][:password] = nil
341
+ end
342
+
343
+ # UI
344
+ wputs "4. Your App UI"
345
+ wputs "--------------"
346
+ @options[:ui] = {}
347
+
348
+ # body theme
349
+ if hints
350
+ 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
351
+ end
352
+ new_line
353
+ wputs "- Which UI scheme do you want to use for the content area?"
354
+ wputs "1. Light (default)", :info
355
+ wputs "2. Dark", :info
356
+ @options[:ui][:theme_background] = answer() == "2" ? "dark" : "light"
357
+ new_line(2)
358
+
359
+ # navbar theme
360
+ new_line
361
+ wputs "- Which UI scheme do you want to use for the navbar?"
362
+ wputs "1. Light", :info
363
+ wputs "2. Dark (default)", :info
364
+ @options[:ui][:theme_navbar] = answer() == "1" ? "light" : "dark"
365
+ new_line(2)
366
+
367
+ # footer theme
368
+ new_line
369
+ wputs "- Which UI scheme do you want to use for the footer?"
370
+ wputs "1. Light", :info
371
+ wputs "2. Dark (default)", :info
372
+ @options[:ui][:theme_footer] = answer() == "1" ? "light" : "dark"
373
+ new_line(2)
374
+
375
+
376
+ # primary color
377
+ if hints
378
+ 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
379
+ new_line
380
+ end
381
+ wputs "- What primary color do you want to use?"
382
+ wputs "tip: expressed as hexadecimal such as #663399", :help
383
+ wputs "(default: #428BCA)"
384
+ choice = answer("Primary color:")
385
+ @options[:ui][:color] = choice == "" ? "#428bca" : choice.downcase
386
+ new_line(2)
387
+
388
+ # font
389
+ if hints
390
+ 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
391
+ new_line
392
+ end
393
+ wputs "- Which font family and fallback options do you want to use as the main one for the UI?"
394
+ wputs "1. Open Sans, Helvetica, Arial, sans-serif (default)", :info
395
+ wputs "2. Arial, Helvetica, sans-serif", :info
396
+ wputs "3. Gentium Basic, Times New Roman, serif", :info
397
+ wputs "4. Anonymous Pro, Courier New, monospace", :info
398
+ choice = answer("Your choice (1-4):")
399
+ case choice
400
+ when "2"
401
+ @options[:ui][:font] = "arial"
402
+ when "3"
403
+ @options[:ui][:font] = "gentium"
404
+ when "4"
405
+ @options[:ui][:font] = "anonymous"
406
+ else
407
+ @options[:ui][:font] = "open"
408
+ end
409
+ new_line(2)
410
+
411
+ # PRODUCTION
412
+ wputs "5. Your Production Settings"
413
+ wputs "---------------------------"
414
+
415
+ # production
416
+ if hints
417
+ wputs "At some point, you will deploy your app to a production environment. I can already set up some settings for you.", :help
418
+ end
419
+ new_line
420
+ wputs "- Do you want to set up some production settings already?"
421
+ wputs "1. Yes (default)", :info
422
+ wputs "2. No", :info
423
+ @options[:production] = answer() == "2" ? false : true
424
+ @options[:production_settings] = {}
425
+ new_line(2)
426
+
427
+ if @options[:production]
428
+ # heroku
429
+ if hints
430
+ 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
431
+ new_line
432
+ end
433
+ wputs "- Where will you host your app?"
434
+ wputs "1. Heroku (default)", :info
435
+ wputs "2. Somewhere else", :info
436
+ @options[:production_settings][:target] = answer() == "2" ? "else" : "heroku"
437
+ new_line(2)
438
+
439
+ # url
440
+ wputs "- What will be the URL of your app?"
441
+ wputs "example: www.my-app.com, blog.my-app.com, ...", :help if hints
442
+ wputs "tip: don't prefix the URL with http://", :help
443
+ @options[:production_settings][:url] = answer("URL:")
444
+ new_line(2)
445
+
446
+ # unicorn
447
+ if hints
448
+ 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
449
+ new_line
450
+ end
451
+ wputs "- Do you want to use Unicorn in production?"
452
+ wputs "1. Yes (default)", :info
453
+ wputs "2. No", :info
454
+ @options[:production_settings][:unicorn] = answer() == "2" ? false : true
455
+ new_line(2)
456
+ else
457
+ @options[:production_settings][:target] = nil
458
+ @options[:production_settings][:url] = nil
459
+ @options[:production_settings][:unicorn] = nil
460
+ end
461
+
462
+ # SUMMARY
463
+ wputs "6. Summary"
464
+ wputs "----------"
465
+ # TODO: Offer to save template and/or whole script
466
+
467
+ # if hints
468
+ # 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
469
+
470
+ # new_line
471
+
472
+ # 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
473
+ # end
474
+ new_line
475
+
476
+ # # save settings
477
+ # wputs "- Do you want to save the app settings in order to execute them later?"
478
+ # wputs "tip: rbricks --script #{@options[:app_name]}.rbs", :help
479
+ # wputs "1. Yes", :info
480
+ # wputs "2. No (default)", :info
481
+ # @options[:save_settings] = answer() == "1" ? true : false
482
+ # new_line(2)
483
+
484
+ # # save template
485
+ # wputs "- Do you want to save common settings as a template?"
486
+ # wputs "tip: rbricks --template template_#{@options[:app_name]}.rbt", :help
487
+ # wputs "1. Yes", :info
488
+ # wputs "2. No (default)", :info
489
+ # @options[:save_template] = answer() == "1" ? true : false
490
+ # new_line(2)
491
+
492
+ # generate now
493
+ wputs "- I am ready! Generate #{@options[:app_name]} now?"
494
+ wputs "1. Do it! (default)", :info
495
+ wputs "2. No, not now", :info
496
+ @options[:generate] = answer() == "2" ? false : true
497
+ new_line
498
+
499
+ @options
500
+
501
+ end
502
+
503
+ # Shortcut/alias methods
504
+
505
+ private
506
+
507
+ def wputs(text, highlight = :none)
508
+ StringHelpers.wputs(text, highlight)
509
+ end
510
+
511
+ def new_line(lines=1)
512
+ StringHelpers.new_line(lines)
513
+ end
514
+
515
+ def answer(choices="Your choice (1-2):", is_downcase = true)
516
+ print "#{choices} "
517
+ if is_downcase
518
+ STDIN.gets.chomp.downcase.strip
519
+ else
520
+ STDIN.gets.chomp.strip
521
+ end
522
+ end
523
+
524
+ end