cambium 0.3.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +1 -1
  3. data/README.md +339 -15
  4. data/{lib/generators/cambium/templates/app/assets/javascripts/admin/admin.js.coffee → app/assets/javascripts/cambium/admin/application.js.coffee} +4 -10
  5. data/app/assets/javascripts/cambium/admin/routers/router.js.coffee +25 -0
  6. data/app/assets/javascripts/cambium/admin/users.js +2 -0
  7. data/app/assets/javascripts/cambium/admin/views/dropdown_menu.js.coffee +24 -0
  8. data/app/assets/javascripts/cambium/admin/views/pickadate.js.coffee +15 -0
  9. data/app/assets/stylesheets/cambium/admin/application.scss +27 -0
  10. data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_colors.scss +7 -7
  11. data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones.scss +18 -18
  12. data/app/assets/stylesheets/cambium/admin/partials/_globals.scss +21 -0
  13. data/app/assets/stylesheets/cambium/admin/partials/activity.scss +52 -0
  14. data/app/assets/stylesheets/cambium/admin/partials/components.scss +64 -0
  15. data/app/assets/stylesheets/cambium/admin/partials/dashboard.scss +48 -0
  16. data/app/assets/stylesheets/cambium/admin/partials/forms.scss +107 -0
  17. data/app/assets/stylesheets/cambium/admin/partials/header.scss +113 -0
  18. data/app/assets/stylesheets/cambium/admin/partials/page_title.scss +42 -0
  19. data/app/assets/stylesheets/cambium/admin/partials/sidebar.scss +41 -0
  20. data/app/assets/stylesheets/cambium/admin/partials/tables.scss +80 -0
  21. data/app/assets/stylesheets/cambium/admin/partials/typography.scss +5 -0
  22. data/app/assets/stylesheets/cambium/admin/partials/wireframe.scss +52 -0
  23. data/app/assets/stylesheets/cambium/admin/users.css +4 -0
  24. data/app/controllers/cambium/admin/dashboard_controller.rb +12 -0
  25. data/app/controllers/cambium/admin/search_controller.rb +9 -0
  26. data/app/controllers/cambium/admin/users_controller.rb +30 -0
  27. data/app/controllers/cambium/admin_controller.rb +90 -0
  28. data/app/helpers/cambium/cambium_helper.rb +205 -0
  29. data/app/presenters/cambium/admin_presenter.rb +127 -0
  30. data/app/views/cambium/admin/_activity.html.erb +6 -0
  31. data/app/views/cambium/admin/_header.html.erb +41 -0
  32. data/app/views/cambium/admin/_sidebar.html.erb +19 -0
  33. data/app/views/cambium/admin/_status.html.erb +5 -0
  34. data/app/views/cambium/admin/dashboard/show.html.erb +5 -0
  35. data/app/views/cambium/admin/edit.html.erb +7 -0
  36. data/app/views/cambium/admin/index.html.erb +7 -0
  37. data/app/views/cambium/admin/new.html.erb +7 -0
  38. data/app/views/cambium/admin/paper_trail/versions/_version.html.erb +20 -0
  39. data/app/views/cambium/admin/search/index.html.erb +38 -0
  40. data/app/views/layouts/admin.html.erb +25 -0
  41. data/bin/rails +12 -0
  42. data/cambium.gemspec +19 -15
  43. data/config/routes.rb +10 -0
  44. data/lib/cambium/configuration.rb +28 -0
  45. data/lib/cambium/engine.rb +2 -1
  46. data/lib/cambium/version.rb +1 -1
  47. data/lib/cambium.rb +12 -1
  48. data/lib/generators/cambium/admin_generator.rb +104 -0
  49. data/lib/generators/cambium/app_generator.rb +205 -0
  50. data/lib/generators/cambium/controller_generator.rb +81 -0
  51. data/lib/generators/cambium/gemfile_generator.rb +36 -0
  52. data/lib/generators/cambium/install_generator.rb +19 -0
  53. data/lib/generators/cambium/user_generator.rb +40 -0
  54. data/lib/generators/{cambium/helpers → helpers}/generators_helper.rb +32 -24
  55. data/lib/generators/templates/Gemfile.erb +79 -0
  56. data/lib/generators/{cambium/templates/app/assets/javascripts/backbone/app.js.coffee → templates/app/assets/javascripts/application.js.coffee} +9 -1
  57. data/lib/generators/templates/app/assets/javascripts/views/default_helpers.js.coffee +16 -0
  58. data/lib/generators/templates/app/assets/stylesheets/admin/admin.scss +3 -0
  59. data/lib/generators/templates/app/controllers/admin/controller.rb.erb +2 -0
  60. data/lib/generators/{cambium/templates → templates}/app/controllers/application_controller.rb +1 -5
  61. data/lib/generators/{cambium/templates → templates}/app/models/user.rb +4 -4
  62. data/lib/generators/templates/app/views/application/_status.html.erb +3 -0
  63. data/lib/generators/{cambium/templates → templates}/app/views/layouts/application.html.erb +1 -1
  64. data/lib/generators/templates/config/admin/controller.yml.erb +24 -0
  65. data/lib/generators/templates/config/admin/sidebar.yml +9 -0
  66. data/lib/generators/templates/config/admin/users.yml +31 -0
  67. data/lib/generators/{cambium/templates → templates}/config/application.rb +6 -4
  68. data/lib/generators/templates/config/initializers/_hash.rb +23 -0
  69. data/lib/generators/templates/config/initializers/_settings.rb +18 -0
  70. data/lib/generators/templates/config/initializers/assets.rb +1 -0
  71. data/lib/generators/templates/config/initializers/cambium.rb +16 -0
  72. data/lib/generators/templates/config/private.yml +16 -0
  73. data/lib/generators/templates/config/routes.rb +54 -0
  74. data/lib/generators/templates/config/settings.yml +16 -0
  75. data/lib/generators/{cambium/templates → templates}/gitignore +1 -1
  76. data/lib/help/cambium_prereqs.txt +13 -0
  77. data/lib/help/pg_search_post_install.txt +13 -0
  78. data/lib/{generators/cambium/templates/lib/tasks → tasks}/db.rake +2 -2
  79. data/lib/{generators/cambium/templates/lib/tasks → tasks}/rename.rake +1 -1
  80. data/test/controllers/cambium/admin/dashboard_controller_test.rb +9 -0
  81. data/test/controllers/cambium/admin/users_controller_test.rb +9 -0
  82. data/test/controllers/cambium/admin_controller_test.rb +9 -0
  83. metadata +192 -152
  84. data/bin/cambium +0 -16
  85. data/lib/generators/cambium/helpers/dependencies_helper.rb +0 -58
  86. data/lib/generators/cambium/install/admin_generator.rb +0 -110
  87. data/lib/generators/cambium/install/app_generator.rb +0 -162
  88. data/lib/generators/cambium/install/config_generator.rb +0 -182
  89. data/lib/generators/cambium/install/utilities_generator.rb +0 -57
  90. data/lib/generators/cambium/model/image_generator.rb +0 -67
  91. data/lib/generators/cambium/model/page_generator.rb +0 -131
  92. data/lib/generators/cambium/model/post_generator.rb +0 -71
  93. data/lib/generators/cambium/model/tag_generator.rb +0 -40
  94. data/lib/generators/cambium/model/user_generator.rb +0 -78
  95. data/lib/generators/cambium/templates/Gemfile +0 -43
  96. data/lib/generators/cambium/templates/Gemfile.erb +0 -40
  97. data/lib/generators/cambium/templates/_partials/pages/admin_icon.rb +0 -6
  98. data/lib/generators/cambium/templates/app/assets/javascripts/.DS_Store +0 -0
  99. data/lib/generators/cambium/templates/app/assets/javascripts/admin/collections/.gitkeep +0 -0
  100. data/lib/generators/cambium/templates/app/assets/javascripts/admin/models/.gitkeep +0 -0
  101. data/lib/generators/cambium/templates/app/assets/javascripts/admin/models/image.js.coffee +0 -14
  102. data/lib/generators/cambium/templates/app/assets/javascripts/admin/models/tag.js.coffee +0 -14
  103. data/lib/generators/cambium/templates/app/assets/javascripts/admin/parser_rules/custom.js +0 -552
  104. data/lib/generators/cambium/templates/app/assets/javascripts/admin/routers/router.js.coffee +0 -37
  105. data/lib/generators/cambium/templates/app/assets/javascripts/admin/tag.jst.ejs +0 -7
  106. data/lib/generators/cambium/templates/app/assets/javascripts/admin/templates/image.jst.ejs +0 -3
  107. data/lib/generators/cambium/templates/app/assets/javascripts/admin/templates/paginator_controls.jst.ejs +0 -8
  108. data/lib/generators/cambium/templates/app/assets/javascripts/admin/templates/paginator_nav.jst.ejs +0 -11
  109. data/lib/generators/cambium/templates/app/assets/javascripts/admin/templates/post_tag.jst.ejs +0 -1
  110. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/accordion.js.coffee +0 -33
  111. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/counter.js.coffee +0 -25
  112. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/dropdown_toggle.js.coffee +0 -16
  113. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/image_upload.js.coffee +0 -28
  114. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/init_counter.js.coffee +0 -13
  115. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/paginator.js.coffee +0 -86
  116. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/publishable.js.coffee +0 -12
  117. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/tags.js.coffee +0 -158
  118. data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/wysiwyg.js.coffee +0 -87
  119. data/lib/generators/cambium/templates/app/assets/javascripts/admin/wysihtml5.js +0 -9521
  120. data/lib/generators/cambium/templates/app/assets/javascripts/application.js +0 -10
  121. data/lib/generators/cambium/templates/app/assets/javascripts/backbone/templates/.keep +0 -0
  122. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/admin.scss +0 -14
  123. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_content.scss +0 -88
  124. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_form.scss +0 -470
  125. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_globals.scss +0 -39
  126. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_header.scss +0 -121
  127. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_nav.scss +0 -45
  128. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_wireframe.scss +0 -24
  129. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/wysihtml5.css +0 -7
  130. data/lib/generators/cambium/templates/app/controllers/admin/images_controller.rb +0 -45
  131. data/lib/generators/cambium/templates/app/controllers/admin/pages_controller.rb +0 -42
  132. data/lib/generators/cambium/templates/app/controllers/admin/posts_controller.rb +0 -39
  133. data/lib/generators/cambium/templates/app/controllers/admin/taggings_controller.rb +0 -69
  134. data/lib/generators/cambium/templates/app/controllers/admin/tags_controller.rb +0 -11
  135. data/lib/generators/cambium/templates/app/controllers/admin/users_controller.rb +0 -13
  136. data/lib/generators/cambium/templates/app/controllers/admin_controller.rb +0 -97
  137. data/lib/generators/cambium/templates/app/controllers/images_controller.rb +0 -45
  138. data/lib/generators/cambium/templates/app/controllers/pages_controller.rb +0 -12
  139. data/lib/generators/cambium/templates/app/controllers/posts_controller.rb +0 -11
  140. data/lib/generators/cambium/templates/app/helpers/admin/pages_controller.rb +0 -47
  141. data/lib/generators/cambium/templates/app/helpers/admin_helper.rb +0 -121
  142. data/lib/generators/cambium/templates/app/models/concerns/name.rb +0 -7
  143. data/lib/generators/cambium/templates/app/models/concerns/title.rb +0 -7
  144. data/lib/generators/cambium/templates/app/models/image.rb +0 -43
  145. data/lib/generators/cambium/templates/app/models/page.rb +0 -81
  146. data/lib/generators/cambium/templates/app/models/post.rb +0 -45
  147. data/lib/generators/cambium/templates/app/models/tag.rb +0 -33
  148. data/lib/generators/cambium/templates/app/models/tagging.rb +0 -20
  149. data/lib/generators/cambium/templates/app/uploaders/image_uploader.rb +0 -91
  150. data/lib/generators/cambium/templates/app/views/admin/_buttons.html.erb +0 -5
  151. data/lib/generators/cambium/templates/app/views/admin/_form.html.erb +0 -11
  152. data/lib/generators/cambium/templates/app/views/admin/_title.html.erb +0 -1
  153. data/lib/generators/cambium/templates/app/views/admin/edit.html.erb +0 -2
  154. data/lib/generators/cambium/templates/app/views/admin/images/_image.html.erb +0 -1
  155. data/lib/generators/cambium/templates/app/views/admin/images/create.js.erb +0 -7
  156. data/lib/generators/cambium/templates/app/views/admin/images/index.json.jbuilder +0 -4
  157. data/lib/generators/cambium/templates/app/views/admin/index.html.erb +0 -50
  158. data/lib/generators/cambium/templates/app/views/admin/new.html.erb +0 -2
  159. data/lib/generators/cambium/templates/app/views/admin/pages/_form.html.erb +0 -26
  160. data/lib/generators/cambium/templates/app/views/admin/posts/_form.html.erb +0 -40
  161. data/lib/generators/cambium/templates/app/views/admin/shared/_footer.html.erb +0 -2
  162. data/lib/generators/cambium/templates/app/views/admin/shared/_header.html.erb +0 -2
  163. data/lib/generators/cambium/templates/app/views/admin/shared/_insert_image.html.erb +0 -12
  164. data/lib/generators/cambium/templates/app/views/admin/shared/_nav.html.erb +0 -12
  165. data/lib/generators/cambium/templates/app/views/admin/shared/_status.html.erb +0 -3
  166. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_editor.html.erb +0 -54
  167. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_column_left.html.erb +0 -9
  168. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_column_right.html.erb +0 -9
  169. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_page.html.erb +0 -22
  170. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_section.html.erb +0 -8
  171. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_publishable.html.erb +0 -33
  172. data/lib/generators/cambium/templates/app/views/admin/users/_form.html.erb +0 -11
  173. data/lib/generators/cambium/templates/app/views/application/_status.html.erb +0 -3
  174. data/lib/generators/cambium/templates/app/views/layouts/.DS_Store +0 -0
  175. data/lib/generators/cambium/templates/app/views/layouts/admin.html.erb +0 -44
  176. data/lib/generators/cambium/templates/app/views/page_templates/default.html.erb +0 -2
  177. data/lib/generators/cambium/templates/app/views/posts/_post.html.erb +0 -4
  178. data/lib/generators/cambium/templates/app/views/posts/index.html.erb +0 -1
  179. data/lib/generators/cambium/templates/app/views/posts/show.html.erb +0 -10
  180. data/lib/generators/cambium/templates/config/app_routes.rb +0 -77
  181. data/lib/generators/cambium/templates/config/database.mysql2.yml.erb +0 -15
  182. data/lib/generators/cambium/templates/config/database.pg.yml.erb +0 -14
  183. data/lib/generators/cambium/templates/config/database.sqlite3.yml.erb +0 -18
  184. data/lib/generators/cambium/templates/config/initializers/_settings.rb +0 -11
  185. data/lib/generators/cambium/templates/config/initializers/assets.rb +0 -1
  186. data/lib/generators/cambium/templates/config/routes.rb.erb +0 -42
  187. data/lib/generators/cambium/templates/config/settings.yml +0 -15
  188. data/lib/generators/cambium/templates/config/settings_private.sample.yml +0 -15
  189. data/lib/generators/cambium/templates/config/settings_private.yml +0 -13
  190. data/lib/generators/cambium/templates/db/migrate/create_pages.rb.erb +0 -24
  191. data/lib/generators/cambium/templates/db/migrate/create_posts.rb +0 -19
  192. data/lib/generators/cambium/templates/lib/.DS_Store +0 -0
  193. data/lib/help/cambium +0 -7
  194. /data/{lib/generators/cambium/templates/app/assets/javascripts/backbone/collections → app/assets/javascripts/cambium/admin/templates}/.keep +0 -0
  195. /data/{lib/generators/cambium/templates/app/assets/javascripts/backbone → app/assets/javascripts/cambium/admin}/views/default_helpers.js.coffee +0 -0
  196. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/__default.scss +0 -0
  197. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_buttons.scss +0 -0
  198. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_components.scss +0 -0
  199. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_forms.scss +0 -0
  200. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_helpers.scss +0 -0
  201. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_images.scss +0 -0
  202. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_nav.scss +0 -0
  203. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_tables.scss +0 -0
  204. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_typography.scss +0 -0
  205. /data/{lib/generators/cambium/templates/app/assets/stylesheets → app/assets/stylesheets/cambium}/admin/bones/bones-config/_wireframe.scss +0 -0
  206. /data/{lib/generators/cambium/templates/app → app}/models/concerns/idx.rb +0 -0
  207. /data/{lib/generators/cambium/templates/app → app}/models/concerns/image_cropper.rb +0 -0
  208. /data/{lib/generators/cambium/templates/app → app}/models/concerns/publishable.rb +0 -0
  209. /data/{lib/generators/cambium/templates/app → app}/models/concerns/slug.rb +0 -0
  210. /data/{lib/generators/cambium/templates/app → app}/models/concerns/tags.rb +0 -0
  211. /data/lib/generators/{cambium/helpers → helpers}/_autoloader.rb +0 -0
  212. /data/lib/generators/{cambium/templates/app/assets/javascripts/backbone → templates/app/assets/javascripts}/routers/router.js.coffee +0 -0
  213. /data/lib/generators/{cambium/templates/app/assets/javascripts/backbone/models → templates/app/assets/javascripts/templates}/.keep +0 -0
  214. /data/lib/generators/{cambium/templates → templates}/app/assets/stylesheets/application.scss +0 -0
  215. /data/lib/generators/{cambium/templates → templates}/app/views/home/index.html.erb +0 -0
  216. /data/lib/generators/{cambium/templates → templates}/db/seeds.rb +0 -0
  217. /data/{lib/generators/cambium/templates/vendor → vendor}/assets/javascripts/modernizr.js +0 -0
  218. /data/{lib/generators/cambium/templates/vendor → vendor}/assets/stylesheets/normalize.scss +0 -0
