cm_page_builder-rails 0.1.9 → 0.1.10
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
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18237b88d8761eaba2c6e86b745b4ba833a71caabf2093ed19506a332c227d5c
|
4
|
+
data.tar.gz: 887a7b0dbad8a02f4628499276b5bc36f03f854f5f9ff8d616cfd5adf3f7e794
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9669da11c92b37892e53c24a57cdec3d730aadb741a521b17cd87df72dc1eaa5ef1c8971da19e40fb21c90cd21c21ec0434add980c6a299624fd17090e1271d0
|
7
|
+
data.tar.gz: 182e84e24169405ee70e0460b6219acb9ee7b85ee03fafdf88c0cc67b8ff2fed772e01ac89a387a56a2eef54fc705d46fc1eb7ea32ead30780bf79aadee83751
|
data/README.md
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/cm_page_builder-rails.svg)](https://badge.fury.io/rb/cm_page_builder-rails)
|
2
|
+
|
1
3
|
# CmPageBuilder::Rails
|
2
4
|
This gem's purpose is to allow easy integration between the Commutatus react package cm-page-builder and any rails applications created by
|
3
5
|
|
@@ -29,7 +31,7 @@ https://keithpblog.org/post/active-storage-on-amazon-s3/
|
|
29
31
|
|
30
32
|
### Building the gem
|
31
33
|
`gem build cm_page_builder-rails.gemspec`
|
32
|
-
`gem push
|
34
|
+
`gem push cm_page_builder-rails-0.1.x.gem`
|
33
35
|
|
34
36
|
## Contributing
|
35
37
|
Contribution directions go here.
|
@@ -5,11 +5,11 @@ module CmPageBuilder::Rails
|
|
5
5
|
|
6
6
|
accepts_nested_attributes_for :page_components, allow_destroy: true
|
7
7
|
|
8
|
-
def
|
8
|
+
def components(**args)
|
9
9
|
page_components.with_attached_component_attachment.select(:id, :uuid, :component_type, :position, :content).map do |component|
|
10
|
-
json_component = component.as_json.transform_keys! {|key| key.camelize(:lower)}
|
10
|
+
json_component = component.as_json.transform_keys! { |key| key.camelize(:lower) }
|
11
11
|
json_component["id"] = component[:uuid]
|
12
|
-
json_component["component_attachment"] = _get_attachment(component)
|
12
|
+
json_component["component_attachment"] = _get_attachment(component, args[:max_width])
|
13
13
|
json_component
|
14
14
|
end
|
15
15
|
end
|
@@ -33,37 +33,40 @@ module CmPageBuilder::Rails
|
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
private
|
37
|
+
|
38
|
+
def _get_attachment(component, max_width=nil)
|
39
|
+
attachment = component.component_attachment.attachment
|
40
|
+
return unless attachment
|
41
|
+
|
39
42
|
attachment_data = {
|
40
43
|
filename: attachment.filename.to_s,
|
41
44
|
url: attachment.service_url
|
42
45
|
}
|
43
|
-
|
44
|
-
|
46
|
+
if attachment.blob.variable?
|
47
|
+
dimensions = attachment.blob.metadata
|
45
48
|
dimensions['orientation'] =
|
46
49
|
if dimensions['width'] > dimensions['height']
|
47
50
|
'landscape'
|
48
51
|
else
|
49
52
|
'portrait'
|
50
53
|
end
|
51
|
-
attachment_data[
|
54
|
+
attachment_data[:dimensions] = dimensions
|
55
|
+
attachment_data[:url] = attachment.variant(resize_to_limit: [max_width, nil]).processed.service_url if max_width
|
52
56
|
end
|
53
57
|
attachment_data
|
54
58
|
end
|
55
|
-
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
60
|
+
def _save_component(component)
|
61
|
+
page_component = page_components.find_or_initialize_by(uuid: component["id"])
|
62
|
+
signed_id = component.dig("component_attachment", "signed_id")
|
63
|
+
component_data = {
|
64
|
+
content: component["content"],
|
65
|
+
position: component["position"],
|
66
|
+
component_type: component["componentType"]
|
67
|
+
}
|
68
|
+
component_data[:component_attachment] = signed_id if signed_id
|
69
|
+
page_component.update!(component_data)
|
70
|
+
end
|
68
71
|
end
|
69
72
|
end
|
@@ -8,7 +8,6 @@
|
|
8
8
|
|
9
9
|
.field
|
10
10
|
input type='hidden' id="content-editor" name="page[components]"
|
11
|
-
- components
|
12
|
-
= react_component("cm_content_manager/Content", {input: "content-editor", components: components})
|
11
|
+
= react_component("cm_content_manager/Content", {input: "content-editor", components: @page.components})
|
13
12
|
|
14
13
|
.actions = f.submit
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cm_page_builder-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Camilo Ernesto Forero Junco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|