enjoy_cms 0.2.0.2 → 0.2.0.3

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -5
  3. data/app/controllers/concerns/enjoy/errors.rb +3 -3
  4. data/app/controllers/concerns/enjoy/localizeable.rb +12 -2
  5. data/app/controllers/concerns/enjoy/seo_pages.rb +11 -4
  6. data/app/models/concerns/enjoy/mappable.rb +0 -4
  7. data/app/models/concerns/enjoy/model_localizeable.rb +30 -0
  8. data/app/models/concerns/enjoy/seoable.rb +1 -18
  9. data/app/models/concerns/enjoy/sitemap_data_field.rb +1 -19
  10. data/app/models/enjoy/contact_message.rb +2 -2
  11. data/app/models/enjoy/embedded_element.rb +2 -2
  12. data/app/models/enjoy/embedded_gallery_image.rb +2 -2
  13. data/app/models/enjoy/gallery.rb +2 -2
  14. data/app/models/enjoy/gallery_image.rb +2 -2
  15. data/app/models/enjoy/menu.rb +2 -2
  16. data/app/models/enjoy/news.rb +2 -2
  17. data/app/models/enjoy/page.rb +2 -2
  18. data/app/models/enjoy/seo.rb +2 -3
  19. data/app/models/enjoy/sitemap_data.rb +2 -3
  20. data/app/views/shared/_obj.html.slim +1 -0
  21. data/app/views/simple_captcha/_simple_captcha.html.slim +1 -1
  22. data/lib/enjoy/admin/contact_message.rb +21 -25
  23. data/lib/enjoy/admin/embedded_element.rb +22 -5
  24. data/lib/enjoy/admin/embedded_gallery_image.rb +12 -7
  25. data/lib/enjoy/admin/gallery.rb +24 -10
  26. data/lib/enjoy/admin/gallery_image.rb +22 -10
  27. data/lib/enjoy/admin/menu.rb +10 -18
  28. data/lib/enjoy/admin/news.rb +62 -45
  29. data/lib/enjoy/admin/page.rb +64 -67
  30. data/lib/enjoy/admin/seo.rb +20 -8
  31. data/lib/enjoy/admin/sitemap_data.rb +27 -0
  32. data/lib/enjoy/admin.rb +3 -340
  33. data/lib/enjoy/controllers/sitemap_data.rb +0 -0
  34. data/lib/enjoy/model.rb +6 -1
  35. data/lib/enjoy/models/gallery.rb +1 -11
  36. data/lib/enjoy/models/gallery_image.rb +1 -11
  37. data/lib/enjoy/models/mongoid/embedded_gallery_image.rb +3 -5
  38. data/lib/enjoy/models/mongoid/gallery.rb +3 -5
  39. data/lib/enjoy/models/mongoid/gallery_image.rb +3 -5
  40. data/lib/enjoy/models/mongoid/menu.rb +1 -11
  41. data/lib/enjoy/models/mongoid/page.rb +1 -11
  42. data/lib/enjoy/models/news.rb +0 -2
  43. data/lib/enjoy/models/seo.rb +2 -0
  44. data/lib/enjoy/models/sitemap_data.rb +4 -0
  45. data/lib/enjoy/rails_admin_menu.rb +3 -3
  46. data/lib/enjoy/version.rb +1 -1
  47. data/lib/enjoy_cms.rb +16 -3
  48. metadata +5 -3
  49. data/lib/enjoy/patch.rb +0 -58
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9c3bb6808528fe136b6fff4b42014592f21983b8
4
- data.tar.gz: 299c68b484d677e16a6c08f1e2b6a154360b92d5
3
+ metadata.gz: 378d560813a049c82be0a4330904b9322dd23057
4
+ data.tar.gz: bf67ae38a9c6a3bdf90ea86f31f8948b0a8f2aee
5
5
  SHA512:
6
- metadata.gz: a34ddbc371a0eddd425be1bb2b49f722f26bd1cc1064e02e543b4e35e231511e6449f8ba5ab110b9a6a587b29dfdbcab9df21ba651a2634f7c917ebe0b39be01
7
- data.tar.gz: 745ce880d8b18ccc951c80eec52955d9f1fcf45a0e1df0dc0cfeaabfcc4fc1991a0a2942a15927ec596c47ef33fe9e913d175fca39d1d8d01cdb5d5738ae2c72
6
+ metadata.gz: ad5e1a8e2fcebec80b7fc7ff612f4a055aca72cdb57ad3ddb2758d04507fdc21004ab5d72ad3e93edb32207796201d2db6acac84a3419f3759f1893795d1e87c
7
+ data.tar.gz: 0b76e3c33cb4a274216d5e0ac8c50b03046ff6474a28c3ac34f3c3793defa398b013d4dfa552ab6b3c87e3aa23c067ef755682508986e7555c08a73068787574
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enjoy_cms (0.2.0.2)
4
+ enjoy_cms (0.2.0.3)
5
5
  ack_rails_admin_jcrop
