enjoy_cms 0.2.0.2 → 0.2.0.3

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -7,21 +7,11 @@ module Enjoy
7
7
  include Enjoy::Enableable
8
8
  include Enjoy::SitemapDataField
9
9
 
10
- module ClassMethods
11
- def gallery_image_class_name
12
- "Enjoy::GalleryImage"
13
- end
14
-
15
- def gallery_image_class
16
- gallery_image_class_name.constantize
17
- end
18
- end
19
-
20
10
  include Enjoy.orm_specific('Gallery')
21
11
 
22
12
  included do
23
13
 
24
- has_many :gallery_images, class_name: gallery_image_class_name
14
+ has_many :gallery_images, class_name: "Enjoy::GalleryImage"
25
15
  field :name, type: String, localize: Enjoy.configuration.localize
26
16
 
27
17
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
@@ -5,21 +5,11 @@ module Enjoy
5
5
  include Enjoy::Model
6
6
  include Enjoy::Enableable
7
7
 
8
- module ClassMethods
9
- def gallery_class_name
10
- "Enjoy::Gallery"
11
- end
12
-
13
- def gallery_class
14
- gallery_class_name.constantize
15
- end
16
- end
17
-
18
8
  include Enjoy.orm_specific('GalleryImage')
19
9
 
20
10
  included do
21
11
 
22
- belongs_to :gallery, class_name: gallery_class_name
12
+ belongs_to :gallery, class_name: "Enjoy::Gallery"
23
13
  field :name, type: String, localize: Enjoy.configuration.localize
24
14
 
25
15
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
@@ -8,15 +8,13 @@ module Enjoy
8
8
  included do
9
9
 
10
10
  enjoy_cms_mongoid_attached_file(:image,
11
- styles: image_styles,
11
+ styles: lambda { |attachment| attachment.instance.image_styles },
12
12
  content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
13
13
  )
14
14
  end
15
15
 
16
- module ClassMethods
17
- def image_styles
18
- {}
19
- end
16
+ def image_styles
17
+ {}
20
18
  end
21
19
  end
22
20
  end
@@ -13,15 +13,13 @@ module Enjoy
13
13
  scope :sorted, -> { order_by([:lft, :asc]) }
14
14
 
15
15
  enjoy_cms_mongoid_attached_file(:image,
16
- styles: image_styles,
16
+ styles: lambda { |attachment| attachment.instance.image_styles },
17
17
  content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
18
18
  )
19
19
  end
20
20
 
21
- module ClassMethods
22
- def image_styles
23
- {}
24
- end
21
+ def image_styles
22
+ {}
25
23
  end
26
24
  end
27
25
  end
@@ -11,15 +11,13 @@ module Enjoy
11
11
  scope :sorted, -> { order_by([:lft, :asc]) }
12
12
 
13
13
  enjoy_cms_mongoid_attached_file(:image,
14
- styles: image_styles,
14
+ styles: lambda { |attachment| attachment.instance.image_styles },
15
15
  content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
16
16
  )
17
17
  end
18
18
 
19
- module ClassMethods
20
- def image_styles
21
- {}
22
- end
19
+ def image_styles
20
+ {}
23
21
  end
24
22
  end
25
23
  end
@@ -4,18 +4,8 @@ module Enjoy
4
4
  module Menu
5
5
  extend ActiveSupport::Concern
6
6
 
7
- module ClassMethods
8
- def page_class_name
9
- "Enjoy::Page"
10
- end
11
-
12
- def page_class
13
- page_class_name.constantize
14
- end
15
- end
16
-
17
7
  included do
18
- has_and_belongs_to_many :pages, inverse_of: :menus, class_name: page_class_name
8
+ has_and_belongs_to_many :pages, inverse_of: :menus, class_name: "Enjoy::Page"
19
9
  alias_method :items, :pages
20
10
 
21
11
  field :name, type: String, default: ""
@@ -4,16 +4,6 @@ module Enjoy
4
4
  module Page
5
5
  extend ActiveSupport::Concern
6
6
 
7
- module ClassMethods
8
- def menu_class_name
9
- "Enjoy::Menu"
10
- end
11
-
12
- def menu_class
13
- menu_class_name.constantize
14
- end
15
- end
16
-
17
7
  included do
18
8
  field :name, type: String, localize: Enjoy.config.localize, default: ""
19
9
 
