heartwood 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +28 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +4 -0
- data/Rakefile +20 -0
- data/app/controllers/cambium/base_controller.rb +3 -0
- data/app/models/concerns/idx.rb +28 -0
- data/app/models/concerns/image_cropper.rb +24 -0
- data/app/models/concerns/publishable.rb +57 -0
- data/app/models/concerns/slug.rb +56 -0
- data/app/models/concerns/tags.rb +33 -0
- data/bin/rails +12 -0
- data/config/routes.rb +2 -0
- data/heartwood.gemspec +43 -0
- data/lib/generators/cambium/app_generator.rb +205 -0
- data/lib/generators/cambium/controller_generator.rb +81 -0
- data/lib/generators/cambium/gemfile_generator.rb +36 -0
- data/lib/generators/cambium/install_generator.rb +19 -0
- data/lib/generators/cambium/user_generator.rb +40 -0
- data/lib/generators/helpers/_autoloader.rb +12 -0
- data/lib/generators/helpers/generators_helper.rb +235 -0
- data/lib/generators/templates/Gemfile.erb +78 -0
- data/lib/generators/templates/app/assets/javascripts/application.js.coffee +24 -0
- data/lib/generators/templates/app/assets/javascripts/routers/router.js.coffee +23 -0
- data/lib/generators/templates/app/assets/javascripts/templates/.keep +0 -0
- data/lib/generators/templates/app/assets/javascripts/views/default_helpers.js.coffee +16 -0
- data/lib/generators/templates/app/assets/stylesheets/admin/admin.scss +3 -0
- data/lib/generators/templates/app/assets/stylesheets/application.scss +9 -0
- data/lib/generators/templates/app/controllers/admin/controller.rb.erb +2 -0
- data/lib/generators/templates/app/controllers/application_controller.rb +11 -0
- data/lib/generators/templates/app/models/user.rb +14 -0
- data/lib/generators/templates/app/views/application/_status.html.erb +3 -0
- data/lib/generators/templates/app/views/home/index.html.erb +7 -0
- data/lib/generators/templates/app/views/layouts/application.html.erb +24 -0
- data/lib/generators/templates/config/application.rb +17 -0
- data/lib/generators/templates/config/initializers/_hash.rb +23 -0
- data/lib/generators/templates/config/initializers/_settings.rb +18 -0
- data/lib/generators/templates/config/initializers/assets.rb +3 -0
- data/lib/generators/templates/config/initializers/heartwood.rb +25 -0
- data/lib/generators/templates/config/private.yml +16 -0
- data/lib/generators/templates/config/routes.rb +54 -0
- data/lib/generators/templates/config/settings.yml +16 -0
- data/lib/generators/templates/db/seeds.rb +25 -0
- data/lib/generators/templates/gitignore +30 -0
- data/lib/heartwood/configuration.rb +29 -0
- data/lib/heartwood/engine.rb +28 -0
- data/lib/heartwood/support/array.rb +9 -0
- data/lib/heartwood/support/false_class.rb +9 -0
- data/lib/heartwood/support/fixnum.rb +13 -0
- data/lib/heartwood/support/float.rb +5 -0
- data/lib/heartwood/support/hash.rb +22 -0
- data/lib/heartwood/support/nil_class.rb +19 -0
- data/lib/heartwood/support/string.rb +28 -0
- data/lib/heartwood/support/true_class.rb +9 -0
- data/lib/heartwood/version.rb +3 -0
- data/lib/heartwood.rb +11 -0
- data/lib/help/heartwood_prereqs.txt +13 -0
- data/lib/help/pg_search_post_install.txt +13 -0
- data/lib/tasks/db.rake +22 -0
- data/lib/tasks/rename.rake +28 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/mailers/.keep +0 -0
- data/spec/dummy/app/models/.keep +0 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +29 -0
- data/spec/dummy/config/application.rb +32 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +41 -0
- data/spec/dummy/config/environments/production.rb +79 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/heartwood_development.sqlite3 +0 -0
- data/spec/dummy/db/heartwood_test.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +15 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/log/development.log +78 -0
- data/spec/dummy/log/test.log +3050 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/1i/1ii3yPGPbB0S_BkYiwVDC7qlKvhKF5P0zr7QiaTpgV4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/7k/7kqdQ5LCh-fs6HP4CUqWvk9w7HRuj6ZT_zkC-hUUMHU.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/8M/8Mpbgok-UsQPhrJQKqd6hVtQogD8YuU6GMn-2KVhC3E.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/Au/AuOTcA4Uen3sMQjy8Mi6nooP_8gMgvlFsjqr8mHpMIs.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/FG/FGeBOdRSmza-XfWb8ERFQydMrExKmdlz2_eksYO3y4Q.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/MB/MBqa7cQSBGYszhtbC7r7yiDA0gjwriFrAaNiQnMbfFw.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/ML/MLT6NKtdybeBwpm6H1d7XzkomTyZnMge5E8EEQkhtrc.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/R2/R2IjUuzOFtsZdvjOQOrasVwjaCegvj-lE6jkTQFL9xs.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/WB/WB2XiMJ4O7--cvm29FJ4zeUyMpU15sqdYtfduF0YeT0.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/YT/YTDOaZ9qOx03chcaLrJy-Ch0Rtn4Nik102vwxZ2a-k8.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/aB/aBAdNO31MRRIPsReAdfHmtSFswygiBIFctx6fBhTTdc.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/fK/fKCgrNQR1G7Gf6VTItx7NTaKXquuw-ufNT5nGlxvBV4.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/hr/hrKDaC8EYPX0veGxFTXgYt7IynAdYyeBjYjzcPazQkk.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/i4/i4-E3GFC6rOjx1w5H9W14IbdPm4ouzkqixHmsK27kmo.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/jE/jEmEy4r1QfD5kzXcHSPcAaAgBwet1M0ZIWQuzyT9TXw.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/l7/l7FREFh3W4tfuo0mF7DdkXKth9VT4R2hiiiq0KS4xpI.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/o8/o8getMbwHiM68k4uUk4shsyjKnDbV_hmifAWyvO-E50.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/wA/wAjBFweHcRdsYa4zx9mayhvC0RDVqaI5gM0LcoCv7a4.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/xW/xWmlGxKNxc1ViyjTyokcbCu6WjNIGDIqPVPXsBwdveA.cache +1 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zP/zPn9M5I_yf8ko0-lpbDwTWjG6wpRvXkA77hDUPzAFZ8.cache +0 -0
- data/spec/dummy/tmp/cache/assets/sprockets/v3.0/zd/zd90ZPTG89ScoQQ_PzPAAe2669wzpdyZuzn7qmr9e3s.cache +0 -0
- data/spec/lib/support/array_spec.rb +14 -0
- data/spec/lib/support/false_class_spec.rb +17 -0
- data/spec/lib/support/fixnum_spec.rb +23 -0
- data/spec/lib/support/float_spec.rb +18 -0
- data/spec/lib/support/hash_spec.rb +21 -0
- data/spec/lib/support/nil_class_spec.rb +23 -0
- data/spec/lib/support/string_spec.rb +44 -0
- data/spec/lib/support/true_class_spec.rb +17 -0
- data/spec/rails_helper.rb +183 -0
- data/spec/spec_helper.rb +99 -0
- data/vendor/assets/javascripts/backbone.js +1920 -0
- data/vendor/assets/javascripts/modernizr.js +4 -0
- data/vendor/assets/javascripts/underscore.js +1548 -0
- data/vendor/assets/stylesheets/normalize.scss +406 -0
- metadata +425 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rails/generators'
|
3
|
+
|
4
|
+
module Heartwood
|
5
|
+
class GemfileGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
desc "Replace your existing Gemfile with Heartwood's default Gemfile."
|
8
|
+
|
9
|
+
source_root File.expand_path('../../templates', __FILE__)
|
10
|
+
|
11
|
+
# Here we figure out some of the more complicated logic
|
12
|
+
# before rendering the Gemfile template
|
13
|
+
#
|
14
|
+
def resolve_options
|
15
|
+
@rails_version = `bundle exec rails -v`.to_s.split(' ').last
|
16
|
+
end
|
17
|
+
|
18
|
+
# Move our default Gemfile to the project's Gemfile.
|
19
|
+
#
|
20
|
+
def add_config_file
|
21
|
+
template "Gemfile.erb", "Gemfile", :force => true
|
22
|
+
gsub_file "Gemfile", /\n\n\n+?/, "\n\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def gem_root
|
28
|
+
Gem::Specification.find_by_name("heartwood").gem_dir
|
29
|
+
end
|
30
|
+
|
31
|
+
def help_message(file)
|
32
|
+
puts File.read("#{gem_root}/lib/help/#{file}.txt")
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rails/generators'
|
3
|
+
|
4
|
+
module Heartwood
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
desc "Add Heartwood config file to your initializers."
|
7
|
+
|
8
|
+
source_root File.expand_path('../../templates', __FILE__)
|
9
|
+
|
10
|
+
# Copy our Heartwood config file into the project's
|
11
|
+
# config/initializers directory.
|
12
|
+
#
|
13
|
+
def add_config_file
|
14
|
+
config_file = "config/initializers/heartwood.rb"
|
15
|
+
copy_file config_file, config_file
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rails/generators'
|
3
|
+
|
4
|
+
module Heartwood
|
5
|
+
class UserGenerator < Rails::Generators::Base
|
6
|
+
|
7
|
+
desc "Create a new user for your app."
|
8
|
+
|
9
|
+
source_root File.expand_path('../../templates', __FILE__)
|
10
|
+
|
11
|
+
class_option(
|
12
|
+
:admin,
|
13
|
+
:type => :boolean,
|
14
|
+
:default => false,
|
15
|
+
:description => "Make the user an admin"
|
16
|
+
)
|
17
|
+
|
18
|
+
argument :email, :type => :string
|
19
|
+
argument :password, :type => :string
|
20
|
+
|
21
|
+
# Create a user with the provided credentials
|
22
|
+
def create_user
|
23
|
+
if options.admin == true
|
24
|
+
User.create!(
|
25
|
+
:email => email,
|
26
|
+
:password => password,
|
27
|
+
:password_confirmation => password,
|
28
|
+
:is_admin => options.admin
|
29
|
+
)
|
30
|
+
else
|
31
|
+
User.create!(
|
32
|
+
:email => email,
|
33
|
+
:password => password,
|
34
|
+
:password_confirmation => password
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -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,235 @@
|
|
1
|
+
module Heartwood
|
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 Heartwood 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 Heartwood 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
|
+
def gem_root
|
227
|
+
Gem::Specification.find_by_name("heartwood").gem_dir
|
228
|
+
end
|
229
|
+
|
230
|
+
def help_message(file)
|
231
|
+
puts File.read("#{gem_root}/lib/help/#{file}.txt")
|
232
|
+
end
|
233
|
+
|
234
|
+
end
|
235
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# ------------------------------------------ Base
|
4
|
+
|
5
|
+
# rails version
|
6
|
+
gem 'rails', '<%= @rails_version %>'
|
7
|
+
|
8
|
+
# app server
|
9
|
+
gem 'unicorn-rails'
|
10
|
+
|
11
|
+
# database adapter
|
12
|
+
gem 'pg'
|
13
|
+
|
14
|
+
# ------------------------------------------ Assets
|
15
|
+
|
16
|
+
# stylesheets helpers
|
17
|
+
gem 'sass-rails'
|
18
|
+
gem 'compass-rails'
|
19
|
+
gem 'bourbon'
|
20
|
+
gem 'bones-rails'
|
21
|
+
|
22
|
+
# javascripts helpers
|
23
|
+
gem 'uglifier'
|
24
|
+
gem 'coffee-rails'
|
25
|
+
gem 'jquery-rails'
|
26
|
+
gem 'backbone-on-rails'
|
27
|
+
|
28
|
+
# ------------------------------------------ View Helpers
|
29
|
+
|
30
|
+
gem 'simple_form'
|
31
|
+
gem 'jbuilder'
|
32
|
+
gem 'pickadate-rails'
|
33
|
+
gem 'kaminari'
|
34
|
+
|
35
|
+
# ------------------------------------------ File Uploads
|
36
|
+
|
37
|
+
gem 'dragonfly'
|
38
|
+
gem 'jquery-fileupload-rails'
|
39
|
+
gem 'jcrop-rails-v2'
|
40
|
+
|
41
|
+
# ------------------------------------------ Utilities
|
42
|
+
|
43
|
+
gem 'devise'
|
44
|
+
gem 'heartwood'
|
45
|
+
gem 'paper_trail'
|
46
|
+
gem 'pg_search'
|
47
|
+
|
48
|
+
# ------------------------------------------ Console Helpers
|
49
|
+
|
50
|
+
gem 'rails-console-tweaks'
|
51
|
+
|
52
|
+
group :console do
|
53
|
+
gem 'wirb'
|
54
|
+
gem 'hirb'
|
55
|
+
gem 'awesome_print'
|
56
|
+
end
|
57
|
+
|
58
|
+
# ------------------------------------------ Error Handling
|
59
|
+
|
60
|
+
group :development do
|
61
|
+
gem 'better_errors'
|
62
|
+
gem 'binding_of_caller'
|
63
|
+
end
|
64
|
+
|
65
|
+
# ------------------------------------------ Performance
|
66
|
+
|
67
|
+
group :production do
|
68
|
+
gem 'rack-cache', :require => 'rack/cache'
|
69
|
+
end
|
70
|
+
|
71
|
+
# ------------------------------------------ Testing
|
72
|
+
|
73
|
+
group :development, :test do
|
74
|
+
gem 'annotate'
|
75
|
+
gem 'factory_girl_rails'
|
76
|
+
gem 'faker'
|
77
|
+
gem 'rspec-rails'
|
78
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#= require jquery
|
2
|
+
#= require jquery_ujs
|
3
|
+
#= require underscore
|
4
|
+
#= require backbone
|
5
|
+
#= require_self
|
6
|
+
#= require_tree ./templates
|
7
|
+
#= require_tree ./views
|
8
|
+
#= require_tree ./routers
|
9
|
+
|
10
|
+
window.App =
|
11
|
+
Collections: {}
|
12
|
+
Routers: {}
|
13
|
+
Views: {}
|
14
|
+
|
15
|
+
$ ->
|
16
|
+
new App.Routers.Router
|
17
|
+
|
18
|
+
# Enable pushState for compatible browsers
|
19
|
+
enablePushState = true
|
20
|
+
|
21
|
+
# Disable for older browsers
|
22
|
+
pushState = !!(enablePushState && window.history && window.history.pushState)
|
23
|
+
|
24
|
+
Backbone.history.start({ pushState: pushState })
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class App.Routers.Router extends Backbone.Router
|
2
|
+
|
3
|
+
initialize: =>
|
4
|
+
@autoLoadClass()
|
5
|
+
|
6
|
+
autoLoadClass: =>
|
7
|
+
# This is a good place to automatically load classes that may be dependent
|
8
|
+
# on a page element, and not necessarily the route.
|
9
|
+
#
|
10
|
+
# For example:
|
11
|
+
#
|
12
|
+
# new App.Views.Nav if $('.main-nav').length > 0
|
13
|
+
#
|
14
|
+
# Or, perhaps you need to load a class on every page. Do that, here, too,
|
15
|
+
# like this:
|
16
|
+
#
|
17
|
+
new App.Views.DefaultHelpers
|
18
|
+
|
19
|
+
routes:
|
20
|
+
'': 'initHomePage'
|
21
|
+
|
22
|
+
initHomePage: ->
|
23
|
+
console.log "Welcome to this awesome site, built using Heartwood!"
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class App.Views.DefaultHelpers extends Backbone.View
|
2
|
+
|
3
|
+
el: 'body'
|
4
|
+
|
5
|
+
initialize: =>
|
6
|
+
@disabledLinks()
|
7
|
+
@fadeOutNotices()
|
8
|
+
|
9
|
+
disabledLinks: =>
|
10
|
+
$('a.disabled').click (e) ->
|
11
|
+
e.preventDefault()
|
12
|
+
|
13
|
+
fadeOutNotices: =>
|
14
|
+
setTimeout () =>
|
15
|
+
$('.notice, .alert').fadeOut()
|
16
|
+
, 3500
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class User < ActiveRecord::Base
|
2
|
+
|
3
|
+
# ------------------------------------------ Devise
|
4
|
+
|
5
|
+
# Include default devise modules. Others available are:
|
6
|
+
# :lockable, :timeoutable, :omniauthable, :confirmable, :registerable
|
7
|
+
devise :database_authenticatable, :recoverable, :rememberable, :trackable,
|
8
|
+
:validatable
|
9
|
+
|
10
|
+
def to_s
|
11
|
+
email
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html class="public">
|
3
|
+
<head>
|
4
|
+
<title><%= @config.app_title %></title>
|
5
|
+
<meta charset="utf-8">
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
7
|
+
<!-- <meta name="description" content="<%%#= @meta[:description] %>"> -->
|
8
|
+
<!-- <meta name="robots" content="noindex, nofollow"> -->
|
9
|
+
<meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0">
|
10
|
+
<meta name="apple-mobile-web-app-capable" content="yes">
|
11
|
+
<meta name="format-detection" content="telephone=no">
|
12
|
+
<%%= stylesheet_link_tag 'application', :media => 'all' %>
|
13
|
+
<%%= javascript_include_tag "modernizr" %>
|
14
|
+
<%%= csrf_meta_tags %>
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
|
18
|
+
<%%= render :partial => 'status' %>
|
19
|
+
|
20
|
+
<%%= yield %>
|
21
|
+
|
22
|
+
<%%= javascript_include_tag 'application' %>
|
23
|
+
</body>
|
24
|
+
</html>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
config.generators do |g|
|
3
|
+
g.fixture true
|
4
|
+
g.fixture_replacement "factory_girl"
|
5
|
+
g.test_framework :rspec
|
6
|
+
g.assets false
|
7
|
+
g.view_specs false
|
8
|
+
g.model_specs false
|
9
|
+
g.controller_specs false
|
10
|
+
g.helper_specs false
|
11
|
+
g.routing_specs false
|
12
|
+
g.request_specs false
|
13
|
+
g.stylesheets false
|
14
|
+
g.javascripts false
|
15
|
+
g.helper false
|
16
|
+
g.skip_routes true
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
class Hash
|
2
|
+
|
3
|
+
def to_ostruct
|
4
|
+
convert_to_ostruct_recursive(self)
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
|
9
|
+
def convert_to_ostruct_recursive(obj)
|
10
|
+
result = obj
|
11
|
+
if result.is_a? Hash
|
12
|
+
result = result.dup.symbolize_keys
|
13
|
+
result.each do |key, val|
|
14
|
+
result[key] = convert_to_ostruct_recursive(val)
|
15
|
+
end
|
16
|
+
result = OpenStruct.new(result)
|
17
|
+
elsif result.is_a? Array
|
18
|
+
result = result.map { |r| convert_to_ostruct_recursive(r) }
|
19
|
+
end
|
20
|
+
result
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Load config/settings.yml into Settings OpenStruct
|
2
|
+
#
|
3
|
+
begin
|
4
|
+
config_file = File.join(Rails.root,'config','settings.yml')
|
5
|
+
Settings = YAML.load_file(config_file)[Rails.env].to_ostruct
|
6
|
+
rescue
|
7
|
+
raise "Can't find file: #{config_file}"
|
8
|
+
end
|
9
|
+
|
10
|
+
# Loads config/private.yml (sensitive settings) into Private
|
11
|
+
# OpenStruct
|
12
|
+
#
|
13
|
+
begin
|
14
|
+
private_file = File.join(Rails.root,'config','private.yml')
|
15
|
+
Private = YAML.load_file(private_file)[Rails.env].to_ostruct
|
16
|
+
rescue
|
17
|
+
raise "Can't find file: #{private_file}"
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Heartwood.configure do |config|
|
2
|
+
|
3
|
+
# -------------------------------------------------- App Info
|
4
|
+
|
5
|
+
# Heartwood uses these to set your root urls for
|
6
|
+
# mailers and other fun stuff.
|
7
|
+
#
|
8
|
+
config.development_url = 'localhost:3000'
|
9
|
+
config.production_url = 'example.com'
|
10
|
+
|
11
|
+
# The title of your app is what Heartwood puts in the
|
12
|
+
# browser tab by default.
|
13
|
+
#
|
14
|
+
config.app_title = 'Heartwood'
|
15
|
+
|
16
|
+
# -------------------------------------------------- Caching
|
17
|
+
|
18
|
+
# Heartwood's Pages come with action caching support. It is disabled by default.
|
19
|
+
# Uncomment the setting below to enable action caching.
|
20
|
+
#
|
21
|
+
# NOTE: You must install the 'actionpack-action_caching' gem for this to work.
|
22
|
+
#
|
23
|
+
# config.cache_pages = true
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file is for storing SENSITIVE settings. This file is
|
2
|
+
# not tracked.
|
3
|
+
#
|
4
|
+
# Values here are accessible through a recursive `Private`
|
5
|
+
# OpenStruct. For example, you can access "ABC123" using the
|
6
|
+
# example below through Private.my_group.my_special_key
|
7
|
+
#
|
8
|
+
development: &default
|
9
|
+
my_group:
|
10
|
+
my_special_key: "ABC123"
|
11
|
+
|
12
|
+
test:
|
13
|
+
<<: *default
|
14
|
+
|
15
|
+
production:
|
16
|
+
<<: *default
|