hancock_cms 1.0.0.4 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c73c9919e423af71ff0ea336d745c1cf035c5bac
4
- data.tar.gz: 438396bab11dc25461ac958065000a3b40f1c971
3
+ metadata.gz: 19baf49e53520cfd21f5fa52f69780c6177548d5
4
+ data.tar.gz: c0deb75181d16ba64cb694bdcff052ebe4d78f87
5
5
  SHA512:
6
- metadata.gz: 5dc52a2fb69be182e8035d79380f51a1d7b2e0570aad51d446d0ba3a240840fff6bf84cdbe6d7bcbe90fa21b3d3084e35ef39df9d2ef76543043fde2a9ec695d
7
- data.tar.gz: 56ee7a7d603e9009310b58baca2cac4da51ad1810c4280308f5dd9519f9f87ea8c3349e389d2d884213e29d1c094951311205b2a7f1728e044b63fcee4e4c4f4
6
+ metadata.gz: 434e073c7e5b703a15fbf259d1801d4eba911c3e026f997f2294e7ccd91aa49db9dd8676eed601038806e5ea191fd4ca127fed3eb9317db41db7a5add0d9deb2
7
+ data.tar.gz: 39105092e18dad6dd92ebfdb4e2f073d0b388d5c09dda03a0d1bc9b2d3544792cc87730217827115e1c0672af6107c27fa07eb146d004b9b9358fe2fd5234a95
@@ -8,7 +8,7 @@ window.hancock_cms.multiselect_dblclick = (selector)->
8
8
  $(document).delegate selector + ' .ra-multiselect-right select option', 'dblclick', (e)->
9
9
  $(e.currentTarget).closest('.ra-multiselect').find('.ra-multiselect-center .ra-multiselect-item-remove').click()
10
10
 
11
- window.hancock_cms.multiselect_dblclick("select.hancock_multiselect + .ra-multiselect")
11
+ window.hancock_cms.multiselect_dblclick("select.hancock_multiselect + .ra-multiselect, select.hancock_enum + .ra-multiselect")
12
12
 
13
13
 
14
14
  $(document).delegate '.toolbar .nav .dropdown-header', 'click', (e)->
@@ -40,4 +40,4 @@ $(window).on 'load', ->
40
40
  mscroll()
41
41
 
42
42
  $(document).bind "page:load", ->
43
- mscroll()
43
+ mscroll()
@@ -0,0 +1,18 @@
1
+ - unless field.multiple?
2
+ = form.select field.method_name, field.enum, { include_blank: true }.reverse_merge({ selected: field.form_value }), field.html_attributes.reverse_merge({ data: { enumeration: true }, placeholder: t('admin.misc.search'), class: 'hancock_enum'})
3
+ - else
4
+ ruby:
5
+ js_data = {
6
+ xhr: false,
7
+ sortable: false,
8
+ cacheAll: true,
9
+ regional: {
10
+ chooseAll: t("admin.misc.chose_all"),
11
+ chosen: t("admin.misc.chosen", name: config.label_plural),
12
+ clearAll: t("admin.misc.clear_all"),
13
+ search: t("admin.misc.search"),
14
+ up: t("admin.misc.up"),
15
+ down: t("admin.misc.down")
16
+ }
17
+ }
18
+ = form.select field.method_name, field.enum, { selected: field.form_value, object: form.object }, field.html_attributes.reverse_merge({data: { filteringmultiselect: true, options: js_data.to_json }, multiple: true, class: 'hancock_enum'})
@@ -1,3 +1,4 @@
1
1
  - if user_signed_in? && respond_to?(:can?) && can?(:access, :rails_admin) && can?(:edit, obj)
2
- .admin_link
3
- = link_to t('hancock.edit'), rails_admin.edit_path(obj.class.model_name.i18n_key.to_s.gsub('/', '~'), obj.id), 'data-no-turbolink' => true
2
+ - cache [current_user, obj] do
3
+ .admin_link
4
+ = link_to t('hancock.edit'), rails_admin.edit_path(obj.class.model_name.i18n_key.to_s.gsub('/', '~'), obj.id), 'data-no-turbolink' => true
@@ -2,17 +2,15 @@ ru:
2
2
  hancock:
3
3
  url: URL
4
4
  content: "Контент"
5
- cache: Кеширование
6
- gallery: "Галерея"
7
5
  cms: "CMS"
8
- menu: "Меню"
6
+ # menu: "Меню"
9
7
  settings: 'Настройки'