@@ -23,7 +13,7 @@ module Enjoy
23
13
  field :content, type: String, localize: Enjoy.config.localize, default: ""
24
14
  field :fullpath, type: String, default: ""
25
15
 
26
- has_and_belongs_to_many :menus, inverse_of: :pages, class_name: menu_class_name
16
+ has_and_belongs_to_many :menus, inverse_of: :pages, class_name: "Enjoy::Menu"
27
17
  acts_as_nested_set
28
18
 
29
19
  scope :sorted, -> { order_by([:lft, :asc]) }
@@ -34,8 +34,6 @@ module Enjoy
34
34
  end
35
35
  smart_excerpt :excerpt, :content, Enjoy.config.news_excerpt
36
36
  manual_slug :report_slug
37
-
38
- Enjoy.apply_patches self
39
37
  end
40
38
 
41
39
  def report_slug
@@ -8,6 +8,8 @@ module Enjoy
8
8
  include Enjoy.orm_specific('Seo')
9
9
 
10
10
  included do
11
+ belongs_to :seoable, polymorphic: true
12
+
11
13
  validates_attachment_content_type :og_image, content_type: /\Aimage\/.*\Z/, if: :og_image?
12
14
  end
13
15
  end
@@ -8,6 +8,10 @@ module Enjoy
8
8
  include Enjoy.orm_specific('SitemapData')
9
9
 
10
10
  SITEMAP_CHANGEFREQ_ARRAY = %w(always hourly daily weekly monthly yearly never)
11
+
12
+ included do
13
+ belongs_to :sitemap_data_field, polymorphic: true
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -12,9 +12,9 @@ module RailsAdmin
12
12
  ret = []
13
13
  menus = Rails.cache.fetch 'menus', expires_in: 10.minutes do
14
14
  if Enjoy.mongoid?
15
- Enjoy::Menu.all.map { |m| {id: m.id.to_s, name: m.name } }
15
+ ::Enjoy::Menu.all.map { |m| {id: m.id.to_s, name: m.name } }
16
16
  else
17
- Enjoy::Menu.all.map { |m| {id: m.id, name: m.name } }
17
+ ::Enjoy::Menu.all.map { |m| {id: m.id, name: m.name } }
18
18
  end
19
19
  end
20
20
  menus.each do |m|
@@ -84,7 +84,7 @@ module RailsAdmin
84
84
  if params['id'].present?
85
85
  begin
86
86
  @object = @abstract_model.model.find(params['id'])
87
- @menu = ::Menu.find(params[:menu])
87
+ @menu = ::Enjoy::Menu.find(params[:menu])
88
88
  if params[:on] == 'true'
89
89
  @object.menus << @menu
90
90
  else
data/lib/enjoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Enjoy
2
- VERSION = "0.2.0.2"
2
+ VERSION = "0.2.0.3"
3
3
  end
data/lib/enjoy_cms.rb CHANGED
@@ -29,10 +29,7 @@ require 'turbolinks'
29
29
  require 'simple-navigation'
30
30
  require 'ack_rails_admin_jcrop'
31
31
 
32
- # require 'enjoy/seo_helpers'
33
32
  require 'enjoy/configuration'
34
- require 'enjoy/patch'
35
- require 'enjoy/admin'
36
33
  require 'enjoy/elastic_search'
37
34
  require 'enjoy/model'
38
35
  require 'enjoy/rails_admin_menu'
@@ -62,6 +59,22 @@ module Enjoy
62
59
  # autoload :Paperclip 'enjoy/mongoid/paperlcip'
63
60
  # end
64
61
 
62
+ autoload :Admin, 'enjoy/admin'
63
+ module Admin
64
+ autoload :SitemapData, 'enjoy/admin/sitemap_data'
65
+ autoload :Seo, 'enjoy/admin/seo'
66
+ autoload :Menu, 'enjoy/admin/menu'
67
+ autoload :Page, 'enjoy/admin/page'
68
+ autoload :News, 'enjoy/admin/news'
69
+ autoload :ContactMessage, 'enjoy/admin/contact_message'
70
+
71
+ autoload :EmbeddedElement, 'enjoy/admin/embedded_element'
72
+
73
+ autoload :EmbeddedGalleryImage, 'enjoy/admin/embedded_gallery_image'
74
+ autoload :GalleryImage, 'enjoy/admin/gallery_image'
75
+ autoload :Gallery, 'enjoy/admin/gallery'
76
+ end
77
+
65
78
  module Models
