editmode 1.3.3 → 1.3.4
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 +14 -0
- data/lib/editmode/chunk_value.rb +18 -2
- data/lib/editmode/helper.rb +1 -1
- data/lib/editmode/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b84d630e273ea3949b9ff1f5f0bd69f5dcf546ff33e15e92e766cd623b269ae
|
4
|
+
data.tar.gz: ce10b6c6fe4d46052f303ab4aeaddde7da8c230ae6c03a299e06e0c42f3d1d93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24ffa6158c7b3c0d22fb4c546b521ec48a51fc2f579575608168cd7a321f103e439c6dc26bf33599483daf957215481b92b5a96bd1e9133e6342bcbba950ddad
|
7
|
+
data.tar.gz: f4d684b4d7713dee4853e304f9a61371eb982e9ce9841fbe283670c5c42176bfdd35847482dd698136e71c598a61e545be8c569f9f1177cb397984f197016e04
|
data/README.md
CHANGED
@@ -107,6 +107,20 @@ e("cnk_16e04a02d577afb610ce", "Email Content", variables: variable_values)
|
|
107
107
|
| item_class | string | `optional` Class name(s) that will be added along with "chunks-collection-item--wrapper" to all collection items |
|
108
108
|
|
109
109
|
|
110
|
+
### Working with Image Transformation
|
111
|
+
Use `transformation` attribute to perform real-time image transformations to deliver perfect images to the end-users.
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
# This chunk should render an image with 200 x 200 dimension
|
115
|
+
= E('id-of-some-image', transformation: "w-200 h-200")
|
116
|
+
|
117
|
+
# For image inside a collection
|
118
|
+
= c('some-collection-id') do
|
119
|
+
= F('Avatar', transformation: "w-200 h-200")
|
120
|
+
```
|
121
|
+
|
122
|
+
Please see complete list of [transformation parameters](https://editmode.com/docs#/imagekit_properties).
|
123
|
+
|
110
124
|
## Caching
|
111
125
|
In order to keep your application speedy, Editmode minimizes the amount of network calls it makes by caching content where it can.
|
112
126
|
|
data/lib/editmode/chunk_value.rb
CHANGED
@@ -9,7 +9,7 @@ module Editmode
|
|
9
9
|
attr_accessor :identifier, :variable_values, :branch_id,
|
10
10
|
:variable_fallbacks, :chunk_type, :project_id,
|
11
11
|
:url, :collection_id, :cache_identifier,
|
12
|
-
:response
|
12
|
+
:response, :transformation
|
13
13
|
|
14
14
|
attr_writer :content
|
15
15
|
|
@@ -22,6 +22,7 @@ module Editmode
|
|
22
22
|
@raw = options[:raw].present?
|
23
23
|
@skip_sanitize = options[:dangerously_skip_sanitization]
|
24
24
|
@skip_cache = options[:skip_cache]
|
25
|
+
@transformation = options[:transformation]
|
25
26
|
|
26
27
|
@url = "#{api_root_url}/chunks/#{identifier}"
|
27
28
|
@cache_identifier = set_cache_identifier(identifier)
|
@@ -40,7 +41,7 @@ module Editmode
|
|
40
41
|
if field.present?
|
41
42
|
field_chunk = field_chunk(field)
|
42
43
|
if field_chunk.present?
|
43
|
-
result = field_chunk['content']
|
44
|
+
result = field_chunk['chunk_type'] == 'image' ? set_transformation_properties!(field_chunk['content']) : field_chunk['content']
|
44
45
|
result = variable_parse!(result, variable_fallbacks, variable_values, @raw, @skip_sanitize)
|
45
46
|
else
|
46
47
|
raise no_response_received(field)
|
@@ -73,6 +74,20 @@ module Editmode
|
|
73
74
|
end
|
74
75
|
|
75
76
|
private
|
77
|
+
def set_transformation_properties!(url)
|
78
|
+
if transformation.present? && url.present?
|
79
|
+
transformation.gsub!(" ", ",")
|
80
|
+
transformation.gsub!(/\s/, '')
|
81
|
+
|
82
|
+
uri = URI(url)
|
83
|
+
uri.query = [uri.query, "tr=#{transformation}"].compact.join("&")
|
84
|
+
|
85
|
+
url = uri.to_s
|
86
|
+
end
|
87
|
+
|
88
|
+
url
|
89
|
+
end
|
90
|
+
|
76
91
|
def allowed_tag_attributes
|
77
92
|
%w(style href title src alt width height class target)
|
78
93
|
end
|
@@ -118,6 +133,7 @@ module Editmode
|
|
118
133
|
def query_params
|
119
134
|
the_params = { 'project_id' => project_id }
|
120
135
|
the_params['branch_id'] = branch_id if branch_id.present?
|
136
|
+
the_params['transformation'] = @transformation if @transformation.present?
|
121
137
|
|
122
138
|
the_params
|
123
139
|
end
|
data/lib/editmode/helper.rb
CHANGED
@@ -17,7 +17,7 @@ module Editmode
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def render_custom_field_raw(label, options={})
|
20
|
-
e(@custom_field_chunk["identifier"], label, options.merge({response: @custom_field_chunk}))
|
20
|
+
e(@custom_field_chunk["identifier"], label, options.merge({response: @custom_field_chunk}))
|
21
21
|
end
|
22
22
|
alias_method :f, :render_custom_field_raw
|
23
23
|
|
data/lib/editmode/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: editmode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Ennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|