10
8
  with_final_slash: "c начальным слешем"
11
9
  page_url_regex: "Регулярное выражение, по которому определяется является ли этот пункт активным"
12
10
  final_in_menu: "В меню сразу отдается конечная ссылка"
13
11
  map: 'Карта'
14
- sitemap: 'Карта сайта'
15
- sitemap_data: 'Данные для карты сайта'
12
+ # sitemap: 'Карта сайта'
13
+ # sitemap_data: 'Данные для карты сайта'
16
14
  edit: Редактировать
17
15
  send: Отправить
18
16
  format_time: "%d.%m.%Y"
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', '~> 1.2'
39
+ spec.add_dependency 'ack_rails_admin_settings', '~> 1.2.1'
40
40
 
41
41
  spec.add_dependency 'kaminari'
42
42
 
@@ -177,7 +177,7 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
177
177
  self.roles.reject! { |r| r.blank? }
178
178
  end
179
179
 
180
- AVAILABLE_ROLES = ["admin", "manager", "client"]
180
+ AVAILABLE_ROLES = ["admin", "manager", "client"].freeze
181
181
 
182
182
  AVAILABLE_ROLES.each do |r|
183
183
  class_eval <<-EVAL
@@ -252,9 +252,9 @@ inject_into_file 'app/models/user.rb', before: /^end/ do <<-TEXT
252
252
 
253
253
  group :roles do
254
254
  active false
255
- field :roles, :enum do
255
+ field :roles, :hancock_enum do
256
256
  enum do
257
- AVAILABLE_ROLES
257
+ ::User::AVAILABLE_ROLES
258
258
  end
259
259
 
260
260
  multiple do
@@ -1,19 +1,19 @@
1
1
  class <%= camelcased_class_name %>
2
2
  include Hancock::Model
3
3
  # include Hancock::Enableable
4
- # include Hancock::Cacheable
5
4
  # include ManualSlug
6
5
 
6
+ # include Hancock::Cache::Cacheable
7
+ # def self.default_cache_keys
8
+ # []
9
+ # end
10
+
7
11
  # acts_as_nested_set
8
12
  # scope :sorted, -> { order_by([:lft, :asc]) }
9
13
 
10
14
  field :name
11
15
  # manual_slug :name
12
16
 
13
- # def self.default_cache_keys
14
- # []
15
- # end
16
-
17
17
  ############# rails_admin ##############
18
18
  #
19
19
  # def self.admin_can_user_defined_actions
@@ -36,7 +36,6 @@ class <%= camelcased_class_name %>
36
36
  # field :enabled, :toggle
37
37
  field :name
38
38
  # group :url, &Hancock::Admin.url_block
39
- # group :cache, &Hancock::Admin.caching_block
40
39
  end
41
40
 
42
41
  end
@@ -1,5 +1,5 @@
1
1
  #!/bin/sh
2
2
 
3
3
  PORT=3000
4
- echo 'server will by started at '$PORT
4
+ echo 'server will be started at '$PORT
5
5
  rails s -b 0.0.0.0 -p $PORT -e development
@@ -1,5 +1,5 @@
1
1
  #!/bin/sh
2
2
 
3
3
  PORT=4000
4
- echo 'server will by started at '$PORT
4
+ echo 'server will be started at '$PORT
5
5
  rails s -b 0.0.0.0 -p $PORT -e development
data/lib/hancock/admin.rb CHANGED
@@ -20,19 +20,6 @@ module Hancock
20
20
  }
21
21
  end
22
22
 
23
- def self.caching_block(is_active = false)
24
- Proc.new {
25
- active is_active
26
- label I18n.t('hancock.cache')
27
- field :perform_caching, :toggle
28
- field :cache_keys_str, :text
29
-
30
- if block_given?
31
- yield self
32
- end
33
- }
34
- end
35
-
36
23
  def self.url_block(is_active = false)
