populate-me 0.8.0 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +2 -2
- data/example/config.ru +2 -0
- data/lib/populate_me/admin/__assets__/css/main.css +26 -1
- data/lib/populate_me/admin/__assets__/img/help/children.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/create.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/delete.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/edit.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/form.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/list.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/login.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/logout.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/menu.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/overview.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/save.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/sort.png +0 -0
- data/lib/populate_me/admin/__assets__/img/help/sublist.png +0 -0
- data/lib/populate_me/admin/__assets__/js/main.js +6 -0
- data/lib/populate_me/admin/views/help.erb +94 -0
- data/lib/populate_me/admin.rb +14 -0
- data/lib/populate_me/document_mixins/typecasting.rb +2 -0
- data/lib/populate_me/version.rb +1 -1
- data/test/test_admin.rb +13 -1
- data/test/test_document_typecasting.rb +2 -4
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '0283a1cacc163b401b90985ec0f9b2d177d86aec6a7c094e41d8d61dfa6d9829'
|
4
|
+
data.tar.gz: 594e28fef86081fb4fff4cf154eeff4d63a666401d010b9b6d013daaf8fd0ab3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '09fa1e58ddd25356a2f120d3be27cd0f1d9866a4c253b9e5a57e111b3abd725df4c946e8ca1891bd91e0fc0481cdcdaba5c9d8d002f9274dfda5e8b82dd95345'
|
7
|
+
data.tar.gz: 4a20550f6d4ab9861723b9e571a632419b0d6fc08586be5e73fb321b410fdc01d69f7d92971dab6146ed83a2a099f6ec2357747fbf111eb74332a2c532a82709
|
data/README.md
CHANGED
@@ -190,8 +190,8 @@ a method instead of a block.
|
|
190
190
|
|
191
191
|
The list of hooks is quite common but here it is as a reminder:
|
192
192
|
|
193
|
-
- `before :
|
194
|
-
- `after :
|
193
|
+
- `before :validate`
|
194
|
+
- `after :validate`
|
195
195
|
- `before :create`
|
196
196
|
- `after :create`
|
197
197
|
- `before :update`
|
data/example/config.ru
CHANGED
@@ -36,6 +36,8 @@ class BlogPost < PopulateMe::Document
|
|
36
36
|
field :content, type: :text
|
37
37
|
field :authors, type: :list
|
38
38
|
field :published, type: :boolean
|
39
|
+
field :date_now, type: :date, input_attributes: {type: :date}
|
40
|
+
field :datetime_now, type: :datetime, input_attributes: {type: :datetime}
|
39
41
|
relationship :comments
|
40
42
|
def validate
|
41
43
|
error_on(:content,'Cannot be blank') if WebUtils.blank?(self.content)
|
@@ -31,13 +31,38 @@ body {
|
|
31
31
|
margin-right: 20px;
|
32
32
|
}
|
33
33
|
|
34
|
-
.column > h1
|
34
|
+
.column > h1,
|
35
|
+
.column > .text-page h1 {
|
35
36
|
font-size: 1.5em;
|
36
37
|
font-weight: normal;
|
37
38
|
margin-top: 1em;
|
38
39
|
margin-bottom: 1.5em;
|
39
40
|
}
|
40
41
|
|
42
|
+
.column > .text-page {
|
43
|
+
padding: 0 20px 20px 20px;
|
44
|
+
overflow: hidden;
|
45
|
+
width: 50%; width: 50vw;
|
46
|
+
max-width: 600px;
|
47
|
+
background-color: #ffffff;
|
48
|
+
}
|
49
|
+
.column > .text-page h2 {
|
50
|
+
font-size: 1.5em;
|
51
|
+
}
|
52
|
+
.column > .text-page img {
|
53
|
+
width: 100%;
|
54
|
+
}
|
55
|
+
.column > .text-page a {
|
56
|
+
color: #268bd2;
|
57
|
+
}
|
58
|
+
.column > .text-page a:hover {
|
59
|
+
text-decoration: underline;
|
60
|
+
}
|
61
|
+
.column > .text-page .frame {
|
62
|
+
padding: 1em;
|
63
|
+
border: 1px solid #002b36;
|
64
|
+
}
|
65
|
+
|
41
66
|
ol {
|
42
67
|
list-style: none;
|
43
68
|
margin: 0;
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -202,6 +202,12 @@ PopulateMe.init_column = function(c) {
|
|
202
202
|
link.attr('href', PopulateMe.update_query_parameter(link.attr('href'), 'data[polymorphic_type]', $this.val()));
|
203
203
|
}).change();
|
204
204
|
|
205
|
+
// Warning when date input not supported
|
206
|
+
var dateFields = $('[type="date"]', c);
|
207
|
+
if ( dateFields.size()>0 && dateFields.prop('type') != 'date' ) {
|
208
|
+
alert('Your browser does not support date fields. You will have to enter dates manually. If you want a better experience and have a date picker, use a modern browser like Chrome.');
|
209
|
+
}
|
210
|
+
|
205
211
|
// Possible callback from custom javascript file.
|
206
212
|
// If you need to do something on init_column,
|
207
213
|
// create this callback.
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<div class='text-page'>
|
2
|
+
|
3
|
+
<h1>Help</h1>
|
4
|
+
|
5
|
+
<h2>Overview</h2>
|
6
|
+
|
7
|
+
<p>The screen is divided in columns and expands on the right as you go further down the hierarchy, a little bit like a file explorer. </p>
|
8
|
+
|
9
|
+
<%= help_img 'Overview', 'overview.png' %>
|
10
|
+
|
11
|
+
<p>The very first column displays your login name (e.g. admin). At the bottom you have a "Logout" button so that you can securely finish your working session.</p>
|
12
|
+
|
13
|
+
<%= help_img 'Logout', 'logout.png' %>
|
14
|
+
|
15
|
+
<p>And then the second column is your starting point which represents as close as possible the sections of your website.</p>
|
16
|
+
|
17
|
+
<%= help_img 'Menu', 'menu.png' %>
|
18
|
+
|
19
|
+
<p>The item you've selected is always blue in order to show you the path you've been through, again like a file explorer.</p>
|
20
|
+
|
21
|
+
<%= help_img 'Subist', 'sublist.png' %>
|
22
|
+
|
23
|
+
<h2>List pages</h2>
|
24
|
+
|
25
|
+
<p>When you have reached a column like the last one on this image, it is a list page.</p>
|
26
|
+
|
27
|
+
<%= help_img 'List', 'list.png' %>
|
28
|
+
|
29
|
+
<p>This can be a list of blog articles, a list of images or a list of contact details. The presentation will always be similar. You will see a relevant title, a relevant image (if there is one), and buttons for actions.If you click the title of the item you'll be able to edit the information of this item.</p>
|
30
|
+
|
31
|
+
<%= help_img 'Edit', 'edit.png' %>
|
32
|
+
|
33
|
+
<p>The "delete" button allows you to delete the item.</p>
|
34
|
+
|
35
|
+
<%= help_img 'Delete', 'delete.png' %>
|
36
|
+
|
37
|
+
<p>While being irreversible and potentially dangerous, the Bureau will warn you and give you the opportunity to cancel before proceeding.</p>
|
38
|
+
|
39
|
+
<p>When you rollover the top of the item, your cursor will turn into a hand which is a clue that you can re-order the items by drag-and-drop.</p>
|
40
|
+
|
41
|
+
<%= help_img 'Sort', 'sort.png' %>
|
42
|
+
|
43
|
+
<p>Sometimes this hand does not appear, it means that the items cannot be sorted manually, generally because they are sorted automatically, alphabetically or by date for example.</p>
|
44
|
+
|
45
|
+
<p>When you want to create a new item, you can click the "plus" button.</p>
|
46
|
+
|
47
|
+
<%= help_img 'Create', 'create.png' %>
|
48
|
+
|
49
|
+
<p>Items will sometimes have other items attached to them. For example a blog article can have a list of images or an artist can have a list of social medias. These are called relationships.</p>
|
50
|
+
|
51
|
+
<p>When this is the case, you will have links for each relationship at the bottom of the items and when you click on them, the system will bring you to another list column which follows the same structure.</p>
|
52
|
+
|
53
|
+
<%= help_img 'Children', 'children.png' %>
|
54
|
+
|
55
|
+
<h2>Form</h2>
|
56
|
+
|
57
|
+
<p>Once you get to finally edit or create something, the page will be a form like the example below.</p>
|
58
|
+
|
59
|
+
<%= help_img 'Form', 'form.png' %>
|
60
|
+
|
61
|
+
<p>This page will probably be quite familiar to you. Field names within forms are meant to be as explicit as possible. For example they also include ideal image dimensions.</p>
|
62
|
+
|
63
|
+
<p>Press "Save"/"Update" when you are finished editing the item.</p>
|
64
|
+
|
65
|
+
<%= help_img 'Save', 'save.png' %>
|
66
|
+
|
67
|
+
<h2>Image specifications</h2>
|
68
|
+
|
69
|
+
<p>All images on the website should be exported for web in one of the following formats:</p>
|
70
|
+
|
71
|
+
<p>— Jpeg<br/>— PNG (if it requires transparancy)<br/>— SVG (for logos and anything vector-based)<br/>— Gif (not recommended unless a short animation is required)</p>
|
72
|
+
|
73
|
+
<p>You will not be able to upload images above a predifined maximum, usually 1MB. Typically most images saved for web can be compressed down to a file size between 150KB and 500KB.</p>
|
74
|
+
|
75
|
+
<h2>Text formating</h2>
|
76
|
+
|
77
|
+
<p>On most text fields, you can add links or make text bold or italic with a simple markup called <a href='https://en.wikipedia.org/wiki/Markdown' target='_blank'>markdown</a>. Here is an example of what you can do:</p>
|
78
|
+
|
79
|
+
<div class='frame'>
|
80
|
+
<p>Markdown is good for *making things look italic* or **making things look bold**. Your can also create links [like this which links to Google](https://www.google.com). Although if you write a URL or an email address, you don't have to do anything because it will be turned into a link automatically anyway.</p>
|
81
|
+
</div>
|
82
|
+
|
83
|
+
<p>Which will be rendered like this:</p>
|
84
|
+
|
85
|
+
<div class='frame'>
|
86
|
+
<p>Markdown is good for <em>making things look italic</em> or <strong>making things look bold</strong>. Your can also create links <a href="https://www.google.com" target='_blank'>like this which links to Google</a>. Although if you write a URL or an email address, you don't have to do anything because it will be turned into a link automatically anyway.</p>
|
87
|
+
</div>
|
88
|
+
|
89
|
+
<p><em>*Surrounding with stars makes text italic*</em><br><strong>**Surrounding text with double stars makes it bold**</strong><br>Links look like: [<a href='javascript:void(0);'>text to link</a>](http://website.com)</p>
|
90
|
+
|
91
|
+
<p>It should be self explanatory but you can do much more with markdown. If you are interrested, we encourage you to read the <a href='https://daringfireball.net/projects/markdown/syntax' target='_blank'>full documentation</a>.</p>
|
92
|
+
|
93
|
+
</div>
|
94
|
+
|
data/lib/populate_me/admin.rb
CHANGED
@@ -25,10 +25,16 @@ class PopulateMe::Admin < Sinatra::Base
|
|
25
25
|
# Load API helpers
|
26
26
|
helpers PopulateMe::API::Helpers
|
27
27
|
helpers do
|
28
|
+
|
28
29
|
def user_name
|
29
30
|
return 'Anonymous' if session.nil?||session[:populate_me_user].nil?
|
30
31
|
session[:populate_me_user]
|
31
32
|
end
|
33
|
+
|
34
|
+
def help_img desc, filename
|
35
|
+
"<img src='#{request.script_name}/__assets__/img/help/#{filename}' alt='#{desc}' />"
|
36
|
+
end
|
37
|
+
|
32
38
|
end
|
33
39
|
|
34
40
|
# Make all templates in admin/views accessible with their basename
|
@@ -58,6 +64,9 @@ class PopulateMe::Admin < Sinatra::Base
|
|
58
64
|
href = l[1].is_a?(String) ? l[1] : "#{request.script_name}/menu#{levels.map{|level|'/'+level}.join}/#{slugify(l[0])}"
|
59
65
|
{ title: l[0], href: href }
|
60
66
|
end
|
67
|
+
if request.path=='/menu'
|
68
|
+
items.push({title: '?', href: "#{request.script_name}/help"})
|
69
|
+
end
|
61
70
|
{
|
62
71
|
template: 'template_menu',
|
63
72
|
page_title: page_title,
|
@@ -86,6 +95,11 @@ class PopulateMe::Admin < Sinatra::Base
|
|
86
95
|
).to_json
|
87
96
|
end
|
88
97
|
|
98
|
+
get '/help' do
|
99
|
+
content_type :html
|
100
|
+
erb :help, layout: false
|
101
|
+
end
|
102
|
+
|
89
103
|
not_found do
|
90
104
|
response.headers['X-Cascade'] = 'pass'
|
91
105
|
{'success'=>false,'message'=>'Not Found'}.to_json
|
data/lib/populate_me/version.rb
CHANGED
data/test/test_admin.rb
CHANGED
@@ -132,11 +132,19 @@ describe PopulateMe::Admin do
|
|
132
132
|
assert_predicate last_response, :ok?
|
133
133
|
assert_json last_response
|
134
134
|
assert_for_view json, 'template_menu', 'Menu'
|
135
|
-
assert_equal 2, json['items'].size
|
136
135
|
expected_h = {
|
137
136
|
'title'=> 'Home Details', 'href'=> '/admin/form/home-details/0'
|
138
137
|
}
|
139
138
|
assert_equal expected_h, json['items'][0]
|
139
|
+
expected_h = {
|
140
|
+
'title'=> 'Project Page', 'href'=> '/menu/project-page'
|
141
|
+
}
|
142
|
+
assert_equal expected_h, json['items'][1]
|
143
|
+
end
|
144
|
+
it 'Adds help link' do
|
145
|
+
get '/menu'
|
146
|
+
assert_equal 3, json['items'].size
|
147
|
+
assert_equal({'title'=>'?', 'href'=>'/help'}, json['items'].last)
|
140
148
|
end
|
141
149
|
end
|
142
150
|
describe 'when url is nested' do
|
@@ -151,6 +159,10 @@ describe PopulateMe::Admin do
|
|
151
159
|
}
|
152
160
|
assert_equal expected_h, json['items'][0]
|
153
161
|
end
|
162
|
+
it 'Does not add help link' do
|
163
|
+
get '/menu/project-page/checks'
|
164
|
+
refute_equal({'title'=>'?', 'href'=>'/help'}, json['items'].last)
|
165
|
+
end
|
154
166
|
end
|
155
167
|
|
156
168
|
end
|
@@ -98,10 +98,8 @@ describe PopulateMe::Document, 'Typecasting' do
|
|
98
98
|
it "Parses the date with Date.parse" do
|
99
99
|
assert_equal Date.parse('10/11/1979'), subject.typecast(:dob,'10/11/1979')
|
100
100
|
end
|
101
|
-
|
102
|
-
|
103
|
-
assert_equal Date.parse('10/11/1979'), subject.typecast(:dob,'10-11-1979')
|
104
|
-
end
|
101
|
+
it "Works with yyyy-mm-dd date html input format" do
|
102
|
+
assert_equal Date.parse('10/11/1979'), subject.typecast(:dob,'1979-11-10')
|
105
103
|
end
|
106
104
|
describe "Value is malformed" do
|
107
105
|
it "Returns nil" 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.9.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: 2019-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: web-utils
|
@@ -198,12 +198,26 @@ files:
|
|
198
198
|
- lib/populate_me/admin/__assets__/css/asmselect.css
|
199
199
|
- lib/populate_me/admin/__assets__/css/jquery-ui.min.css
|
200
200
|
- lib/populate_me/admin/__assets__/css/main.css
|
201
|
+
- lib/populate_me/admin/__assets__/img/help/children.png
|
202
|
+
- lib/populate_me/admin/__assets__/img/help/create.png
|
203
|
+
- lib/populate_me/admin/__assets__/img/help/delete.png
|
204
|
+
- lib/populate_me/admin/__assets__/img/help/edit.png
|
205
|
+
- lib/populate_me/admin/__assets__/img/help/form.png
|
206
|
+
- lib/populate_me/admin/__assets__/img/help/list.png
|
207
|
+
- lib/populate_me/admin/__assets__/img/help/login.png
|
208
|
+
- lib/populate_me/admin/__assets__/img/help/logout.png
|
209
|
+
- lib/populate_me/admin/__assets__/img/help/menu.png
|
210
|
+
- lib/populate_me/admin/__assets__/img/help/overview.png
|
211
|
+
- lib/populate_me/admin/__assets__/img/help/save.png
|
212
|
+
- lib/populate_me/admin/__assets__/img/help/sort.png
|
213
|
+
- lib/populate_me/admin/__assets__/img/help/sublist.png
|
201
214
|
- lib/populate_me/admin/__assets__/js/asmselect.js
|
202
215
|
- lib/populate_me/admin/__assets__/js/columnav.js
|
203
216
|
- lib/populate_me/admin/__assets__/js/jquery-ui.min.js
|
204
217
|
- lib/populate_me/admin/__assets__/js/main.js
|
205
218
|
- lib/populate_me/admin/__assets__/js/mustache.js
|
206
219
|
- lib/populate_me/admin/__assets__/js/sortable.js
|
220
|
+
- lib/populate_me/admin/views/help.erb
|
207
221
|
- lib/populate_me/admin/views/page.erb
|
208
222
|
- lib/populate_me/api.rb
|
209
223
|
- lib/populate_me/attachment.rb
|
@@ -257,8 +271,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
257
271
|
- !ruby/object:Gem::Version
|
258
272
|
version: '0'
|
259
273
|
requirements: []
|
260
|
-
|
261
|
-
rubygems_version: 2.6.13
|
274
|
+
rubygems_version: 3.0.2
|
262
275
|
signing_key:
|
263
276
|
specification_version: 4
|
264
277
|
summary: PopulateMe is an admin system for web applications.
|