6
6
  addressable
7
7
  ckeditor
@@ -89,7 +89,7 @@ GEM
89
89
  execjs
90
90
  coffee-script-source (1.10.0)
91
91
  concurrent-ruby (1.0.0)
92
- devise (3.5.5)
92
+ devise (3.5.6)
93
93
  bcrypt (~> 3.0)
94
94
  orm_adapter (~> 0.1)
95
95
  railties (>= 3.2.6, < 5)
@@ -100,7 +100,7 @@ GEM
100
100
  execjs (2.6.0)
101
101
  font-awesome-rails (4.5.0.0)
102
102
  railties (>= 3.2, < 5.0)
103
- geocoder (1.2.14)
103
+ geocoder (1.3.0)
104
104
  glebtv-simple_captcha (0.6.7)
105
105
  globalid (0.3.6)
106
106
  activesupport (>= 4.1.0)
@@ -221,7 +221,7 @@ GEM
221
221
  actionpack (>= 4.0)
222
222
  activesupport (>= 4.0)
223
223
  sprockets (>= 3.0.0)
224
- stringex (2.5.2)
224
+ stringex (2.6.0)
225
225
  thor (0.19.1)
226
226
  thread_safe (0.3.5)
227
227
  tilt (2.0.2)
@@ -231,7 +231,7 @@ GEM
231
231
  thread_safe (~> 0.1)
232
232
  validates_email_format_of (1.6.3)
233
233
  i18n
234
- warden (1.2.5)
234
+ warden (1.2.6)
235
235
  rack (>= 1.0)
236
236
  x-real-ip (0.2.1)
237
237
  activesupport
@@ -33,13 +33,13 @@ module Enjoy::Errors
33
33
  #redirect_to scope.new_user_session_path, alert: "Необходимо авторизоваться"
34
34
  authenticate_user!
35
35
  else
36
- redirect_to '/', alert: t('rs.errors.access_denied')
36
+ redirect_to '/', alert: t('enjoy.errors.access_denied')
37
37
  end
38
38
  end
39
39
  end
40
40
 
41
41
  rescue_from ActionController::InvalidAuthenticityToken do |exception|
42
- redirect_to '/', alert: t('rs.errors.form_expired')
42
+ redirect_to '/', alert: t('enjoy.errors.form_expired')
43
43
  end
44
44
  end
45
45
 
@@ -71,7 +71,7 @@ module Enjoy::Errors
71
71
  Rails.logger.error "__________________________"
72
72
  begin
73
73
  if rails_admin?
74
- render text: t('rs.errors.internal_error_full', klass: exception.class.name, message: exception.message), status: 500
74
+ render text: t('enjoy.errors.internal_error_full', klass: exception.class.name, message: exception.message), status: 500
75
75
  return
76
76
  end
77
77
  rescue Exception => e
@@ -12,7 +12,7 @@ module Enjoy::Localizeable
12
12
  {locale: params[:locale]}
13
13
  end
14
14
  def nav_get_menu_items(type)
15
- pages = Enjoy::Menu.find(type.to_s).pages.enabled
15
+ pages = menu_class.find(type.to_s).pages.enabled
16
16
  if Enjoy.mongoid?
17
17
  pages = pages.where(:"name.#{I18n.locale}".exists => true)
18
18
  elsif Enjoy.active_record?
@@ -27,7 +27,17 @@ module Enjoy::Localizeable
27
27
  page_class.enabled.where(fullpath: path.gsub(/(\/ru|\/en)/, "")).first
28
28
  end
29
29
 
30
+ def page_class_name
31
+ "Enjoy::Page"
32
+ end
30
33
  def page_class
31
- Enjoy::Page
34
+ page_class_name.constantize
35
+ end
36
+
37
+ def menu_class_name
38
+ "Enjoy::Menu"
39
+ end
40
+ def menu_class
41
+ menu_class_name.constantize
32
42
  end
