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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: de123a1818a074db261ed098f4eb3439c0d51bef
|
4
|
+
data.tar.gz: 9ec3510f0f9a4d01f013bb0fb4f90b8f56cd563b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4dc0ea26ee1de4d636255ef34d7456ad54e00072789b274ef2c9c76f64894d79747526b55be521c597a93708c4b3610e4e6bbae47aba41f639165035d0d47334
|
7
|
+
data.tar.gz: 426edc2d985fb326659f009e11fd34883157d7459aa816706cc10a1053f793247e88eda485b4bcf482cafd7061aeced7472b9fd720c1c3fc78856e5fdd81f223
|
data/.gitignore
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
tmp
|
15
|
+
*.bundle
|
16
|
+
*.so
|
17
|
+
*.o
|
18
|
+
*.a
|
19
|
+
mkmf.log
|
20
|
+
*.DS_Store
|
21
|
+
|
22
|
+
# Dummy App for Testing
|
23
|
+
spec/dummy/db/*.sqlite3
|
24
|
+
spec/dummy/db/*.sqlite3-journal
|
25
|
+
spec/dummy/log/*.log
|
26
|
+
spec/dummy/tmp/
|
27
|
+
spec/dummy/.sass-cache
|
28
|
+
spec/reports
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3.3
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014-2015 Sean C Davis, Warren Harrison
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
|
8
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
9
|
+
load 'rails/tasks/engine.rake'
|
10
|
+
|
11
|
+
Bundler::GemHelper.install_tasks
|
12
|
+
|
13
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
14
|
+
|
15
|
+
require 'rspec/core'
|
16
|
+
require 'rspec/core/rake_task'
|
17
|
+
|
18
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
19
|
+
RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
20
|
+
task :default => :spec
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Idx
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
|
6
|
+
# ------------------------------------------ Scopes
|
7
|
+
|
8
|
+
scope :by_idx, -> { reorder('idx asc') }
|
9
|
+
|
10
|
+
# ------------------------------------------ Callbacks
|
11
|
+
|
12
|
+
after_create :create_idx
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
# ------------------------------------------ Instance Methods
|
17
|
+
|
18
|
+
def to_param
|
19
|
+
idx.to_s
|
20
|
+
end
|
21
|
+
|
22
|
+
def create_idx
|
23
|
+
last_obj = self.idx_class.send(self.class.table_name).by_idx.last
|
24
|
+
idx = last_obj.idx + 1
|
25
|
+
update_columns(:idx => idx)
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module ImageCropper
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
|
6
|
+
# We use these accessors to pass values to CarrierWave and RMagick without
|
7
|
+
# needing to store them in the database.
|
8
|
+
#
|
9
|
+
attr_accessor :crop_x, :crop_y, :crop_w, :crop_h
|
10
|
+
|
11
|
+
# Like the accessors, this is used for cropping images.
|
12
|
+
#
|
13
|
+
after_update :crop_image
|
14
|
+
end
|
15
|
+
|
16
|
+
# This simply makes carrierwave and rmagick recreate all its versions. We only
|
17
|
+
# call it if the `crop_x` attribute is present, as we use that as our trigger.
|
18
|
+
# Otherwise, we're recreating versions without changing anything.
|
19
|
+
#
|
20
|
+
def crop_image
|
21
|
+
filename.recreate_versions! if crop_x.present?
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module Publishable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
|
6
|
+
# --------------------------------- Attributes
|
7
|
+
|
8
|
+
attr_accessor :active, :active_date, :active_time, :inactive_date,
|
9
|
+
:inactive_time
|
10
|
+
|
11
|
+
# --------------------------------- Scopes
|
12
|
+
|
13
|
+
scope :published, -> { where("(active_at <= ? AND inactive_at > ?) OR
|
14
|
+
(active_at <= ? AND inactive_at IS ?)",
|
15
|
+
Time.now, Time.now, Time.now, nil) }
|
16
|
+
scope :unpublished, -> { where("active_at > ? OR inactive_at < ? OR
|
17
|
+
(active_at IS ? AND inactive_at IS ?)",
|
18
|
+
Time.now, Time.now, nil, nil) }
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
# --------------------------------- Instance Methods
|
23
|
+
|
24
|
+
def published?
|
25
|
+
return false if active_at.nil?
|
26
|
+
(active_at <= Time.now and inactive_at == nil) or
|
27
|
+
(active_at <= Time.now and inactive_at >= Time.now)
|
28
|
+
end
|
29
|
+
|
30
|
+
def formatted_active_date
|
31
|
+
formatted_date(active_at)
|
32
|
+
end
|
33
|
+
|
34
|
+
def formatted_inactive_date
|
35
|
+
formatted_date(inactive_at)
|
36
|
+
end
|
37
|
+
|
38
|
+
def formatted_date(date)
|
39
|
+
return '' if date.nil?
|
40
|
+
date.strftime("%d %B, %Y")
|
41
|
+
end
|
42
|
+
|
43
|
+
def formatted_active_time
|
44
|
+
return '' if active_at.nil?
|
45
|
+
active_at.strftime("%l:%M %p")
|
46
|
+
end
|
47
|
+
|
48
|
+
def formatted_inactive_time
|
49
|
+
return '' if inactive_at.nil?
|
50
|
+
inactive_at.strftime("%l:%M %p")
|
51
|
+
end
|
52
|
+
|
53
|
+
def publish!
|
54
|
+
update_column :active_at, Time.now
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Slug
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
after_save :sluggify_slug
|
6
|
+
|
7
|
+
def self.find(input)
|
8
|
+
input.to_i == 0 ? find_by_slug(input) : super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def sluggify_slug
|
13
|
+
if slug.blank?
|
14
|
+
update_column(:slug, create_slug)
|
15
|
+
else
|
16
|
+
new_slug = slug.gsub(/[^a-zA-Z0-9 \-]/, "") # remove all bad characters
|
17
|
+
new_slug.gsub!(/\ /, "-") # replace spaces with underscores
|
18
|
+
new_slug.gsub!(/\-+/, "-") # replace repeating underscores
|
19
|
+
update_column(:slug, new_slug) unless slug == new_slug
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def create_slug
|
24
|
+
slug = self.title.downcase.gsub(/\&/, ' and ') # & -> and
|
25
|
+
slug.gsub!(/[^a-zA-Z0-9 \-]/, "") # remove all bad characters
|
26
|
+
slug.gsub!(/\ /, "-") # replace spaces with underscores
|
27
|
+
slug.gsub!(/\-+/, "-") # replace repeating underscores
|
28
|
+
|
29
|
+
dups = self.class.name.constantize.where(:slug => slug)
|
30
|
+
if dups.count == 1 and dups.first != self
|
31
|
+
if self.idx.present?
|
32
|
+
slug = "#{slug}-#{self.idx}"
|
33
|
+
else
|
34
|
+
slug = "#{slug}-#{self.id}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
slug
|
38
|
+
end
|
39
|
+
|
40
|
+
def make_slug_unique(slug)
|
41
|
+
dups = self.class.name.constantize.where(:slug => slug)
|
42
|
+
if dups.count == 1 and dups.first != self
|
43
|
+
if self.idx.present?
|
44
|
+
slug = "#{slug}-#{self.idx}"
|
45
|
+
else
|
46
|
+
slug = "#{slug}-#{self.id}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
slug
|
50
|
+
end
|
51
|
+
|
52
|
+
def to_param
|
53
|
+
slug
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Tags
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
|
4
|
+
included do
|
5
|
+
has_many :taggings, :as => :taggable
|
6
|
+
has_many :tags, :through => :taggings
|
7
|
+
|
8
|
+
attr_accessor :tag_list
|
9
|
+
|
10
|
+
after_save :update_tags!
|
11
|
+
end
|
12
|
+
|
13
|
+
def update_tags!
|
14
|
+
unless tag_list.nil?
|
15
|
+
self.tags = []
|
16
|
+
used_tags = []
|
17
|
+
tag_list.split(',').each do |name|
|
18
|
+
name.strip!
|
19
|
+
if !used_tags.include?(name) && name.present?
|
20
|
+
used_tags << name
|
21
|
+
tag = Tag.where(:ci_name => name.downcase).first
|
22
|
+
if tag.nil?
|
23
|
+
tag = Tag.create(:name => name)
|
24
|
+
else
|
25
|
+
tag.update(:name => name) unless name == tag.name
|
26
|
+
end
|
27
|
+
self.tags << tag
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/heartwood/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
data/config/routes.rb
ADDED
data/heartwood.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'heartwood/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "heartwood"
|
8
|
+
spec.version = Heartwood::VERSION
|
9
|
+
spec.authors = ["Sean C Davis", "Warren Harrison"]
|
10
|
+
spec.email = ["scdavis41@gmail.com", "warren@hungry-media.com"]
|
11
|
+
spec.summary = %q{Rails generators to facilitate development.}
|
12
|
+
spec.description = %q{}
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.test_files = Dir["spec/**/*"]
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.14'
|
21
|
+
spec.add_development_dependency 'capybara-screenshot'
|
22
|
+
spec.add_development_dependency 'capybara'
|
23
|
+
spec.add_development_dependency 'database_cleaner'
|
24
|
+
spec.add_development_dependency 'factory_girl_rails'
|
25
|
+
spec.add_development_dependency 'guard-rspec'
|
26
|
+
spec.add_development_dependency 'poltergeist'
|
27
|
+
spec.add_development_dependency 'rspec-rails'
|
28
|
+
spec.add_development_dependency 'sqlite3'
|
29
|
+
|
30
|
+
# spec.add_dependency 'ancestry'
|
31
|
+
# spec.add_dependency 'bones-rails', '>= 1.1.3'
|
32
|
+
# spec.add_dependency 'dragonfly'
|
33
|
+
# spec.add_dependency 'kaminari'
|
34
|
+
# spec.add_dependency 'mark_it_zero', '~> 0.3.0'
|
35
|
+
# spec.add_dependency 'paper_trail'
|
36
|
+
# spec.add_dependency 'pg_search'
|
37
|
+
# spec.add_dependency 'pickadate-rails'
|
38
|
+
spec.add_dependency 'rails', '~> 5.0.0'
|
39
|
+
spec.add_dependency 'rake'
|
40
|
+
# spec.add_dependency 'superslug', '~> 1.3.0'
|
41
|
+
# spec.add_dependency 'trumbowyg_rails'
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,205 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rails/generators'
|
3
|
+
require File.expand_path('../../helpers/_autoloader.rb', __FILE__)
|
4
|
+
|
5
|
+
module Heartwood
|
6
|
+
class AppGenerator < Rails::Generators::Base
|
7
|
+
|
8
|
+
desc "Add all the pieces to your application per your configuration."
|
9
|
+
|
10
|
+
source_root File.expand_path('../../templates', __FILE__)
|
11
|
+
|
12
|
+
class_option(
|
13
|
+
:config_check,
|
14
|
+
:type => :boolean,
|
15
|
+
:default => true,
|
16
|
+
:description => "Verify config at config/initializers/heartwood.rb"
|
17
|
+
)
|
18
|
+
|
19
|
+
# If there is no configuration file tell the user to run
|
20
|
+
# that generator first (unless user has manually
|
21
|
+
# overridden).
|
22
|
+
#
|
23
|
+
def verify_configuration
|
24
|
+
if options.config_check?
|
25
|
+
unless File.exists?("#{Rails.root}/config/initializers/heartwood.rb")
|
26
|
+
help_message('heartwood_prereqs')
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Wrap our config values up in an easier-to-type
|
33
|
+
# variable
|
34
|
+
#
|
35
|
+
def set_config
|
36
|
+
@config = Heartwood.configuration
|
37
|
+
end
|
38
|
+
|
39
|
+
# Set root url for mailer in development and production
|
40
|
+
#
|
41
|
+
def set_url_config
|
42
|
+
environment(
|
43
|
+
"config.action_mailer.default_url_options = { :host => '#{@config.development_url}' }",
|
44
|
+
:env => "development"
|
45
|
+
)
|
46
|
+
environment(
|
47
|
+
"config.action_mailer.default_url_options = { :host => '#{@config.production_url}' }",
|
48
|
+
:env => "production"
|
49
|
+
)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Add modernizr to our list of assets to precompile when
|
53
|
+
# we're ready to deploy
|
54
|
+
#
|
55
|
+
def set_precompiled_assets
|
56
|
+
environment(
|
57
|
+
"config.assets.precompile += %w( modernizr.js )",
|
58
|
+
:env => "production"
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
# Add settings to application config file
|
63
|
+
# (config/application.rb)
|
64
|
+
#
|
65
|
+
def add_application_config
|
66
|
+
environment { file_contents("config/application.rb") }
|
67
|
+
end
|
68
|
+
|
69
|
+
# Assets initializer for Rails 4.1+
|
70
|
+
#
|
71
|
+
def add_assets_initializer
|
72
|
+
file = "config/initializers/assets.rb"
|
73
|
+
template(file, file)
|
74
|
+
end
|
75
|
+
|
76
|
+
# Add custom gitignore file
|
77
|
+
#
|
78
|
+
def add_gitignore
|
79
|
+
remove_file ".gitignore"
|
80
|
+
template "gitignore", ".gitignore"
|
81
|
+
end
|
82
|
+
|
83
|
+
# Add a default public controller, so we have a working
|
84
|
+
# home page when we're done.
|
85
|
+
#
|
86
|
+
def add_home_controller
|
87
|
+
generate "controller home index"
|
88
|
+
end
|
89
|
+
|
90
|
+
# Add our default public views
|
91
|
+
#
|
92
|
+
def add_public_views
|
93
|
+
directory "app/views/application"
|
94
|
+
directory "app/views/home", :force => true
|
95
|
+
end
|
96
|
+
|
97
|
+
# Our layouts are templated so we can start with
|
98
|
+
# some custom information.
|
99
|
+
#
|
100
|
+
def add_layouts
|
101
|
+
app = "app/views/layouts/application.html.erb"
|
102
|
+
template app, app, :force => true
|
103
|
+
end
|
104
|
+
|
105
|
+
# We're going to automatically install backbone unless
|
106
|
+
# the user has disabled it
|
107
|
+
#
|
108
|
+
def add_js_framework
|
109
|
+
directory("app/assets/javascripts", "app/assets/javascripts")
|
110
|
+
end
|
111
|
+
|
112
|
+
# Next, we need to replace our application.js file to add
|
113
|
+
# backbone and its dependencies, along with our default
|
114
|
+
# scripts.
|
115
|
+
#
|
116
|
+
def add_js_manifest
|
117
|
+
app_js = "app/assets/javascripts/application.js"
|
118
|
+
remove_file app_js
|
119
|
+
app_js += ".coffee"
|
120
|
+
template app_js, app_js
|
121
|
+
end
|
122
|
+
|
123
|
+
# Add our application.scss file. Since we don't know what
|
124
|
+
# file exists, we look for and delete all and replace with
|
125
|
+
# ours.
|
126
|
+
#
|
127
|
+
def add_public_manifest
|
128
|
+
['css','scss','scss.css'].each do |ext|
|
129
|
+
file = "app/assets/stylesheets/application.#{ext}"
|
130
|
+
remove_file(file) if File.exists?(file)
|
131
|
+
end
|
132
|
+
manifest_file = "app/assets/stylesheets/application.scss"
|
133
|
+
template manifest_file, manifest_file
|
134
|
+
end
|
135
|
+
|
136
|
+
# Go through standard Devise installation
|
137
|
+
#
|
138
|
+
def install_devise
|
139
|
+
generate "devise:install"
|
140
|
+
end
|
141
|
+
|
142
|
+
# Add a User model
|
143
|
+
#
|
144
|
+
def add_devise_user_model
|
145
|
+
generate "devise User"
|
146
|
+
end
|
147
|
+
|
148
|
+
# Copy our custom user model template into the app
|
149
|
+
#
|
150
|
+
def add_user_model_file
|
151
|
+
copy_file "app/models/user.rb", "app/models/user.rb", :force => true
|
152
|
+
end
|
153
|
+
|
154
|
+
# Override Devise's default redirects and sign in/out
|
155
|
+
#
|
156
|
+
def add_application_controller_redirects
|
157
|
+
insert_into_file(
|
158
|
+
"app/controllers/application_controller.rb",
|
159
|
+
template_snippet("app/controllers/application_controller.rb"),
|
160
|
+
:after => ":exception"
|
161
|
+
)
|
162
|
+
end
|
163
|
+
|
164
|
+
# Install Simple Form automatically
|
165
|
+
#
|
166
|
+
def install_simple_form
|
167
|
+
generate "simple_form:install"
|
168
|
+
end
|
169
|
+
|
170
|
+
# Add ruby class overrides and additions
|
171
|
+
#
|
172
|
+
def add_ruby_class_overrides
|
173
|
+
template "config/initializers/_hash.rb", "config/initializers/_hash.rb"
|
174
|
+
end
|
175
|
+
|
176
|
+
# Add our settings and private settings files
|
177
|
+
#
|
178
|
+
def add_settings_files
|
179
|
+
template "config/initializers/_settings.rb",
|
180
|
+
"config/initializers/_settings.rb"
|
181
|
+
['settings','private'].each do |s|
|
182
|
+
template "config/#{s}.yml", "config/#{s}.yml"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# Add the custom seed generator, which loads content
|
187
|
+
# from CSV into the database.
|
188
|
+
#
|
189
|
+
def add_seed_generator
|
190
|
+
remove_file "db/seeds.rb"
|
191
|
+
template "db/seeds.rb", "db/seeds.rb"
|
192
|
+
end
|
193
|
+
|
194
|
+
# Add our default routes file, which is commented out
|
195
|
+
# except for the root path to the home controller.
|
196
|
+
#
|
197
|
+
# We don't override routes here in case the user started
|
198
|
+
# to edit their routes file before running this generator.
|
199
|
+
#
|
200
|
+
def add_default_routes
|
201
|
+
template "config/routes.rb", "config/routes.rb", :force => true
|
202
|
+
end
|
203
|
+
|
204
|
+
end
|
205
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rails/generators'
|
3
|
+
require File.expand_path('../../helpers/_autoloader.rb', __FILE__)
|
4
|
+
|
5
|
+
module Heartwood
|
6
|
+
class ControllerGenerator < Rails::Generators::Base
|
7
|
+
|
8
|
+
desc "Installs a controller to use in Heartwood's CMS."
|
9
|
+
|
10
|
+
source_root File.expand_path('../../templates', __FILE__)
|
11
|
+
|
12
|
+
argument :model, :type => :string
|
13
|
+
|
14
|
+
# class_option(
|
15
|
+
# :config_check,
|
16
|
+
# :type => :boolean,
|
17
|
+
# :default => true,
|
18
|
+
# :description => "Verify config at config/initializers/heartwood.rb"
|
19
|
+
# )
|
20
|
+
|
21
|
+
# If there is no configuration file tell the user to run
|
22
|
+
# that generator first (unless user has manually
|
23
|
+
# overridden).
|
24
|
+
#
|
25
|
+
# def verify_configuration
|
26
|
+
# if options.config_check?
|
27
|
+
# unless File.exists?("#{Rails.root}/config/initializers/heartwood.rb")
|
28
|
+
# help_message('heartwood_prereqs')
|
29
|
+
# exit
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
# end
|
33
|
+
|
34
|
+
def confirm_model
|
35
|
+
@model = model.classify.singularize.constantize
|
36
|
+
# rescue
|
37
|
+
# puts "Can't find the model: #{model}"
|
38
|
+
# exit
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_model_attrs
|
42
|
+
@model_pl = @model.to_s.tableize.downcase.pluralize
|
43
|
+
@columns = @model.columns.reject { |col|
|
44
|
+
['id','created_at','updated_at'].include?(col.name) }
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_controller
|
48
|
+
generate "controller admin/#{@model_pl}"
|
49
|
+
template(
|
50
|
+
"app/controllers/admin/controller.rb.erb",
|
51
|
+
"app/controllers/admin/#{@model_pl}_controller.rb",
|
52
|
+
:force => true
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_routes
|
57
|
+
route = " namespace :admin do\n"
|
58
|
+
route += " resources :#{@model_pl}\n"
|
59
|
+
route += " end\n"
|
60
|
+
insert_into_file(
|
61
|
+
"config/routes.rb",
|
62
|
+
route,
|
63
|
+
:after => /mount\ Heartwood\:(.*)\n/
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_config_file
|
68
|
+
template "config/admin/controller.yml.erb", "config/admin/#{@model_pl}.yml"
|
69
|
+
end
|
70
|
+
|
71
|
+
def add_sidebar_item
|
72
|
+
config = "#{@model_pl}:\n"
|
73
|
+
config += " label: #{@model_pl.titleize}\n"
|
74
|
+
config += " route: main_app.admin_#{@model_pl}\n"
|
75
|
+
config += " icon: cog\n"
|
76
|
+
config += " controllers: ['#{@model_pl}']\n"
|
77
|
+
append_to_file("config/admin/sidebar.yml", config)
|
78
|
+
end
|
79
|
+
|
80
|
+
end
|
81
|
+
end
|