37
24
  Proc.new {
38
25
  active is_active
@@ -3,7 +3,7 @@ module Hancock::Controller
3
3
  included do
4
4
  include Hancock::Errors
5
5
  include Hancock::Fancybox
6
- if !!defined?(Hancock::Pages)
6
+ if defined?(Hancock::Pages)
7
7
  include Hancock::Pages::SeoPages
8
8
  include Hancock::Pages::NavMenu
9
9
  include Hancock::Pages::Blocksetable
@@ -6,6 +6,10 @@ module Hancock
6
6
  # require File.expand_path('../tasks', __FILE__)
7
7
  # end
8
8
 
9
+ initializer "RailsAdminSettingsPatch (CMS)" do
10
+ ::RailsAdminSettings::Setting.send(:include, Hancock::RailsAdminSettingsPatch)
11
+ end
12
+
9
13
  initializer "hancock_cms.email_defaults" do
10
14
  # Write default email settings to DB so they can be changed.
11
15
 
data/lib/hancock/model.rb CHANGED
@@ -33,7 +33,7 @@ module Hancock
33
33
  include Hancock::BooleanField
34
34
  include Hancock::SortField
35
35
 
36
- if Hancock.mongoid? and !!defined?(RailsAdminComments)
36
+ if Hancock.mongoid? and defined?(RailsAdminComments)
37
37
  include RailsAdminComments::Commentable
38
38
  include RailsAdminComments::ModelCommentable
39
39
  end
@@ -0,0 +1,23 @@
1
+ require 'rails_admin/config/fields/types/enum'
2
+
3
+ module RailsAdmin
4
+ module Config
5
+ module Fields
6
+ module Types
7
+ class HancockEnum < RailsAdmin::Config::Fields::Types::Enum
8
+ # Register field type for the type loader
9
+ RailsAdmin::Config::Fields::Types.register(self)
10
+
11
+ register_instance_option :partial do
12
+ :form_hancock_enum
13
+ end
14
+
15
+ register_instance_option :help do
16
+ 'Двойной клик перемещает между списками'
17
+ end
18
+
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,10 +1,10 @@
1
- require 'rails_admin/config/fields/types/enum'
1
+ require 'hancock/rails_admin_ext/hancock_enum'
2
2
 
3
3
  module RailsAdmin
4
4
  module Config
5
5
  module Fields
6
6
  module Types
7
- class HancockSlugs < RailsAdmin::Config::Fields::Types::Enum
7
+ class HancockSlugs < RailsAdmin::Config::Fields::Types::HancockEnum
8
8
  # Register field type for the type loader
9
9
  RailsAdmin::Config::Fields::Types::register(self)
10
10
 
@@ -0,0 +1,32 @@
1
+ module Hancock
2
+ module RailsAdminSettingsPatch
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ include Hancock::RailsAdminPatch
7
+
8
+ def self.manager_can_default_actions
9
+ [:show, :read, :edit, :update]
10
+ end
11
+ def self.manager_can_add_actions
12
+ ret = []
13
+ ret << :model_accesses if defined?(RailsAdminUserAbilities)
14
+ ret += [:comments, :model_comments] if defined?(RailsAdminComments)
15
+ ret << :hancock_touch if defined?(Hancock::Cache::Cacheable)
16
+ ret.freeze
17
+ end
18
+ def self.manager_cannot_actions
19
+ [:new, :create, :delete, :destroy]
20
+ end
21
+
22
+ def self.rails_admin_add_visible_actions
23
+ ret = []
24
+ ret << :model_accesses if defined?(RailsAdminUserAbilities)
25
+ ret += [:comments, :model_comments] if defined?(RailsAdminComments)
26
+ ret << :hancock_touch if defined?(Hancock::Cache::Cacheable)
27
+ ret.freeze
28
+ end
29
+ end
30
+
31
+ end
32
+ end
@@ -1,3 +1,3 @@
1
1
  module Hancock
2
- VERSION = "1.0.0.4".freeze
2
+ VERSION = "1.0.1".freeze
3
3
  end
data/lib/hancock_cms.rb CHANGED
@@ -25,6 +25,7 @@ require 'codemirror-rails'
25
25
  require 'rails_admin'
26
26
  require 'hancock/rails_admin_ext/config'
27
27
 
28
+ require 'hancock/rails_admin_ext/hancock_enum'
28
29
  require 'hancock/rails_admin_ext/hancock_hash'
29
30
  require 'hancock/rails_admin_ext/hancock_html'
30
31
  require 'hancock/rails_admin_ext/hancock_slugs'
@@ -40,6 +41,7 @@ require 'rails_admin_nested_set'
40
41
  require 'rails_admin_toggleable'
41
42
 
42
43
  require 'ack_rails_admin_settings'
44
+ require 'hancock/rails_admin_settings_patch'
43
45
 
44
46
  # require 'x-real-ip'
45
47
 
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
4
+ version: 1.0.1
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-14 00:00:00.000000000 Z
11
+ date: 2016-12-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -190,14 +190,14 @@ dependencies:
190
190
  requirements:
191
191
  - - "~>"
192
192
  - !ruby/object:Gem::Version
193
- version: '1.2'
193
+ version: 1.2.1
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: '1.2'
200
+ version: 1.2.1
201
201
  - !ruby/object:Gem::Dependency
202
202
  name: kaminari
203
203
  requirement: !ruby/object:Gem::Requirement
@@ -283,7 +283,6 @@ files:
283
283
  - app/controllers/concerns/hancock/decorators/sessions.rb
284
284
  - app/controllers/concerns/hancock/errors.rb
285
285
  - app/controllers/concerns/hancock/fancybox.rb
286
- - app/controllers/concerns/hancock/no_cache.rb
287
286
  - app/controllers/hancock/home_controller.rb
288
287
  - app/controllers/hancock/registrations_controller.rb
289
288
  - app/controllers/hancock/sessions_controller.rb
@@ -291,7 +290,6 @@ files:
291
290
  - app/helpers/hancock/home_helper.rb
292
291
  - app/helpers/hancock/powered_helper.rb
293
292
  - app/models/concerns/hancock/boolean_field.rb
294
- - app/models/concerns/hancock/cacheable.rb
295
293
  - app/models/concerns/hancock/decorators/embedded_element.rb
296
294
  - app/models/concerns/hancock/embedded_findable.rb
297
295
  - app/models/concerns/hancock/enableable.rb
@@ -336,6 +334,7 @@ files:
336
334
  - app/views/rails_admin/main/_check_boxes.html.slim
337
335
  - app/views/rails_admin/main/_enum_check_boxes.html.slim
338
336
  - app/views/rails_admin/main/_enum_radio_buttons.html.slim
337
+ - app/views/rails_admin/main/_form_hancock_enum.html.slim
339
338
  - app/views/rails_admin/main/_form_hancock_multiselect.html.slim
340
339
  - app/views/rails_admin/main/_form_raw.html.slim
341
340
  - app/views/rails_admin/main/_hancock_hash.html.slim
@@ -411,6 +410,7 @@ files:
411
410
  - lib/hancock/plugin.rb
412
411
  - lib/hancock/plugin_configuration.rb
413
412
  - lib/hancock/rails_admin_ext/config.rb
413
+ - lib/hancock/rails_admin_ext/hancock_enum.rb
414
414
  - lib/hancock/rails_admin_ext/hancock_hash.rb
415
415
  - lib/hancock/rails_admin_ext/hancock_html.rb
416
416
  - lib/hancock/rails_admin_ext/hancock_multiselect.rb
@@ -419,6 +419,7 @@ files:
419
419
  - lib/hancock/rails_admin_ext/patches/group_patch.rb
420
420
  - lib/hancock/rails_admin_ext/patches/hancock_cms_group.rb
421
421
  - lib/hancock/rails_admin_ext/patches/new_controller_patch.rb
422
+ - lib/hancock/rails_admin_settings_patch.rb
422
423
  - lib/hancock/routes.rb
423
424
  - lib/hancock/simple_form_patch.rb
424
425
  - lib/hancock/tasks.rb
@@ -1,12 +0,0 @@
1
- module Hancock::NoCache
2
- extend ActiveSupport::Concern
3
- included do
4
- before_filter :set_cache_buster
5
- end
6
-
7
- protected
8
- def set_cache_buster
9
- expires_now()
10
- response.headers["Pragma"] = "no-cache"
11
- end
12
- end
@@ -1,51 +0,0 @@
1
- if Hancock.mongoid?
2
-
3
- module Hancock::Cacheable
4
- extend ActiveSupport::Concern
5
-
6
- included do
7
- field :cache_keys_str, type: String, default: -> { default_cache_keys.join("\n") }
8
- def self.default_cache_keys
9
- []
10
- end
11
- def default_cache_keys
12
- self.class.default_cache_keys
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
-
31
-
32
- def cache_keys
33
- cache_keys_str.split(/\s+/).map { |k| k.strip }.reject { |k| k.blank? }
34
- end
35
- field :perform_caching, type: Boolean, default: true
36
-
37
- after_touch :clear_cache
38
- after_save :clear_cache
39
- after_destroy :clear_cache
40
- def clear_cache
41
- if perform_caching
42
- cache_keys.each do |k|
43
- Rails.cache.delete(k)
44
- end
45
- end
46
- end
47
-
48
- end
49
- end
50
-
51
- end