33
43
  end
@@ -22,10 +22,10 @@ module Enjoy::SeoPages
22
22
  path = path[0..-2]
23
23
  do_redirect = true
24
24
  end
25
- page = Enjoy::Page.enabled.where(fullpath: path).first
25
+ page = page_class.enabled.where(fullpath: path).first
26
26
 
27
27
  if page.nil? && !params[:slug].blank?
28
- page = Enjoy::Page.enabled.where(fullpath: "/" + params[:slug]).first
28
+ page = page_class.enabled.where(fullpath: "/" + params[:slug]).first
29
29
  end
30
30
 
31
31
  if page.nil?
@@ -57,12 +57,12 @@ module Enjoy::SeoPages
57
57
  do_redirect = true
58
58
  end
59
59
 
60
- page = Page.enabled.any_of({fullpath: path}, {redirect: path}).first
60
+ page = page_class.enabled.any_of({fullpath: path}, {redirect: path}).first
61
61
  if page.nil?
62
62
  do_redirect = true
63
63
  spath = path.chomp(File.extname(path))
64
64
  if spath != path
65
- page = Enjoy::Page.enabled.any_of({fullpath: spath}, {redirect: spath}).first
65
+ page = page_class.enabled.any_of({fullpath: spath}, {redirect: spath}).first
66
66
  end
67
67
  end
68
68
  if !page.nil? && do_redirect
@@ -77,6 +77,13 @@ module Enjoy::SeoPages
77
77
  nil
78
78
  end
79
79
 
80
+ def page_class_name
81
+ "Enjoy::Page"
82
+ end
83
+ def page_class
84
+ page_class_name.constantize
85
+ end
86
+
80
87
  def rails_admin?
81
88
  self.is_a?(RailsAdmin::ApplicationController) || self.is_a?(RailsAdmin::MainController)
82
89
  end
@@ -88,8 +88,4 @@ module Enjoy::Mappable
88
88
  map_address
89
89
  end
90
90
  end
91
-
92
- def self.admin
93
- Enjoy.map_config
94
- end
95
91
  end
@@ -0,0 +1,30 @@
1
+ module Enjoy::ModelLocalizeable
2
+ extend ActiveSupport::Concern
3
+
4
+ module ClassMethods
5
+ def convert2localize
6
+ self.all.to_a.map do |p|
7
+ p.convert2localize
8
+ end
9
+ end
10
+ end
11
+
12
+ def convert2localize
13
+ arr = {}
14
+ self.localized_fields.keys.each do |f|
15
+ next if self[f].is_a?(Hash)
16
+ arr[f] = self.remove_attribute(f)
17
+ self[f] = {}
18
+ end
19
+ self.save
20
+
21
+ I18n.available_locales.each do |l|
22
+ I18n.with_locale(l) do
23
+ arr.each_pair do |f, v|
24
+ self.send(f + "=", v)
25
+ end
26
+ end
27
+ end
28
+ self.save
29
+ end
30
+ end
@@ -4,7 +4,7 @@ module Enjoy::Seoable
4
4
  FIELDS = LOCALIZED_FIELDS + [:og_image, :robots]
5
5
 
6
6
  included do
7
- has_one :seo, as: :seoable, autosave: true, class_name: seo_class_name
7
+ has_one :seo, as: :seoable, autosave: true, class_name: "Enjoy::Seo"
8
8
  accepts_nested_attributes_for :seo
9
9
 
10
10
  delegate *FIELDS, to: :seo
@@ -15,7 +15,6 @@ module Enjoy::Seoable
15
15
  delegate *(LOCALIZED_FIELDS.map {|f| "#{f}_translations=".to_sym }), to: :seo
16
16
  end
17
17
 
18
-
19
18
  alias seo_without_build seo
20
19
  def seo
21
20
  seo_without_build || build_seo
@@ -34,20 +33,4 @@ module Enjoy::Seoable
34
33
  {aspectRation: 800.0/600.0}
35
34
  end
36
35
 
37
- module ClassMethods
38
- def seo_class_name
39
- "Enjoy::Seo"
40
- end
41
-
42
- def seo_class
43
- seo_class_name.constantize
44
- end
45
- end
46
- def seo_class_name
47
- self.class.seo_class_name
48
- end
49
-
50
- def seo_class
51
- self.class.seo_class
52
- end
53
36
  end
@@ -3,7 +3,7 @@ module Enjoy::SitemapDataField
3
3
  FIELDS = [:sitemap_show, :sitemap_lastmod, :sitemap_changefreq, :sitemap_priority]
