hancock_cms 1.0.0 → 1.0.0.2
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/README.md +7 -3
- data/app/assets/stylesheets/hancock/cms/devise.sass +32 -21
- data/app/assets/stylesheets/hancock/rails_admin/cms.theming.sass +3 -3
- data/app/controllers/concerns/hancock/current_user.rb +1 -1
- data/app/controllers/concerns/hancock/errors.rb +2 -1
- data/app/models/concerns/hancock/cacheable.rb +2 -1
- data/{config/initializers → app/models/concerns/hancock}/embedded_findable.rb +2 -2
- data/app/views/layouts/rails_admin/_footer_navigation.html.slim +1 -1
- data/app/views/layouts/rails_admin/application.html.haml +2 -1
- data/hancock_cms.gemspec +1 -1
- data/lib/generators/hancock/cms/setup_generator.rb +359 -0
- data/lib/generators/hancock/cms/templates/assets/javascripts/application.coffee.erb +1 -1
- data/lib/generators/hancock/cms/templates/assets/stylesheets/hancock/rails_admin/custom/theming.sass.erb +0 -0
- data/lib/generators/hancock/cms/templates/hancock_cms.erb +2 -0
- data/lib/hancock/admin/embedded_element.rb +3 -0
- data/lib/hancock/configuration.rb +4 -0
- data/lib/hancock/engine.rb +32 -28
- data/lib/hancock/model.rb +7 -5
- data/lib/hancock/models/mongoid/embedded_element.rb +3 -1
- data/lib/hancock/rails_admin_ext/config.rb +15 -11
- data/lib/hancock/version.rb +1 -1
- data/template.rb +12 -349
- metadata +9 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d1d53055fa4e4e284f13175d853efb63d27b3b85
|
|
4
|
+
data.tar.gz: d2036a23ad9b9a7c268cdb907544608e68f39633
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d8b8a4b523a035f6788f64110d2fba5d8c23baa3a6b66b20f490621ba98b15c631af0e4267e26de03e2c6603f3afaf0458fcb1e590d7ca8ef19003ffec901324
|
|
7
|
+
data.tar.gz: 7122a9ac480af5c5a8ad32d4ef3beafcdc19f6b4f35e598c98bd427f6a7ce043dd0533b7995f6e11a682d71162284cff865fafcd3f7a4ade2a08a14bc5db9197
|
data/README.md
CHANGED
|
@@ -50,13 +50,17 @@ If not, uninstall rails and install again
|
|
|
50
50
|
|
|
51
51
|
Then, for mongoid:
|
|
52
52
|
|
|
53
|
-
rails new my_app -T -O -m https://raw.githubusercontent.com/red-rocks/hancock_cms/rails4/template.rb
|
|
53
|
+
rails new my_app -B -T -O -m https://raw.githubusercontent.com/red-rocks/hancock_cms/rails4/template.rb
|
|
54
|
+
cd my_app
|
|
55
|
+
rails g hancock:cms:setup
|
|
54
56
|
|
|
55
57
|
for ActiveRecord:
|
|
56
58
|
|
|
57
|
-
rails new my_app -T --database=postgresql -m https://raw.githubusercontent.com/red-rocks/hancock_cms/rails4/template.rb
|
|
59
|
+
rails new my_app -B -T --database=postgresql -m https://raw.githubusercontent.com/red-rocks/hancock_cms/rails4/template.rb
|
|
60
|
+
cd my_app
|
|
61
|
+
rails g hancock:cms:setup
|
|
58
62
|
|
|
59
|
-
generator creates a new RVM gemset,
|
|
63
|
+
generator creates a new RVM gemset, runs `bundle install` and setup some files (assets, config/initializers/*, routes, etc).
|
|
60
64
|
|
|
61
65
|
### Localization
|
|
62
66
|
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
overflow: auto
|
|
9
9
|
white-space: nowrap
|
|
10
10
|
text-align: center
|
|
11
|
-
|
|
11
|
+
font-family: "Verdana", SansSerif
|
|
12
|
+
font-weight: normal
|
|
12
13
|
&:before
|
|
13
14
|
height: 100%
|
|
14
15
|
display: inline-block
|
|
@@ -21,9 +22,7 @@
|
|
|
21
22
|
vertical-align: middle
|
|
22
23
|
text-align: left
|
|
23
24
|
background: #fff
|
|
24
|
-
|
|
25
|
-
-moz-box-shadow: 0 8px 17px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19)
|
|
26
|
-
box-shadow: 0 8px 17px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19)
|
|
25
|
+
+box-shadow(0 8px 17px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19))
|
|
27
26
|
min-width: 400px
|
|
28
27
|
|
|
29
28
|
.white-box
|
|
@@ -62,36 +61,30 @@
|
|
|
62
61
|
.form-control
|
|
63
62
|
background-image: linear-gradient(#9675ce, #9675ce), linear-gradient(rgba(120, 130, 140, 0.13), rgba(120, 130, 140, 0.13))
|
|
64
63
|
border: 0 none
|
|
65
|
-
border-radius
|
|
66
|
-
box-shadow
|
|
64
|
+
+border-radius(0)
|
|
65
|
+
+box-shadow(none)
|
|
67
66
|
background-color: rgba(0, 0, 0, 0)
|
|
68
67
|
background-position: center bottom, center calc(99%)
|
|
69
68
|
background-repeat: no-repeat
|
|
70
69
|
background-size: 0 2px, 100% 1px
|
|
71
70
|
background-color: #ffffff
|
|
72
|
-
box-shadow: none
|
|
73
71
|
color: #565656
|
|
74
72
|
height: 38px
|
|
75
73
|
width: 100%
|
|
76
74
|
padding: 7px 12px
|
|
77
|
-
transition
|
|
75
|
+
+transition(all 300ms linear 0s)
|
|
78
76
|
display: block
|
|
79
77
|
font-size: 14px
|
|
80
78
|
line-height: 1.42857143
|
|
81
|
-
|
|
82
|
-
-o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
|
|
83
|
-
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s
|
|
79
|
+
+transition(border-color ease-in-out .15s,box-shadow ease-in-out .15s)
|
|
84
80
|
input
|
|
85
81
|
width: 100%
|
|
86
|
-
height: 100%
|
|
87
82
|
|
|
88
83
|
.link-to-recover
|
|
89
84
|
float: right
|
|
90
85
|
padding-right: 10px
|
|
91
86
|
a
|
|
92
|
-
|
|
93
|
-
-o-transition: color ease-in-out .15s
|
|
94
|
-
transition: color ease-in-out .15s
|
|
87
|
+
+transition(color ease-in-out .15s)
|
|
95
88
|
color: #333C44
|
|
96
89
|
&:hover
|
|
97
90
|
color: #EF5350
|
|
@@ -123,9 +116,7 @@
|
|
|
123
116
|
cursor: pointer
|
|
124
117
|
max-width: 100%
|
|
125
118
|
color: #333C44
|
|
126
|
-
|
|
127
|
-
-o-transition: color ease-in-out .15s
|
|
128
|
-
transition: color ease-in-out .15s
|
|
119
|
+
+transition(color ease-in-out .15s)
|
|
129
120
|
&:hover
|
|
130
121
|
label
|
|
131
122
|
color: #EF5350
|
|
@@ -145,9 +136,7 @@
|
|
|
145
136
|
padding: 10px 16px
|
|
146
137
|
font-size: 18px
|
|
147
138
|
line-height: 1.3333333
|
|
148
|
-
|
|
149
|
-
-o-transition: all ease-in-out .15s
|
|
150
|
-
transition: all ease-in-out .15s
|
|
139
|
+
+transition(all ease-in-out .15s)
|
|
151
140
|
&:hover
|
|
152
141
|
background: rgba(#ee5350, 0.8)
|
|
153
142
|
border: 1px solid rgba(#ee5350, 0.8)
|
|
@@ -155,3 +144,25 @@
|
|
|
155
144
|
|
|
156
145
|
.form-group.links
|
|
157
146
|
margin-top: 25px
|
|
147
|
+
|
|
148
|
+
.devise-box .white-box form .form-group .form-control
|
|
149
|
+
padding: 0
|
|
150
|
+
input
|
|
151
|
+
position: relative
|
|
152
|
+
margin: 0
|
|
153
|
+
border: 0px
|
|
154
|
+
border-bottom: 1px solid #ccc
|
|
155
|
+
+transition(all 0.3s)
|
|
156
|
+
&:focus
|
|
157
|
+
border-bottom: 1px solid #3c6085
|
|
158
|
+
|
|
159
|
+
.devise-box .white-box form .form-group .checkbox-primary
|
|
160
|
+
min-height: auto
|
|
161
|
+
|
|
162
|
+
.devise-box .white-box form .form-group .checkbox-primary label
|
|
163
|
+
padding-left: 0px
|
|
164
|
+
input
|
|
165
|
+
margin: 0px
|
|
166
|
+
margin-right: 5px
|
|
167
|
+
display: inline-block
|
|
168
|
+
vertical-align: middle
|
|
@@ -608,7 +608,7 @@ a
|
|
|
608
608
|
td
|
|
609
609
|
position: relative
|
|
610
610
|
vertical-align: middle
|
|
611
|
-
text-align:
|
|
611
|
+
text-align: left
|
|
612
612
|
padding: 3px 4px 3px 4px
|
|
613
613
|
td.other.right, td.last.links
|
|
614
614
|
padding: 6px 10px 6px 0px
|
|
@@ -699,5 +699,5 @@ body.rails_admin .form-horizontal .tab-content .tab-pane
|
|
|
699
699
|
+box-shadow(inset 0 1px 1px rgba(0, 0, 0, 0.075))
|
|
700
700
|
+transform(border-color ease-in-out 0.15s box-shadow ease-in-out 0.15s)
|
|
701
701
|
|
|
702
|
-
body.rails_admin .table
|
|
703
|
-
max-width: 120px
|
|
702
|
+
body.rails_admin .table
|
|
703
|
+
max-width: 120px
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module Hancock::Errors
|
|
2
2
|
extend ActiveSupport::Concern
|
|
3
|
+
|
|
3
4
|
included do
|
|
4
5
|
if Rails.env.production? || Rails.env.staging? || (respond_to?(:hancock_check_errors) and hancock_check_errors)
|
|
5
6
|
rescue_from Exception, with: :render_500
|
|
@@ -90,5 +91,5 @@ module Hancock::Errors
|
|
|
90
91
|
def render_error(code = 500)
|
|
91
92
|
render template: "hancock/errors/error_#{code}", formats: [:html], handlers: [:slim], layout: Hancock.config.error_layout, status: code
|
|
92
93
|
end
|
|
93
|
-
|
|
94
|
+
|
|
94
95
|
end
|
|
@@ -11,12 +11,13 @@ if Hancock.mongoid?
|
|
|
11
11
|
def default_cache_keys
|
|
12
12
|
self.class.default_cache_keys
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
def cache_keys
|
|
16
16
|
cache_keys_str.split(/\s+/).map { |k| k.strip }.reject { |k| k.blank? }
|
|
17
17
|
end
|
|
18
18
|
field :perform_caching, type: Boolean, default: true
|
|
19
19
|
|
|
20
|
+
after_touch :clear_cache
|
|
20
21
|
after_save :clear_cache
|
|
21
22
|
after_destroy :clear_cache
|
|
22
23
|
def clear_cache
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
if defined?(Mongoid)
|
|
2
2
|
|
|
3
|
-
module
|
|
3
|
+
module Hancock
|
|
4
4
|
|
|
5
5
|
# Helps to override find method in an embedded document.
|
|
6
6
|
# Usage :
|
|
7
|
-
# - add to your model "include
|
|
7
|
+
# - add to your model "include Hancock::EmbeddedFindable"
|
|
8
8
|
# - override find method with:
|
|
9
9
|
# def self.find(id)
|
|
10
10
|
# find_through(Book, 'chapter', id)
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
RailsAdmin.I18n.init('#{I18n.locale}', JSON.parse("#{j I18n.t("admin.js").to_json}"))
|
|
14
14
|
|
|
15
15
|
%body.rails_admin
|
|
16
|
-
|
|
16
|
+
#loading.label.label-warning{style: 'display:none; position:fixed; right:20px; bottom:20px; z-index:100000'}= t('admin.loading')
|
|
17
17
|
%nav.admin-navbar.admin-navbar-fixed.bg-red{:role => "navigation"}
|
|
18
18
|
= render "layouts/rails_admin/navigation"
|
|
19
19
|
|
|
@@ -66,3 +66,4 @@
|
|
|
66
66
|
-# = render "layouts/rails_admin/sidebar_navigation"
|
|
67
67
|
-# .col-sm-9.col-sm-offset-3.col-md-10.col-md-offset-2.sidebar-content
|
|
68
68
|
-# .content{:'data-pjax-container' => true}= render template: 'layouts/rails_admin/pjax'
|
|
69
|
+
0
|
data/hancock_cms.gemspec
CHANGED
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
|
36
36
|
spec.add_dependency 'rails_admin_nested_set'
|
|
37
37
|
spec.add_dependency 'rails_admin_toggleable'
|
|
38
38
|
|
|
39
|
-
spec.add_dependency 'ack_rails_admin_settings'
|
|
39
|
+
spec.add_dependency 'ack_rails_admin_settings', '~> 1.2'
|
|
40
40
|
|
|
41
41
|
spec.add_dependency 'kaminari'
|
|
42
42
|
|
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
require 'rails/generators'
|
|
2
|
+
# require "rails/generators/rails/app/app_generator"
|
|
3
|
+
|
|
4
|
+
module Hancock::Cms
|
|
5
|
+
class SetupGenerator < Rails::Generators::Base
|
|
6
|
+
|
|
7
|
+
desc 'Hancock CMS Carcass generator'
|
|
8
|
+
def install
|
|
9
|
+
|
|
10
|
+
####### DEVISE #######
|
|
11
|
+
|
|
12
|
+
generate "devise:install"
|
|
13
|
+
gsub_file 'config/initializers/devise.rb', "'please-change-me-at-config-initializers-devise@example.com'", "'noreply@#{app_name.dasherize.downcase}.ru'"
|
|
14
|
+
inject_into_file 'config/initializers/devise.rb', after: /^end/ do <<-TEXT
|
|
15
|
+
|
|
16
|
+
Rails.application.config.to_prepare do
|
|
17
|
+
Devise::SessionsController.layout "hancock/devise/sessions"
|
|
18
|
+
Devise::RegistrationsController.layout "hancock/devise/registrations"
|
|
19
|
+
Devise::ConfirmationsController.layout "hancock/devise/confirmations"
|
|
20
|
+
Devise::UnlocksController.layout "hancock/devise/unlocks"
|
|
21
|
+
Devise::PasswordsController.layout "hancock/devise/passwords"
|
|
22
|
+
end
|
|
23
|
+
TEXT
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
generate "devise", "User"
|
|
27
|
+
####### ROUTES #######
|
|
28
|
+
|
|
29
|
+
remove_file 'config/routes.rb'
|
|
30
|
+
create_file 'config/routes.rb' do <<-TEXT
|
|
31
|
+
Rails.application.routes.draw do
|
|
32
|
+
devise_for :users, controllers: {sessions: 'hancock/sessions'}
|
|
33
|
+
|
|
34
|
+
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
|
35
|
+
|
|
36
|
+
hancock_cms_routes
|
|
37
|
+
end
|
|
38
|
+
TEXT
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
####### INITIALIZERS #######
|
|
43
|
+
|
|
44
|
+
inject_into_file 'config/initializers/assets.rb', before: /\z/ do <<-TEXT
|
|
45
|
+
Rails.application.config.assets.precompile += %w( *.svg )
|
|
46
|
+
Rails.application.config.assets.precompile += %w( ckeditor/* )
|
|
47
|
+
Rails.application.config.assets.precompile += %w( codemirror.js codemirror.css codemirror/**/* )
|
|
48
|
+
TEXT
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
if mongoid
|
|
52
|
+
generate "ckeditor:install", "--orm=mongoid", "--backend=paperclip"
|
|
53
|
+
else
|
|
54
|
+
generate "ckeditor:install", "--orm=active_record", "--backend=paperclip"
|
|
55
|
+
end
|
|
56
|
+
gsub_file 'config/initializers/ckeditor.rb', "# config.image_file_types = %w(jpg jpeg png gif tiff)", "config.image_file_types = %w(jpg jpeg png gif tiff svg)"
|
|
57
|
+
gsub_file 'config/initializers/ckeditor.rb', "# config.authorize_with :cancan", "config.authorize_with :cancancan"
|
|
58
|
+
gsub_file 'config/initializers/ckeditor.rb', "# config.assets_languages = ['en', 'uk']", "config.assets_languages = ['en', 'ru']"
|
|
59
|
+
|
|
60
|
+
if mongoid
|
|
61
|
+
remove_file 'config/initializers/cookies_serializer.rb'
|
|
62
|
+
create_file 'config/initializers/cookies_serializer.rb' do <<-TEXT
|
|
63
|
+
# Be sure to restart your server when you modify this file.
|
|
64
|
+
# json serializer breaks Devise + Mongoid. DO NOT ENABLE
|
|
65
|
+
# See https://github.com/plataformatec/devise/pull/2882
|
|
66
|
+
# Rails.application.config.action_dispatch.cookies_serializer = :json
|
|
67
|
+
Rails.application.config.action_dispatch.cookies_serializer = :marshal
|
|
68
|
+
TEXT
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
gsub_file 'config/initializers/filter_parameter_logging.rb', "[:password]", "[:password, :password_confirmation]"
|
|
73
|
+
|
|
74
|
+
# generate 'paperclip_optimizer:install'
|
|
75
|
+
# remove_file 'config/initializers/paperclip_optimizer.rb'
|
|
76
|
+
# generate "hancock:cms:paperclip_optimizer"
|
|
77
|
+
|
|
78
|
+
# generate 'rails_email_preview:install'
|
|
79
|
+
# remove_file 'app/mailer_previews/contact_mailer_preview.rb'
|
|
80
|
+
# create_file 'app/mailer_previews/contact_mailer_preview.rb' do <<-TEXT
|
|
81
|
+
# class ContactMailerPreview
|
|
82
|
+
# def new_message_email
|
|
83
|
+
# Hancock::Feedback::ContactMailer.new_message_email(Hancock::Feedback::ContactMessage.all.to_a.sample)
|
|
84
|
+
# end
|
|
85
|
+
# end
|
|
86
|
+
# TEXT
|
|
87
|
+
# end
|
|
88
|
+
|
|
89
|
+
generate "hancock:cms:config"
|
|
90
|
+
|
|
91
|
+
generate "hancock:cms:rack"
|
|
92
|
+
|
|
93
|
+
generate "hancock:cms:admin"
|
|
94
|
+
|
|
95
|
+
remove_file 'config/initializers/session_store.rb'
|
|
96
|
+
if mongoid
|
|
97
|
+
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
|
98
|
+
# Be sure to restart your server when you modify this file.
|
|
99
|
+
|
|
100
|
+
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
|
101
|
+
Rails.application.config.session_store :mongoid_store
|
|
102
|
+
TEXT
|
|
103
|
+
end
|
|
104
|
+
else
|
|
105
|
+
generate 'active_record_store:session_migration'
|
|
106
|
+
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
|
107
|
+
# Be sure to restart your server when you modify this file.
|
|
108
|
+
|
|
109
|
+
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
|
110
|
+
Rails.application.config.session_store :active_record_store
|
|
111
|
+
TEXT
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# unless mongoid
|
|
116
|
+
# generate 'simple_captcha'
|
|
117
|
+
# end
|
|
118
|
+
|
|
119
|
+
generate "simple_form:install"
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
####### CONTROLLERS #######
|
|
123
|
+
|
|
124
|
+
remove_file 'app/controllers/application_controller.rb'
|
|
125
|
+
create_file 'app/controllers/application_controller.rb' do <<-TEXT
|
|
126
|
+
class ApplicationController < ActionController::Base
|
|
127
|
+
include Hancock::Controller
|
|
128
|
+
end
|
|
129
|
+
TEXT
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
####### MODELS #######
|
|
134
|
+
|
|
135
|
+
generate "hancock:cms:ability"
|
|
136
|
+
|
|
137
|
+
gsub_file 'app/models/user.rb', '# :confirmable, :lockable, :timeoutable and :omniauthable' do <<-TEXT
|
|
138
|
+
include Hancock::Model
|
|
139
|
+
include Hancock::Enableable
|
|
140
|
+
include Hancock::RailsAdminPatch
|
|
141
|
+
def self.manager_can_default_actions
|
|
142
|
+
[:show, :read]
|
|
143
|
+
end
|
|
144
|
+
def manager_cannot_actions
|
|
145
|
+
[:new, :create, :delete, :destroy]
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
cattr_accessor :current_user
|
|
149
|
+
|
|
150
|
+
# Include default devise modules. Others available are:
|
|
151
|
+
# :confirmable, :lockable, :timeoutable and :omniauthable
|
|
152
|
+
TEXT
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
gsub_file 'app/models/user.rb', ':registerable,', ' :lockable,'
|
|
156
|
+
if mongoid
|
|
157
|
+
gsub_file 'app/models/user.rb', '# field :failed_attempts', 'field :failed_attempts'
|
|
158
|
+
gsub_file 'app/models/user.rb', '# field :unlock_token', 'field :unlock_token'
|
|
159
|
+
gsub_file 'app/models/user.rb', '# field :locked_at', 'field :locked_at'
|
|
160
|
+
|
|
161
|
+
inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
162
|
+
|
|
163
|
+
field :name, type: String
|
|
164
|
+
field :login, type: String
|
|
165
|
+
field :roles, type: Array, default: []
|
|
166
|
+
|
|
167
|
+
before_save do
|
|
168
|
+
self.roles ||= []
|
|
169
|
+
self.roles.reject! { |r| r.blank? }
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
AVAILABLE_ROLES = ["admin", "manager", "client"]
|
|
173
|
+
|
|
174
|
+
AVAILABLE_ROLES.each do |r|
|
|
175
|
+
class_eval <<-EVAL
|
|
176
|
+
def \#{r}?
|
|
177
|
+
self.roles and self.roles.include?("\#{r}")
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
scope :\#{r.pluralize}, -> { any_in(roles: "\#{r}") }
|
|
181
|
+
EVAL
|
|
182
|
+
end
|
|
183
|
+
|
|
184
|
+
def self.generate_first_admin_user
|
|
185
|
+
if ::User.admins.all.count == 0
|
|
186
|
+
_email_pass = 'admin@#{app_name.dasherize.downcase}.ru'
|
|
187
|
+
if ::User.new(roles: ["admin"], email: _email_pass, password: _email_pass, password_confirmation: _email_pass).save
|
|
188
|
+
puts "AdminUser with email and password '\#{_email_pass}' was created!"
|
|
189
|
+
else
|
|
190
|
+
puts 'Creating AdminUser error'
|
|
191
|
+
end
|
|
192
|
+
else
|
|
193
|
+
puts 'AdminUsers are here already'
|
|
194
|
+
end
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def self.generate_first_manager_user
|
|
198
|
+
if ::User.managers.all.count == 0
|
|
199
|
+
_email_pass = 'manager@#{app_name.dasherize.downcase}.ru'
|
|
200
|
+
if ::User.create(roles: ["manager"], email: _email_pass, password: _email_pass, password_confirmation: _email_pass)
|
|
201
|
+
puts "ManagerUser with email and password '\#{_email_pass}' was created!"
|
|
202
|
+
else
|
|
203
|
+
puts 'Creating ManagerUser error'
|
|
204
|
+
end
|
|
205
|
+
else
|
|
206
|
+
puts 'ManagerUsers are here already'
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
210
|
+
rails_admin do
|
|
211
|
+
list do
|
|
212
|
+
field :email
|
|
213
|
+
field :name
|
|
214
|
+
field :login
|
|
215
|
+
field :roles do
|
|
216
|
+
pretty_value do
|
|
217
|
+
render_object = (bindings[:controller] || bindings[:view])
|
|
218
|
+
render_object.content_tag(:p, bindings[:object].roles.join(", ")) if render_object
|
|
219
|
+
end
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
edit do
|
|
224
|
+
group :login do
|
|
225
|
+
active false
|
|
226
|
+
field :email, :string do
|
|
227
|
+
visible do
|
|
228
|
+
render_object = (bindings[:controller] || bindings[:view])
|
|
229
|
+
render_object and (render_object.current_user.admin? or (render_object.current_user.manager? and render_object.current_user == bindings[:object]))
|
|
230
|
+
end
|
|
231
|
+
end
|
|
232
|
+
field :name, :string
|
|
233
|
+
field :login, :string do
|
|
234
|
+
visible do
|
|
235
|
+
render_object = (bindings[:controller] || bindings[:view])
|
|
236
|
+
render_object and render_object.current_user.admin?
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
group :roles do
|
|
242
|
+
active false
|
|
243
|
+
field :roles, :enum do
|
|
244
|
+
enum do
|
|
245
|
+
AVAILABLE_ROLES
|
|
246
|
+
end
|
|
247
|
+
|
|
248
|
+
multiple do
|
|
249
|
+
true
|
|
250
|
+
end
|
|
251
|
+
|
|
252
|
+
visible do
|
|
253
|
+
render_object = (bindings[:controller] || bindings[:view])
|
|
254
|
+
render_object and render_object.current_user.admin?
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
|
|
259
|
+
group :password do
|
|
260
|
+
active false
|
|
261
|
+
field :password do
|
|
262
|
+
visible do
|
|
263
|
+
render_object = (bindings[:controller] || bindings[:view])
|
|
264
|
+
render_object and (render_object.current_user.admin? or render_object.current_user == bindings[:object])
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
field :password_confirmation do
|
|
268
|
+
visible do
|
|
269
|
+
render_object = (bindings[:controller] || bindings[:view])
|
|
270
|
+
render_object and (render_object.current_user.admin? or render_object.current_user == bindings[:object])
|
|
271
|
+
end
|
|
272
|
+
end
|
|
273
|
+
end
|
|
274
|
+
end
|
|
275
|
+
|
|
276
|
+
end
|
|
277
|
+
TEXT
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
###### HANCOCK OTHERS ######
|
|
283
|
+
|
|
284
|
+
unless mongoid
|
|
285
|
+
generate "hancock:cms:migration"
|
|
286
|
+
generate "rails_admin_settings:migration"
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
remove_file 'app/views/layouts/application.html.erb'
|
|
290
|
+
generate "hancock:cms:layout"
|
|
291
|
+
|
|
292
|
+
unless mongoid
|
|
293
|
+
rake "db:migrate"
|
|
294
|
+
end
|
|
295
|
+
|
|
296
|
+
run 'rails r "User.generate_first_admin_user"'
|
|
297
|
+
|
|
298
|
+
remove_file 'app/assets/stylesheets/application.css'
|
|
299
|
+
remove_file 'app/assets/javascripts/application.js'
|
|
300
|
+
generate "hancock:cms:assets", app_name
|
|
301
|
+
|
|
302
|
+
remove_file 'public/robots.txt'
|
|
303
|
+
generate "hancock:cms:robots", app_name
|
|
304
|
+
|
|
305
|
+
#god+unicorn
|
|
306
|
+
generate "hancock:cms:unicorn_god", app_name
|
|
307
|
+
#scripts
|
|
308
|
+
generate "hancock:cms:scripts", app_name
|
|
309
|
+
|
|
310
|
+
FileUtils.cp(Pathname.new(destination_root).join('config', 'secrets.yml').to_s, Pathname.new(destination_root).join('config', 'secrets.yml.example').to_s)
|
|
311
|
+
|
|
312
|
+
unless mongoid
|
|
313
|
+
generate "paper_trail:install"
|
|
314
|
+
generate "friendly_id"
|
|
315
|
+
rake "db:migrate"
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
generate "rspec:install"
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
####### GIT #######
|
|
322
|
+
|
|
323
|
+
remove_file '.gitignore'
|
|
324
|
+
create_file '.gitignore' do <<-TEXT
|
|
325
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
326
|
+
#
|
|
327
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
|
328
|
+
# or operating system, you probably want to add a global ignore instead:
|
|
329
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
|
330
|
+
.idea
|
|
331
|
+
.idea/*
|
|
332
|
+
|
|
333
|
+
/.bundle
|
|
334
|
+
/log/*.log
|
|
335
|
+
/tmp/*
|
|
336
|
+
/public/assets
|
|
337
|
+
/public/ckeditor_assets
|
|
338
|
+
Gemfile.lock
|
|
339
|
+
TEXT
|
|
340
|
+
end
|
|
341
|
+
|
|
342
|
+
create_file 'extra/.gitkeep', ''
|
|
343
|
+
|
|
344
|
+
git :init
|
|
345
|
+
git add: "."
|
|
346
|
+
git commit: %Q{ -m 'Initial commit' }
|
|
347
|
+
|
|
348
|
+
end
|
|
349
|
+
|
|
350
|
+
def mongoid
|
|
351
|
+
defined? Mongoid
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
def app_name
|
|
355
|
+
Rails.application.class.parent_name
|
|
356
|
+
end
|
|
357
|
+
|
|
358
|
+
end
|
|
359
|
+
end
|
|
File without changes
|
|
@@ -3,8 +3,11 @@ module Hancock
|
|
|
3
3
|
module EmbeddedElement
|
|
4
4
|
def self.config(nav_label = nil, fields = {})
|
|
5
5
|
if nav_label.is_a?(Hash)
|
|
6
|
+
nav_label, fields = nav_label[:nav_label], nav_label
|
|
7
|
+
elsif nav_label.is_a?(Array)
|
|
6
8
|
nav_label, fields = nil, nav_label
|
|
7
9
|
end
|
|
10
|
+
|
|
8
11
|
Proc.new {
|
|
9
12
|
navigation_label(nav_label || I18n.t('hancock.cms'))
|
|
10
13
|
field :enabled, :toggle do
|
|
@@ -27,6 +27,8 @@ module Hancock
|
|
|
27
27
|
|
|
28
28
|
attr_accessor :captcha_on_development
|
|
29
29
|
|
|
30
|
+
attr_accessor :history_tracking
|
|
31
|
+
|
|
30
32
|
def initialize
|
|
31
33
|
@main_index_layout = 'application'
|
|
32
34
|
@error_layout = 'application'
|
|
@@ -43,6 +45,8 @@ module Hancock
|
|
|
43
45
|
@registration_captcha = @admin_enter_captcha
|
|
44
46
|
|
|
45
47
|
@captcha_on_development = false
|
|
48
|
+
|
|
49
|
+
@history_tracking = true
|
|
46
50
|
end
|
|
47
51
|
end
|
|
48
52
|
end
|
data/lib/hancock/engine.rb
CHANGED
|
@@ -10,39 +10,43 @@ module Hancock
|
|
|
10
10
|
# Write default email settings to DB so they can be changed.
|
|
11
11
|
|
|
12
12
|
#temp
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
begin
|
|
14
|
+
if Settings and Settings.table_exists?
|
|
15
15
|
# Settings.default_email_from(default: 'noreply@site.domain')
|
|
16
16
|
# Settings.form_email(default: 'admin@site.domain')
|
|
17
17
|
# Settings.email_topic(default: 'с сайта')
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
initializer 'hancock_cms.paperclip' do
|
|
23
|
-
# require 'paperclip/style'
|
|
24
|
-
# module ::Paperclip
|
|
25
|
-
# class Style
|
|
26
|
-
# alias_method :processor_options_without_auto_orient, :processor_options
|
|
27
|
-
# def processor_options
|
|
28
|
-
# processor_options_without_auto_orient.merge(auto_orient: false)
|
|
29
|
-
# end
|
|
30
|
-
# end
|
|
31
|
-
# end
|
|
18
|
+
Settings.logo_image(kind: :image)
|
|
19
|
+
end
|
|
20
|
+
rescue
|
|
21
|
+
end
|
|
32
22
|
end
|
|
23
|
+
# initializer 'hancock_cms.paperclip' do
|
|
24
|
+
# # require 'paperclip/style'
|
|
25
|
+
# # module ::Paperclip
|
|
26
|
+
# # class Style
|
|
27
|
+
# # alias_method :processor_options_without_auto_orient, :processor_options
|
|
28
|
+
# # def processor_options
|
|
29
|
+
# # processor_options_without_auto_orient.merge(auto_orient: false)
|
|
30
|
+
# # end
|
|
31
|
+
# # end
|
|
32
|
+
# # end
|
|
33
|
+
# end
|
|
33
34
|
|
|
34
|
-
config.after_initialize do
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
# config.after_initialize do
|
|
36
|
+
# # trigger autoload so models are registered in Mongoid::Elasticearch
|
|
37
|
+
# # Hancock.config.search_models.map(&:constantize)
|
|
38
|
+
#
|
|
39
|
+
# # Write default email settings to DB so they can be changed.
|
|
40
|
+
# begin
|
|
41
|
+
# if Settings and Settings.table_exists?
|
|
42
|
+
# # Settings.default_email_from(default: 'noreply@site.domain')
|
|
43
|
+
# # Settings.form_email(default: 'admin@site.domain')
|
|
44
|
+
# # Settings.email_topic(default: 'с сайта')
|
|
45
|
+
# Settings.logo_image(kind: :image)
|
|
46
|
+
# end
|
|
47
|
+
# rescue
|
|
48
|
+
# end
|
|
49
|
+
# end
|
|
37
50
|
|
|
38
|
-
# Write default email settings to DB so they can be changed.
|
|
39
|
-
if Settings and Settings.table_exists?
|
|
40
|
-
# Settings.default_email_from(default: 'noreply@site.domain')
|
|
41
|
-
# Settings.form_email(default: 'admin@site.domain')
|
|
42
|
-
# Settings.email_topic(default: 'с сайта')
|
|
43
|
-
#
|
|
44
|
-
Settings.logo_image(kind: :image)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
51
|
end
|
|
48
52
|
end
|
data/lib/hancock/model.rb
CHANGED
|
@@ -38,11 +38,13 @@ module Hancock
|
|
|
38
38
|
include RailsAdminComments::ModelCommentable
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
if Hancock.
|
|
42
|
-
if
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
if Hancock.config.history_tracking
|
|
42
|
+
if Hancock.mongoid?
|
|
43
|
+
if defined?(TrackablePatch)
|
|
44
|
+
include TrackablePatch
|
|
45
|
+
elsif defined?(Trackable)
|
|
46
|
+
include Trackable
|
|
47
|
+
end
|
|
46
48
|
end
|
|
47
49
|
end
|
|
48
50
|
|
|
@@ -84,19 +84,23 @@ module Hancock
|
|
|
84
84
|
if rails_admin_actions.respond_to?(action)
|
|
85
85
|
rails_admin_actions.send(action) do
|
|
86
86
|
visible do
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
ret = bindings[:abstract_model].model.rails_admin_visible_actions.include?(action)
|
|
87
|
+
if !bindings or bindings[:abstract_model].blank?
|
|
88
|
+
true
|
|
90
89
|
else
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
90
|
+
ret = false
|
|
91
|
+
if bindings[:abstract_model].model.respond_to?(:rails_admin_visible_actions)
|
|
92
|
+
ret = bindings[:abstract_model].model.rails_admin_visible_actions.include?(action)
|
|
93
|
+
else
|
|
94
|
+
if visibility = Hancock.rails_admin_config.actions_visibility[action]
|
|
95
|
+
if visibility.is_a?(Proc)
|
|
96
|
+
ret = visibility.call(self)
|
|
97
|
+
else
|
|
98
|
+
ret = visibility.include? bindings[:abstract_model].model_name
|
|
99
|
+
end
|
|
96
100
|
end
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
|
|
101
|
+
end # if bindings[:abstract_model].model.respond_to?(:rails_admin_visible_actions)
|
|
102
|
+
ret
|
|
103
|
+
end # !bindings or bindings[:abstract_model].blank?
|
|
100
104
|
end # visible do
|
|
101
105
|
end # rails_admin_actions.send(action) do
|
|
102
106
|
end # if rails_admin_actions.respond_to?(action)
|
data/lib/hancock/version.rb
CHANGED
data/template.rb
CHANGED
|
@@ -34,13 +34,16 @@ gem 'compass-rails'
|
|
|
34
34
|
# gem 'ack-paperclip-meta', github: "red-rocks/paperclip-meta"
|
|
35
35
|
|
|
36
36
|
# gem 'rails_admin_multiple_file_upload'
|
|
37
|
+
gem 'rails_admin_user_abilities', '~> 0.1.0'
|
|
37
38
|
# gem 'rails_admin_user_abilities', github: "red-rocks/rails_admin_user_abilities"
|
|
39
|
+
gem 'rails_admin_model_settings', '~> 0.2.1'
|
|
38
40
|
# gem 'rails_admin_model_settings', github: "red-rocks/rails_admin_model_settings"
|
|
39
41
|
|
|
42
|
+
# #{if mongoid then "gem 'hancock_cms_mongoid'" else "gem 'hancock_cms_activerecord'" end}, github: 'red-rocks/hancock_cms', branch: 'rails4'
|
|
43
|
+
#{if mongoid then "gem 'hancock_cms_mongoid'" else "gem 'hancock_cms_activerecord'" end}, path: "/home/ack/www/redrocks/hancock"
|
|
40
44
|
|
|
41
|
-
#
|
|
42
|
-
|
|
43
|
-
gem 'devise'
|
|
45
|
+
# gem 'recaptcha', require: 'recaptcha/rails'
|
|
46
|
+
# gem 'glebtv-simple_captcha'
|
|
44
47
|
|
|
45
48
|
gem 'slim-rails'
|
|
46
49
|
gem 'rs_russian'
|
|
@@ -69,7 +72,8 @@ group :development do
|
|
|
69
72
|
# gem 'coffee-rails-source-maps'
|
|
70
73
|
# gem 'compass-rails-source-maps'
|
|
71
74
|
|
|
72
|
-
gem 'ack_favicon_maker_rails',
|
|
75
|
+
gem 'ack_favicon_maker_rails', '~> 1.0.1'
|
|
76
|
+
# gem 'ack_favicon_maker_rails', github: 'ack43/favicon_maker_rails'
|
|
73
77
|
|
|
74
78
|
# gem 'rails_email_preview', '~> 1.0.3'
|
|
75
79
|
|
|
@@ -98,7 +102,7 @@ group :production do
|
|
|
98
102
|
gem "god"
|
|
99
103
|
end
|
|
100
104
|
|
|
101
|
-
gem 'glebtv_mongoid_userstamp', '0.6.
|
|
105
|
+
gem 'glebtv_mongoid_userstamp', '0.6.2'
|
|
102
106
|
TEXT
|
|
103
107
|
end
|
|
104
108
|
|
|
@@ -106,11 +110,9 @@ RVM_RUBY_VERSION = "2.3.1"
|
|
|
106
110
|
create_file '.ruby-version', "#{RVM_RUBY_VERSION}\n"
|
|
107
111
|
create_file '.ruby-gemset', "#{app_name.underscore}\n"
|
|
108
112
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
run 'bundle install --without production'
|
|
113
|
-
|
|
113
|
+
run "rvm #{RVM_RUBY_VERSION} do rvm gemset create #{app_name.underscore}"
|
|
114
|
+
run "rvm #{RVM_RUBY_VERSION}@#{app_name.underscore} do gem install bundler"
|
|
115
|
+
run "rvm #{RVM_RUBY_VERSION}@#{app_name.underscore} do bundle install --without production"
|
|
114
116
|
|
|
115
117
|
####### CONFIG #######
|
|
116
118
|
|
|
@@ -223,342 +225,3 @@ module #{app_name.underscore.camelcase}
|
|
|
223
225
|
end
|
|
224
226
|
TEXT
|
|
225
227
|
end
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
####### DEVISE #######
|
|
229
|
-
|
|
230
|
-
generate "devise:install"
|
|
231
|
-
gsub_file 'config/initializers/devise.rb', "'please-change-me-at-config-initializers-devise@example.com'", "'noreply@#{app_name.dasherize.downcase}.ru'"
|
|
232
|
-
inject_into_file 'config/initializers/devise.rb', after: /^end/ do <<-TEXT
|
|
233
|
-
Rails.application.config.to_prepare do
|
|
234
|
-
Devise::SessionsController.layout "hancock/devise/sessions"
|
|
235
|
-
Devise::RegistrationsController.layout "hancock/devise/registrations"
|
|
236
|
-
Devise::ConfirmationsController.layout "hancock/devise/confirmations"
|
|
237
|
-
Devise::UnlocksController.layout "hancock/devise/unlocks"
|
|
238
|
-
Devise::PasswordsController.layout "hancock/devise/passwords"
|
|
239
|
-
end
|
|
240
|
-
TEXT
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
generate "devise", "User"
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
####### ROUTES #######
|
|
247
|
-
|
|
248
|
-
remove_file 'config/routes.rb'
|
|
249
|
-
create_file 'config/routes.rb' do <<-TEXT
|
|
250
|
-
Rails.application.routes.draw do
|
|
251
|
-
devise_for :users, controllers: {sessions: 'hancock/sessions'}
|
|
252
|
-
|
|
253
|
-
mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
|
|
254
|
-
mount Ckeditor::Engine => '/ckeditor'
|
|
255
|
-
|
|
256
|
-
hancock_cms_routes
|
|
257
|
-
end
|
|
258
|
-
TEXT
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
####### INITIALIZERS #######
|
|
263
|
-
|
|
264
|
-
inject_into_file 'config/initializers/assets.rb', before: /\z/ do <<-TEXT
|
|
265
|
-
Rails.application.config.assets.precompile += %w( *.svg )
|
|
266
|
-
Rails.application.config.assets.precompile += %w( ckeditor/* )
|
|
267
|
-
Rails.application.config.assets.precompile += %w( codemirror.js codemirror.css codemirror/**/* )
|
|
268
|
-
TEXT
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
if mongoid
|
|
272
|
-
generate "ckeditor:install", "--orm=mongoid", "--backend=paperclip"
|
|
273
|
-
else
|
|
274
|
-
generate "ckeditor:install", "--orm=active_record", "--backend=paperclip"
|
|
275
|
-
end
|
|
276
|
-
gsub_file 'config/initializers/ckeditor.rb', "# config.image_file_types = %w(jpg jpeg png gif tiff)", "config.image_file_types = %w(jpg jpeg png gif tiff svg)"
|
|
277
|
-
gsub_file 'config/initializers/ckeditor.rb', "# config.authorize_with :cancan", "config.authorize_with :cancancan"
|
|
278
|
-
gsub_file 'config/initializers/ckeditor.rb', "# config.assets_languages = ['en', 'uk']", "config.assets_languages = ['en', 'ru']"
|
|
279
|
-
|
|
280
|
-
if mongoid
|
|
281
|
-
remove_file 'config/initializers/cookies_serializer.rb'
|
|
282
|
-
create_file 'config/initializers/cookies_serializer.rb' do <<-TEXT
|
|
283
|
-
# Be sure to restart your server when you modify this file.
|
|
284
|
-
# json serializer breaks Devise + Mongoid. DO NOT ENABLE
|
|
285
|
-
# See https://github.com/plataformatec/devise/pull/2882
|
|
286
|
-
# Rails.application.config.action_dispatch.cookies_serializer = :json
|
|
287
|
-
Rails.application.config.action_dispatch.cookies_serializer = :marshal
|
|
288
|
-
TEXT
|
|
289
|
-
end
|
|
290
|
-
end
|
|
291
|
-
|
|
292
|
-
gsub_file 'config/initializers/filter_parameter_logging.rb', "[:password]", "[:password, :password_confirmation]"
|
|
293
|
-
|
|
294
|
-
# generate 'paperclip_optimizer:install'
|
|
295
|
-
# remove_file 'config/initializers/paperclip_optimizer.rb'
|
|
296
|
-
# generate "hancock:cms:paperclip_optimizer"
|
|
297
|
-
|
|
298
|
-
# generate 'rails_email_preview:install'
|
|
299
|
-
# remove_file 'app/mailer_previews/contact_mailer_preview.rb'
|
|
300
|
-
# create_file 'app/mailer_previews/contact_mailer_preview.rb' do <<-TEXT
|
|
301
|
-
# class ContactMailerPreview
|
|
302
|
-
# def new_message_email
|
|
303
|
-
# Hancock::Feedback::ContactMailer.new_message_email(Hancock::Feedback::ContactMessage.all.to_a.sample)
|
|
304
|
-
# end
|
|
305
|
-
# end
|
|
306
|
-
# TEXT
|
|
307
|
-
# end
|
|
308
|
-
|
|
309
|
-
generate "hancock:cms:config"
|
|
310
|
-
|
|
311
|
-
generate "hancock:cms:rack"
|
|
312
|
-
|
|
313
|
-
generate "hancock:cms:admin"
|
|
314
|
-
|
|
315
|
-
remove_file 'config/initializers/session_store.rb'
|
|
316
|
-
if mongoid
|
|
317
|
-
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
|
318
|
-
# Be sure to restart your server when you modify this file.
|
|
319
|
-
|
|
320
|
-
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
|
321
|
-
Rails.application.config.session_store :mongoid_store
|
|
322
|
-
TEXT
|
|
323
|
-
end
|
|
324
|
-
else
|
|
325
|
-
generate 'active_record_store:session_migration'
|
|
326
|
-
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
|
327
|
-
# Be sure to restart your server when you modify this file.
|
|
328
|
-
|
|
329
|
-
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
|
330
|
-
Rails.application.config.session_store :active_record_store
|
|
331
|
-
TEXT
|
|
332
|
-
end
|
|
333
|
-
end
|
|
334
|
-
|
|
335
|
-
# unless mongoid
|
|
336
|
-
# generate 'simple_captcha'
|
|
337
|
-
# end
|
|
338
|
-
|
|
339
|
-
generate "simple_form:install"
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
####### CONTROLLERS #######
|
|
343
|
-
|
|
344
|
-
remove_file 'app/controllers/application_controller.rb'
|
|
345
|
-
create_file 'app/controllers/application_controller.rb' do <<-TEXT
|
|
346
|
-
class ApplicationController < ActionController::Base
|
|
347
|
-
include Hancock::Controller
|
|
348
|
-
end
|
|
349
|
-
TEXT
|
|
350
|
-
end
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
####### MODELS #######
|
|
354
|
-
|
|
355
|
-
generate "hancock:cms:ability"
|
|
356
|
-
|
|
357
|
-
gsub_file 'app/models/user.rb', '# :confirmable, :lockable, :timeoutable and :omniauthable' do <<-TEXT
|
|
358
|
-
include Hancock::Model
|
|
359
|
-
include Hancock::Enableable
|
|
360
|
-
include Hancock::RailsAdminPatch
|
|
361
|
-
def self.manager_can_default_actions
|
|
362
|
-
[:show, :read]
|
|
363
|
-
end
|
|
364
|
-
def manager_cannot_actions
|
|
365
|
-
[:new, :create, :delete, :destroy]
|
|
366
|
-
end
|
|
367
|
-
|
|
368
|
-
cattr_accessor :current_user
|
|
369
|
-
|
|
370
|
-
# Include default devise modules. Others available are:
|
|
371
|
-
# :confirmable, :lockable, :timeoutable and :omniauthable
|
|
372
|
-
TEXT
|
|
373
|
-
end
|
|
374
|
-
|
|
375
|
-
gsub_file 'app/models/user.rb', ':registerable,', ' :lockable,'
|
|
376
|
-
if mongoid
|
|
377
|
-
gsub_file 'app/models/user.rb', '# field :failed_attempts', 'field :failed_attempts'
|
|
378
|
-
gsub_file 'app/models/user.rb', '# field :unlock_token', 'field :unlock_token'
|
|
379
|
-
gsub_file 'app/models/user.rb', '# field :locked_at', 'field :locked_at'
|
|
380
|
-
|
|
381
|
-
inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
382
|
-
|
|
383
|
-
field :name, type: String
|
|
384
|
-
field :login, type: String
|
|
385
|
-
field :roles, type: Array, default: []
|
|
386
|
-
|
|
387
|
-
before_save do
|
|
388
|
-
self.roles ||= []
|
|
389
|
-
self.roles.reject! { |r| r.blank? }
|
|
390
|
-
end
|
|
391
|
-
|
|
392
|
-
AVAILABLE_ROLES = ["admin", "manager", "client"]
|
|
393
|
-
|
|
394
|
-
AVAILABLE_ROLES.each do |r|
|
|
395
|
-
class_eval <<-EVAL
|
|
396
|
-
def \#{r}?
|
|
397
|
-
self.roles and self.roles.include?("\#{r}")
|
|
398
|
-
end
|
|
399
|
-
|
|
400
|
-
scope :\#{r.pluralize}, -> { any_in(roles: "\#{r}") }
|
|
401
|
-
EVAL
|
|
402
|
-
end
|
|
403
|
-
|
|
404
|
-
def self.generate_first_admin_user
|
|
405
|
-
if ::User.admins.all.count == 0
|
|
406
|
-
_email_pass = 'admin@#{app_name.dasherize.downcase}.ru'
|
|
407
|
-
if ::User.new(roles: ["admin"], email: _email_pass, password: _email_pass, password_confirmation: _email_pass).save
|
|
408
|
-
puts "AdminUser with email and password '\#{_email_pass}' was created!"
|
|
409
|
-
else
|
|
410
|
-
puts 'Creating AdminUser error'
|
|
411
|
-
end
|
|
412
|
-
else
|
|
413
|
-
puts 'AdminUsers are here already'
|
|
414
|
-
end
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
def self.generate_first_manager_user
|
|
418
|
-
if ::User.managers.all.count == 0
|
|
419
|
-
_email_pass = 'manager@#{app_name.dasherize.downcase}.ru'
|
|
420
|
-
if ::User.create(roles: ["manager"], email: _email_pass, password: _email_pass, password_confirmation: _email_pass)
|
|
421
|
-
puts "ManagerUser with email and password '\#{_email_pass}' was created!"
|
|
422
|
-
else
|
|
423
|
-
puts 'Creating ManagerUser error'
|
|
424
|
-
end
|
|
425
|
-
else
|
|
426
|
-
puts 'ManagerUsers are here already'
|
|
427
|
-
end
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
rails_admin do
|
|
431
|
-
list do
|
|
432
|
-
field :email
|
|
433
|
-
field :name
|
|
434
|
-
field :login
|
|
435
|
-
field :roles do
|
|
436
|
-
pretty_value do
|
|
437
|
-
render_object = (bindings[:controller] || bindings[:view])
|
|
438
|
-
render_object.content_tag(:p, bindings[:object].roles.join(", ")) if render_object
|
|
439
|
-
end
|
|
440
|
-
end
|
|
441
|
-
end
|
|
442
|
-
|
|
443
|
-
edit do
|
|
444
|
-
group :login do
|
|
445
|
-
active false
|
|
446
|
-
field :email, :string do
|
|
447
|
-
visible do
|
|
448
|
-
render_object = (bindings[:controller] || bindings[:view])
|
|
449
|
-
render_object and (render_object.current_user.admin? or (render_object.current_user.manager? and render_object.current_user == bindings[:object]))
|
|
450
|
-
end
|
|
451
|
-
end
|
|
452
|
-
field :name, :string
|
|
453
|
-
field :login, :string do
|
|
454
|
-
visible do
|
|
455
|
-
render_object = (bindings[:controller] || bindings[:view])
|
|
456
|
-
render_object and render_object.current_user.admin?
|
|
457
|
-
end
|
|
458
|
-
end
|
|
459
|
-
end
|
|
460
|
-
|
|
461
|
-
group :roles do
|
|
462
|
-
active false
|
|
463
|
-
field :roles, :enum do
|
|
464
|
-
enum do
|
|
465
|
-
AVAILABLE_ROLES
|
|
466
|
-
end
|
|
467
|
-
|
|
468
|
-
multiple do
|
|
469
|
-
true
|
|
470
|
-
end
|
|
471
|
-
|
|
472
|
-
visible do
|
|
473
|
-
render_object = (bindings[:controller] || bindings[:view])
|
|
474
|
-
render_object and render_object.current_user.admin?
|
|
475
|
-
end
|
|
476
|
-
end
|
|
477
|
-
end
|
|
478
|
-
|
|
479
|
-
group :password do
|
|
480
|
-
active false
|
|
481
|
-
field :password do
|
|
482
|
-
visible do
|
|
483
|
-
render_object = (bindings[:controller] || bindings[:view])
|
|
484
|
-
render_object and (render_object.current_user.admin? or render_object.current_user == bindings[:object])
|
|
485
|
-
end
|
|
486
|
-
end
|
|
487
|
-
field :password_confirmation do
|
|
488
|
-
visible do
|
|
489
|
-
render_object = (bindings[:controller] || bindings[:view])
|
|
490
|
-
render_object and (render_object.current_user.admin? or render_object.current_user == bindings[:object])
|
|
491
|
-
end
|
|
492
|
-
end
|
|
493
|
-
end
|
|
494
|
-
end
|
|
495
|
-
|
|
496
|
-
end
|
|
497
|
-
TEXT
|
|
498
|
-
end
|
|
499
|
-
end
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
###### HANCOCK OTHERS ######
|
|
503
|
-
|
|
504
|
-
unless mongoid
|
|
505
|
-
generate "hancock:cms:migration"
|
|
506
|
-
generate "rails_admin_settings:migration"
|
|
507
|
-
end
|
|
508
|
-
|
|
509
|
-
remove_file 'app/views/layouts/application.html.erb'
|
|
510
|
-
generate "hancock:cms:layout"
|
|
511
|
-
|
|
512
|
-
unless mongoid
|
|
513
|
-
rake "db:migrate"
|
|
514
|
-
end
|
|
515
|
-
|
|
516
|
-
remove_file 'app/assets/stylesheets/application.css'
|
|
517
|
-
remove_file 'app/assets/javascripts/application.js'
|
|
518
|
-
generate "hancock:cms:assets", app_name
|
|
519
|
-
|
|
520
|
-
remove_file 'public/robots.txt'
|
|
521
|
-
generate "hancock:cms:robots", app_name
|
|
522
|
-
|
|
523
|
-
#god+unicorn
|
|
524
|
-
generate "hancock:cms:unicorn_god", app_name
|
|
525
|
-
#scripts
|
|
526
|
-
generate "hancock:cms:scripts", app_name
|
|
527
|
-
|
|
528
|
-
FileUtils.cp(Pathname.new(destination_root).join('config', 'secrets.yml').to_s, Pathname.new(destination_root).join('config', 'secrets.yml.example').to_s)
|
|
529
|
-
|
|
530
|
-
unless mongoid
|
|
531
|
-
generate "paper_trail:install"
|
|
532
|
-
generate "friendly_id"
|
|
533
|
-
rake "db:migrate"
|
|
534
|
-
end
|
|
535
|
-
|
|
536
|
-
generate "rspec:install"
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
####### GIT #######
|
|
540
|
-
|
|
541
|
-
remove_file '.gitignore'
|
|
542
|
-
create_file '.gitignore' do <<-TEXT
|
|
543
|
-
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
|
544
|
-
#
|
|
545
|
-
# If you find yourself ignoring temporary files generated by your text editor
|
|
546
|
-
# or operating system, you probably want to add a global ignore instead:
|
|
547
|
-
# git config --global core.excludesfile '~/.gitignore_global'
|
|
548
|
-
.idea
|
|
549
|
-
.idea/*
|
|
550
|
-
|
|
551
|
-
/.bundle
|
|
552
|
-
/log/*.log
|
|
553
|
-
/tmp/*
|
|
554
|
-
/public/assets
|
|
555
|
-
/public/ckeditor_assets
|
|
556
|
-
Gemfile.lock
|
|
557
|
-
TEXT
|
|
558
|
-
end
|
|
559
|
-
|
|
560
|
-
create_file 'extra/.gitkeep', ''
|
|
561
|
-
|
|
562
|
-
git :init
|
|
563
|
-
git add: "."
|
|
564
|
-
git commit: %Q{ -m 'Initial commit' }
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hancock_cms
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.0
|
|
4
|
+
version: 1.0.0.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexander Kiseliev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-
|
|
11
|
+
date: 2016-12-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -188,16 +188,16 @@ dependencies:
|
|
|
188
188
|
name: ack_rails_admin_settings
|
|
189
189
|
requirement: !ruby/object:Gem::Requirement
|
|
190
190
|
requirements:
|
|
191
|
-
- - "
|
|
191
|
+
- - "~>"
|
|
192
192
|
- !ruby/object:Gem::Version
|
|
193
|
-
version: '
|
|
193
|
+
version: '1.2'
|
|
194
194
|
type: :runtime
|
|
195
195
|
prerelease: false
|
|
196
196
|
version_requirements: !ruby/object:Gem::Requirement
|
|
197
197
|
requirements:
|
|
198
|
-
- - "
|
|
198
|
+
- - "~>"
|
|
199
199
|
- !ruby/object:Gem::Version
|
|
200
|
-
version: '
|
|
200
|
+
version: '1.2'
|
|
201
201
|
- !ruby/object:Gem::Dependency
|
|
202
202
|
name: kaminari
|
|
203
203
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -293,6 +293,7 @@ files:
|
|
|
293
293
|
- app/models/concerns/hancock/boolean_field.rb
|
|
294
294
|
- app/models/concerns/hancock/cacheable.rb
|
|
295
295
|
- app/models/concerns/hancock/decorators/embedded_element.rb
|
|
296
|
+
- app/models/concerns/hancock/embedded_findable.rb
|
|
296
297
|
- app/models/concerns/hancock/enableable.rb
|
|
297
298
|
- app/models/concerns/hancock/geocodeable.rb
|
|
298
299
|
- app/models/concerns/hancock/hash_field.rb
|
|
@@ -342,7 +343,6 @@ files:
|
|
|
342
343
|
- app/views/rails_admin/main/_hancock_html_ml.html.slim
|
|
343
344
|
- app/views/shared/_admin_link.html.slim
|
|
344
345
|
- app/views/shared/_messages.html.slim
|
|
345
|
-
- config/initializers/embedded_findable.rb
|
|
346
346
|
- config/initializers/hancock_cms.rb
|
|
347
347
|
- config/initializers/simple_captcha.rb
|
|
348
348
|
- config/locales/en.hancock.yml
|
|
@@ -371,12 +371,14 @@ files:
|
|
|
371
371
|
- lib/generators/hancock/cms/rack_generator.rb
|
|
372
372
|
- lib/generators/hancock/cms/robots_generator.rb
|
|
373
373
|
- lib/generators/hancock/cms/scripts_generator.rb
|
|
374
|
+
- lib/generators/hancock/cms/setup_generator.rb
|
|
374
375
|
- lib/generators/hancock/cms/templates/Gemfile.erb
|
|
375
376
|
- lib/generators/hancock/cms/templates/ability.erb
|
|
376
377
|
- lib/generators/hancock/cms/templates/admin.erb
|
|
377
378
|
- lib/generators/hancock/cms/templates/application.erb
|
|
378
379
|
- lib/generators/hancock/cms/templates/assets/javascripts/application.coffee.erb
|
|
379
380
|
- lib/generators/hancock/cms/templates/assets/stylesheets/application.sass.erb
|
|
381
|
+
- lib/generators/hancock/cms/templates/assets/stylesheets/hancock/rails_admin/custom/theming.sass.erb
|
|
380
382
|
- lib/generators/hancock/cms/templates/hancock_cms.erb
|
|
381
383
|
- lib/generators/hancock/cms/templates/model.erb
|
|
382
384
|
- lib/generators/hancock/cms/templates/paperclip_optimizer.erb
|