@@ -1,162 +0,0 @@
1
- require 'rake'
2
- require 'rails/generators'
3
- require File.expand_path('../../helpers/_autoloader.rb', __FILE__)
4
-
5
- module Cambium
6
- module Install
7
- class AppGenerator < Rails::Generators::Base
8
- desc "Setup app files for new rails project"
9
-
10
- source_root File.expand_path('../../templates', __FILE__)
11
-
12
- # Add a default public controller, so we have a working home page when
13
- # we're done.
14
- #
15
- def add_home_controller
16
- generate "controller home index"
17
- gsub_file("config/routes.rb", /\ \ get\ \'home\/index\'\n\n/, '')
18
- end
19
-
20
- # Add our default routes, ommitting admin routes (which are added via the
21
- # admin generator)
22
- #
23
- def add_default_routes
24
- insert_into_file(
25
- "config/routes.rb",
26
- file_contents("config/app_routes.rb"),
27
- :after => "Rails.application.routes.draw do"
28
- )
29
- end
30
-
31
- # Add our default public views
32
- #
33
- def add_public_views
34
- directory "app/views/application"
35
- directory "app/views/home", :force => true
36
- end
37
-
38
- # Our layouts are templated so we can start with some custom information.
39
- #
40
- def add_layouts
41
- @site_title = Rails.application.class.parent_name.humanize.titleize
42
- site_title = ask "\n#{set_color('App Title:', :green, :bold)} [default: #{@site_title}]"
43
- @site_title = site_title unless site_title.blank?
44
-
45
- app = "app/views/layouts/application.html.erb"
46
- remove_file app
47
- template app, app
48
- end
49
-
50
- # Backbone.js is our default javascript framework. We don't yet have an
51
- # option to ignore, so here we automatically install it.
52
- #
53
- def install_backbone
54
- directory "app/assets/javascripts/backbone",
55
- "app/assets/javascripts"
56
- end
57
-
58
- # Next, we need to replace our application.js file to add backbone and its
59
- # dependencies, along with our default scripts.
60
- #
61
- def default_application_js
62
- app_js = "app/assets/javascripts/application.js"
63
- remove_file app_js
64
- template app_js, app_js
65
- end
66
-
67
- # Don't forget about modernizr! This is where all the other vendor scripts
68
- # should be added, although today we only use Modernizr.
69
- #
70
- # Modernizr is called from the application layout since it is
71
- # automatically added.
72
- #
73
- def add_other_vendor_javascripts
74
- modernizr = "vendor/assets/javascripts/modernizr.js"
75
- copy_file modernizr, modernizr
76
- end
77
-
78
- # Now we need to add our styles. We begin here by adding our vendor styles
79
- # that are not already available via a gem.
80
- #
81
- def add_vendor_styles
82
- normalize = "vendor/assets/stylesheets/normalize.scss"
83
- template normalize, normalize
84
- end
85
-
86
- # Once we have the files and gems we need, we can add our public manifest
87
- # file. We ask the user if they are ok with us deleting theirs.
88
- #
89
- # Note: Injecting seems easier here, and it would be, but we can't predict
90
- # the name of this file, which is why we don't do it. It could be done
91
- # with a longer method.
92
- #
93
- def add_public_manifest
94
- q = "\nWe're going to add our default application.scss file and remove yours. Is that ok?"
95
- if yes? q
96
- ['css','scss','scss.css'].each { |ext| remove_file "app/assets/stylesheets/application.#{ext}" }
97
- end
98
- template "app/assets/stylesheets/application.scss",
99
- "app/assets/stylesheets/application.scss"
100
- end
101
-
102
- # If we have the user model generated, then we will try to create a
103
- # default user.
104
- #
105
- def add_default_user
106
- if class_exists?('User')
107
- create_user
108
- else
109
- msg = "\nUser model does not exist yet. If you want to use Cambium "
110
- msg += "to add a user model, then you can run:\n"
111
- say set_color(msg, :yellow, :bold)
112
- say " $ bundle exec rake cambium:model:user\n\n"
113
- msg = "and Cambium will handle the installation of Devise.\n"
114
- say set_color(msg, :yellow, :bold)
115
- end
116
- end
117
-
118
- # Add some gems to the gemfile, but don't install (we've been running into
119
- # dependency issues)
120
- #
121
- def add_application_gems
122
- gems = [
123
- 'unicorn-rails',
124
- 'jquery-rails',
125
- 'uglifier',
126
- 'sass-rails',
127
- 'bourbon',
128
- 'coffee-rails',
129
- 'backbone-on-rails'
130
- ]
131
- add_gems_to_gemfile(gems)
132
- added_gems = []
133
- gems.each { |g| added_gems << g unless gem_exists?(g) }
134
- gemfile_update_notification(added_gems)
135
- end
136
-
137
- # ------------------------------------------ Private Methods
138
-
139
- private
140
-
141
- # create_user is down here because it can then keep looping until a
142
- # valid record is created.
143
- #
144
- def create_user
145
- email = confirm_ask "#{set_color('Default User Email', :green, :bold)}:"
146
- password = confirm_ask "#{set_color('Default User Password', :green, :bold)}:"
147
- u = User.new(
148
- :email => email,
149
- :password => password,
150
- :password_confirmation => password,
151
- )
152
- u.is_admin = true if u.respond_to?(:is_admin)
153
- if u.save
154
- say "User created successfully!"
155
- else
156
- create_user
157
- end
158
- end
159
-
160
- end
161
- end
162
- end
@@ -1,182 +0,0 @@
1
- require 'rake'
2
- require 'rails/generators'
3
- require File.expand_path('../../helpers/_autoloader.rb', __FILE__)
4
-
5
- module Cambium
6
- module Install
7
- class ConfigGenerator < Rails::Generators::Base
8
- desc "Setup config files for new rails project"
9
-
10
- source_root File.expand_path('../../templates', __FILE__)
11
-
12
- # Initialize git repository. If repo was already initialized, repo is
13
- # reinitialized, but that shouldn't hurt anything.
14
- #
15
- def git_init
16
- run_cmd "git init"
17
- end
18
-
19
- # Set vars to use throughout this generator
20
- #
21
- def cambium_setup
22
- @config = {
23
- :db => {},
24
- :app => {}
25
- }
26
- end
27
-
28
- # Read existing project files to set default config values
29
- #
30
- def auto_config
31
- # read Gemfile
32
- File.open("#{Rails.root}/Gemfile") do |f|
33
- f.each_line do |line|
34
- # find database adapter
35
- if line.include?("'mysql2'")
36
- @config[:db][:adapter] = "mysql2"
37
- elsif line.include?("'pg'")
38
- @config[:db][:adapter] = "pg"
39
- elsif line.include?("'sqlite3'")
40
- @config[:db][:adapter] = "sqlite3"
41
- end
42
- # find rails version
43
- if line.match(/gem\ \'rails\'/)
44
- @config[:app][:version] = line.gsub(/gem\ \'rails\'\,/, '').gsub(/\'/, '').strip
45
- end
46
- end
47
- end
48
- # Find the application class name
49
- @config[:app][:name] = Rails.application.class.parent_name
50
- end
51
-
52
- # These next few methods let the user adjust the default config if they
53
- # wish. Otherwise, we use default values from the previous method.
54
- #
55
- # --------
56
- #
57
- # Set correct database adapter.
58
- #
59
- # Note: If the user wants to change the adapter, we *could* change the
60
- # adapter on the fly and install the new one here. Instead, we tell the
61
- # user what to do and exit. This make absolutely sure we've gotten rid of
62
- # the original adapter in the Gemfile and added the new one.
63
- #
64
- def set_database_adapter
65
- if @config[:db][:adapter].present?
66
- if yes?("\nCambium, in all its wisdom, thinks your database adapter as #{set_color(@config[:db][:adapter], :green, :bold)}. Is this correct? [yes, no]")
67
- say("Oh, goodie! Moving on...")
68
- else
69
- new_adapter = ask("What would you prefer?", :limited_to => ['mysql2','pg','sqlite3'])
70
- unless new_adapter == @config[:db][:adapter]
71
- say set_color("\nPlease add:", :red, :bold)
72
- say "\n gem '#{new_adapter}'"
73
- say set_color("\nto your Gemfile. Then run `bundle install` and `bundle exec cambium setup`.", :red, :bold)
74
- exit
75
- end
76
- end
77
- end
78
- end
79
-
80
- # Set the database base name (where we append "_#{stage}" to each stage)
81
- #
82
- def set_database_name
83
- @config[:db][:name] = @config[:app][:name].underscore.downcase
84
- db_name = ask "\n#{set_color('Database Base Name:', :green, :bold)} [default: #{@config[:db][:name]}]"
85
- @config[:db][:name] = db_name unless db_name.blank?
86
- end
87
-
88
- # Set database credentials
89
- #
90
- def set_database_creds
91
- @config[:db][:user] = confirm_ask("#{set_color('Database User', :green, :bold)}: [leave blank for no user]")
92
- if @config[:db][:user].present?
93
- @config[:db][:password] = confirm_ask("#{set_color('Database Password', :green, :bold)}: [leave blank for no password]")
94
- else
95
- @config[:db][:password] = ''
96
- end
97
- end
98
-
99
- # Set root URL (for mailers)
100
- #
101
- def set_root_url
102
- # development
103
- @config[:app][:dev_url] = ask("\n#{set_color('Development URL', :green, :bold)}: [leave blank for localhost:3000]")
104
- @config[:app][:dev_url] = 'localhost:3000' if @config[:app][:dev_url].blank?
105
- environment(
106
- "config.action_mailer.default_url_options = { :host => '#{@config[:app][:dev_url]}' }",
107
- :env => "development"
108
- )
109
- # production
110
- @config[:app][:prod_url] = ask("#{set_color('Production URL', :green, :bold)}: [leave blank for localhost:3000]")
111
- @config[:app][:prod_url] = 'localhost:3000' if @config[:app][:prod_url].blank?
112
- environment(
113
- "config.action_mailer.default_url_options = { :host => '#{@config[:app][:prod_url]}' }",
114
- :env => "production"
115
- )
116
- environment(
117
- "config.assets.precompile += %w( admin/admin.css admin/admin.js admin/wysihtml5.css modernizr.js )",
118
- :env => "production"
119
- )
120
- end
121
-
122
- # Add settings to application config file (config/application.rb)
123
- #
124
- def add_application_config
125
- environment { file_contents("config/application.rb") }
126
- end
127
-
128
- # Assets initializer for Rails 4.1+
129
- #
130
- def add_assets_initializer
131
- template "config/initializers/assets.rb",
132
- "config/initializers/assets.rb"
133
- end
134
-
135
- # Create database based on custom config
136
- #
137
- def setup_database
138
- copy_file "#{Rails.root}/config/database.yml", "config/database.sample.yml"
139
- remove_file "config/database.yml"
140
- template "config/database.#{@config[:db][:adapter]}.yml.erb", "config/database.yml"
141
- rake "db:create"
142
- rake "db:migrate"
143
- end
144
-
145
- # Add custom gitignore file
146
- #
147
- def add_gitignore
148
- remove_file ".gitignore"
149
- template "gitignore", ".gitignore"
150
- end
151
-
152
- # We used to start the user out by installing all the gems we will need
153
- # throughout the project. Now, we're going to ask the user if they want to
154
- # replace their Gemfile with our custom file. If they say "no," then we
155
- # will install the gems we need at a later step.
156
- #
157
- def add_recommended_gems
158
- msg = "\nWe have a set of gems we recommend by default. You can \n"
159
- msg += "start with this Gemfile if you'd like. Of course, we'll \n"
160
- msg += "install gems for you when we need them."
161
- say msg
162
- if yes? "\nWould you like to replace your existing Gemfile with our default?"
163
- remove_file "Gemfile"
164
- template "Gemfile.erb", "Gemfile"
165
- say "\nYour Gemfile has been updated, but now you need to run:"
166
- say "\n $ bundle install"
167
- say "\nto install all your gems. Feel free to any gems you don't want, "
168
- say "\nsince we will add gems to your project as we need them."
169
- else
170
- say "You got it!"
171
- end
172
- end
173
-
174
- # Outgoing message
175
- #
176
- def tell_user_we_are_done
177
- say "\n#{set_color('Config completed!', :green, :bold)}"
178
- end
179
-
180
- end
181
- end
182
- end
@@ -1,57 +0,0 @@
1
- require 'rake'
2
- require 'rails/generators'
3
- require "#{Gem::Specification.find_by_name("cambium").gem_dir}/lib/generators/cambium/helpers/generators_helper.rb"
4
- include Cambium::GeneratorsHelper
5
-
6
- module Cambium
7
- module Install
8
- class UtilitiesGenerator < Rails::Generators::Base
9
- desc "Setup utilities for new rails project"
10
-
11
- # ------------------------------------------ Class Methods
12
-
13
- source_root File.expand_path('../../templates', __FILE__)
14
-
15
- # ------------------------------------------ Model Concerns
16
-
17
- def add_model_concerns
18
- [
19
- 'idx',
20
- 'name',
21
- 'publishable',
22
- 'slug',
23
- 'title',
24
- ].each do |concern|
25
- copy_file "app/models/concerns/#{concern}.rb",
26
- "app/models/concerns/#{concern}.rb"
27
- end
28
- end
29
-
30
- # ------------------------------------------ Settings Files
31
-
32
- def add_settings_files
33
- template "config/initializers/_settings.rb",
34
- "config/initializers/_settings.rb"
35
- ['settings','settings_private','settings_private.sample'].each do |s|
36
- template "config/#{s}.yml", "config/#{s}.yml"
37
- end
38
- end
39
-
40
- # ------------------------------------------ Seeds
41
-
42
- def add_seed_generator
43
- remove_file "db/seeds.rb"
44
- template "db/seeds.rb", "db/seeds.rb"
45
- end
46
-
47
- # ------------------------------------------ Rake Tasks
48
-
49
- def add_rake_tasks
50
- ['db','rename'].each do |task|
51
- template "lib/tasks/#{task}.rake", "lib/tasks/#{task}.rake"
52
- end
53
- end
54
-
55
- end
56
- end
57
- end
@@ -1,67 +0,0 @@
1
- require 'rake'
2
- require 'rails/generators'
3
- require File.expand_path('../../helpers/_autoloader.rb', __FILE__)
4
-
5
- module Cambium
6
- module Model
7
- class ImageGenerator < Rails::Generators::Base
8
- desc "Create a simple image model"
9
-
10
- source_root File.expand_path('../../templates', __FILE__)
11
-
12
- # Let's make sure we have the admin setup already.
13
- #
14
- def set_dependencies
15
- check_dependencies(['cambium:install:admin'])
16
- end
17
-
18
- # Install gems we need for images
19
- #
20
- def install_gem_dependencies
21
- install_gem 'carrierwave'
22
- install_gem 'rmagick', :require => 'RMagick'
23
- end
24
-
25
- # Since the Image model is so simple, we can generate it from the command
26
- # line instead of copying templates.
27
- #
28
- def generate_model
29
- generate "model Image filename"
30
- end
31
-
32
- # Add our pre-built model file
33
- #
34
- def add_model_files
35
- copy_file("app/models/image.rb", "app/models/image.rb", :force => true)
36
- end
37
-
38
- # Add our image uploader, which uses CarrierWave
39
- #
40
- def add_uploaders
41
- generate "uploader Image"
42
- uploader_path = "app/uploaders/image_uploader.rb"
43
- copy_file uploader_path, uploader_path, :force => true
44
- end
45
-
46
- # Add our image cropper model concern. Currently, we don't have the
47
- # cropping tool functional within the admin.
48
- #
49
- def add_model_concerns
50
- add_model_concern 'image_cropper'
51
- end
52
-
53
- # Before we finish up, we need to add our admin files.
54
- #
55
- def add_admin_files
56
- template("app/controllers/admin/images_controller.rb",
57
- "app/controllers/admin/images_controller.rb")
58
- directory("app/views/admin/images", "app/views/admin/images")
59
- end
60
-
61
- def finish_up
62
- migrate_and_annotate
63
- end
64
-
65
- end
66
- end
67
- end
@@ -1,131 +0,0 @@
1
- require 'rake'
2
- require 'rails/generators'
3
- require File.expand_path('../../helpers/_autoloader.rb', __FILE__)
4
-
5
- module Cambium
6
- module Model
7
- class PageGenerator < Rails::Generators::Base
8
- desc "Add pages to your project"
9
-
10
- source_root File.expand_path('../../templates', __FILE__)
11
-
12
- # Since we're using images, we need to make sure the image generator has
13
- # already been run. And, like all other models, we want to make sure we
14
- # already have an admin available to us.
15
- #
16
- def set_dependencies
17
- check_dependencies(['cambium:install:admin','cambium:model:image'])
18
- end
19
-
20
- # We need a couple concerns, so we add them here unless they are already
21
- # part of the project.
22
- #
23
- def add_concerns
24
- add_model_concerns(['publishable', 'slug'])
25
- end
26
-
27
- # Add our model file.
28
- #
29
- def add_model_files
30
- template("app/models/page.rb", "app/models/page.rb")
31
- end
32
-
33
- # Since we have to customize the up/down methods in the migration, we
34
- # don't generate the model, we just copy an interpreted template.
35
- #
36
- def add_migration_files
37
- template(
38
- "db/migrate/create_pages.rb.erb",
39
- "db/migrate/#{timestamp}_create_pages.rb"
40
- )
41
- migrate_and_annotate
42
- end
43
-
44
- # We are setting a global template directory for reference throughout the
45
- # project.
46
- #
47
- def add_application_config
48
- application 'config.template_directory = "#{Rails.root}/app/views/page_templates"'
49
- end
50
-
51
- # We add our page templates directory and our default template.
52
- #
53
- def add_page_templates
54
- directory('app/views/page_templates','app/views/page_templates')
55
- end
56
-
57
- # We have two controllers here -- one for the app and one for the admin.
58
- # We'll add them both instead of generating them since they are
59
- # customized.
60
- #
61
- def add_controller_files
62
- template("app/controllers/pages_controller.rb",
63
- "app/controllers/pages_controller.rb")
64
- template("app/controllers/admin/pages_controller.rb",
65
- "app/controllers/admin/pages_controller.rb")
66
- end
67
-
68
- # We add the customized views that override the default admin views, while
69
- # the app views are driven by the page template
70
- #
71
- def add_admin_views
72
- directory("app/views/admin/pages", "app/views/admin/pages")
73
- end
74
-
75
- # We need to add routes to routes file for the app and the admin. We
76
- # expect to see an admin, so we don't have a check, but we do need the
77
- # public route. Since the contents of the routes file are variable, we
78
- # have a check and notify the user if we can't find what we need.
79
- #
80
- def add_routes
81
- # App
82
- insert_into_file(
83
- "config/routes.rb",
84
- "get '/:slug', :to => 'pages#show', :as => 'page'\n\n ",
85
- :before => /root\ (.*)\n/
86
- )
87
- if File.read(Rails.root.join('config','routes.rb')).include?('/:slug')
88
- uncomment_lines(
89
- Rails.root.join('config','routes.rb'),
90
- /get\ \'\/\:slug/
91
- )
92
- else
93
- add_routes_manually
94
- end
95
- # Admin
96
- insert_into_file(
97
- "config/routes.rb",
98
- " resources :pages, :except => [:show]\n",
99
- :after => /namespace\ \:admin(.*)\n/
100
- )
101
- end
102
-
103
- # In the admin helper, we can add a link and an icon to the sidebar. The
104
- # easiest way to do this is to add it to the top. The user can move if
105
- # they'd like.
106
- #
107
- def add_admin_icon
108
- insert_into_file(
109
- "app/helpers/admin_helper.rb",
110
- file_contents('_partials/pages/admin_icon.rb'),
111
- :after => /items\ \=\ \[\n/
112
- )
113
- end
114
-
115
- private
116
-
117
- # If we couldn't find a root route in the config file, then we tell the
118
- # user to add the routes manually.
119
- #
120
- def add_routes_manually
121
- say set_color(
122
- "\nAdd the following to the end of your config/routes.rb file:\n",
123
- :yellow,
124
- :bold
125
- )
126
- say " get '/:slug', :to => 'pages#show', :as => 'page'\n"
127
- end
128
-
129
- end
130
- end
131
- end
@@ -1,71 +0,0 @@
1
- require 'rake'
2
- require 'rails/generators'
3
- require "#{Gem::Specification.find_by_name("cambium").gem_dir}/lib/generators/cambium/helpers/generators_helper.rb"
4
- include Cambium::GeneratorsHelper
5
-
6
- module Cambium
7
- module Model
8
- class PostGenerator < Rails::Generators::Base
9
- desc "Add blog posts to your project"
10
-
11
- # ------------------------------------------ Class Methods
12
-
13
- source_root File.expand_path('../../templates', __FILE__)
14
-
15
- # ------------------------------------------ Model Concern
16
-
17
- def add_model_concerns
18
- copy_file "app/models/concerns/publishable.rb", "app/models/concerns/publishable.rb"
19
- copy_file "app/models/concerns/slug.rb", "app/models/concerns/slug.rb"
20
- copy_file "app/models/concerns/tags.rb", "app/models/concerns/tags.rb"
21
- end
22
-
23
- # ------------------------------------------ Add Model Templates
24
-
25
- def add_model_files
26
- model_path = "app/models/post.rb"
27
- template(model_path, model_path)
28
- end
29
-
30
- # ------------------------------------------ Add Migration Templates
31
-
32
- def add_migration_files
33
- template(
34
- 'db/migrate/create_posts.rb',
35
- "db/migrate/#{timestamp}_create_posts.rb"
36
- )
37
- end
38
-
39
- # ------------------------------------------ Add Controller Templates
40
-
41
- def add_controller_files
42
- controller_path = "app/controllers/posts_controller.rb"
43
- template(controller_path, controller_path)
44
- end
45
-
46
- # ------------------------------------------ Add View Templates
47
-
48
- def add_view_files
49
- view_path = "app/views/posts"
50
- directory(view_path, view_path)
51
- end
52
-
53
- # ------------------------------------------ Migrate & Annotate
54
-
55
- def migrate_and_annotate
56
- rake "db:migrate"
57
- run_cmd "#{be} annotate"
58
- end
59
-
60
- # ------------------------------------------ User output
61
- # This is kind of a cop out in leu of appending to the *end* of routes.rb
62
- def notes_to_user
63
- puts "\n== Don't forget to add routes for blog posts ================="
64
- puts "get '/news', :to => 'posts#index', :as => 'posts'"
65
- puts "get '/news/:slug', :to => 'posts#show', :as => 'post'"
66
- puts "\n"
67
- end
68
-
69
- end
70
- end
71
- end