enjoy_cms 0.1.0.beta1 → 0.2.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +15 -15
  3. data/README.md +1 -1
  4. data/app/controllers/concerns/enjoy/nav_menu.rb +12 -2
  5. data/app/models/concerns/enjoy/seoable.rb +26 -9
  6. data/app/models/concerns/enjoy/sitemap_data_field.rb +35 -0
  7. data/app/models/enjoy/embedded_element.rb +2 -2
  8. data/app/models/enjoy/embedded_gallery_image.rb +1 -1
  9. data/app/models/enjoy/sitemap_data.rb +13 -0
  10. data/app/views/enjoy/contacts/index.html.slim +1 -1
  11. data/app/views/enjoy/contacts/new.html.slim +2 -2
  12. data/app/views/shared/_obj.html.slim +4 -3
  13. data/lib/enjoy/admin.rb +38 -28
  14. data/lib/enjoy/controller.rb +2 -2
  15. data/lib/enjoy/models/active_record/sitemap_data.rb +11 -0
  16. data/lib/enjoy/models/contact_message.rb +2 -2
  17. data/lib/enjoy/models/embedded_gallery_image.rb +1 -1
  18. data/lib/enjoy/models/gallery.rb +12 -10
  19. data/lib/enjoy/models/gallery_image.rb +11 -5
  20. data/lib/enjoy/models/menu.rb +1 -5
  21. data/lib/enjoy/models/mongoid/embedded_gallery_image.rb +7 -2
  22. data/lib/enjoy/models/mongoid/gallery.rb +7 -1
  23. data/lib/enjoy/models/mongoid/gallery_image.rb +7 -1
  24. data/lib/enjoy/models/mongoid/menu.rb +11 -0
  25. data/lib/enjoy/models/mongoid/news.rb +4 -2
  26. data/lib/enjoy/models/mongoid/page.rb +12 -2
  27. data/lib/enjoy/models/mongoid/seo.rb +10 -6
  28. data/lib/enjoy/models/mongoid/sitemap_data.rb +20 -0
  29. data/lib/enjoy/models/news.rb +2 -2
  30. data/lib/enjoy/models/page.rb +2 -6
  31. data/lib/enjoy/models/seo.rb +1 -8
  32. data/lib/enjoy/models/sitemap_data.rb +13 -0
  33. data/lib/enjoy/rails_admin_menu.rb +4 -4
  34. data/lib/enjoy/tasks.rb +1 -1
  35. data/lib/enjoy/version.rb +1 -1
  36. data/lib/enjoy_cms.rb +8 -5
  37. data/lib/generators/enjoy/templates/ability.erb +21 -2
  38. data/lib/generators/enjoy/templates/admin.erb +3 -3
  39. data/template.rb +6 -6
  40. metadata +7 -3
  41. data/app/models/concerns/enjoy/sitemap_data.rb +0 -23
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c91e2c1674c4bb1bb096be9fd64088bf83806348
4
- data.tar.gz: b2907dcd0e29d94170dac29ab220a2f7005fb21a
3
+ metadata.gz: 5d5c04ee3315ba7a3fb3752388af5ecbf888c664
4
+ data.tar.gz: 0ac404aa2c4572cb2c6a851e91e6fdb1bf252780
5
5
  SHA512:
6
- metadata.gz: b5fcbf1ee7a9d011724f07b1218ee9ac03e9f9822957d97af9ce4cf6189e3f768751d57a19b753ef68b5dddeb434ffb30d568514dffd4a0a2af3f9b2ab78f5d1
7
- data.tar.gz: 6a210f4e87e3367e8e7d73dff28f8a33766793ede0b2dd54bda880168e9d0d4c58a2217f7a18a4172772178de9c536a64098608f2b53b3e051a2023d8845e262
6
+ metadata.gz: 34c6bc123f19a7dfe62b36079c2f548a1db8d2e6dc84e00c5ddecc1b173fc70d54f75681111a421dad0471829073419449508e5334a99ec40a9a57c3e2d5bc75
7
+ data.tar.gz: d4731e9a2e3c93b501407a91f0a5983f74a3479ea6eecfca802600beda07fd6f6451a45880928140a70f386be731b312fde87b882386fcdfc6b8b90b6e4673fb
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enjoy_cms (0.1.0.beta1)
4
+ enjoy_cms (0.2.0.beta)
5
5
  ack_rails_admin_jcrop
6
6
  addressable
7
7
  ckeditor
@@ -72,9 +72,9 @@ GEM
72
72
  addressable (2.4.0)
73
73
  arel (6.0.3)
74
74
  bcrypt (3.1.10)
75
- bson (4.0.0)
75
+ bson (4.0.1)
76
76
  builder (3.2.2)
77
- ckeditor (4.1.5)
77
+ ckeditor (4.1.6)
78
78
  cocaine
79
79
  orm_adapter (~> 0.5.0)
80
80
  climate_control (0.0.3)
@@ -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.3)
92
+ devise (3.5.5)
93
93
  bcrypt (~> 3.0)
94
94
  orm_adapter (~> 0.1)
95
95
  railties (>= 3.2.6, < 5)
@@ -108,7 +108,7 @@ GEM
108
108
  tilt
109
109
  htmlentities (4.3.4)
110
110
  i18n (0.7.0)
111
- jquery-rails (4.0.5)
111
+ jquery-rails (4.1.0)
112
112
  rails-dom-testing (~> 1.0)
113
113
  railties (>= 4.2.0)
114
114
  thor (>= 0.14, < 2.0)
