enjoy_cms 0.3.0.4 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +4 -4
- data/app/controllers/concerns/enjoy/blocksetable.rb +37 -0
- data/app/models/concerns/enjoy/html_field.rb +1 -1
- data/app/models/concerns/enjoy/mongoid_paperclip.rb +1 -0
- data/app/views/rails_admin/main/_enjoy_html.html.slim +4 -2
- data/enjoy_cms.gemspec +0 -1
- data/lib/enjoy/admin/news.rb +4 -0
- data/lib/enjoy/admin/page.rb +4 -0
- data/lib/enjoy/admin/page_block.rb +5 -0
- data/lib/enjoy/admin/page_blockset.rb +7 -1
- data/lib/enjoy/controller.rb +1 -0
- data/lib/enjoy/models/mongoid/contact_message.rb +3 -0
- data/lib/enjoy/models/mongoid/gallery.rb +4 -0
- data/lib/enjoy/models/mongoid/gallery_image.rb +4 -0
- data/lib/enjoy/models/mongoid/menu.rb +4 -0
- data/lib/enjoy/models/mongoid/news.rb +4 -0
- data/lib/enjoy/models/mongoid/page.rb +4 -0
- data/lib/enjoy/models/mongoid/page_block.rb +40 -1
- data/lib/enjoy/models/mongoid/page_blockset.rb +6 -4
- data/lib/enjoy/models/mongoid/seo.rb +5 -1
- data/lib/enjoy/models/mongoid/sitemap_data.rb +6 -1
- data/lib/enjoy/models/news.rb +1 -1
- data/lib/enjoy/models/page_block.rb +10 -0
- data/lib/enjoy/models/page_blockset.rb +10 -0
- data/lib/enjoy/rails_admin_enjoy_html.rb +17 -3
- data/lib/enjoy/version.rb +1 -1
- data/lib/generators/enjoy/templates/ability.erb +2 -1
- data/template.rb +1 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1d161c901fcad77111f3812b158201ac4a9f1e1
|
4
|
+
data.tar.gz: 3c94d129878ee36a5c0ab63d2bfe96b4bef846d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7269789b50e12233a1958fe60e84f9b199e75db62ade20ba653672be54583484cce0c098c4cb11cd21f260da642424d61722a335d1eadd758072944f73f85b6
|
7
|
+
data.tar.gz: 01e548a6a35a178cac39af26a8d6c8e07d51c639cc07c7549f5311fb78de2d34b8d6afdd49f667f60ab18fece0e61603f9c16b3a86408d35dae55cf092458187
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
enjoy_cms (0.3.
|
4
|
+
enjoy_cms (0.3.1)
|
5
5
|
ack_rails_admin_jcrop
|
6
6
|
addressable
|
7
7
|
ckeditor
|
@@ -76,7 +76,7 @@ GEM
|
|
76
76
|
addressable (2.4.0)
|
77
77
|
arel (6.0.3)
|
78
78
|
bcrypt (3.1.10)
|
79
|
-
bson (4.0.
|
79
|
+
bson (4.0.3)
|
80
80
|
builder (3.2.2)
|
81
81
|
ckeditor (4.1.6)
|
82
82
|
cocaine
|
@@ -92,7 +92,7 @@ GEM
|
|
92
92
|
coffee-script-source
|
93
93
|
execjs
|
94
94
|
coffee-script-source (1.10.0)
|
95
|
-
concurrent-ruby (1.0.
|
95
|
+
concurrent-ruby (1.0.1)
|
96
96
|
devise (3.5.6)
|
97
97
|
bcrypt (~> 3.0)
|
98
98
|
orm_adapter (~> 0.1)
|
@@ -247,7 +247,7 @@ GEM
|
|
247
247
|
sprockets (3.5.2)
|
248
248
|
concurrent-ruby (~> 1.0)
|
249
249
|
rack (> 1, < 3)
|
250
|
-
sprockets-rails (3.0.
|
250
|
+
sprockets-rails (3.0.3)
|
251
251
|
actionpack (>= 4.0)
|
252
252
|
activesupport (>= 4.0)
|
253
253
|
sprockets (>= 3.0.0)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Enjoy::Blocksetable
|
2
|
+
extend ActiveSupport::Concern
|
3
|
+
included do
|
4
|
+
helper_method :render_blockset
|
5
|
+
end
|
6
|
+
|
7
|
+
private
|
8
|
+
def render_blockset(view, type)
|
9
|
+
ret = []
|
10
|
+
begin
|
11
|
+
blocks = blockset_get_blocks(type)
|
12
|
+
blocks.each do |block|
|
13
|
+
ret << block.render_or_content_html(view)
|
14
|
+
end
|
15
|
+
rescue Exception => exception
|
16
|
+
Rails.logger.error exception.message
|
17
|
+
Rails.logger.error exception.backtrace.join("\n")
|
18
|
+
puts exception.message
|
19
|
+
puts exception.backtrace.join("\n")
|
20
|
+
capture_exception(exception) if respond_to?(:capture_exception)
|
21
|
+
# ret << blocks || []
|
22
|
+
end
|
23
|
+
ret.join.html_safe
|
24
|
+
end
|
25
|
+
|
26
|
+
def blockset_get_blocks(type)
|
27
|
+
blockset = blockset_class.find(type.to_s)
|
28
|
+
blockset.blocks.enabled.sorted.to_a if blockset
|
29
|
+
end
|
30
|
+
|
31
|
+
def blockset_class_name
|
32
|
+
"Enjoy::PageBlockset"
|
33
|
+
end
|
34
|
+
def blockset_class
|
35
|
+
blockset_class_name.constantize
|
36
|
+
end
|
37
|
+
end
|
@@ -6,7 +6,7 @@ if Enjoy.mongoid?
|
|
6
6
|
def enjoy_cms_html_field(name, opts = {})
|
7
7
|
clear_by_default = opts.delete(:clear_by_default)
|
8
8
|
clear_by_default = false unless clear_by_default == true
|
9
|
-
|
9
|
+
|
10
10
|
field "#{name}_html", opts
|
11
11
|
field "#{name}_clear", type: Boolean, default: clear_by_default
|
12
12
|
|
@@ -6,8 +6,10 @@ ruby:
|
|
6
6
|
customConfig: field.config_js ? field.config_js : field.base_location + "config.js"
|
7
7
|
}
|
8
8
|
}
|
9
|
-
=
|
9
|
+
_html_attributes = field.html_attributes.reverse_merge(data: { richtext: 'ckeditor', options: js_data.to_json, value: field.form_value[:html] })
|
10
|
+
= form.text_area field.html_method, _html_attributes
|
10
11
|
|
11
12
|
label{style='display: block;'}
|
12
|
-
|
13
|
+
- _html_attributes = field.html_attributes.reverse_merge({ value: field.form_value[:clear], checked: field.form_value[:clear].in?([true, '1']), required: false, class: "form-control"})
|
14
|
+
span{style='float: left'}= form.send field.boolean_view_helper, field.clear_method, _html_attributes
|
13
15
|
div{style='margin-left: 35px; line-height: 40px;'} Убирать теги
|
data/enjoy_cms.gemspec
CHANGED
data/lib/enjoy/admin/news.rb
CHANGED
@@ -19,6 +19,8 @@ module Enjoy
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
field :excerpt, :enjoy_html
|
22
|
+
# field :excerpt_html, :ck_editor
|
23
|
+
# field :excerpt_clear, :toggle
|
22
24
|
field :slugs, :enum do
|
23
25
|
enum_method do
|
24
26
|
:slugs
|
@@ -38,6 +40,8 @@ module Enjoy
|
|
38
40
|
|
39
41
|
edit do
|
40
42
|
field :content, :enjoy_html
|
43
|
+
# field :content_html, :ck_editor
|
44
|
+
# field :content_clear, :toggle
|
41
45
|
fields.each_pair do |name, type|
|
42
46
|
if type.nil?
|
43
47
|
field name
|
data/lib/enjoy/admin/page.rb
CHANGED
@@ -22,7 +22,11 @@ module Enjoy
|
|
22
22
|
edit do
|
23
23
|
field :name
|
24
24
|
field :excerpt, :enjoy_html
|
25
|
+
# field :excerpt_html, :ck_editor
|
26
|
+
# field :excerpt_clear, :toggle
|
25
27
|
field :content, :enjoy_html
|
28
|
+
# field :content_html, :ck_editor
|
29
|
+
# field :content_clear, :toggle
|
26
30
|
|
27
31
|
group :menu do
|
28
32
|
label I18n.t('enjoy.menu')
|
@@ -6,8 +6,13 @@ module Enjoy
|
|
6
6
|
# navigation_label 'CMS'
|
7
7
|
|
8
8
|
field :enabled, :toggle
|
9
|
+
field :partial, :toggle
|
9
10
|
field :name
|
11
|
+
field :file_path, :string
|
12
|
+
|
10
13
|
field :content, :enjoy_html
|
14
|
+
# field :content_html, :ck_editor
|
15
|
+
# field :content_clear, :toggle
|
11
16
|
|
12
17
|
fields.each_pair do |name, type|
|
13
18
|
if type.nil?
|
@@ -6,9 +6,9 @@ module Enjoy
|
|
6
6
|
# navigation_label 'CMS'
|
7
7
|
|
8
8
|
field :enabled, :toggle
|
9
|
+
field :text_slug
|
9
10
|
field :name
|
10
11
|
|
11
|
-
|
12
12
|
field :blocks
|
13
13
|
|
14
14
|
fields.each_pair do |name, type|
|
@@ -36,6 +36,12 @@ module Enjoy
|
|
36
36
|
# end
|
37
37
|
# end
|
38
38
|
|
39
|
+
sort_embedded(
|
40
|
+
{
|
41
|
+
fields: [:blocks]
|
42
|
+
}
|
43
|
+
)
|
44
|
+
|
39
45
|
if block_given?
|
40
46
|
yield self
|
41
47
|
end
|
data/lib/enjoy/controller.rb
CHANGED
@@ -7,6 +7,10 @@ module Enjoy
|
|
7
7
|
include Enjoy::HtmlField
|
8
8
|
|
9
9
|
included do
|
10
|
+
if defined?(RailsAdminComments)
|
11
|
+
include RailsAdminComments::Commentable
|
12
|
+
end
|
13
|
+
|
10
14
|
field :name, type: String, localize: Enjoy.config.localize, default: ""
|
11
15
|
|
12
16
|
field :regexp, type: String, default: ""
|
@@ -7,10 +7,49 @@ module Enjoy
|
|
7
7
|
include Enjoy::HtmlField
|
8
8
|
|
9
9
|
included do
|
10
|
-
|
10
|
+
field :file_path, type: String, localize: Enjoy.config.localize, default: ""
|
11
|
+
field :partial, type: Boolean, default: true
|
12
|
+
embedded_in :blockset, inverse_of: :blocks, class_name: "Enjoy::PageBlockset"
|
11
13
|
|
12
14
|
enjoy_cms_html_field :content, type: String, localize: Enjoy.config.localize, default: ""
|
13
15
|
end
|
16
|
+
|
17
|
+
def file_pathname_as_partial
|
18
|
+
self.file_pathname.dirname.join("_#{self.file_pathname.basename}")
|
19
|
+
end
|
20
|
+
|
21
|
+
def file_pathname_for_fs
|
22
|
+
self.partial ? self.file_path_as_partial : self.file_pathname
|
23
|
+
end
|
24
|
+
|
25
|
+
def render_or_content_html(view, opts = {})
|
26
|
+
unless self.file_path.blank?
|
27
|
+
opts.merge!(partial: self.file_path)
|
28
|
+
view.render(opts) rescue self.content_html.html_safe
|
29
|
+
else
|
30
|
+
self.content_html.html_safe
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def render_or_content(view, opts = {})
|
35
|
+
unless self.file_path.blank?
|
36
|
+
opts.merge!(partial: self.file_path)
|
37
|
+
view.render(opts) rescue self.content
|
38
|
+
else
|
39
|
+
self.content
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def file_fullpath(with_ext = false, ext = ".html.slim")
|
44
|
+
ret = nil
|
45
|
+
unless self.file_path.blank?
|
46
|
+
res_filename = self.file_pathname_for_fs.to_s
|
47
|
+
res_filename += ext if with_ext
|
48
|
+
ret = Rails.root.join("views", res_filename)
|
49
|
+
end
|
50
|
+
return ret
|
51
|
+
end
|
52
|
+
|
14
53
|
end
|
15
54
|
end
|
16
55
|
end
|
@@ -5,12 +5,14 @@ module Enjoy
|
|
5
5
|
extend ActiveSupport::Concern
|
6
6
|
|
7
7
|
included do
|
8
|
-
|
8
|
+
if defined?(RailsAdminComments)
|
9
|
+
include RailsAdminComments::Commentable
|
10
|
+
end
|
9
11
|
|
10
|
-
|
12
|
+
field :name, type: String, default: ""
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
embeds_many :blocks, inverse_of: :blockset, class_name: "Enjoy::PageBlock"
|
15
|
+
accepts_nested_attributes_for :blocks
|
14
16
|
end
|
15
17
|
end
|
16
18
|
end
|
@@ -6,6 +6,10 @@ module Enjoy
|
|
6
6
|
include Enjoy::MongoidPaperclip
|
7
7
|
included do
|
8
8
|
|
9
|
+
if defined?(RailsAdminComments)
|
10
|
+
include RailsAdminComments::Commentable
|
11
|
+
end
|
12
|
+
|
9
13
|
field :name, type: String, localize: Enjoy.config.localize
|
10
14
|
field :h1, type: String, localize: Enjoy.config.localize
|
11
15
|
|
@@ -28,7 +32,7 @@ module Enjoy
|
|
28
32
|
def og_image_convert_options
|
29
33
|
{}
|
30
34
|
end
|
31
|
-
|
35
|
+
|
32
36
|
end
|
33
37
|
end
|
34
38
|
end
|
@@ -3,8 +3,13 @@ module Enjoy
|
|
3
3
|
module Mongoid
|
4
4
|
module SitemapData
|
5
5
|
extend ActiveSupport::Concern
|
6
|
-
|
6
|
+
|
7
7
|
included do
|
8
|
+
|
9
|
+
if defined?(RailsAdminComments)
|
10
|
+
include RailsAdminComments::Commentable
|
11
|
+
end
|
12
|
+
|
8
13
|
field :sitemap_show, type: Boolean, default: true
|
9
14
|
field :sitemap_lastmod, type: DateTime
|
10
15
|
field :sitemap_changefreq, type: String, default: 'daily'
|
data/lib/enjoy/models/news.rb
CHANGED
@@ -6,6 +6,16 @@ module Enjoy
|
|
6
6
|
include Enjoy.orm_specific('PageBlock')
|
7
7
|
|
8
8
|
included do
|
9
|
+
validates :file_path, format: {
|
10
|
+
# with: /\A(?!layouts\/).*\Z/,
|
11
|
+
without: /\Alayouts\/.*\Z/,
|
12
|
+
message: "Недопустимый путь к файлу"
|
13
|
+
}
|
14
|
+
|
15
|
+
attr_accessor :file_pathname
|
16
|
+
after_initialize do
|
17
|
+
self.file_pathname = Pathname.new(file_path) unless file_path.nil?
|
18
|
+
end
|
9
19
|
end
|
10
20
|
end
|
11
21
|
end
|
@@ -4,11 +4,21 @@ module Enjoy
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
include Enjoy::Model
|
6
6
|
include Enjoy::Enableable
|
7
|
+
include ManualSlug
|
7
8
|
|
8
9
|
include Enjoy.orm_specific('PageBlockset')
|
9
10
|
|
10
11
|
included do
|
12
|
+
manual_slug :name
|
13
|
+
|
14
|
+
# after_save do
|
15
|
+
# Rails.cache.delete 'blocksets'
|
16
|
+
# end
|
17
|
+
# after_destroy do
|
18
|
+
# Rails.cache.delete 'blocksets'
|
19
|
+
# end
|
11
20
|
end
|
21
|
+
|
12
22
|
end
|
13
23
|
end
|
14
24
|
end
|
@@ -7,17 +7,26 @@ module RailsAdmin
|
|
7
7
|
RailsAdmin::Config::Fields::Types::register(self)
|
8
8
|
include RailsAdmin::Engine.routes.url_helpers
|
9
9
|
|
10
|
+
register_instance_option :html_method do
|
11
|
+
"#{name}_html"
|
12
|
+
end
|
13
|
+
|
14
|
+
register_instance_option :clear_method do
|
15
|
+
"#{name}_clear"
|
16
|
+
end
|
17
|
+
|
10
18
|
register_instance_option :pretty_value do
|
11
|
-
bindings[:object].send(
|
19
|
+
bindings[:object].send(html_method)
|
12
20
|
end
|
13
21
|
|
14
22
|
register_instance_option :form_value do
|
15
23
|
{
|
16
|
-
html: bindings[:object].send(
|
17
|
-
clear: bindings[:object].send(
|
24
|
+
html: bindings[:object].send(html_method),
|
25
|
+
clear: bindings[:object].send(clear_method)
|
18
26
|
}
|
19
27
|
end
|
20
28
|
|
29
|
+
|
21
30
|
register_instance_option :formatted_value do
|
22
31
|
pretty_value
|
23
32
|
end
|
@@ -25,11 +34,16 @@ module RailsAdmin
|
|
25
34
|
register_instance_option :export_value do
|
26
35
|
pretty_value
|
27
36
|
end
|
37
|
+
|
28
38
|
|
29
39
|
register_instance_option :boolean_view_helper do
|
30
40
|
:check_box
|
31
41
|
end
|
32
42
|
|
43
|
+
register_instance_option :allowed_methods do
|
44
|
+
[html_method, clear_method]
|
45
|
+
end
|
46
|
+
|
33
47
|
register_instance_option :partial do
|
34
48
|
:enjoy_html
|
35
49
|
end
|
data/lib/enjoy/version.rb
CHANGED
data/template.rb
CHANGED
@@ -22,7 +22,7 @@ gem 'sass-rails'
|
|
22
22
|
gem 'compass-rails'
|
23
23
|
gem 'compass'
|
24
24
|
|
25
|
-
#{if mongoid then "gem 'enjoy_cms_mongoid'" else "gem 'enjoy_cms_activerecord'" end}, '~> 0.3.
|
25
|
+
#{if mongoid then "gem 'enjoy_cms_mongoid'" else "gem 'enjoy_cms_activerecord'" end}, '~> 0.3.1'
|
26
26
|
|
27
27
|
gem 'devise'
|
28
28
|
|
@@ -74,7 +74,6 @@ end
|
|
74
74
|
gem 'slim'
|
75
75
|
gem 'sprockets'
|
76
76
|
|
77
|
-
|
78
77
|
gem 'sitemap_generator'
|
79
78
|
gem 'rails_admin_sitemap'
|
80
79
|
|
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.3.
|
4
|
+
version: 0.3.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-02-
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -455,6 +455,7 @@ files:
|
|
455
455
|
- app/assets/stylesheets/enjoy_cms/flash.sass
|
456
456
|
- app/assets/stylesheets/enjoy_cms/normalize.scss
|
457
457
|
- app/assets/stylesheets/enjoy_cms/powered.sass
|
458
|
+
- app/controllers/concerns/enjoy/blocksetable.rb
|
458
459
|
- app/controllers/concerns/enjoy/decorators/contacts.rb
|
459
460
|
- app/controllers/concerns/enjoy/decorators/home.rb
|
460
461
|
- app/controllers/concerns/enjoy/decorators/news.rb
|