cambium 0.2.2 → 0.3.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.
- checksums.yaml +4 -4
- data/cambium.gemspec +25 -23
- data/lib/cambium/version.rb +1 -1
- data/lib/generators/cambium/helpers/_autoloader.rb +12 -0
- data/lib/generators/cambium/helpers/dependencies_helper.rb +58 -0
- data/lib/generators/cambium/helpers/generators_helper.rb +227 -0
- data/lib/generators/cambium/install/admin_generator.rb +68 -74
- data/lib/generators/cambium/install/app_generator.rb +86 -95
- data/lib/generators/cambium/install/config_generator.rb +98 -108
- data/lib/generators/cambium/install/utilities_generator.rb +2 -50
- data/lib/generators/cambium/model/image_generator.rb +67 -0
- data/lib/generators/cambium/model/page_generator.rb +131 -0
- data/lib/generators/cambium/model/post_generator.rb +71 -0
- data/lib/generators/cambium/model/tag_generator.rb +40 -0
- data/lib/generators/cambium/model/user_generator.rb +78 -0
- data/lib/generators/cambium/templates/Gemfile +43 -0
- data/lib/generators/cambium/templates/_partials/pages/admin_icon.rb +6 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/admin.js.coffee +3 -1
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/models/image.js.coffee +14 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/models/tag.js.coffee +14 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/parser_rules/custom.js +552 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/routers/router.js.coffee +21 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/tag.jst.ejs +7 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/templates/image.jst.ejs +3 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/templates/post_tag.jst.ejs +1 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/image_upload.js.coffee +28 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/tags.js.coffee +158 -0
- data/lib/generators/cambium/templates/app/assets/javascripts/admin/views/wysiwyg.js.coffee +77 -0
- data/lib/generators/cambium/templates/app/controllers/admin/images_controller.rb +45 -0
- data/lib/generators/cambium/templates/app/controllers/admin/pages_controller.rb +42 -0
- data/lib/generators/cambium/templates/app/controllers/admin/posts_controller.rb +39 -0
- data/lib/generators/cambium/templates/app/controllers/admin/taggings_controller.rb +69 -0
- data/lib/generators/cambium/templates/app/controllers/admin/tags_controller.rb +11 -0
- data/lib/generators/cambium/templates/app/controllers/admin_controller.rb +11 -2
- data/lib/generators/cambium/templates/app/controllers/application_controller.rb +2 -2
- data/lib/generators/cambium/templates/app/controllers/images_controller.rb +45 -0
- data/lib/generators/cambium/templates/app/controllers/pages_controller.rb +12 -0
- data/lib/generators/cambium/templates/app/controllers/posts_controller.rb +11 -0
- data/lib/generators/cambium/templates/app/helpers/admin/pages_controller.rb +47 -0
- data/lib/generators/cambium/templates/app/helpers/admin_helper.rb +1 -1
- data/lib/generators/cambium/templates/app/models/concerns/image_cropper.rb +24 -0
- data/lib/generators/cambium/templates/app/models/concerns/publishable.rb +32 -4
- data/lib/generators/cambium/templates/app/models/concerns/slug.rb +4 -0
- data/lib/generators/cambium/templates/app/models/concerns/tags.rb +6 -1
- data/lib/generators/cambium/templates/app/models/image.rb +43 -0
- data/lib/generators/cambium/templates/app/models/page.rb +81 -0
- data/lib/generators/cambium/templates/app/models/post.rb +45 -0
- data/lib/generators/cambium/templates/app/models/tag.rb +33 -0
- data/lib/generators/cambium/templates/app/models/tagging.rb +20 -0
- data/lib/generators/cambium/templates/app/uploaders/image_uploader.rb +91 -0
- data/lib/generators/cambium/templates/app/views/admin/images/_image.html.erb +1 -0
- data/lib/generators/cambium/templates/app/views/admin/images/create.js.erb +7 -0
- data/lib/generators/cambium/templates/app/views/admin/images/index.json.jbuilder +4 -0
- data/lib/generators/cambium/templates/app/views/admin/pages/_form.html.erb +26 -0
- data/lib/generators/cambium/templates/app/views/admin/posts/_form.html.erb +40 -0
- data/lib/generators/cambium/templates/app/views/admin/shared/_insert_image.html.erb +12 -0
- data/lib/generators/cambium/templates/app/views/admin/shared/forms/_editor.html.erb +3 -3
- data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_page.html.erb +5 -1
- data/lib/generators/cambium/templates/app/views/home/index.html.erb +7 -0
- data/lib/generators/cambium/templates/app/views/page_templates/default.html.erb +2 -0
- data/lib/generators/cambium/templates/app/views/posts/_post.html.erb +4 -0
- data/lib/generators/cambium/templates/app/views/posts/index.html.erb +1 -0
- data/lib/generators/cambium/templates/app/views/posts/show.html.erb +10 -0
- data/lib/generators/cambium/templates/config/app_routes.rb +77 -0
- data/lib/generators/cambium/templates/config/routes.rb.erb +11 -2
- data/lib/generators/cambium/templates/db/migrate/create_pages.rb.erb +24 -0
- data/lib/generators/cambium/templates/db/migrate/create_posts.rb +19 -0
- data/lib/generators/cambium/templates/gitignore +1 -0
- metadata +52 -256
- data/lib/generators/cambium/install/users_generator.rb +0 -104
- data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_icons.scss +0 -5194
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6881a831904e091c4228d69c086ba4a5622c60be
|
|
4
|
+
data.tar.gz: a35bac2b1517e59608167978861ca1a92cb1b94c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0fcfddb768d58f562c4243f7b3506d08b37e2e5bb3968c04db8b3ea9a7a6d42b66ad263e53b327aeb8d1443e9ac62cb4782c2c5f4930d5a601f059841c9cb7d0
|
|
7
|
+
data.tar.gz: 2ec1f058a8301385f794bb1ae7c623e93ae5eec0d874fbda981c030b27f6b872ff8134cda3ecce8452c52ac72bb108b26bd7d95ee5a2739286394ffd84ca528e
|
data/cambium.gemspec
CHANGED
|
@@ -6,8 +6,8 @@ require 'cambium/version'
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "cambium"
|
|
8
8
|
spec.version = Cambium::VERSION
|
|
9
|
-
spec.authors = ["Sean C Davis"]
|
|
10
|
-
spec.email = ["scdavis41@gmail.com"]
|
|
9
|
+
spec.authors = ["Sean C Davis","Warren Harrison"]
|
|
10
|
+
spec.email = ["scdavis41@gmail.com","warren@hungry-media.com"]
|
|
11
11
|
spec.summary = %q{Rails generators to facilitate development.}
|
|
12
12
|
spec.description = %q{}
|
|
13
13
|
spec.homepage = ""
|
|
@@ -21,26 +21,28 @@ Gem::Specification.new do |spec|
|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.6"
|
|
22
22
|
spec.add_dependency "rake"
|
|
23
23
|
spec.add_dependency "rails"
|
|
24
|
-
|
|
25
|
-
[
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
24
|
+
|
|
25
|
+
# [
|
|
26
|
+
# 'ancestry',
|
|
27
|
+
# 'annotate', all models
|
|
28
|
+
# 'backbone-on-rails', install:app
|
|
29
|
+
# 'bones-rails',
|
|
30
|
+
# 'bourbon', install:app
|
|
31
|
+
# 'coffee-rails', install:app
|
|
32
|
+
# 'devise', model:user
|
|
33
|
+
# 'factory_girl_rails',
|
|
34
|
+
# 'faker',
|
|
35
|
+
# 'hirb',
|
|
36
|
+
# 'jbuilder',
|
|
37
|
+
# 'jquery-rails', install:app
|
|
38
|
+
# 'jquery-fileupload-rails',
|
|
39
|
+
# 'kaminari',
|
|
40
|
+
# 'pickadate-rails',
|
|
41
|
+
# 'sass-rails', install:app
|
|
42
|
+
# 'simple_form',
|
|
43
|
+
# 'uglifier', install:app
|
|
44
|
+
# 'unicorn-rails', install:app
|
|
45
|
+
# 'wysihtml5-rails',
|
|
46
|
+
# ].each { |g| spec.add_dependency g }
|
|
45
47
|
|
|
46
48
|
end
|
data/lib/cambium/version.rb
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Dir.glob(File.expand_path('../../helpers/**/*.rb', __FILE__)).each do |file|
|
|
2
|
+
unless file == __FILE__
|
|
3
|
+
require file
|
|
4
|
+
module_name = []
|
|
5
|
+
File.read(file).each_line do |line|
|
|
6
|
+
if line =~ /module\ /
|
|
7
|
+
module_name << line.gsub(/module\ /, '').strip
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
include module_name.join('::').constantize
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
module Cambium
|
|
2
|
+
module DependenciesHelper
|
|
3
|
+
|
|
4
|
+
# This method accepts an array of dependencies as THE GENERATOR COMMAND. So,
|
|
5
|
+
# for example, if we need to make sure `bundle exec rails generate
|
|
6
|
+
# cambium:install:users` has been run, we would call
|
|
7
|
+
# check_dependencies(['cambium:install:users']).
|
|
8
|
+
#
|
|
9
|
+
# We use that value to determine the subsequent method to call. So,
|
|
10
|
+
# check_dependencies(['cambium:install:users']) will call
|
|
11
|
+
# require_cambium_install_users
|
|
12
|
+
#
|
|
13
|
+
def check_dependencies(dependencies = [])
|
|
14
|
+
cmds = []
|
|
15
|
+
dependencies.each do |d|
|
|
16
|
+
cmds << d unless eval("#{d.split(':').join('_')}_generated?")
|
|
17
|
+
end
|
|
18
|
+
if cmds.size > 0
|
|
19
|
+
display_dependency_errors(cmds)
|
|
20
|
+
exit
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# Gives the user output of the errors
|
|
25
|
+
#
|
|
26
|
+
def display_dependency_errors(cmds)
|
|
27
|
+
say set_color(
|
|
28
|
+
"\nERROR! You need to run the following command(s):\n",
|
|
29
|
+
:red,
|
|
30
|
+
:bold
|
|
31
|
+
)
|
|
32
|
+
cmds.each { |cmd| say " $ bundle exec rails g #{cmd}" }
|
|
33
|
+
say set_color(
|
|
34
|
+
"\nbefore running this generator.",
|
|
35
|
+
:red,
|
|
36
|
+
:bold
|
|
37
|
+
)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
##########################################################################
|
|
41
|
+
# The following methods are the individual checks and their appropriate
|
|
42
|
+
# responses.
|
|
43
|
+
##########################################################################
|
|
44
|
+
|
|
45
|
+
def cambium_install_admin_generated?
|
|
46
|
+
class_exists?('AdminController')
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def cambium_model_user_generated?
|
|
50
|
+
class_exists?('User')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def cambium_model_image_generated?
|
|
54
|
+
class_exists?('Image')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
module Cambium
|
|
2
|
+
module GeneratorsHelper
|
|
3
|
+
|
|
4
|
+
# ------------------------------------------ System Commands / Aliases
|
|
5
|
+
|
|
6
|
+
# Shorthand for `bundle exec`
|
|
7
|
+
#
|
|
8
|
+
def be
|
|
9
|
+
"bundle exec"
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Runs a system command, but with pretty output
|
|
13
|
+
#
|
|
14
|
+
def run_cmd(cmd, options = {})
|
|
15
|
+
print_table(
|
|
16
|
+
[
|
|
17
|
+
[set_color("run", :green, :bold), cmd]
|
|
18
|
+
],
|
|
19
|
+
:indent => 9
|
|
20
|
+
)
|
|
21
|
+
if options[:quiet] == true
|
|
22
|
+
`#{cmd}`
|
|
23
|
+
else
|
|
24
|
+
system(cmd)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Make sure we get a matching answer before moving on. Useful for usernames,
|
|
29
|
+
# passwords, and other items where user error is harmful (or painful)
|
|
30
|
+
#
|
|
31
|
+
def confirm_ask(question)
|
|
32
|
+
answer = ask("\n#{question}")
|
|
33
|
+
match = ask("CONFIRM #{question}")
|
|
34
|
+
if answer == match
|
|
35
|
+
answer
|
|
36
|
+
else
|
|
37
|
+
say set_color("Did not match.", :red)
|
|
38
|
+
confirm_ask(question)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Run rake db:migrate
|
|
43
|
+
#
|
|
44
|
+
def migrate
|
|
45
|
+
rake "db:migrate"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Annotate our models and tests
|
|
49
|
+
#
|
|
50
|
+
def annotate
|
|
51
|
+
# need to make sure we have the annotate gem to avoid errors
|
|
52
|
+
install_gem('annotate')
|
|
53
|
+
run_cmd "#{be} annotate"
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
# Run migrate and annotate
|
|
57
|
+
#
|
|
58
|
+
def migrate_and_annotate
|
|
59
|
+
migrate
|
|
60
|
+
annotate
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# ------------------------------------------ Templating
|
|
64
|
+
|
|
65
|
+
# Copy template file to project unless it's already there
|
|
66
|
+
#
|
|
67
|
+
def copy_unless_exists(path, new_path = path)
|
|
68
|
+
copy_file(path, new_path) unless File.exists?("#{Rails.root}/#{new_path}")
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def copy_files(files, dir)
|
|
72
|
+
files.each { |f| copy_unless_exists("#{dir}/#{f}") }
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# Get the path to a particular template
|
|
76
|
+
#
|
|
77
|
+
def template_file(name)
|
|
78
|
+
File.expand_path("../../templates/#{name}", __FILE__)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Partial template path are for templates that aren't the entire file to be
|
|
82
|
+
# copied.
|
|
83
|
+
#
|
|
84
|
+
def template_partial_path(name)
|
|
85
|
+
File.expand_path("../../templates/_partials/#{name}", __FILE__)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Read a template and return its contents
|
|
89
|
+
#
|
|
90
|
+
def file_contents(template)
|
|
91
|
+
File.read(template_file(template))
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def template_snippet(template)
|
|
95
|
+
require 'erb'
|
|
96
|
+
ERB.new(File.read(template_file(template))).result(binding)
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
# Copies model concern templates to the project
|
|
100
|
+
#
|
|
101
|
+
def add_model_concern(name)
|
|
102
|
+
copy_unless_exists "app/models/concerns/#{name}.rb"
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Alias for previous method
|
|
106
|
+
#
|
|
107
|
+
def model_concern(name)
|
|
108
|
+
add_model_concern(name)
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# Add multiple concerns
|
|
112
|
+
#
|
|
113
|
+
def add_model_concerns(concerns)
|
|
114
|
+
concerns.each { |c| add_model_concern(c) }
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# Copy multiple directories
|
|
118
|
+
#
|
|
119
|
+
def directories(dir_arr, container)
|
|
120
|
+
dir_arr.each do |dir|
|
|
121
|
+
directory "#{container}/#{dir}", "#{container}/#{dir}"
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# ------------------------------------------ Gems
|
|
126
|
+
|
|
127
|
+
# Run `bundle install`
|
|
128
|
+
#
|
|
129
|
+
def bundle
|
|
130
|
+
run_cmd "bundle install"
|
|
131
|
+
run_cmd "bundle clean"
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# Get the local path where the gems are installed
|
|
135
|
+
#
|
|
136
|
+
def gem_dir
|
|
137
|
+
gem_dir = `bundle show rails`
|
|
138
|
+
gem_dir = gem_dir.split('/')
|
|
139
|
+
gem_dir[0..-3].join('/')
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Add gem to Gemfile
|
|
143
|
+
#
|
|
144
|
+
def add_to_gemfile(name, options = {})
|
|
145
|
+
unless gem_exists?(name)
|
|
146
|
+
if options[:require].present?
|
|
147
|
+
text = "\n\ngem '#{name}', :require => '#{options[:require]}'"
|
|
148
|
+
else
|
|
149
|
+
text = "\n\ngem '#{name}'"
|
|
150
|
+
end
|
|
151
|
+
insert_into_file "Gemfile", text, :after => "rubygems.org'"
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
# Add several gems to the gemfile
|
|
156
|
+
def add_gems_to_gemfile(gems)
|
|
157
|
+
gems.each { |g| add_to_gemfile(g) }
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
# Find if a gem exists
|
|
161
|
+
#
|
|
162
|
+
def gem_exists?(name)
|
|
163
|
+
Gem::Specification::find_all_by_name(name).any?
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# First, install the gem in the local gem directory, then add it to the
|
|
167
|
+
# Gemfile (if it doesn't already exist).
|
|
168
|
+
#
|
|
169
|
+
# Note: This will run bundle install after adding the gem, unless specified
|
|
170
|
+
# otherwise.
|
|
171
|
+
#
|
|
172
|
+
def install_gem(name, options = {})
|
|
173
|
+
if gem_exists?(name)
|
|
174
|
+
say "Found existing gem: #{name}"
|
|
175
|
+
else
|
|
176
|
+
run "gem install #{name} -i #{gem_dir}"
|
|
177
|
+
add_to_gemfile(name, options)
|
|
178
|
+
bundle if options[:bundle].nil? || options[:bundle] == true
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Install an array of gems -- useful if needing to install more than one
|
|
183
|
+
# gem.
|
|
184
|
+
#
|
|
185
|
+
def install_gems(gem_arr)
|
|
186
|
+
gem_arr.each { |gem_name| install_gem(gem_name, :bundle => false) }
|
|
187
|
+
bundle
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# Notifies the user of the gems that were installed and how desperately
|
|
191
|
+
# important they are.
|
|
192
|
+
#
|
|
193
|
+
def gem_installation_notification(gems)
|
|
194
|
+
say "\nThis generator installed the following gems (and added them to "
|
|
195
|
+
say "your Gemfile):\n\n"
|
|
196
|
+
gems.each { |g| say " #{g}" }
|
|
197
|
+
say "\nThese gems *may* be necessary for Cambium to work properly. "
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
# Similar to gem_installation_notification, except here we just tell the
|
|
201
|
+
# user we added gems to the gemfile and they will have to bundle
|
|
202
|
+
#
|
|
203
|
+
def gemfile_update_notification(gems)
|
|
204
|
+
say "\nThis generator added some gems to your Gemfile. You will want to "
|
|
205
|
+
say "run:\n\n $ bundle install"
|
|
206
|
+
say "\nto complete this generator. Please note, "
|
|
207
|
+
say "these gems *may* be necessary for Cambium to work properly."
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
# ------------------------------------------ Miscellaneous
|
|
211
|
+
|
|
212
|
+
# Return current time in migration timestamp format
|
|
213
|
+
#
|
|
214
|
+
def timestamp
|
|
215
|
+
Time.now.gmtime.strftime('%Y%m%d%H%M%S')
|
|
216
|
+
end
|
|
217
|
+
|
|
218
|
+
# Check to see if a class exists. This can be helpful in determining if
|
|
219
|
+
# other generators have been run.
|
|
220
|
+
#
|
|
221
|
+
def class_exists?(class_name)
|
|
222
|
+
klass = Module.const_get(class_name)
|
|
223
|
+
klass.is_a?(Class)
|
|
224
|
+
end
|
|
225
|
+
|
|
226
|
+
end
|
|
227
|
+
end
|
|
@@ -1,115 +1,109 @@
|
|
|
1
1
|
require 'rake'
|
|
2
2
|
require 'rails/generators'
|
|
3
|
+
require File.expand_path('../../helpers/_autoloader.rb', __FILE__)
|
|
3
4
|
|
|
4
5
|
module Cambium
|
|
5
6
|
module Install
|
|
6
7
|
class AdminGenerator < Rails::Generators::Base
|
|
7
8
|
desc "Setup admin files for new rails project"
|
|
8
9
|
|
|
9
|
-
# ------------------------------------------ Class Methods
|
|
10
|
-
|
|
11
10
|
source_root File.expand_path('../../templates', __FILE__)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def add_admin_controller
|
|
16
|
-
template "app/controllers/admin_controller.rb",
|
|
17
|
-
"app/controllers/admin_controller.rb"
|
|
11
|
+
|
|
12
|
+
def set_dependencies
|
|
13
|
+
check_dependencies(['cambium:model:user'])
|
|
18
14
|
end
|
|
19
15
|
|
|
20
|
-
#
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
# Admin controllers are added in this manner because we have controllers
|
|
17
|
+
# in the directory which we do not want to copy over by default.
|
|
18
|
+
#
|
|
19
|
+
def add_admin_controller
|
|
20
|
+
copy_files [
|
|
21
|
+
'admin_controller.rb',
|
|
22
|
+
'admin/users_controller.rb'
|
|
23
|
+
], "app/controllers"
|
|
25
24
|
end
|
|
26
25
|
|
|
27
|
-
#
|
|
28
|
-
|
|
26
|
+
# Continuing from the previous method, we also need to individually copy
|
|
27
|
+
# the view files over, since these default views have to site directly in
|
|
28
|
+
# the app/views/admin folder, and can't be placed in a subdirectory.
|
|
29
|
+
#
|
|
30
|
+
# Any new partial will have to be added here manually.
|
|
31
|
+
#
|
|
29
32
|
def add_admin_views
|
|
30
|
-
|
|
33
|
+
copy_files [
|
|
34
|
+
'_buttons.html.erb',
|
|
35
|
+
'_form.html.erb',
|
|
36
|
+
'_title.html.erb',
|
|
37
|
+
'edit.html.erb',
|
|
38
|
+
'index.html.erb',
|
|
39
|
+
'new.html.erb'
|
|
40
|
+
], "app/views/admin"
|
|
41
|
+
directories ['shared','users'], "app/views/admin"
|
|
31
42
|
end
|
|
32
43
|
|
|
33
|
-
#
|
|
34
|
-
|
|
44
|
+
# The admin layout gives us the customization we need to layout our CMS.
|
|
45
|
+
# Here we ask the user for some input for those items that will vary from
|
|
46
|
+
# project-to-project.
|
|
47
|
+
#
|
|
35
48
|
def add_layouts
|
|
36
49
|
@site_title = "#{Rails.application.class.parent_name.humanize.titleize} Admin"
|
|
37
50
|
site_title = ask "\n#{set_color('Admin Title:', :green, :bold)} [default: #{@site_title}]"
|
|
38
51
|
@site_title = site_title unless site_title.blank?
|
|
39
|
-
|
|
40
52
|
admin = "app/views/layouts/admin.html.erb"
|
|
41
53
|
template admin, admin
|
|
42
54
|
end
|
|
43
55
|
|
|
44
|
-
#
|
|
45
|
-
|
|
56
|
+
# Currently, all the helper methods are shoved into one file. The plan is
|
|
57
|
+
# to break the methods out into individual helpers, namespaced under
|
|
58
|
+
# admin.
|
|
59
|
+
#
|
|
46
60
|
def add_admin_helper
|
|
47
61
|
template "app/helpers/admin_helper.rb",
|
|
48
62
|
"app/helpers/admin_helper.rb"
|
|
49
63
|
end
|
|
50
64
|
|
|
51
|
-
#
|
|
52
|
-
|
|
53
|
-
|
|
65
|
+
# Like the app side, the admin uses the Backbone.js framework since it's
|
|
66
|
+
# lightweight and easy-to-use. We've added several scripts to make your
|
|
67
|
+
# CMS powerful right out of the box.
|
|
68
|
+
#
|
|
69
|
+
def add_admin_javascripts
|
|
54
70
|
directory "app/assets/javascripts/admin",
|
|
55
71
|
"app/assets/javascripts/admin"
|
|
56
72
|
end
|
|
57
73
|
|
|
58
|
-
#
|
|
59
|
-
|
|
74
|
+
# Our admin styles use Bones, along with some customization on top of
|
|
75
|
+
# Bones. Let's install these.
|
|
76
|
+
#
|
|
60
77
|
def add_admin_styles
|
|
61
78
|
directory "app/assets/stylesheets/admin",
|
|
62
79
|
"app/assets/stylesheets/admin"
|
|
63
80
|
end
|
|
64
81
|
|
|
65
|
-
#
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def be
|
|
92
|
-
"bundle exec"
|
|
93
|
-
end
|
|
94
|
-
|
|
95
|
-
def g
|
|
96
|
-
"#{be} rails g"
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
def rake
|
|
100
|
-
"#{be} rake"
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
def confirm_ask(question)
|
|
104
|
-
answer = ask("\n#{question}")
|
|
105
|
-
match = ask("CONFIRM #{question}")
|
|
106
|
-
if answer == match
|
|
107
|
-
answer
|
|
108
|
-
else
|
|
109
|
-
say set_color("Did not match.", :red)
|
|
110
|
-
confirm_ask(question)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
82
|
+
# Here we are adding the gems we will need for the admin. Many of these
|
|
83
|
+
# are duplicates from the app gems, but that's ok, since we check to see
|
|
84
|
+
# if they exist first.
|
|
85
|
+
#
|
|
86
|
+
def add_application_gems
|
|
87
|
+
gems = [
|
|
88
|
+
'unicorn-rails',
|
|
89
|
+
'jquery-rails',
|
|
90
|
+
'uglifier',
|
|
91
|
+
'sass-rails',
|
|
92
|
+
'bourbon',
|
|
93
|
+
'coffee-rails',
|
|
94
|
+
'backbone-on-rails',
|
|
95
|
+
'bones-rails',
|
|
96
|
+
'jbuilder',
|
|
97
|
+
'pickadate-rails',
|
|
98
|
+
'simple_form',
|
|
99
|
+
'wysihtml5-rails',
|
|
100
|
+
'jquery-fileupload-rails',
|
|
101
|
+
]
|
|
102
|
+
add_gems_to_gemfile(gems)
|
|
103
|
+
added_gems = []
|
|
104
|
+
gems.each { |g| added_gems << g unless gem_exists?(g) }
|
|
105
|
+
gemfile_update_notification(added_gems)
|
|
106
|
+
end
|
|
113
107
|
|
|
114
108
|
end
|
|
115
109
|
end
|