@@ -125,18 +125,18 @@ GEM
125
125
  mime-types (2.99)
126
126
  mini_magick (4.3.6)
127
127
  mini_portile2 (2.0.0)
128
- minitest (5.8.3)
129
- mongo (2.2.1)
128
+ minitest (5.8.4)
129
+ mongo (2.2.2)
130
130
  bson (~> 4.0)
131
- mongoid (5.0.2)
131
+ mongoid (5.1.0)
132
132
  activemodel (~> 4.0)
133
133
  mongo (~> 2.1)
134
- origin (~> 2.1)
134
+ origin (~> 2.2)
135
135
  tzinfo (>= 0.3.37)
136
136
  nested_form (0.3.2)
137
- nokogiri (1.6.7.1)
137
+ nokogiri (1.6.7.2)
138
138
  mini_portile2 (~> 2.0.0.rc2)
139
- origin (2.1.1)
139
+ origin (2.2.0)
140
140
  orm_adapter (0.5.0)
141
141
  rack (1.6.4)
142
142
  rack-pjax (0.8.0)
@@ -161,7 +161,7 @@ GEM
161
161
  activesupport (>= 4.2.0.beta, < 5.0)
162
162
  nokogiri (~> 1.6.0)
163
163
  rails-deprecated_sanitizer (>= 1.0.1)
164
- rails-html-sanitizer (1.0.2)
164
+ rails-html-sanitizer (1.0.3)
165
165
  loofah (~> 2.0)
166
166
  rails_admin (0.8.1)
167
167
  builder (~> 3.1)
@@ -192,12 +192,12 @@ GEM
192
192
  activesupport (= 4.2.4)
193
193
  rake (>= 0.8.7)
194
194
  thor (>= 0.18.1, < 2.0)
195
- rake (10.4.2)
195
+ rake (10.5.0)
196
196
  remotipart (1.2.1)
197
197
  responders (2.1.1)
198
198
  railties (>= 4.2.0, < 5.1)
199
199
  safe_yaml (1.0.4)
200
- sass (3.4.20)
200
+ sass (3.4.21)
201
201
  sass-rails (5.0.4)
202
202
  railties (>= 4.0.0, < 5.0)
203
203
  sass (~> 3.1)
@@ -224,7 +224,7 @@ GEM
224
224
  stringex (2.5.2)
225
225
  thor (0.19.1)
226
226
  thread_safe (0.3.5)
227
- tilt (2.0.1)
227
+ tilt (2.0.2)
228
228
  turbolinks (2.5.3)
229
229
  coffee-rails
230
230
  tzinfo (1.2.2)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # EnjoyCms
1
+ # EnjoyCMS
2
2
 
3
3
  # DEVELOPMENT VERSION. DO NOT USE IT
4
4
 
@@ -11,7 +11,9 @@ module Enjoy::NavMenu
11
11
  block = nil
12
12
  else
13
13
  block = Proc.new do |sub_nav|
14
- subs.each { |sub| render_with_subs(items, sub_nav, sub) }
14
+ subs.each { |sub|
15
+ render_with_subs(items, sub_nav, sub)
16
+ }
15
17
  end
16
18
  end
17
19
  cr = item.clean_regexp
@@ -53,7 +55,8 @@ module Enjoy::NavMenu
53
55
  item.redirect.blank? ? item.fullpath : item.redirect
54
56
  end
55
57
  def nav_get_menu_items(type)
56
- Enjoy::Menu.find(type.to_s).pages.enabled.sorted.to_a
58
+ menu = menu_class.find(type.to_s)
59
+ menu.pages.enabled.sorted.to_a if menu
57
60
  end
58
61
  def nav_extra_data_before(type, primary)
59
62
  # override for additional config or items
@@ -61,4 +64,11 @@ module Enjoy::NavMenu
61
64
  def nav_extra_data_after(type, primary)
62
65
  # override for additional config or items
63
66
  end
67
+
68
+ def menu_class_name
69
+ "Enjoy::Menu"
70
+ end
71
+ def menu_class
72
+ menu_class_name.constantize
73
+ end
64
74
  end
@@ -4,18 +4,22 @@ 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
7
+ has_one :seo, as: :seoable, autosave: true, class_name: seo_class_name
8
8
  accepts_nested_attributes_for :seo
9
+
9
10
  delegate *FIELDS, to: :seo
10
11
  delegate *(FIELDS.map {|f| "#{f}=".to_sym }), to: :seo
11
- alias seo_without_build seo
12
- def seo
13
- seo_without_build || build_seo
14
- end
12
+
15
13
  if Enjoy.config.localize
16
14
  delegate *(LOCALIZED_FIELDS.map {|f| "#{f}_translations".to_sym }), to: :seo
17
15
  delegate *(LOCALIZED_FIELDS.map {|f| "#{f}_translations=".to_sym }), to: :seo
18
16
  end
17
+
18
+
19
+ alias seo_without_build seo
20
+ def seo
21
+ seo_without_build || build_seo
22
+ end
19
23
  end
20
24
 
21
25
  def page_title
@@ -26,11 +30,24 @@ module Enjoy::Seoable
26
30
  og_title.blank? ? name : og_title
27
31
  end
28
32
 
29
- def self.admin
30
- Enjoy.seo_config
31
- end
32
-
33
33
  def og_image_jcrop_options
34
34
  {aspectRation: 800.0/600.0}
35
35
  end
36
+
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
36
53
  end