66
79
  autoload :SitemapData, 'enjoy/models/sitemap_data'
67
80
  autoload :Seo, 'enjoy/models/seo'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enjoy_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.2
4
+ version: 0.2.0.3
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-01-29 00:00:00.000000000 Z
11
+ date: 2016-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -417,6 +417,7 @@ files:
417
417
  - app/models/concerns/enjoy/enableable.rb
418
418
  - app/models/concerns/enjoy/geocodeable.rb
419
419
  - app/models/concerns/enjoy/mappable.rb
420
+ - app/models/concerns/enjoy/model_localizeable.rb
420
421
  - app/models/concerns/enjoy/mongoid_paperclip.rb
421
422
  - app/models/concerns/enjoy/seoable.rb
422
423
  - app/models/concerns/enjoy/sitemap_data_field.rb
@@ -489,12 +490,14 @@ files:
489
490
  - lib/enjoy/admin/news.rb
490
491
  - lib/enjoy/admin/page.rb
491
492
  - lib/enjoy/admin/seo.rb
493
+ - lib/enjoy/admin/sitemap_data.rb
492
494
  - lib/enjoy/configuration.rb
493
495
  - lib/enjoy/controller.rb
494
496
  - lib/enjoy/controllers/contacts.rb
495
497
  - lib/enjoy/controllers/news.rb
496
498
  - lib/enjoy/controllers/pages.rb
497
499
  - lib/enjoy/controllers/search.rb
500
+ - lib/enjoy/controllers/sitemap_data.rb
498
501
  - lib/enjoy/elastic_search.rb
499
502
  - lib/enjoy/engine.rb
500
503
  - lib/enjoy/migration.rb
@@ -525,7 +528,6 @@ files:
525
528
  - lib/enjoy/models/page.rb
526
529
  - lib/enjoy/models/seo.rb
527
530
  - lib/enjoy/models/sitemap_data.rb
528
- - lib/enjoy/patch.rb
529
531
  - lib/enjoy/rails_admin_menu.rb
530
532
  - lib/enjoy/simple_form_patch.rb
531
533
  - lib/enjoy/tasks.rb
data/lib/enjoy/patch.rb DELETED
@@ -1,58 +0,0 @@
1
- module Enjoy
2
- class PatchDSL
3
- def self.call(&blk)
4
- instance = new
5
- instance.instance_eval(&blk)
6
- instance.instance_variables.inject({}) { |result_hash, instance_variable|
7
- result_hash[instance_variable[1..-1].to_sym] = instance.instance_variable_get(instance_variable)
8
- result_hash
9
- }
10
- end
11
-
12
- def initialize
13
- @model = Proc.new {}
14
- @admin = Proc.new {}
15
- @list = Proc.new {}
16
- @show = Proc.new {}
17
- @edit = Proc.new {}
18
- @export = Proc.new {}
19
- end
20
-
21
- def model(&blk); @model = blk; end
22
- def admin(&blk); @admin = blk; end
23
- def list(&blk); @list = blk; end
24
- def show(&blk); @show = blk; end
25
- def edit(&blk); @edit = blk; end
26
- def export(&blk); @export = blk; end
27
- end
28
-
29
- @@patches = {}
30
-
31
- def self.only_patches(s, sections)
32
- s.instance_eval do
33
- sections.each do |section|
34
- send section do
35
- Enjoy.apply_patches self
36
- end
37
- end
38
- end
39
- end
40
-
41
- def self.apply_patches(s)
42
- if s.class.name.index('RailsAdmin::Config::Sections::').nil?
43
- if s.class.name == 'RailsAdmin::Config::Model'
44
- s.instance_eval(&@@patches[s.abstract_model.model_name][:admin]) unless @@patches[s.abstract_model.model_name].nil?
45
- else
46
- s.instance_eval(&@@patches[s.name][:model]) unless @@patches[s.name].nil?
47
- end
48
- else
49
- model = s.abstract_model.model_name
50
- action = s.class.name.split('::')[-1].downcase.to_sym
51
- s.instance_eval(&@@patches[model][action]) unless @@patches[model].nil?
52
- end
53
- end
54
-
55
- def self.patch(model, &blk)
56
- @@patches[model] = PatchDSL.call(&blk)
57
- end
58
- end