4
4
 
5
5
  included do
6
- has_one :sitemap_data, as: :sitemap_data_field, autosave: true, class_name: sitemap_data_class_name
6
+ has_one :sitemap_data, as: :sitemap_data_field, autosave: true, class_name: "Enjoy::SitemapData"
7
7
  accepts_nested_attributes_for :sitemap_data
8
8
 
9
9
  delegate *FIELDS, to: :sitemap_data
@@ -14,22 +14,4 @@ module Enjoy::SitemapDataField
14
14
  sitemap_data_without_build || build_sitemap_data
15
15
  end
16
16
  end
17
-
18
- module ClassMethods
19
- def sitemap_data_class_name
20
- "Enjoy::SitemapData"
21
- end
22
-
23
- def sitemap_data_class
24
- sitemap_data_class_name.constantize
25
- end
26
- end
27
-
28
- def sitemap_data_class_name
29
- self.class.sitemap_data_class_name
30
- end
31
-
32
- def sitemap_data_class
33
- self.class.sitemap_data_class
34
- end
35
17
  end
@@ -6,7 +6,7 @@ module Enjoy
6
6
 
7
7
  class ContactMessage
8
8
  include Enjoy::Models::ContactMessage
9
- Enjoy.apply_patches self
10
- rails_admin &Enjoy.contact_message_config
9
+
10
+ rails_admin &Enjoy::Admin::ContactMessage.config
11
11
  end
12
12
  end
@@ -2,10 +2,10 @@ module Enjoy
2
2
  if Enjoy.mongoid?
3
3
  class EmbeddedElement
4
4
  include Enjoy::Models::EmbeddedElement
5
- Enjoy.apply_patches self
5
+
6
6
 
7
7
  # use it in inherited model
8
- #rails_admin &Enjoy.embedded_image_config
8
+ # rails_admin &Enjoy::Admin::EmbeddedElement.config
9
9
 
10
10
  # use it in rails_admin in parent model for sort
11
11
  # sort_embedded({fields: [:embedded_field_1, :embedded_field_2...]})
@@ -2,10 +2,10 @@ module Enjoy
2
2
  if Enjoy.mongoid?
3
3
  class EmbeddedGalleryImage < Enjoy::EmbeddedElement
4
4
  include Enjoy::Models::EmbeddedGalleryImage
5
- Enjoy.apply_patches self
5
+
6
6
 
7
7
  # use it in inherited model
8
- #rails_admin &Enjoy.embedded_image_config
8
+ # rails_admin &Enjoy::Admin::EmbeddedGalleryImage.config
9
9
 
10
10
  # use it in rails_admin in parent model for sort
11
11
  # sort_embedded({fields: [:embedded_field_1, :embedded_field_2...]})
@@ -2,9 +2,9 @@ module Enjoy
2
2
  if Enjoy.mongoid?
3
3
  class Gallery
4
4
  include Enjoy::Models::Gallery
5
- Enjoy.apply_patches self
5
+
6
6
 
7
- rails_admin &Enjoy.gallery_config
7
+ rails_admin &Enjoy::Admin::Gallery.config
8
8
  end
9
9
  end
10
10
  end
@@ -2,9 +2,9 @@ module Enjoy
2
2
  if Enjoy.mongoid?
3
3
  class GalleryImage
4
4
  include Enjoy::Models::GalleryImage
5
- Enjoy.apply_patches self
5
+
6
6
 
7
- rails_admin &Enjoy.image_config
7
+ rails_admin &Enjoy::Admin::GalleryImage.config
8
8
  end
9
9
  end
10
10
  end
@@ -6,7 +6,7 @@ module Enjoy
6
6
 
7
7
  class Menu
8
8
  include Enjoy::Models::Menu
9
- Enjoy.apply_patches self
10
- rails_admin &Enjoy.menu_config
9
+
10
+ rails_admin &Enjoy::Admin::Menu.config
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Enjoy
6
6
 
7
7
  class News
8
8
  include Enjoy::Models::News
9
- Enjoy.apply_patches self
10
- rails_admin &Enjoy.news_config
9
+
10
+ rails_admin &Enjoy::Admin::News.config
11
11
  end
12
12
  end
@@ -6,7 +6,7 @@ module Enjoy
6
6
 
7
7
  class Page
8
8
  include Enjoy::Models::Page
