enjoy_cms 0.3.2 → 0.3.2.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: e33a4e7ad3766cc568450aa9727d67007767e578
4
- data.tar.gz: 5b1163592a2342e6909390363095a0cd94766e8a
3
+ metadata.gz: 354d416d79c06e6aa4f9c6d253612da52463bb6e
4
+ data.tar.gz: 7043ba2b10c631495778dcd34c393af32591ef30
5
5
  SHA512:
6
- metadata.gz: 716b95fed34f32026ebe624807e5fca67c89e94dbc58fe4cf46ee1f29cc93576f0cfb63879989216e240073502605df41f2095baeb06aee772747471bda3593a
7
- data.tar.gz: 2c89eea1c204394f1bc0321e830bde1936bca3e274fae3c31145799d2deed2b7441641ab490e45fb89fa46a63c948930552ead100ebbee82a3b2bd41b5cb306a
6
+ metadata.gz: ec5259f872d9eca07687544b85bf60ed5eceb53a0afc98b530f8c94d6978d64fdddf909420eb0c903b81b57bdffc628455bdc37d4ac063fab6cc3899889a5898
7
+ data.tar.gz: 01b88b44db165280794b8fb991a382df8df0718ac067ddc76a11ffb92d5cb270ac04b6c4655f170232454098c468d699733cbe617d9bb55f58c07cda93b8af5e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- enjoy_cms (0.3.2)
4
+ enjoy_cms (0.3.2.1)
5
5
  ack_rails_admin_jcrop
6
6
  addressable
7
7
  ckeditor
@@ -0,0 +1,57 @@
1
+ if defined?(Mongoid)
2
+
3
+ module Mongoid
4
+
5
+ # Helps to override find method in an embedded document.
6
+ # Usage :
7
+ # - add to your model "include Mongoid::EmbeddedFindable"
8
+ # - override find method with:
9
+ # def self.find(id)
10
+ # find_through(Book, 'chapter', id)
11
+ # end
12
+ module EmbeddedFindable
13
+
14
+ extend ActiveSupport::Concern
15
+
16
+ included do
17
+
18
+ # Search an embedded document by id.
19
+ #
20
+ # Document is stored within embedding_class collection, and can be accessed through provided relation.
21
+ # Also supports chained relationships (if the searched document is nested in several embedded documents)
22
+ #
23
+ # Example, with a chapter embedded in a book, the book being embedded in a library.
24
+ # use find_through(Library, "books", book_id) in Book class
25
+ # and find_through(Library, "books.chapters", chapter_id) in Chapter class
26
+ def self.find_through(embedding_class, relation, id = nil)
27
+ return nil if id.nil? || id.blank?
28
+
29
+ id = BSON::ObjectId.from_string(id) if id.is_a?(String)
30
+ relation = relation.to_s unless relation.is_a?(String)
31
+
32
+ relation_parts = relation.split('.')
33
+ parent = embedding_class.send(:all)
34
+
35
+ while relation_parts.length > 0
36
+ item = if parent.is_a?(Mongoid::Criteria) || parent.is_a?(Array)
37
+ parent.where("#{relation_parts.join('.')}._id" => id).first
38
+ else
39
+ parent
40
+ end
41
+ return nil if item.nil?
42
+ parent = item.send(relation_parts.shift)
43
+ end
44
+
45
+ if parent.is_a?(Mongoid::Criteria) || parent.is_a?(Array)
46
+ parent.where('_id' => id).first
47
+ else
48
+ parent
49
+ end
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
57
+ end
@@ -45,7 +45,7 @@ module Enjoy
45
45
  end
46
46
 
47
47
  edit do
48
- group :text do
48
+ group :content do
49
49
  active false
50
50
  field :content, :enjoy_html
51
51
  # field :content_html, :ck_editor
data/lib/enjoy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Enjoy
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.2.1"
3
3
  end
data/lib/enjoy_cms.rb CHANGED
@@ -17,6 +17,7 @@ require 'rails_admin'
17
17
  require 'rails_admin_nested_set'
18
18
  require 'rails_admin_toggleable'
19
19
  # require 'rails_admin_settings'
20
+ require 'rails_admin_sort_embedded'
20
21
 
