hancock_cms 2.0.0.1 → 2.0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/README.md +2 -2
- data/app/models/concerns/hancock/cacheable.rb +17 -0
- data/app/views/blocks/_preloader.html.slim +0 -0
- data/app/views/layouts/application.html.slim +15 -7
- data/config/initializers/nested_set_patch.rb +89 -0
- data/lib/generators/hancock/cms/setup_generator.rb +33 -2
- data/lib/generators/hancock/cms/templates/scripts/server.sh +1 -1
- data/lib/generators/hancock/cms/templates/scripts/server_alt.sh +1 -1
- data/lib/hancock/rails_admin_ext/config.rb +11 -1
- data/lib/hancock/version.rb +1 -1
- data/lib/hancock_cms.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0596d7c61478cd10684f4d1c9c9b5361de0f3de5'
|
4
|
+
data.tar.gz: 4f4c14ff3ddf539e96ea445df5d0510986c7d4a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0747b77095baeadfe3bcd8c0dbc427234a2eb569586264bad110e5cc1d1e09fc971df94a63ddd0bbef331727fd0d065e4781a47d389943e9311dc45be81fcf1d
|
7
|
+
data.tar.gz: ef3f1fbd6012aecc0eecae628dc76365d60653e6b94525e670c4dafc6253bae1506bc3858633f05bab3ab7ead7046ef79d7b9504ab744a3e0c54e5d43d3ee7d3
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.3
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ And then execute:
|
|
29
29
|
|
30
30
|
Or install it yourself as:
|
31
31
|
|
32
|
-
$ gem install hancock_cms -v 2.0
|
32
|
+
$ gem install hancock_cms -v 2.0
|
33
33
|
|
34
34
|
For activerecord, generate migrations and run them
|
35
35
|
|
@@ -48,7 +48,7 @@ Make sure you have rails 5.0 installed
|
|
48
48
|
If not, uninstall rails and install again
|
49
49
|
|
50
50
|
gem uninstall rails
|
51
|
-
gem install rails -v 5.0
|
51
|
+
gem install rails -v 5.0
|
52
52
|
|
53
53
|
Then, for mongoid:
|
54
54
|
|
@@ -11,6 +11,23 @@ if Hancock.mongoid?
|
|
11
11
|
def default_cache_keys
|
12
12
|
self.class.default_cache_keys
|
13
13
|
end
|
14
|
+
def set_default_cache_keys(strategy = :append)
|
15
|
+
_old_keys = cache_keys
|
16
|
+
|
17
|
+
_keys = case strategy.to_sym
|
18
|
+
when :append
|
19
|
+
(_old_keys + default_cache_keys).uniq
|
20
|
+
when :overwrite, :replace
|
21
|
+
default_cache_keys
|
22
|
+
else
|
23
|
+
_old_keys
|
24
|
+
end
|
25
|
+
self
|
26
|
+
end
|
27
|
+
def set_default_cache_keys!(strategy = :append)
|
28
|
+
self.set_default_cache_keys(strategy) and self.save
|
29
|
+
end
|
30
|
+
|
14
31
|
|
15
32
|
def cache_keys
|
16
33
|
cache_keys_str.split(/\s+/).map { |k| k.strip }.reject { |k| k.blank? }
|
File without changes
|
@@ -6,19 +6,27 @@ html lang="ru"
|
|
6
6
|
title= yield(:title) || page_title
|
7
7
|
= yield :meta
|
8
8
|
= csrf_meta_tags
|
9
|
-
|
9
|
+
|
10
|
+
/ - cache 'favicons', skip_digest: true do
|
11
|
+
/ = render partial: 'blocks/favicon'
|
10
12
|
|
11
13
|
- async = false #Rails.env.production?
|
12
14
|
= stylesheet_link_tag "application", media: "all", async: async
|
13
15
|
= javascript_include_tag "application", async: async
|
14
16
|
/[if lt IE 9]
|
15
17
|
= javascript_include_tag "//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.2/html5shiv.min.js", async: async
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
- cache 'layouts/application/custom_head', skip_digest: true do
|
19
|
+
- _cache_key = ['views/layouts/application/custom_head']
|
20
|
+
css:
|
21
|
+
#{Settings.ns('application_layout').custom_css(default: '', kind: :css, label: "Дополнительный CSS", cache_keys: _cache_key)}
|
22
|
+
javascript:
|
23
|
+
#{Settings.ns('application_layout').custom_js(default: '', kind: :js, label: "Дополнительный JS", cache_keys: _cache_key)}
|
24
|
+
|
25
|
+
body{class="application_layout #{controller_name} #{action_name} #{controller_name}_#{action_name}"}
|
20
26
|
|
21
|
-
|
27
|
+
- cache 'preloader', skip_digest: true do
|
28
|
+
= render partial: 'blocks/preloader'
|
29
|
+
|
22
30
|
#root role="main"
|
23
31
|
|
24
32
|
header#header
|
@@ -32,4 +40,4 @@ html lang="ru"
|
|
32
40
|
footer#footer
|
33
41
|
= render partial: 'blocks/footer'
|
34
42
|
|
35
|
-
= render partial: 'hancock/toplink/toplink'
|
43
|
+
= render partial: 'hancock/toplink/toplink'
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Patach for glebtv-mongoid_nested_set and rails5 (belongs_to is required)
|
2
|
+
require 'glebtv-mongoid_nested_set'
|
3
|
+
|
4
|
+
module Mongoid::Acts::NestedSet
|
5
|
+
module Base
|
6
|
+
# Configuration options are:
|
7
|
+
#
|
8
|
+
# * +:parent_field+ - field name to use for keeping the parent id (default: parent_id)
|
9
|
+
# * +:left_field+ - field name for left boundary data, default 'lft'
|
10
|
+
# * +:right_field+ - field name for right boundary data, default 'rgt'
|
11
|
+
# * +:outline_number_field+ - field name for the number field, default nil. If set,
|
12
|
+
# the value will be used as a field name to keep track of each node's
|
13
|
+
# "outline number" (e.g. 1.2.5).
|
14
|
+
# * +:scope+ - restricts what is to be considered a list. Given a symbol, it'll attach
|
15
|
+
# "_id" (if it hasn't been already) and use that as the foreign key restriction. You
|
16
|
+
# can also pass an array to scope by multiple attributes
|
17
|
+
# * +:dependent+ - behavior for cascading destroy. If set to :destroy, all the child
|
18
|
+
# objects are destroyed alongside this object by calling their destroy method. If set
|
19
|
+
# to :delete_all (default), all the child objects are deleted without calling their
|
20
|
+
# destroy method.
|
21
|
+
# * +:klass+ - class to use for queries (defaults to self)
|
22
|
+
#
|
23
|
+
# See Mongoid::Acts::NestedSet::ClassMethods for a list of class methods and
|
24
|
+
# Mongoid::Acts::NestedSet::InstanceMethods for a list of instance methods added to
|
25
|
+
# acts_as_nested_set models
|
26
|
+
def acts_as_nested_set(options = {})
|
27
|
+
options = {
|
28
|
+
:parent_field => 'parent_id',
|
29
|
+
:left_field => 'lft',
|
30
|
+
:right_field => 'rgt',
|
31
|
+
:outline_number_field => nil,
|
32
|
+
:dependent => :delete_all, # or :destroy
|
33
|
+
:klass => self,
|
34
|
+
}.merge(options)
|
35
|
+
|
36
|
+
if options[:scope].is_a?(Symbol) && options[:scope].to_s !~ /_id$/
|
37
|
+
options[:scope] = "#{options[:scope]}_id".intern
|
38
|
+
end
|
39
|
+
|
40
|
+
class_attribute :acts_as_nested_set_options, :instance_writer => false
|
41
|
+
self.acts_as_nested_set_options = options
|
42
|
+
|
43
|
+
unless self.is_a?(Document::ClassMethods)
|
44
|
+
include Document
|
45
|
+
include OutlineNumber if outline_number_field_name
|
46
|
+
|
47
|
+
field left_field_name, :type => Integer
|
48
|
+
field right_field_name, :type => Integer
|
49
|
+
field outline_number_field_name, :type => String if outline_number_field_name
|
50
|
+
field :depth, :type => Integer
|
51
|
+
|
52
|
+
has_many :children, :class_name => self.name, :foreign_key => parent_field_name, :inverse_of => :parent, :order => left_field_name.to_sym.asc
|
53
|
+
# was
|
54
|
+
# belongs_to :parent, :class_name => self.name, :foreign_key => parent_field_name
|
55
|
+
# became
|
56
|
+
belongs_to :parent, :class_name => self.name, :foreign_key => parent_field_name, required: false
|
57
|
+
|
58
|
+
attr_accessor :skip_before_destroy
|
59
|
+
|
60
|
+
define_callbacks :move, :terminator => callback_terminator
|
61
|
+
|
62
|
+
before_create :set_default_left_and_right
|
63
|
+
before_save :store_new_parent
|
64
|
+
after_save :move_to_new_parent
|
65
|
+
before_destroy :destroy_descendants
|
66
|
+
|
67
|
+
# no assignment to structure fields
|
68
|
+
[left_field_name, right_field_name].each do |field|
|
69
|
+
module_eval <<-"end_eval", __FILE__, __LINE__
|
70
|
+
def #{field}=(x)
|
71
|
+
raise NameError, "Unauthorized assignment to #{field}: it's an internal field handled by acts_as_nested_set code, use move_to_* methods instead.", "#{field}"
|
72
|
+
end
|
73
|
+
end_eval
|
74
|
+
end
|
75
|
+
|
76
|
+
scope :roots, lambda {
|
77
|
+
where(parent_field_name => nil).asc(left_field_name)
|
78
|
+
}
|
79
|
+
scope :leaves, lambda {
|
80
|
+
where("this.#{quoted_right_field_name} - this.#{quoted_left_field_name} == 1").asc(left_field_name)
|
81
|
+
}
|
82
|
+
scope :with_depth, lambda { |level|
|
83
|
+
where(:depth => level).asc(left_field_name)
|
84
|
+
}
|
85
|
+
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
@@ -100,6 +100,7 @@ remove_file 'config/initializers/session_store.rb'
|
|
100
100
|
if mongoid
|
101
101
|
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
102
102
|
# Be sure to restart your server when you modify this file.
|
103
|
+
|
103
104
|
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
104
105
|
Rails.application.config.session_store :mongoid_store
|
105
106
|
TEXT
|
@@ -108,6 +109,7 @@ else
|
|
108
109
|
generate 'active_record_store:session_migration'
|
109
110
|
create_file 'config/initializers/session_store.rb' do <<-TEXT
|
110
111
|
# Be sure to restart your server when you modify this file.
|
112
|
+
|
111
113
|
#Rails.application.config.session_store :cookie_store, key: '_#{app_name.tableize.singularize}_session'
|
112
114
|
Rails.application.config.session_store :active_record_store
|
113
115
|
TEXT
|
@@ -143,10 +145,20 @@ include Hancock::Model
|
|
143
145
|
def self.manager_can_default_actions
|
144
146
|
[:show, :read]
|
145
147
|
end
|
146
|
-
def manager_cannot_actions
|
148
|
+
def self.manager_cannot_actions
|
147
149
|
[:new, :create, :delete, :destroy]
|
148
150
|
end
|
151
|
+
|
152
|
+
######################### RailsAdminUserAbilities #########################
|
153
|
+
# def self.rails_admin_user_defined_visible_actions
|
154
|
+
# [:user_abilities]
|
155
|
+
# end
|
156
|
+
# has_one :ability, class_name: "RailsAdminUserAbilities::UserAbility", as: :rails_admin_user_abilitable
|
157
|
+
# scope :for_rails_admin, -> { where(:roles.in => ['admin', 'manager']) } # could be any you want, just need to
|
158
|
+
###########################################################################
|
159
|
+
|
149
160
|
cattr_accessor :current_user
|
161
|
+
|
150
162
|
# Include default devise modules. Others available are:
|
151
163
|
# :confirmable, :lockable, :timeoutable and :omniauthable
|
152
164
|
TEXT
|
@@ -159,27 +171,37 @@ gsub_file 'app/models/user.rb', '# field :unlock_token', 'field :unlock_token'
|
|
159
171
|
gsub_file 'app/models/user.rb', '# field :locked_at', 'field :locked_at'
|
160
172
|
|
161
173
|
inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
174
|
+
|
162
175
|
field :name, type: String
|
163
176
|
field :login, type: String
|
164
177
|
field :roles, type: Array, default: []
|
178
|
+
|
165
179
|
before_save do
|
166
180
|
self.roles ||= []
|
167
181
|
self.roles.reject! { |r| r.blank? }
|
168
182
|
end
|
183
|
+
|
169
184
|
AVAILABLE_ROLES = ["admin", "manager", "client"]
|
185
|
+
|
170
186
|
AVAILABLE_ROLES.each do |r|
|
171
187
|
class_eval <<-EVAL
|
172
188
|
def \#{r}?
|
173
189
|
self.roles and self.roles.include?("\#{r}")
|
174
190
|
end
|
191
|
+
|
175
192
|
scope :\#{r.pluralize}, -> { any_in(roles: "\#{r}") }
|
176
193
|
EVAL
|
177
194
|
end
|
195
|
+
|
178
196
|
def self.generate_first_admin_user
|
179
197
|
if ::User.admins.all.count == 0
|
180
198
|
_email_pass = 'admin@#{app_name.dasherize.downcase}.ru'
|
181
199
|
if ::User.new(roles: ["admin"], email: _email_pass, password: _email_pass, password_confirmation: _email_pass).save
|
200
|
+
puts "#################################################################################"
|
201
|
+
puts "#################################################################################"
|
182
202
|
puts "AdminUser with email and password '\#{_email_pass}' was created!"
|
203
|
+
puts "#################################################################################"
|
204
|
+
puts "#################################################################################"
|
183
205
|
else
|
184
206
|
puts 'Creating AdminUser error'
|
185
207
|
end
|
@@ -187,6 +209,7 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
187
209
|
puts 'AdminUsers are here already'
|
188
210
|
end
|
189
211
|
end
|
212
|
+
|
190
213
|
def self.generate_first_manager_user
|
191
214
|
if ::User.managers.all.count == 0
|
192
215
|
_email_pass = 'manager@#{app_name.dasherize.downcase}.ru'
|
@@ -199,6 +222,7 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
199
222
|
puts 'ManagerUsers are here already'
|
200
223
|
end
|
201
224
|
end
|
225
|
+
|
202
226
|
rails_admin do
|
203
227
|
list do
|
204
228
|
field :email
|
@@ -211,6 +235,7 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
211
235
|
end
|
212
236
|
end
|
213
237
|
end
|
238
|
+
|
214
239
|
edit do
|
215
240
|
group :login do
|
216
241
|
active false
|
@@ -228,21 +253,25 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
228
253
|
end
|
229
254
|
end
|
230
255
|
end
|
256
|
+
|
231
257
|
group :roles do
|
232
258
|
active false
|
233
259
|
field :roles, :enum do
|
234
260
|
enum do
|
235
261
|
AVAILABLE_ROLES
|
236
262
|
end
|
263
|
+
|
237
264
|
multiple do
|
238
265
|
true
|
239
266
|
end
|
267
|
+
|
240
268
|
visible do
|
241
269
|
render_object = (bindings[:controller] || bindings[:view])
|
242
270
|
render_object and render_object.current_user.admin?
|
243
271
|
end
|
244
272
|
end
|
245
273
|
end
|
274
|
+
|
246
275
|
group :password do
|
247
276
|
active false
|
248
277
|
field :password do
|
@@ -259,6 +288,7 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
|
|
259
288
|
end
|
260
289
|
end
|
261
290
|
end
|
291
|
+
|
262
292
|
end
|
263
293
|
TEXT
|
264
294
|
end
|
@@ -315,6 +345,7 @@ create_file '.gitignore' do <<-TEXT
|
|
315
345
|
# git config --global core.excludesfile '~/.gitignore_global'
|
316
346
|
.idea
|
317
347
|
.idea/*
|
348
|
+
|
318
349
|
/.bundle
|
319
350
|
/log/*.log
|
320
351
|
/tmp/*
|
@@ -333,7 +364,7 @@ git commit: %Q{ -m 'Initial commit' }
|
|
333
364
|
end
|
334
365
|
|
335
366
|
def mongoid
|
336
|
-
defined? Mongoid
|
367
|
+
!!defined? Mongoid
|
337
368
|
end
|
338
369
|
|
339
370
|
def app_name
|
@@ -40,6 +40,16 @@ module Hancock
|
|
40
40
|
|
41
41
|
action_unvisible_for(:custom_show_in_app, Proc.new { false })
|
42
42
|
action_visible_for(:model_settings, Proc.new { false })
|
43
|
+
|
44
|
+
if defined?(RailsAdminNestedSet)
|
45
|
+
action_visible_for(:nested_set, Proc.new { false })
|
46
|
+
end
|
47
|
+
|
48
|
+
if defined?(RailsAdminMultipleFileUpload)
|
49
|
+
action_visible_for(:multiple_file_upload, Proc.new { false })
|
50
|
+
action_visible_for(:multiple_file_upload_collection, Proc.new { false })
|
51
|
+
end
|
52
|
+
|
43
53
|
end
|
44
54
|
|
45
55
|
def add_action(action_name)
|
@@ -81,7 +91,7 @@ module Hancock
|
|
81
91
|
def actions_config(rails_admin_actions)
|
82
92
|
|
83
93
|
@actions_list.each do |action|
|
84
|
-
if rails_admin_actions.respond_to?(action)
|
94
|
+
if rails_admin_actions.respond_to?(action) and !RailsAdmin::Config::Actions.all.map { |a| a.class.name.demodulize.underscore }.include?(action.to_s)
|
85
95
|
rails_admin_actions.send(action) do
|
86
96
|
visible do
|
87
97
|
if !bindings or bindings[:abstract_model].blank?
|
data/lib/hancock/version.rb
CHANGED
data/lib/hancock_cms.rb
CHANGED
@@ -76,7 +76,7 @@ module Hancock
|
|
76
76
|
Hancock::MODELS << model unless Hancock::MODELS.include?(model)
|
77
77
|
end
|
78
78
|
def register_plugin(plugin)
|
79
|
-
Hancock::PLUGINS << plugin unless Hancock::
|
79
|
+
Hancock::PLUGINS << plugin unless Hancock::PLUGINS.include?(plugin)
|
80
80
|
end
|
81
81
|
|
82
82
|
def clear_history_from_empty_objects
|
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: 2.0.0.
|
4
|
+
version: 2.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-12-
|
11
|
+
date: 2016-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -307,6 +307,7 @@ files:
|
|
307
307
|
- app/views/blocks/_favicon.html.slim
|
308
308
|
- app/views/blocks/_footer.html.slim
|
309
309
|
- app/views/blocks/_header.html.slim
|
310
|
+
- app/views/blocks/_preloader.html.slim
|
310
311
|
- app/views/devise/passwords/edit.html.slim
|
311
312
|
- app/views/devise/passwords/new.html.slim
|
312
313
|
- app/views/devise/registrations/edit.html.slim
|
@@ -344,6 +345,7 @@ files:
|
|
344
345
|
- app/views/shared/_admin_link.html.slim
|
345
346
|
- app/views/shared/_messages.html.slim
|
346
347
|
- config/initializers/hancock_cms.rb
|
348
|
+
- config/initializers/nested_set_patch.rb
|
347
349
|
- config/initializers/simple_captcha.rb
|
348
350
|
- config/locales/en.hancock.yml
|
349
351
|
- config/locales/en.hancock_admin.yml
|
@@ -449,7 +451,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
449
451
|
version: '0'
|
450
452
|
requirements: []
|
451
453
|
rubyforge_project:
|
452
|
-
rubygems_version: 2.5.
|
454
|
+
rubygems_version: 2.5.2
|
453
455
|
signing_key:
|
454
456
|
specification_version: 4
|
455
457
|
summary: Please DO NOT use this gem directly, use hancock_cms_mongoid or hancock_cms_activerecord
|