9
- Enjoy.apply_patches self
10
- rails_admin &Enjoy.page_config
9
+
10
+ rails_admin &Enjoy::Admin::Page.config
11
11
  end
12
12
  end
@@ -6,8 +6,7 @@ module Enjoy
6
6
 
7
7
  class Seo
8
8
  include Enjoy::Models::Seo
9
- Enjoy.apply_patches self
10
- rails_admin &Enjoy.seo_config
11
- belongs_to :seoable, polymorphic: true
9
+
10
+ rails_admin &Enjoy::Admin::Seo.config
12
11
  end
13
12
  end
@@ -6,8 +6,7 @@ module Enjoy
6
6
 
7
7
  class SitemapData
8
8
  include Enjoy::Models::SitemapData
9
- Enjoy.apply_patches self
10
- rails_admin &Enjoy.sitemap_data_config
11
- belongs_to :sitemap_data_field, polymorphic: true
9
+
10
+ rails_admin &Enjoy::Admin::SitemapData.config
12
11
  end
13
12
  end
@@ -8,6 +8,7 @@
8
8
  = raw @seo_page.page_content
9
9
  - else
10
10
  = raw obj.content
11
+ .admin_button
11
12
  - if !obj.nil?
12
13
  = render 'shared/admin_link', obj: obj
13
14
  - if !@seo_page.nil? && (@seo_page.id != obj.id || @seo_page.class.name != obj.class.name)
@@ -3,7 +3,7 @@ label.form-label
3
3
  .input_image_block
4
4
  .image
5
5
  = simple_captcha_options[:image]
6
- .input
6
+ .field
7
7
  = simple_captcha_options[:field]
8
8
 
9
9
  - unless simple_captcha_options[:error_messages].blank?
@@ -1,35 +1,31 @@
1
1
  module Enjoy
2
2
  module Admin
3
3
  module ContactMessage
4
- extend ActiveSupport::Concern
5
- include Enjoy::Model
6
- include Enjoy.orm_specific('ContactMessage')
7
-
8
- included do
9
-
10
- apply_simple_captcha message: Enjoy.configuration.contacts_captcha_error_message
11
-
12
- validates_email_format_of :email, unless: 'email.blank?'
13
- if Enjoy.config.contacts_message_required
14
- validates_presence_of :content
15
- end
16
- validate do
17
- if email.blank? && phone.blank?
18
- errors.add(:email, I18n.t('rs.no_contact_info'))
4
+ def self.config
5
+ Proc.new {
6
+ # navigation_label I18n.t('enjoy.contact_message')
7
+ field :c_at do
8
+ read_only true
19
9
  end
20
- end
10
+ field :name
11
+ field :content, :text
12
+ field :email
13
+ field :phone
21
14
 
22
- after_create do
23
- mailer_class.send(mailer_method, self).deliver
24
- end
15
+ Enjoy.config.contacts_fields.each_pair do |fn, ft|
16
+ next if ft.nil?
17
+ if ft.is_a?(Array)
18
+ field fn, ft[1].to_sym
19
+ else
20
+ field fn
21
+ end
22
+ end
25
23
 
26
- def mailer_class
27
- Enjoy::ContactMailer
28
- end
24
+ if block_given?
25
+ yield self
26
+ end
29
27
 
30
- def mailer_method
31
- :new_message_email
32
- end
28
+ }
33
29
  end
34
30
  end
35
31
  end
@@ -1,11 +1,28 @@
1
1
  module Enjoy
2
2
  module Admin
3
3
  module EmbeddedElement
4
- extend ActiveSupport::Concern
5
- include Enjoy::Model
6
- include Enjoy::Enableable
7
- include Enjoy::Sortable
8
- include Enjoy.orm_specific('EmbeddedElement')
4
+ def self.config(_navigation_label = I18n.t('enjoy.cms'), fields = {})
5
+ Proc.new {
6
+ # navigation_label(_navigation_label) unless _navigation_label.nil?
7
+ field :enabled, :toggle
8
+ field :name, :string
9
+ fields.each_pair do |name, type|
10
+ if type.nil?
11
+ field name
12
+ else
13
+ if type.is_a?(Array)
14
+ field name, type[0], &type[1]
15
+ else
16
+ field name, type
17
+ end
18
+ end
19
+ end
20
+
21
+ if block_given?
22
+ yield self
23
+ end
24
+ }
25
+ end
9
26
  end
10
27
  end
11
28
  end