21
22
  require 'x-real-ip'
22
23
 
@@ -53,6 +53,12 @@ RailsAdmin.config do |config|
53
53
  end
54
54
  end
55
55
 
56
+ sort_embedded do
57
+ visible do
58
+ ['Enjoy::PageBlockset'].include? bindings[:abstract_model].model_name
59
+ end
60
+ end
61
+
56
62
  toggle
57
63
  toggle_menu do
58
64
  visible do
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.1'
25
+ #{if mongoid then "gem 'enjoy_cms_mongoid'" else "gem 'enjoy_cms_activerecord'" end}, '~> 0.3.2'
26
26
 
27
27
  gem 'devise'
28
28
 
@@ -111,67 +111,6 @@ end
111
111
 
112
112
  create_file 'extra/.gitkeep', ''
113
113
 
114
- if mongoid
115
- remove_file 'config/initializers/embedded_findable.rb'
116
- create_file 'config/initializers/embedded_findable.rb' do <<-TEXT
117
- module Mongoid
118
-
119
- # Helps to override find method in an embedded document.
120
- # Usage :
121
- # - add to your model "include Mongoid::EmbeddedFindable"
122
- # - override find method with:
123
- # def self.find(id)
124
- # find_through(Book, 'chapter', id)
125
- # end
126
- module EmbeddedFindable
127
-
128
- extend ActiveSupport::Concern
129
-
130
- included do
131
-
132
- # Search an embedded document by id.
133
- #
134
- # Document is stored within embedding_class collection, and can be accessed through provided relation.
135
- # Also supports chained relationships (if the searched document is nested in several embedded documents)
136
- #
137
- # Example, with a chapter embedded in a book, the book being embedded in a library.
138
- # use find_through(Library, "books", book_id) in Book class
139
- # and find_through(Library, "books.chapters", chapter_id) in Chapter class
140
- def self.find_through(embedding_class, relation, id = nil)
141
- return nil if id.nil? || id.blank?
142
-
143
- id = BSON::ObjectId.from_string(id) if id.is_a?(String)
144
- relation = relation.to_s unless relation.is_a?(String)
145
-
146
- relation_parts = relation.split('.')
147
- parent = embedding_class.send(:all)
148
-
149
- while relation_parts.length > 0
150
- item = if parent.is_a?(Mongoid::Criteria) || parent.is_a?(Array)
151
- parent.where("\#{relation_parts.join('.')}._id" => id).first
152
- else
153
- parent
154
- end
155
- return nil if item.nil?
156
- parent = item.send(relation_parts.shift)
157
- end
158
-
159
- if parent.is_a?(Mongoid::Criteria) || parent.is_a?(Array)
160
- parent.where('_id' => id).first
161
- else
162
- parent
163
- end
164
- end
165
-
166
- end
167
-
168
- end
169
-
170
- end
171
- TEXT
172
- end
173
- end
174
-
175
114
  if mongoid
176
115
  remove_file 'config/initializers/cookies_serializer.rb'
177
116
  create_file 'config/initializers/cookies_serializer.rb' do <<-TEXT
@@ -196,8 +135,8 @@ Rails.application.config.session_store :mongoid_store
196
135
  end
197
136
  end
198
137
 
199
- remove_file 'paperclip_optimizer.rb'
200
- create_file 'paperclip_optimizer.rb' do <<-TEXT
138
+ remove_file 'config/initializers/paperclip_optimizer.rb'
139
+ create_file 'config/initializers/paperclip_optimizer.rb' do <<-TEXT
201
140
  # Set global optimisation options for all Paperclip models
202
141
 
203
142
  # By default, image_optim enables all the compression binaries it supports and
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.2
4
+ version: 0.3.2.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-03-01 00:00:00.000000000 Z
11
+ date: 2016-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -502,6 +502,7 @@ files:
502
502
  - app/views/shared/_obj.html.slim
503
503
  - app/views/shared/_og.html.slim
504
504
  - app/views/simple_captcha/_simple_captcha.html.slim
505
+ - config/initializers/embedded_findable.rb
505
506
  - config/initializers/simple_captcha.rb
506
507
  - config/locales/en.enjoy.yml
507
508
  - config/locales/en.enjoy_admin.yml