promethee 0.1.5 → 0.1.6
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/README.md +91 -2
- data/app/views/promethee/_edit.html.erb +2 -3
- data/app/views/promethee/_show.html.erb +3 -1
- data/lib/promethee.rb +3 -0
- data/lib/promethee/core_ext/tags.rb +2 -1
- data/lib/promethee/data.rb +9 -0
- data/lib/promethee/localization.rb +7 -0
- data/lib/promethee/rails/helper.rb +2 -19
- data/lib/promethee/rails/version.rb +1 -1
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14fcd1ec2bd76b0e5a05757927c5fb38b292638c
|
4
|
+
data.tar.gz: 2fb7d856837d11869f7390ef44fc97985fa7da22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2c4c4b361aa1e2e6a938127cfaa83c43a89adbee44969d3452b1e8ec9b110d386454671a35278c2c4910976578d59c4e083c563c141501cdef51334ed3d44fb
|
7
|
+
data.tar.gz: '0219cf7aa0bbc9f06c677966db46c4bfcf86c282731ecb9700f8abf02f196aafb281ebf30232271b499131368a3f7641c63cd48be40d8dcf75c5dc9c94b9c1f1'
|
data/README.md
CHANGED
@@ -63,26 +63,36 @@ The data is:
|
|
63
63
|
|
64
64
|
```ruby
|
65
65
|
@page.data = {
|
66
|
+
id: 'ero342ezr',
|
66
67
|
type: 'page',
|
68
|
+
version: 1,
|
67
69
|
children: [
|
68
70
|
{
|
71
|
+
id: '7lebjl4j6',
|
69
72
|
type: 'row',
|
73
|
+
version: 1,
|
70
74
|
children: [
|
71
75
|
{
|
72
|
-
|
76
|
+
id: '8lebjl4j6',
|
77
|
+
type: 'column',
|
78
|
+
version: 1,
|
73
79
|
attributes: {
|
74
80
|
size: 4,
|
75
81
|
offset: 0
|
76
82
|
},
|
77
83
|
children: [
|
78
84
|
{
|
85
|
+
id: '9lebjl4j6',
|
79
86
|
type: 'text',
|
87
|
+
version: 1,
|
80
88
|
attributes: {
|
81
89
|
body: '<p><b>This</b> is a text</p>'
|
82
90
|
}
|
83
91
|
},
|
84
92
|
{
|
93
|
+
id: '12lebjl4j6',
|
85
94
|
type: 'image',
|
95
|
+
version: 1,
|
86
96
|
attributes: {
|
87
97
|
src: 'https://c1.staticflickr.com/5/4089/4975306844_f849232195_b.jpg',
|
88
98
|
alt: 'Prométhée'
|
@@ -159,7 +169,7 @@ With stylesheets set:
|
|
159
169
|
#### The editor has components
|
160
170
|
|
161
171
|
The component is made of a show and and edit.
|
162
|
-
|
172
|
+
The component has to be registered in order to be addable to the page.
|
163
173
|
In the edit, the component description looks like:
|
164
174
|
```
|
165
175
|
{
|
@@ -173,6 +183,21 @@ In the edit, the component description looks like:
|
|
173
183
|
}
|
174
184
|
}
|
175
185
|
```
|
186
|
+
The name and thumbs are used in the list of components, whereas the data is what will be injected in the page when component is added.
|
187
|
+
|
188
|
+
To register a component, the code is:
|
189
|
+
```javascript
|
190
|
+
angular.injector(['ng', 'Promethee']).get('definitions').push({
|
191
|
+
name: 'Image',
|
192
|
+
thumb: 'http://via.placeholder.com/300x200',
|
193
|
+
data: {
|
194
|
+
type: 'image',
|
195
|
+
attributes: {
|
196
|
+
src: 'https://source.unsplash.com/random/1920x1080'
|
197
|
+
}
|
198
|
+
}
|
199
|
+
});
|
200
|
+
```
|
176
201
|
|
177
202
|
#### The editor previews in an iframe
|
178
203
|
|
@@ -181,6 +206,70 @@ When you send your data, it renders the page in the default layout.
|
|
181
206
|
|
182
207
|
This is used to generate a live responsive preview.
|
183
208
|
|
209
|
+
### Render localized (l10n)
|
210
|
+
|
211
|
+
The page can be localized.
|
212
|
+
|
213
|
+
The localization data looks like:
|
214
|
+
```
|
215
|
+
@localization.data = {
|
216
|
+
locale: 'fr',
|
217
|
+
components: [
|
218
|
+
{
|
219
|
+
id: '9lebjl4j6',
|
220
|
+
type: 'text',
|
221
|
+
version: 1,
|
222
|
+
master_version: 1,
|
223
|
+
attributes: {
|
224
|
+
body: '<p><b>Ceci</b> est un texte</p>'
|
225
|
+
}
|
226
|
+
}
|
227
|
+
]
|
228
|
+
}
|
229
|
+
```
|
230
|
+
|
231
|
+
The view is:
|
232
|
+
|
233
|
+
```erb
|
234
|
+
<%= promethee @page.data, l: @localization.data %>
|
235
|
+
```
|
236
|
+
|
237
|
+
Which renders to:
|
238
|
+
|
239
|
+
```html
|
240
|
+
<div class="promethee">
|
241
|
+
<div class="row promethee__component promethee__component--row">
|
242
|
+
<div class="col-md-4 promethee__component promethee__component--col">
|
243
|
+
<div class="promethee__component promethee__component--text">
|
244
|
+
<p><b>Ceci</b> est un texte</p>
|
245
|
+
</div>
|
246
|
+
<div class="promethee__component promethee__component--image">
|
247
|
+
<img src="https://c1.staticflickr.com/5/4089/4975306844_f849232195_b.jpg" alt="Prométhée">
|
248
|
+
</div>
|
249
|
+
</div>
|
250
|
+
</div>
|
251
|
+
</div>
|
252
|
+
```
|
253
|
+
|
254
|
+
### Edit localization
|
255
|
+
|
256
|
+
```erb
|
257
|
+
<%= form_for @localization do |f| %>
|
258
|
+
<%= f.promethee_localizer :data, master: @page.data %>
|
259
|
+
<%= f.submit %>
|
260
|
+
<% end %>
|
261
|
+
```
|
262
|
+
|
263
|
+
This would do quite the same thing:
|
264
|
+
|
265
|
+
```erb
|
266
|
+
<form action="/localization" method="post">
|
267
|
+
<%= promethee_localizer :localization, :data, localization_data: @localization.data, master_data: @page.data %>
|
268
|
+
<input type="submit">
|
269
|
+
</form>
|
270
|
+
```
|
271
|
+
|
272
|
+
|
184
273
|
### Roadmap
|
185
274
|
- ~~Gem setup~~
|
186
275
|
- ~~renderer helper~~
|
@@ -29,14 +29,13 @@ data = data.to_json unless data.is_a? String
|
|
29
29
|
// Data (TODO use Adder and probably page definition to init)
|
30
30
|
if (data === null || data === '') {
|
31
31
|
data = {
|
32
|
+
id: '',
|
32
33
|
type: 'page',
|
34
|
+
version: 1,
|
33
35
|
children: []
|
34
36
|
};
|
35
37
|
}
|
36
38
|
$scope.data = data;
|
37
|
-
// $scope.component = {
|
38
|
-
// children: data
|
39
|
-
// };
|
40
39
|
|
41
40
|
// Preview modes
|
42
41
|
$scope.fullscreen = false;
|
@@ -1,5 +1,7 @@
|
|
1
1
|
<%
|
2
|
-
|
2
|
+
master_data = Promethee::Data.prepare data
|
3
|
+
l = Promethee::Data.prepare l
|
4
|
+
Promethee::Localization.localize! master_data, l unless l.nil?
|
3
5
|
%>
|
4
6
|
<div class="promethee">
|
5
7
|
<%= render 'promethee/components/page', page: data %>
|
data/lib/promethee.rb
CHANGED
@@ -6,7 +6,8 @@ module ActionView
|
|
6
6
|
# https://github.com/rails/rails/blob/bdc581616b760d1e2be3795c6f0f3ab4b1e125a5/actionview/lib/action_view/helpers/tags/text_field.rb
|
7
7
|
class PrometheeEditor < Base
|
8
8
|
def render
|
9
|
-
data = @
|
9
|
+
data = object.send @method_name unless object.nil?
|
10
|
+
data = @options[:value] if @options.include? :value
|
10
11
|
ApplicationController.renderer.render partial: 'promethee/edit', locals: { data: data }
|
11
12
|
end
|
12
13
|
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
class Promethee::Localization
|
2
|
+
def self.localize!(master_data, localization_data)
|
3
|
+
localized_components = localization_data[:components].select { |component| component[:id] == master_data[:id] }.first
|
4
|
+
master_data[:attributes].merge! localized_components[:attributes] unless localized_components.nil?
|
5
|
+
master_data[:children].each { |d| localize! d, localization_data } unless master_data[:children].nil?
|
6
|
+
end
|
7
|
+
end
|
@@ -1,26 +1,9 @@
|
|
1
1
|
module Promethee::Rails::Helper
|
2
|
-
def promethee(data)
|
3
|
-
ApplicationController.renderer.render partial: 'promethee/show', locals: { data: data }
|
4
|
-
end
|
5
|
-
|
6
|
-
def promethee_template(type)
|
7
|
-
render "/promethee/#{'components/' unless [:component, :components].include? type.to_s.to_sym }#{type}_edit"
|
8
|
-
end
|
9
|
-
|
10
|
-
def promethee_templates
|
11
|
-
Promethee::Component.types.map{ |type| promethee_template type }.join.html_safe
|
2
|
+
def promethee(data, options = {})
|
3
|
+
ApplicationController.renderer.render partial: 'promethee/show', locals: { data: data, l: options[:l] }
|
12
4
|
end
|
13
5
|
|
14
6
|
def promethee_class_for component
|
15
7
|
"promethee__component promethee__component--#{component[:type]}"
|
16
8
|
end
|
17
|
-
|
18
|
-
def promethee_editor_for(type)
|
19
|
-
component_class = type.to_s.classify
|
20
|
-
component = type[0].downcase + type[1..-1]
|
21
|
-
|
22
|
-
content_tag :div, 'ng-controller': "#{component_class} as #{component}", 'ng-init': "#{component}.data = data" do
|
23
|
-
concat yield(Promethee::Component.as(type))
|
24
|
-
end
|
25
|
-
end
|
26
9
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promethee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Dargelos
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-11-
|
14
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -247,6 +247,8 @@ files:
|
|
247
247
|
- lib/promethee/core_ext/form_builder.rb
|
248
248
|
- lib/promethee/core_ext/form_helper.rb
|
249
249
|
- lib/promethee/core_ext/tags.rb
|
250
|
+
- lib/promethee/data.rb
|
251
|
+
- lib/promethee/localization.rb
|
250
252
|
- lib/promethee/rails/engine.rb
|
251
253
|
- lib/promethee/rails/helper.rb
|
252
254
|
- lib/promethee/rails/version.rb
|
@@ -271,7 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
271
273
|
version: '0'
|
272
274
|
requirements: []
|
273
275
|
rubyforge_project:
|
274
|
-
rubygems_version: 2.6.
|
276
|
+
rubygems_version: 2.6.11
|
275
277
|
signing_key:
|
276
278
|
specification_version: 4
|
277
279
|
summary: Bring fire to your page
|