@@ -0,0 +1,35 @@
1
+ module Enjoy::SitemapDataField
2
+ extend ActiveSupport::Concern
3
+ FIELDS = [:sitemap_show, :sitemap_lastmod, :sitemap_changefreq, :sitemap_priority]
4
+
5
+ included do
6
+ has_one :sitemap_data, as: :sitemap_data_field, autosave: true, class_name: sitemap_data_class_name
7
+ accepts_nested_attributes_for :sitemap_data
8
+
9
+ delegate *FIELDS, to: :sitemap_data
10
+ delegate *(FIELDS.map {|f| "#{f}=".to_sym }), to: :sitemap_data
11
+
12
+ alias sitemap_data_without_build sitemap_data
13
+ def sitemap_data
14
+ sitemap_data_without_build || build_sitemap_data
15
+ end
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
+ end
@@ -1,7 +1,7 @@
1
1
  module Enjoy
2
2
  if Enjoy.mongoid?
3
- class Enjoy
4
- include Enjoy::Models::Enjoy
3
+ class EmbeddedElement
4
+ include Enjoy::Models::EmbeddedElement
5
5
  Enjoy.apply_patches self
6
6
 
7
7
  # use it in inherited model
@@ -1,6 +1,6 @@
1
1
  module Enjoy
2
2
  if Enjoy.mongoid?
3
- class EmbeddedGalleryImage < Enjoy
3
+ class EmbeddedGalleryImage < Enjoy::EmbeddedElement
4
4
  include Enjoy::Models::EmbeddedGalleryImage
5
5
  Enjoy.apply_patches self
6
6
 
@@ -0,0 +1,13 @@
1
+ module Enjoy
2
+ if Enjoy.active_record?
3
+ class SitemapData < ActiveRecord::Base
4
+ end
5
+ end
6
+
7
+ class SitemapData
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
12
+ end
13
+ end
@@ -1,7 +1,7 @@
1
1
  = render 'shared/obj', obj: @seo_page
2
2
 
3
3
  #enjoy_cms_contact_form
4
- = simple_form_for @contact_message, url: enjoy.contacts_path do |f|
4
+ = simple_form_for @contact_message, url: enjoy_cms.contacts_path do |f|
5
5
  = f.input :name
6
6
  = f.input :email
7
7
  = f.input :phone
@@ -1,10 +1,10 @@
1
1
  = render 'shared/obj', obj: @seo_page
2
2
 
3
3
  #enjoy_cms_contact_form
4
- = simple_form_for @contact_message, url: enjoy.contacts_path do |f|
4
+ = simple_form_for @contact_message, url: enjoy_cms.contacts_path do |f|
5
5
  = f.input :name
6
6
  = f.input :email
7
7
  = f.input :phone
8
8
  = f.input :content
9
- = f.input :captcha
9
+ = f.input :captcha, as: :simple_captcha
10
10
  = f.submit t('enjoy.send')
@@ -1,7 +1,8 @@
1
1
  - unless obj.nil?
2
2
  .text_content
3
- - if (!defined?(h1) || h1) && !obj.h1.blank?
4
- h1= obj.h1
3
+ - seo = obj.seo
4
+ - if (!defined?(h1) || h1) && seo and !seo.h1.blank?
5
+ h1= seo.h1
5
6
  - if obj.content.blank?
6
7
  - unless @seo_page.nil?
7
8
  = raw @seo_page.page_content
@@ -18,4 +19,4 @@
18
19
 
19
20
  - content_for :title do
20
21
  - if obj.title
21
- title= obj.title
22
+ title= obj.title
data/lib/enjoy/admin.rb CHANGED
@@ -3,7 +3,7 @@ module Enjoy
3
3
  def map_config(is_active = true)
4
4
  Proc.new {
5
5
  active is_active
6
- label I18n.t('rs.map')
6
+ label I18n.t('enjoy.map')
7
7
  field :address, :string
8
8
  field :map_address, :string
9
9
  field :map_hint, :string
@@ -22,18 +22,10 @@ module Enjoy
22
22
 
23
23
  def seo_config(is_active = true)
24
24
  Proc.new {
25
- if respond_to?(:active)
26
- active is_active
27
- label "SEO"
28
- else
29
- visible false
25
+ navigation_label 'SEO'
26
+ field :seoable do
27
+ read_only true
30
28
  end
31
- Enjoy.seo_fields(self)
32
- }
33
- end
34
-
35
- def seo_fields(s)
36
- s.instance_eval do
37
29
  field :h1, :string
38
30
  field :title, :string
39
31
  field :keywords, :text
@@ -49,7 +41,7 @@ module Enjoy
49
41
  if block_given?
50
42
  yield
51
43
  end
52
- end
44
+ }
53
45
  end
54
46
 
55
47
  def page_config(fields = {})
@@ -77,16 +69,16 @@ module Enjoy
77
69
  field :content, :ck_editor
78
70
  Enjoy.apply_patches self
79
71
  group :menu do
80
- label I18n.t('rs.menu')
72
+ label I18n.t('enjoy.menu')
81
73
  field :menus
82
74
  field :fullpath, :string do
83
- help I18n.t('rs.with_final_slash')
75
+ help I18n.t('enjoy.with_final_slash')
84
76
  end
85
77
  field :regexp, :string do
86
- help I18n.t('rs.page_url_regex')
78
+ help I18n.t('enjoy.page_url_regex')
87
79
  end
88
80
  field :redirect, :string do
89
- help I18n.t('rs.final_in_menu')
81
+ help I18n.t('enjoy.final_in_menu')
90
82
  end
