populate-me 0.18.0 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/populate_me/admin/__assets__/css/asmselect.css +6 -0
- data/lib/populate_me/admin/__assets__/css/main.css +27 -17
- data/lib/populate_me/admin/__assets__/js/asmselect.js +11 -0
- data/lib/populate_me/admin/views/page.erb +20 -15
- data/lib/populate_me/document_mixins/admin_adapter.rb +11 -1
- data/lib/populate_me/document_mixins/schema.rb +10 -2
- data/lib/populate_me/version.rb +1 -1
- data/populate-me.gemspec +1 -1
- data/test/test_document_schema.rb +22 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5df767f90ac00a4c7d0ba71fcecde372cf97d5be50bc15ae658765a4ec824ad
|
4
|
+
data.tar.gz: 7a7d5bb403a9ed932a39efa5b7aa83060536ba3c0a49dba59a6e8b4faef46171
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3050513b41fc1ed44b6e43157fe7f77dd16f03e210e9b4207ce6e691f72508cb4cc9eb95280a63951cf2769c7a1cc597a66ebaf4f253fb9537919a99e6fb3853
|
7
|
+
data.tar.gz: 6412fb04a742195c9ae4e77c085fe16d27b4412760e455b958aa3fefa954149b3d0dce1da393bd6f0480671eb3c166e4409e7da06b563e68865780591fcb57d4
|
@@ -44,6 +44,12 @@
|
|
44
44
|
background-color: #e5e5e5;
|
45
45
|
}
|
46
46
|
|
47
|
+
.asmListItemPreview {
|
48
|
+
height: 3em;
|
49
|
+
display: inline-block;
|
50
|
+
margin-right: 1em;
|
51
|
+
}
|
52
|
+
|
47
53
|
.asmListItemLabel {
|
48
54
|
/* this is a span that surrounds the text in the item, except for the remove link */
|
49
55
|
padding: 5px;
|
@@ -4,13 +4,13 @@ html, body {
|
|
4
4
|
margin: 0;
|
5
5
|
padding: 0;
|
6
6
|
color: #002b36;
|
7
|
-
background-color: #
|
7
|
+
background-color: #ffffff;
|
8
8
|
height: 100%;
|
9
9
|
font-family: 'Avenir', sans-serif;
|
10
10
|
}
|
11
11
|
|
12
12
|
body {
|
13
|
-
line-height: 1.
|
13
|
+
line-height: 1.5;
|
14
14
|
}
|
15
15
|
|
16
16
|
#finder {
|
@@ -18,11 +18,12 @@ body {
|
|
18
18
|
}
|
19
19
|
|
20
20
|
.column {
|
21
|
-
|
21
|
+
position: relative;
|
22
|
+
background: #eeeeee;
|
22
23
|
height: 100%;
|
23
24
|
min-width: 250px;
|
24
25
|
overflow: auto;
|
25
|
-
box-shadow: 0px 0px 10px #
|
26
|
+
box-shadow: 0px 0px 10px #555555;
|
26
27
|
}
|
27
28
|
|
28
29
|
.column > h1, .column > ol,
|
@@ -63,6 +64,16 @@ body {
|
|
63
64
|
border: 1px solid #002b36;
|
64
65
|
}
|
65
66
|
|
67
|
+
.column > footer.main-footer {
|
68
|
+
position: absolute;
|
69
|
+
left: 0;
|
70
|
+
bottom: 0;
|
71
|
+
width: 100%;
|
72
|
+
font-size: 0.5em;
|
73
|
+
padding: 20px;
|
74
|
+
box-sizing: border-box;
|
75
|
+
}
|
76
|
+
|
66
77
|
ol {
|
67
78
|
list-style: none;
|
68
79
|
margin: 0;
|
@@ -75,10 +86,7 @@ a {
|
|
75
86
|
/* border-bottom: 1px solid #002b36; */
|
76
87
|
}
|
77
88
|
a:hover, a.selected {
|
78
|
-
/* Blue */
|
79
89
|
color: #268bd2;
|
80
|
-
/* Green/Blue */
|
81
|
-
/* color: #2aa198; */
|
82
90
|
}
|
83
91
|
|
84
92
|
button { cursor: pointer; }
|
@@ -116,7 +124,7 @@ button.admin-delete:focus, button.admin-delete-nested:focus, .handle-button:focu
|
|
116
124
|
cursor: -webkit-grab;
|
117
125
|
cursor: grab;
|
118
126
|
}
|
119
|
-
.handle:active {
|
127
|
+
.handle:active {
|
120
128
|
cursor: -moz-grabbing;
|
121
129
|
cursor: -webkit-grabbing;
|
122
130
|
cursor: grabbing;
|
@@ -125,7 +133,7 @@ button.admin-delete:focus, button.admin-delete-nested:focus, .handle-button:focu
|
|
125
133
|
[type=submit] {
|
126
134
|
border: 0px;
|
127
135
|
cursor: pointer;
|
128
|
-
color: #
|
136
|
+
color: #ffffff;
|
129
137
|
background-color: #859900;
|
130
138
|
}
|
131
139
|
[type=submit]:hover {
|
@@ -141,11 +149,12 @@ button.admin-delete:focus, button.admin-delete-nested:focus, .handle-button:focu
|
|
141
149
|
user-select: none;
|
142
150
|
}
|
143
151
|
.documents.grid {
|
144
|
-
width:
|
152
|
+
width: 80%; width: 80vw;
|
145
153
|
}
|
146
154
|
.documents > li, .nested-documents > li {
|
147
155
|
display: block;
|
148
156
|
margin-bottom: 1em;
|
157
|
+
border-top: 1px solid #dddddd;
|
149
158
|
}
|
150
159
|
.documents.grid > li {
|
151
160
|
display: inline-block;
|
@@ -160,8 +169,8 @@ button.admin-delete:focus, button.admin-delete-nested:focus, .handle-button:focu
|
|
160
169
|
width: 200px;
|
161
170
|
}
|
162
171
|
.documents > li:hover, .nested-documents > li:hover {
|
163
|
-
background-color: #
|
164
|
-
outline: 0.5em solid #
|
172
|
+
background-color: #dddddd;
|
173
|
+
outline: 0.5em solid #dddddd;
|
165
174
|
}
|
166
175
|
.nested-documents > li > header {
|
167
176
|
background: #002b36;
|
@@ -172,7 +181,7 @@ button.admin-delete:focus, button.admin-delete-nested:focus, .handle-button:focu
|
|
172
181
|
border: 1px dashed #839496;
|
173
182
|
background-color: #eee8d5;
|
174
183
|
}
|
175
|
-
.local-menu { font-size: 0.
|
184
|
+
.local-menu { font-size: 0.8em; margin-top: 0.5em; }
|
176
185
|
|
177
186
|
/* Forms */
|
178
187
|
|
@@ -187,7 +196,7 @@ form {
|
|
187
196
|
input[type=text], input[type=email], input[type=search],
|
188
197
|
textarea {
|
189
198
|
border: 0px;
|
190
|
-
color: #
|
199
|
+
color: #555555;
|
191
200
|
background-color: #ffffff;
|
192
201
|
width: 400px;
|
193
202
|
padding: 0.5em;
|
@@ -202,8 +211,9 @@ textarea:focus {
|
|
202
211
|
/* color: #002b36; */
|
203
212
|
}
|
204
213
|
|
205
|
-
textarea { height:
|
214
|
+
textarea { height: 4em; resize: vertical; transition: 0.2s; }
|
206
215
|
textarea.oneline { height: 1em; resize: none; }
|
216
|
+
textarea:focus { height: 50vh; }
|
207
217
|
|
208
218
|
fieldset {
|
209
219
|
border: 0;
|
@@ -226,9 +236,9 @@ fieldset {
|
|
226
236
|
|
227
237
|
.asmListItem {
|
228
238
|
background-color: #ffffff;
|
229
|
-
border: 1px solid #
|
239
|
+
border: 1px solid #eeeeee;
|
230
240
|
}
|
231
|
-
.asmListItem:hover { background-color: #
|
241
|
+
.asmListItem:hover { background-color: #dddddd; }
|
232
242
|
.asmListItemLabel { padding-right: 2em; }
|
233
243
|
.asmListSortable .asmListItemLabel {
|
234
244
|
cursor: move;
|
@@ -263,6 +263,17 @@
|
|
263
263
|
.addClass(options.listItemLabelClass)
|
264
264
|
.html($O.html());
|
265
265
|
|
266
|
+
if ( $O.data('preview') ) {
|
267
|
+
|
268
|
+
var $itemPreview = $("<img/>")
|
269
|
+
.attr("alt", '')
|
270
|
+
.attr("src", $O.data('preview'))
|
271
|
+
.addClass('asmListItemPreview');
|
272
|
+
|
273
|
+
$itemLabel.prepend($itemPreview);
|
274
|
+
|
275
|
+
}
|
276
|
+
|
266
277
|
var $item = $("<li></li>")
|
267
278
|
.attr('rel', optionId)
|
268
279
|
.addClass(options.listItemClass)
|
@@ -19,6 +19,9 @@
|
|
19
19
|
<% if settings.logout_path? %>
|
20
20
|
<p><a href="<%= request.script_name %><%= settings.logout_path %>">Logout</a></p>
|
21
21
|
<% end %>
|
22
|
+
<footer class='main-footer'>
|
23
|
+
Populate Me is Content Managment System for premium design-led websites coded by <a href="https://www.rive.studio" target="_blank">Rive Studio</a>.<br/>© <%= Time.now.year %> Mickaël Riga
|
24
|
+
</footer>
|
22
25
|
</li></ol>
|
23
26
|
|
24
27
|
<!-- Templates -->
|
@@ -61,21 +64,23 @@
|
|
61
64
|
|
62
65
|
<script id="template-document" type="x-tmpl-mustache">
|
63
66
|
<li class='admin-list-item' data-id='{{id}}'>
|
64
|
-
<
|
65
|
-
<
|
66
|
-
|
67
|
-
|
68
|
-
<
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
67
|
+
<div class="{{#sort_field}}handle{{/sort_field}}" title='{{#sort_field}}Drag and drop{{/sort_field}}'>
|
68
|
+
<header>
|
69
|
+
<button type='button' class='admin-delete' title='Delete' value='<%= request.script_name %>/api/{{admin_url}}'>×</button>
|
70
|
+
</header>
|
71
|
+
<a href="<%= request.script_name %>/form/{{admin_url}}" class='column-push' title='Edit'>
|
72
|
+
<span class='item-title'>{{title}}</span>
|
73
|
+
{{#image_url}}
|
74
|
+
<br />
|
75
|
+
<img src='{{image_url}}{{cache_buster}}' alt='{{title}}' width='300' />
|
76
|
+
{{/image_url}}
|
77
|
+
</a>
|
78
|
+
<ol class='local-menu'>
|
79
|
+
{{#local_menu}}
|
80
|
+
<li>→ <a href="{{href}}" {{#new_page}}target='_blank'{{/new_page}}{{^new_page}}class='column-push'{{/new_page}} title='Open'>{{title}}</a></li>
|
81
|
+
{{/local_menu}}
|
82
|
+
</ol>
|
83
|
+
</div>
|
79
84
|
</li>
|
80
85
|
</script>
|
81
86
|
|
@@ -92,7 +92,17 @@ module PopulateMe
|
|
92
92
|
|
93
93
|
def admin_find o={}
|
94
94
|
o[:query] ||= {}
|
95
|
-
docs = self.cast
|
95
|
+
docs = self.cast do
|
96
|
+
if o.key?( :fields )
|
97
|
+
documents.map do |h|
|
98
|
+
h.select do |k,v|
|
99
|
+
o[:fields].map(&:to_s).include?( k )
|
100
|
+
end
|
101
|
+
end
|
102
|
+
else
|
103
|
+
documents
|
104
|
+
end
|
105
|
+
end.find_all do |d|
|
96
106
|
o[:query].inject(true) do |out,(k,v)|
|
97
107
|
out && (d.__send__(k)==v)
|
98
108
|
end
|
@@ -165,11 +165,19 @@ module PopulateMe
|
|
165
165
|
end
|
166
166
|
end
|
167
167
|
|
168
|
+
def default_select_fields
|
169
|
+
[
|
170
|
+
self.id_string_key,
|
171
|
+
self.label_field,
|
172
|
+
self.admin_image_field,
|
173
|
+
].compact.uniq
|
174
|
+
end
|
175
|
+
|
168
176
|
def to_select_options o={}
|
169
177
|
proc do
|
170
178
|
items = self.admin_find({
|
171
|
-
query: (o[:query]||{}),
|
172
|
-
fields: [
|
179
|
+
query: ( o[:query] || {} ),
|
180
|
+
fields: ( o[:fields] || default_select_fields ),
|
173
181
|
})
|
174
182
|
output = items.sort_by do |i|
|
175
183
|
i.to_s.downcase
|
data/lib/populate_me/version.rb
CHANGED
data/populate-me.gemspec
CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |s|
|
|
25
25
|
s.add_development_dependency 'minitest', '~> 5.8'
|
26
26
|
s.add_development_dependency 'rack-test', '~> 0.6'
|
27
27
|
s.add_development_dependency 'rack-cerberus', '~> 1.0'
|
28
|
-
s.add_development_dependency 'mongo', '~> 2.
|
28
|
+
s.add_development_dependency 'mongo', '~> 2.17'
|
29
29
|
s.add_development_dependency 'rack-grid-serve', '~> 0.0.8'
|
30
30
|
s.add_development_dependency 'aws-sdk-s3', '~> 1'
|
31
31
|
s.add_development_dependency 'racksh', '~> 1.0'
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'helper'
|
2
|
+
require 'web_utils'
|
2
3
|
require 'populate_me/document'
|
3
4
|
require 'populate_me/attachment'
|
4
5
|
|
@@ -114,6 +115,14 @@ describe PopulateMe::Document, 'Schema' do
|
|
114
115
|
]
|
115
116
|
end
|
116
117
|
|
118
|
+
class SelectWithMoreFields < PopulateMe::Document
|
119
|
+
field :name
|
120
|
+
field :parent_name
|
121
|
+
def to_s
|
122
|
+
WebUtils.blank?(self.parent_name) ? self.name : "#{ self.parent_name } / #{ self.name }"
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
117
126
|
before do
|
118
127
|
Selectoptionable.documents = []
|
119
128
|
Selectoptionable.new(id: '1', name: 'Joe', slug: 'joe').save
|
@@ -122,10 +131,14 @@ describe PopulateMe::Document, 'Schema' do
|
|
122
131
|
Selectoptionable.new(id: '4', name: 'Averell', slug: 'averell').save
|
123
132
|
Selectpreviewable.documents = []
|
124
133
|
Selectpreviewable.new(id: '1', name: 'Project', img: 'project.jpg').save
|
134
|
+
SelectWithMoreFields.documents = []
|
135
|
+
SelectWithMoreFields.new(id: '1', name: 'Product', parent_name: 'Collection').save
|
125
136
|
end
|
126
137
|
|
127
138
|
after do
|
128
139
|
Selectoptionable.documents = []
|
140
|
+
Selectpreviewable.documents = []
|
141
|
+
SelectWithMoreFields.documents = []
|
129
142
|
end
|
130
143
|
|
131
144
|
it 'Formats all items for a select_options' do
|
@@ -156,6 +169,15 @@ describe PopulateMe::Document, 'Schema' do
|
|
156
169
|
assert_equal '/attachment/selectpreviewable/project.populate_me_thumb.jpg', output[0][:preview_uri]
|
157
170
|
end
|
158
171
|
|
172
|
+
it 'Adds fields to query if option is passed' do
|
173
|
+
output = SelectWithMoreFields.to_select_options.call
|
174
|
+
assert_equal 'Product', output[0][:description]
|
175
|
+
output = SelectWithMoreFields.to_select_options({
|
176
|
+
fields: SelectWithMoreFields.default_select_fields + [:parent_name],
|
177
|
+
}).call
|
178
|
+
assert_equal 'Collection / Product', output[0][:description]
|
179
|
+
end
|
180
|
+
|
159
181
|
end
|
160
182
|
|
161
183
|
describe 'Polymorphism' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: populate-me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.19.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mickael Riga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: web-utils
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: '2.
|
117
|
+
version: '2.17'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: '2.
|
124
|
+
version: '2.17'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: rack-grid-serve
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|