@@ -1,14 +1,19 @@
1
1
  module Enjoy
2
2
  module Admin
3
3
  module EmbeddedGalleryImage
4
- extend ActiveSupport::Concern
5
- include Enjoy::Model
6
- include Enjoy::Enableable
7
- include Enjoy::Sortable
8
- include Enjoy.orm_specific('EmbeddedGalleryImage')
4
+ def self.config(fields = {})
5
+ jcrop_proc = Proc.new do
6
+ jcrop_options :image_jcrop_options
7
+ end
9
8
 
10
- included do
11
- validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
9
+ fields = {image: [:jcrop, jcrop_proc]}.merge(fields)
10
+ if block_given?
11
+ Enjoy::Admin::EmbeddedElement.config(nil, fields) do |config|
12
+ yield config
13
+ end
14
+ else
15
+ Enjoy::Admin::EmbeddedElement.config(nil, fields)
16
+ end
12
17
  end
13
18
  end
14
19
  end
@@ -1,19 +1,33 @@
1
1
  module Enjoy
2
2
  module Admin
3
3
  module Gallery
4
- extend ActiveSupport::Concern
5
- include Enjoy::Model
6
- include ManualSlug
7
- include Enjoy::Enableable
8
- include Enjoy::SitemapData
9
- include Enjoy.orm_specific('Gallery')
4
+ def self.self.config
5
+ Proc.new {
6
+ # navigation_label I18n.t('enjoy.gallery')
7
+ field :enabled, :toggle
10
8
 
11
- included do
9
+ field :name, :string
10
+ field :slugs, :enum do
11
+ enum_method do
12
+ :slugs
13
+ end
14
+ visible do
15
+ bindings[:view].current_user.admin?
16
+ end
17
+ multiple do
18
+ true
19
+ end
20
+ end
21
+ field :text_slug
12
22
 
13
- has_many :gallery_images, class_name: "Enjoy::GalleryImage"
14
- field :name, type: String, localize: Enjoy.configuration.localize
23
+ field :image, :jcrop do
24
+ jcrop_options :image_jcrop_options
25
+ end
15
26
 
16
- validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
27
+ if block_given?
28
+ yield self
29
+ end
30
+ }
17
31
  end
18
32
  end
19
33
  end
@@ -1,17 +1,29 @@
1
1
  module Enjoy
2
2
  module Admin
3
3
  module GalleryImage
4
- extend ActiveSupport::Concern
5
- include Enjoy::Model
6
- include Enableable
7
- include Enjoy.orm_specific('GalleryImage')
4
+ def self.config(without_gallery = false, fields = {})
5
+ Proc.new {
6
+ # navigation_label I18n.t('enjoy.gallery')
7
+ field :enabled, :toggle
8
+ unless without_gallery
9
+ field :gallery
10
+ end
11
+ field :name, :string
12
+ field :image, :jcrop do
13
+ jcrop_options :image_jcrop_options
14
+ end
15
+ fields.each_pair do |name, type|
16
+ if type.nil?
17
+ field name
18
+ else
19
+ field name, type
20
+ end
21
+ end
8
22
 
9
- included do
10
-
11
- belongs_to :gallery, class_name: "Enjoy::Gallery"
12
- field :name, type: String, localize: Enjoy.configuration.localize
13
-
14
- validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
23
+ if block_given?
24
+ yield self
25
+ end
26
+ }
15
27
  end
16
28
  end
17
29
  end
@@ -1,26 +1,18 @@
1
1
  module Enjoy
2
2
  module Admin
3
3
  module Menu
4
- extend ActiveSupport::Concern
5
- include Enjoy::Model
6
- include Enableable
7
- include ManualSlug
8
- include Enjoy.orm_specific('Menu')
4
+ def self.config
5
+ Proc.new {
6
+ # navigation_label 'CMS'
9
7
 
10
- included do
8
+ field :enabled, :toggle
9
+ field :text_slug
10
+ field :name
11
11
 
12
- field :name, type: String
13
- manual_slug :name
14
-
15
- after_save do
16
- Rails.cache.delete 'menus'
17
- end
18
- after_destroy do
19
- Rails.cache.delete 'menus'
20
- end
21
-
22
- has_and_belongs_to_many :pages, inverse_of: :menus, class_name: "Enjoy::Page"
23
- alias_method :items, :pages
12
+ if block_given?
13
+ yield self
14
+ end
15
+ }
24
16
  end
25
17
  end
26
18
  end