91
83
  field :text_slug
92
84
  end
@@ -102,12 +94,17 @@ module Enjoy
102
94
  end
103
95
  end
104
96
  group :seo do
105
- active true
97
+ active false
106
98
  field :seo do
107
99
  active true
108
100
  end
109
101
  end
110
- group :sitemap_data, &Enjoy.sitemap_data_config
102
+ group :sitemap_data do
103
+ active false
104
+ field :sitemap_data do
105
+ active true
106
+ end
107
+ end
111
108
  end
112
109
  Enjoy.only_patches self, [:show, :export]
113
110
  nested_set({
@@ -139,7 +136,7 @@ module Enjoy
139
136
 
140
137
  def contact_message_config
141
138
  Proc.new {
142
- # navigation_label I18n.t('rs.settings')
139
+ # navigation_label I18n.t('enjoy.settings')
143
140
  field :c_at do
144
141
  read_only true
145
142
  end
@@ -218,8 +215,18 @@ module Enjoy
218
215
  end
219
216
  end
220
217
  Enjoy.apply_patches self
221
- group :seo, &Enjoy.seo_config
222
- group :sitemap_data, &Enjoy.sitemap_data_config
218
+ group :seo do
219
+ active false
220
+ field :seo do
221
+ active true
222
+ end
223
+ end
224
+ group :sitemap_data do
225
+ active false
226
+ field :sitemap_data do
227
+ active true
228
+ end
229
+ end
223
230
  end
224
231
 
225
232
  Enjoy.only_patches self, [:show, :list, :export]
@@ -232,13 +239,16 @@ module Enjoy
232
239
 
233
240
  def sitemap_data_config(is_active = false)
234
241
  Proc.new {
235
- active is_active
236
- label I18n.t('rs.sitemap_data')
237
- field :sitemap_show
242
+ navigation_label 'SEO'
243
+ label I18n.t('enjoy.sitemap_data')
244
+ field :sitemap_data_field do
245
+ read_only true
246
+ end
247
+ field :sitemap_show, :toggle
238
248
  field :sitemap_lastmod
239
249
  field :sitemap_changefreq, :enum do
240
250
  enum do
241
- SitemapData::SITEMAP_CHANGEFREQ_ARRAY
251
+ Enjoy::SitemapData::SITEMAP_CHANGEFREQ_ARRAY
242
252
  end
243
253
  end
244
254
  field :sitemap_priority
@@ -295,7 +305,7 @@ module Enjoy
295
305
 
296
306
  def gallery_config
297
307
  Proc.new {
298
- # navigation_label I18n.t('rs.gallery')
308
+ # navigation_label I18n.t('enjoy.gallery')
299
309
  field :enabled, :toggle
300
310
 
301
311
  field :name, :string
@@ -324,7 +334,7 @@ module Enjoy
324
334
 
325
335
  def image_config(without_gallery = false, fields = {})
326
336
  Proc.new {
327
- # navigation_label I18n.t('rs.gallery')
337
+ # navigation_label I18n.t('enjoy.gallery')
328
338
  field :enabled, :toggle
329
339
  unless without_gallery
330
340
  field :gallery
@@ -7,6 +7,7 @@ module Enjoy::Controller
7
7
  include Enjoy::Fancybox
8
8
  protect_from_forgery with: :exception
9
9
  helper_method :page_title
10
+ helper_method :hide_ym_ga
10
11
  end
11
12
 
12
13
  protected
@@ -23,9 +24,8 @@ module Enjoy::Controller
23
24
  redirect_to '/' unless user_signed_in? && current_user.has_role?('admin')
24
25
  end
25
26
 
26
-
27
+
27
28
  def hide_ym_ga
28
29
  false
29
30
  end
30
- helper_method :hide_ym_ga
31
31
  end
@@ -0,0 +1,11 @@
1
+ module Enjoy
2
+ module Models
3
+ module ActiveRecord
4
+ module SitemapData
5
+ extend ActiveSupport::Concern
6
+ included do
7
+ end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -3,7 +3,7 @@ module Enjoy
3
3
  module ContactMessage
4
4
  extend ActiveSupport::Concern
5
5
  include Enjoy::Model
6
-
6
+
7
7
  include Enjoy.orm_specific('ContactMessage')
8
8
 
9
9
  included do
@@ -16,7 +16,7 @@ module Enjoy
16
16
  end
17
17
  validate do
18
18
  if email.blank? && phone.blank?
19
- errors.add(:email, I18n.t('rs.no_contact_info'))
19
+ errors.add(:email, I18n.t('enjoy.no_contact_info'))
20
20
  end
21
21
  end
22
22
 
@@ -5,7 +5,7 @@ module Enjoy
5
5
  include Enjoy::Model
6
6
  include Enjoy::Enableable
7
7
  include Enjoy::Sortable
8
-
8
+
9
9
  include Enjoy.orm_specific('EmbeddedGalleryImage')
10
10
 
11
11
  included do
@@ -5,8 +5,18 @@ module Enjoy
5
5
  include Enjoy::Model
6
6
  include ManualSlug
7
7
  include Enjoy::Enableable
8
- include Enjoy::SitemapData
9
-
8
+ include Enjoy::SitemapDataField
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
+
10
20
  include Enjoy.orm_specific('Gallery')
11
21
 
12
22
  included do
@@ -16,14 +26,6 @@ module Enjoy
16
26
 
17
27
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
18
28
  end
19
-
20
- def gallery_image_class_name
21
- "Enjoy::GalleryImage"
22
- end
23
-
24
- def image_styles
25
- {}
26
- end
27
29
  end
28
30
  end
29
31
  end
@@ -4,7 +4,17 @@ module Enjoy
4
4
  extend ActiveSupport::Concern
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
+
8
18
  include Enjoy.orm_specific('GalleryImage')
9
19
 
10
20
  included do
@@ -14,10 +24,6 @@ module Enjoy
14
24
 
15
25
  validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image?
16
26
  end
17
-
18
- def gallery_class_name
19
- "Enjoy::Gallery"
20
- end
21
27
  end
22
28
  end
23
29
  end
@@ -5,7 +5,7 @@ module Enjoy
5
5
  include Enjoy::Model
6
6
  include ManualSlug
7
7
  include Enjoy::Enableable
8
-
8
+
9
9
  include Enjoy.orm_specific('Menu')
10
10
  included do
11
11
 
@@ -19,10 +19,6 @@ module Enjoy
19
19
  Rails.cache.delete 'menus'
20
20
  end
21
21
  end
22
-
23
- def page_class_name
24
- "Enjoy::Page"
25
- end
26
22
  end
27
23
  end
28
24
  end
@@ -4,15 +4,20 @@ module Enjoy
4
4
  module EmbeddedGalleryImage
5
5
  extend ActiveSupport::Concern
6
6
  include Enjoy::MongoidPaperclip
7
- include Enjoy::EmbeddedElement
8
7
 
9
8
  included do
10
9
 
11
- enjoy_mongoid_attached_file(:image,
10
+ enjoy_cms_mongoid_attached_file(:image,
12
11
  styles: image_styles,
13
12
  content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
14
13
  )
15
14
  end
15
+
16
+ module ClassMethods
17
+ def image_styles
18
+ {}
19
+ end
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -12,11 +12,17 @@ module Enjoy
12
12
  acts_as_nested_set
13
13
  scope :sorted, -> { order_by([:lft, :asc]) }
14
14
 
15
- enjoy_mongoid_attached_file(:image,
15
+ enjoy_cms_mongoid_attached_file(:image,
16
16
  styles: image_styles,
17
17
  content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
18
18
  )
19
19
  end
20
+
21
+ module ClassMethods
22
+ def image_styles
23
+ {}
24
+ end
25
+ end
20
26
  end
21
27
  end
22
28
  end
@@ -10,11 +10,17 @@ module Enjoy
10
10
  acts_as_nested_set
11
11
  scope :sorted, -> { order_by([:lft, :asc]) }
12
12
 
13
- enjoy_mongoid_attached_file(:image,
13
+ enjoy_cms_mongoid_attached_file(:image,
14
14
  styles: image_styles,
15
15
  content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
16
16
  )
17
17
  end
18
+
19
+ module ClassMethods
20
+ def image_styles
21
+ {}
22
+ end
23
+ end
18
24
  end
19
25
  end
20
26
  end
@@ -3,6 +3,17 @@ module Enjoy
3
3
  module Mongoid
4
4
  module Menu
5
5
  extend ActiveSupport::Concern
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
+
6
17
  included do
7
18
  has_and_belongs_to_many :pages, inverse_of: :menus, class_name: page_class_name
8
19
  alias_method :items, :pages
@@ -6,12 +6,14 @@ module Enjoy
6
6
  unless Enjoy.config.news_image_styles.nil?
7
7
  include Enjoy::MongoidPaperclip
8
8
  end
9
- included do
10
9
 
10
+ included do
11
+ field :name, type: String, localize: Enjoy.config.localize, default: ""
12
+
11
13
  field :time, type: Time
12
14
  index({enabled: 1, time: 1})
13
15
  unless Enjoy.config.news_image_styles.nil?
14
- enjoy_mongoid_attached_file(:image,
16
+ enjoy_cms_mongoid_attached_file(:image,
15
17
  styles: Enjoy.configuration.news_image_styles,
16
18
  content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
17
19
  )
@@ -3,7 +3,19 @@ module Enjoy
3
3
  module Mongoid
4
4
  module Page
5
5
  extend ActiveSupport::Concern
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
+
6
17
  included do
18
+ field :name, type: String, localize: Enjoy.config.localize, default: ""
7
19
 
8
20
  field :regexp, type: String, default: ""
9
21
  field :redirect, type: String, default: ""
@@ -14,8 +26,6 @@ module Enjoy
14
26
  has_and_belongs_to_many :menus, inverse_of: :pages, class_name: menu_class_name
15
27
  acts_as_nested_set
16
28
 
17
- manual_slug :name
18
-
19
29
  scope :sorted, -> { order_by([:lft, :asc]) }
20
30
  scope :menu, ->(menu_id) { enabled.sorted.where(menu_ids: menu_id) }
21
31
  end
@@ -3,7 +3,7 @@ module Enjoy
3
3
  module Mongoid
4
4
  module Seo
5
5
  extend ActiveSupport::Concern
6
- include ::Mongoid::Paperclip
6
+ include Enjoy::MongoidPaperclip
7
7
  included do
8
8
 
9
9
  field :name, type: String, localize: Enjoy.config.localize
@@ -15,11 +15,15 @@ module Enjoy
15
15
  field :robots, type: String, localize: Enjoy.config.localize
16
16
 
17
17
  field :og_title, type: String, localize: Enjoy.config.localize
18
- unless Enjoy.config.news_image_styles.nil?
19
- enjoy_mongoid_attached_file(:image,
20
- styles: og_image_styles,
21
- content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
22
- )
18
+ enjoy_cms_mongoid_attached_file(:og_image,
19
+ styles: og_image_styles,
20
+ content_type: { content_type: ["image/jpg", "image/jpeg", "image/png"] }
21
+ )
22
+ end
23
+
24
+ module ClassMethods
25
+ def og_image_styles
26
+ {thumb: "800x600>"}
23
27
  end
24
28
  end
25
29
  end
@@ -0,0 +1,20 @@
1
+ module Enjoy
2
+ module Models
3
+ module Mongoid
4
+ module SitemapData
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ field :sitemap_show, type: Boolean, default: true
9
+ field :sitemap_lastmod, type: DateTime
10
+ field :sitemap_changefreq, type: String, default: 'daily'
11
+ field :sitemap_priority, type: Float
12
+
13
+ scope :sitemap_show, -> { where(sitemap_show: true) }
14
+ scope :for_sitemap, -> { sitemap_show }
15
+ scope :show_in_sitemap, -> { sitemap_show }
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -6,8 +6,8 @@ module Enjoy
6
6
  include ManualSlug
7
7
  include Enjoy::Seoable
8
8
  include Enjoy::Enableable
9
- include Enjoy::SitemapData
10
-
9
+ include Enjoy::SitemapDataField
10
+
11
11
  include Enjoy.orm_specific('News')
12
12
 
13
13
  # if Enjoy.config.search_enabled
@@ -6,7 +6,7 @@ module Enjoy
6
6
  include ManualSlug
7
7
  include Enjoy::Enableable
8
8
  include Enjoy::Seoable
9
- include Enjoy::SitemapData
9
+ include Enjoy::SitemapDataField
10
10
 
11
11
  include Enjoy.orm_specific('Page')
12
12
 
@@ -24,16 +24,12 @@ module Enjoy
24
24
  end
25
25
 
26
26
  def page_h1
27
- _ret = h1
27
+ _ret = seo ? seo.h1 : nil
28
28
  _ret = name if _ret.blank?
29
29
  _ret = title if _ret.blank?
30
30
  _ret
31
31
  end
32
32
 
33
- def menu_class_name
34
- "Enjoy::Menu"
35
- end
36
-
37
33
  def get_fullpath
38
34
  redirect.blank? ? fullpath : redirect
39
35
  end
@@ -4,19 +4,12 @@ module Enjoy
4
4
  extend ActiveSupport::Concern
5
5
  include Enjoy::Model
6
6
  include Enjoy::Enableable
7
- include Enjoy::Seoable
8
-
7
+
9
8
  include Enjoy.orm_specific('Seo')
10
9
 
11
10
  included do
12
-
13
- Enjoy.apply_patches self
14
11
  validates_attachment_content_type :og_image, content_type: /\Aimage\/.*\Z/, if: :og_image?
15
12
  end
16
-
17
- def og_image_styles
18
- {thumb: "800x600>"}
19
- end
20
13
  end
21
14
  end
22
15
  end
@@ -0,0 +1,13 @@
1
+ module Enjoy
2
+ module Models
3
+ module SitemapData
4
+ extend ActiveSupport::Concern
5
+ include Enjoy::Model
6
+ include Enjoy::Enableable
7
+
8
+ include Enjoy.orm_specific('SitemapData')
9
+
10
+ SITEMAP_CHANGEFREQ_ARRAY = %w(always hourly daily weekly monthly yearly never)
11
+ end
12
+ end
13
+ 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
- ::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
- ::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|
@@ -125,9 +125,9 @@ module RailsAdmin
125
125
  else
126
126
  flash[:error] = I18n.t('rs.m.no_id')
127
127
  end
128
-
128
+
129
129
  end
130
-
130
+
131
131
  redirect_to :back unless params['ajax'].present?
132
132
  end
133
133
  end
data/lib/enjoy/tasks.rb CHANGED
@@ -4,7 +4,7 @@ require 'rake'
4
4
  # Require generator at runtime. If we don't do this the ActionView helpers are included
5
5
  # before the Rails environment can be loaded by other Rake tasks, which causes problems
6
6
  # for those tasks when rendering using ActionView.
7
- namespace :rs do
7
+ namespace :enjoy do
8
8
  # Require generator only. When installed as a plugin the require will fail, so in
9
9
  # that case, load the environment first.
10
10
  task :require do
data/lib/enjoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Enjoy
2
- VERSION = "0.1.0.beta1"
2
+ VERSION = "0.2.0.beta"
3
3
  end
data/lib/enjoy_cms.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  unless defined?(Enjoy) && Enjoy.respond_to?(:orm) && [:active_record, :mongoid].include?(Enjoy.orm)
2
- puts "please use Enjoy_mongoid or Enjoy_activerecord and not enjoy directly"
2
+ puts "please use enjoy_cms_mongoid or enjoy_cms_activerecord and not enjoy directly"
3
3
  exit 1
4
4
  end
5
5
 
@@ -39,8 +39,6 @@ require 'enjoy/rails_admin_menu'
39
39
  require 'enjoy/engine'
40
40
  require 'enjoy/controller'
41
41
 
42
- require 'manual_slug'
43
-
44
42
 
45
43
  module Enjoy
46
44
  class << self
@@ -65,26 +63,28 @@ module Enjoy
65
63
  # end
66
64
 
67
65
  module Models
66
+ autoload :SitemapData, 'enjoy/models/sitemap_data'
68
67
  autoload :Seo, 'enjoy/models/seo'
69
68
  autoload :Menu, 'enjoy/models/menu'
70
69
  autoload :Page, 'enjoy/models/page'
71
70
  autoload :News, 'enjoy/models/news'
72
71
  autoload :ContactMessage, 'enjoy/models/contact_message'
73
72
 
74
- autoload :Enjoy, 'enjoy/models/embedded_element'
73
+ autoload :EmbeddedElement, 'enjoy/models/embedded_element'
75
74
 
76
75
  autoload :EmbeddedGalleryImage, 'enjoy/models/embedded_gallery_image'
77
76
  autoload :GalleryImage, 'enjoy/models/gallery_image'
78
77
  autoload :Gallery, 'enjoy/models/gallery'
79
78
 
80
79
  module Mongoid
80
+ autoload :SitemapData, 'enjoy/models/mongoid/sitemap_data'
81
81
  autoload :Seo, 'enjoy/models/mongoid/seo'
82
82
  autoload :Menu, 'enjoy/models/mongoid/menu'
83
83
  autoload :Page, 'enjoy/models/mongoid/page'
84
84
  autoload :News, 'enjoy/models/mongoid/news'
85
85
  autoload :ContactMessage, 'enjoy/models/mongoid/contact_message'
86
86
 
87
- autoload :Enjoy, 'enjoy/models/mongoid/embedded_element'
87
+ autoload :EmbeddedElement, 'enjoy/models/mongoid/embedded_element'
88
88
 
89
89
  autoload :EmbeddedGalleryImage, 'enjoy/models/mongoid/embedded_gallery_image'
90
90
  autoload :GalleryImage, 'enjoy/models/mongoid/gallery_image'
@@ -92,6 +92,7 @@ module Enjoy
92
92
  end
93
93
 
94
94
  module ActiveRecord
95
+ autoload :SitemapData, 'enjoy/models/active_record/sitemap_data'
95
96
  autoload :Seo, 'enjoy/models/active_record/seo'
96
97
  autoload :Menu, 'enjoy/models/active_record/menu'
97
98
  autoload :Page, 'enjoy/models/active_record/page'
@@ -107,3 +108,5 @@ module Enjoy
107
108
  autoload :Search, 'enjoy/controllers/search'
108
109
  end
109
110
  end
111
+
112
+ require 'manual_slug'
@@ -6,11 +6,15 @@ class Ability
6
6
  can :read, :all
7
7
  can :access, :rails_admin # grant access to rails_admin
8
8
  can :dashboard # grant access to the dashboard
9
+
9
10
  if user.admin?
10
11
  admin_ui(user)
11
12
  elsif user.manager?
12
13
  manager_ui(user)
13
14
  end
15
+
16
+ cannot [:new, :create], Enjoy::Seo
17
+ cannot [:new, :create], Enjoy::SitemapData
14
18
  end
15
19
  end
16
20
 
@@ -19,8 +23,23 @@ class Ability
19
23
  end
20
24
 
21
25
  def manager_ui(user)
22
- cannot :manage, Menu
26
+ cannot :manage, Enjoy::Menu
23
27
  cannot [:edit, :destroy, :new, :create], User
24
28
  can :edit, user
29
+
30
+ manager_models.each do |model|
31
+ can manager_actions, model
32
+ end
33
+ end
34
+
35
+ def manager_actions
36
+ [:edit, :new, :create, :nested_set, :sort_embedded]
37
+ end
38
+
39
+ def manager_models
40
+ [
41
+ Enjoy::Page, Enjoy::News,
42
+ Enjoy::Seo, Enjoy::SitemapData
43
+ ]
25
44
  end
26
- end
45
+ end
@@ -42,21 +42,21 @@ RailsAdmin.config do |config|
42
42
 
43
43
  nested_set do
44
44
  visible do
45
- ['Page', 'Gallery', 'GalleryImage'].include? bindings[:abstract_model].model_name
45
+ ['Enjoy::Page', 'Enjoy::Gallery', 'Enjoy::GalleryImage'].include? bindings[:abstract_model].model_name
46
46
  end
47
47
  end
48
48
 
49
49
  custom_show_in_app do
50
50
  visible do
51
51
  #temporary
52
- false #['Page', 'News'].include? bindings[:abstract_model].model_name
52
+ false #['Enjoy::Page', 'Enjoy::News'].include? bindings[:abstract_model].model_name
53
53
  end
54
54
  end
55
55
 
56
56
  toggle
57
57
  toggle_menu do
58
58
  visible do
59
- ['Page'].include? bindings[:abstract_model].model_name
59
+ ['Enjoy::Page'].include? bindings[:abstract_model].model_name
60
60
  end
61
61
  end
62
62
  sitemap
data/template.rb CHANGED
@@ -22,7 +22,7 @@ gem 'sass-rails'
22
22
  gem 'compass-rails', '~> 2.0.0'
23
23
  gem 'compass', '~> 1.0.0'
24
24
 
25
- #{if mongoid then "gem 'Enjoy_mongoid'" else "gem 'Enjoy_activerecord'" end}, '~> 0.1.0.beta1', git: 'https://github.com/enjoycreative/Enjoy'
25
+ #{if mongoid then "gem 'enjoy_cms_mongoid'" else "gem 'enjoy_cms_activerecord'" end}, '~> 0.2.0.beta', git: 'https://github.com/enjoycreative/enjoy_cms'
26
26
 
27
27
  gem 'devise'
28
28
 
@@ -201,11 +201,11 @@ end
201
201
 
202
202
  create_file 'config/navigation.rb' do <<-TEXT
203
203
  # empty file to please simple_navigation, we are not using it
204
- # See https://github.com/enjoycreative/Enjoy/blob/master/app/controllers/concerns/enjoy/menu.rb
204
+ # See https://github.com/enjoycreative/enjoy_cms/blob/master/app/controllers/concerns/enjoy/menu.rb
205
205
  TEXT
206
206
  end
207
207
 
208
- create_file 'README.md', "## #{app_name}\nProject generated by Enjoy\nORM: #{if mongoid then 'Mongoid' else 'ActiveRecord' end}\n\n"
208
+ create_file 'README.md', "## #{app_name}\nProject generated by EnjoyCMS\nORM: #{if mongoid then 'Mongoid' else 'ActiveRecord' end}\n\n"
209
209
 
210
210
  create_file '.ruby-version', "2.2.3\n"
211
211
  create_file '.ruby-gemset', "#{app_name}\n"
@@ -386,7 +386,7 @@ Rails.application.routes.draw do
386
386
  mount RailsAdmin::Engine => '/admin', as: 'rails_admin'
387
387
  mount Ckeditor::Engine => '/ckeditor'
388
388
 
389
- mount Enjoy::Engine => '/'
389
+ mount Enjoy::Engine => '/', as: 'enjoy_cms'
390
390
  end
391
391
  TEXT
392
392
  end
@@ -595,7 +595,7 @@ remove_file 'app/assets/stylesheets/application.css'
595
595
  remove_file 'app/assets/stylesheets/application.css.sass'
596
596
  create_file 'app/assets/stylesheets/application.sass' do <<-TEXT
597
597
  @import 'compass'
598
- @import 'Enjoy'
598
+ @import 'enjoy_cms'
599
599
 
600
600
  #wrapper
601
601
  width: 960px
@@ -615,7 +615,7 @@ end
615
615
  remove_file 'app/assets/javascripts/application.js'
616
616
  remove_file 'app/assets/javascripts/application.js.coffee'
617
617
  create_file 'app/assets/javascripts/application.coffee' do <<-TEXT
618
- #= require Enjoy
618
+ #= require enjoy_cms
619
619
  TEXT
620
620
  end
621
621
 
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.1.0.beta1
4
+ version: 0.2.0.beta
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-04 00:00:00.000000000 Z
11
+ date: 2016-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -419,7 +419,7 @@ files:
419
419
  - app/models/concerns/enjoy/mappable.rb
420
420
  - app/models/concerns/enjoy/mongoid_paperclip.rb
421
421
  - app/models/concerns/enjoy/seoable.rb
422
- - app/models/concerns/enjoy/sitemap_data.rb
422
+ - app/models/concerns/enjoy/sitemap_data_field.rb
423
423
  - app/models/concerns/enjoy/sort_field.rb
424
424
  - app/models/concerns/enjoy/sortable.rb
425
425
  - app/models/enjoy/contact_message.rb
@@ -431,6 +431,7 @@ files:
431
431
  - app/models/enjoy/news.rb
432
432
  - app/models/enjoy/page.rb
433
433
  - app/models/enjoy/seo.rb
434
+ - app/models/enjoy/sitemap_data.rb
434
435
  - app/views/blocks/_favicon.html.slim
435
436
  - app/views/blocks/_footer.html.slim
436
437
  - app/views/blocks/_seo_block.html.slim
@@ -503,6 +504,7 @@ files:
503
504
  - lib/enjoy/models/active_record/news.rb
504
505
  - lib/enjoy/models/active_record/page.rb
505
506
  - lib/enjoy/models/active_record/seo.rb
507
+ - lib/enjoy/models/active_record/sitemap_data.rb
506
508
  - lib/enjoy/models/contact_message.rb
507
509
  - lib/enjoy/models/embedded_element.rb
508
510
  - lib/enjoy/models/embedded_gallery_image.rb
@@ -518,9 +520,11 @@ files:
518
520
  - lib/enjoy/models/mongoid/news.rb
519
521
  - lib/enjoy/models/mongoid/page.rb
520
522
  - lib/enjoy/models/mongoid/seo.rb
523
+ - lib/enjoy/models/mongoid/sitemap_data.rb
521
524
  - lib/enjoy/models/news.rb
522
525
  - lib/enjoy/models/page.rb
523
526
  - lib/enjoy/models/seo.rb
527
+ - lib/enjoy/models/sitemap_data.rb
524
528
  - lib/enjoy/patch.rb
525
529
  - lib/enjoy/rails_admin_menu.rb
526
530
  - lib/enjoy/simple_form_patch.rb
@@ -1,23 +0,0 @@
1
- module Enjoy::SitemapData
2
- extend ActiveSupport::Concern
3
-
4
- SITEMAP_CHANGEFREQ_ARRAY = %w(always hourly daily weekly monthly yearly never)
5
-
6
- included do
7
- if Enjoy.mongoid?
8
- field :sitemap_show, type: Boolean, default: true
9
- field :sitemap_lastmod, type: DateTime
10
- field :sitemap_changefreq, type: String, default: 'daily'
11
- field :sitemap_priority, type: Float
12
-
13
- scope :sitemap_show, -> { where(sitemap_show: true) }
14
- scope :for_sitemap, -> { sitemap_show }
15
- scope :show_in_sitemap, -> { sitemap_show }
16
- elsif Enjoy.active_record?
17
- end
18
- end
19
-
20
- def self.admin
21
- Enjoy.sitemap_data_config
22
- end
23
- end