enjoy_cms 0.3.2 → 0.3.2.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/config/initializers/embedded_findable.rb +57 -0
- data/lib/enjoy/admin/news.rb +1 -1
- data/lib/enjoy/version.rb +1 -1
- data/lib/enjoy_cms.rb +1 -0
- data/lib/generators/enjoy/templates/admin.erb +6 -0
- data/template.rb +3 -64
- 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: 354d416d79c06e6aa4f9c6d253612da52463bb6e
|
4
|
+
data.tar.gz: 7043ba2b10c631495778dcd34c393af32591ef30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec5259f872d9eca07687544b85bf60ed5eceb53a0afc98b530f8c94d6978d64fdddf909420eb0c903b81b57bdffc628455bdc37d4ac063fab6cc3899889a5898
|
7
|
+
data.tar.gz: 01b88b44db165280794b8fb991a382df8df0718ac067ddc76a11ffb92d5cb270ac04b6c4655f170232454098c468d699733cbe617d9bb55f58c07cda93b8af5e
|
data/Gemfile.lock
CHANGED
@@ -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
|
data/lib/enjoy/admin/news.rb
CHANGED
data/lib/enjoy/version.rb
CHANGED
data/lib/enjoy_cms.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.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-
|
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
|