editmode 1.3.7 → 1.6.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fbb861dabf26cb4d95d4a0b56f2cd791849ffcb305d6e762ad787bb728b40fb
4
- data.tar.gz: d34a6147915164dadadac1495984b4a964bfe5d145d36c8c7c498fa4522903bd
3
+ metadata.gz: 3562a1b7e78951687db2ceb19bdb9ff6553f744e982f4e4b59306aca5dc67a98
4
+ data.tar.gz: 89994562d87db5aace1b901e19a4b73cbffa31121ee19370ba26d9c98a86cec3
5
5
  SHA512:
6
- metadata.gz: 5cece1f007bb9224ced9a4bee87c29716d2b5c1457814f6b70dcb6ae3784fd4703960ae87d8d87cb218886e023592e6521bc857ac115eadb0607cd5ff904332b
7
- data.tar.gz: f3967f25a4989c74f5b58b764b03820b7451d80234594eb12beb73265bd4ce8d6bf3d7d716113face40b691924ff6268b31f056b6595ecb133e52f39479a85f8
6
+ metadata.gz: 4181d73541784b2eccb1fe141c3905c0cf95b255fc719912ac77de504357f751a4b591090da84719c4b0d7eb3d238c1ca914330132195e4c834a6c7336021923
7
+ data.tar.gz: 409ddeaac99feea4a855e2722544cbfa82bd23c4283b537a65dce606f70d843f59c99a967f6e75adbb2f93e16c5d1cb5e9ee799be07e6248a5d657efc1f1952e
data/README.md CHANGED
@@ -33,6 +33,11 @@ end
33
33
  That's it, you're all set up. By default Editmode will now include editmode.js in every page of your rails application, unless you disable auto-include.
34
34
  <hr/>
35
35
 
36
+ #### 3. (Rails 6) Ensuring the Magic Editor works with Content Security Policy
37
+
38
+ - Add "https://static.editmode.com" to `style_src` and `script_src` in your content security policy.
39
+ - Add "https://api.editmode.com" to `connect_src` in your content security policy.
40
+
36
41
  ## Rendering Content
37
42
 
38
43
  Editmode provides helper methods for use in your rails views and controllers.
@@ -38,7 +38,8 @@ module Editmode
38
38
  :collection_identifier => collection_identifier,
39
39
  :branch_id => branch_id,
40
40
  :limit => limit,
41
- :tags => tags
41
+ :tags => tags,
42
+ :project_id => Editmode.project_id
42
43
  }.to_query
43
44
 
44
45
  url = URI(api_root_url)
@@ -63,10 +64,10 @@ module Editmode
63
64
 
64
65
  if chunks.any?
65
66
  content_tag :div, class: "chunks-collection-wrapper #{parent_class}", data: {chunk_collection_identifier: collection_identifier} do
66
- chunks.each do |chunk|
67
+ chunks.each_with_index do |chunk, index|
67
68
  @custom_field_chunk = chunk
68
69
  concat(content_tag(:div, class: "chunks-collection-item--wrapper #{item_class}") do
69
- yield(@custom_field_chunk)
70
+ yield(@custom_field_chunk, index)
70
71
  end)
71
72
  end
72
73
 
@@ -139,19 +139,22 @@ module Editmode
139
139
 
140
140
  def get_content
141
141
  if !cached?
142
- http_response = HTTParty.get(url, query: query_params, headers: {referrer: @referrer})
143
- response_received = true if http_response.code == 200
142
+ @response = HTTParty.get(url, query: query_params, headers: {referrer: @referrer})
143
+ response_received = true if @response.code == 200
144
144
  end
145
145
 
146
146
  if !cached? && !response_received
147
- message = http_response.try(:[], 'message') || no_response_received(identifier)
147
+ message = @response.try(:[], 'message') || no_response_received(identifier)
148
148
 
149
149
  raise message
150
150
  else
151
- Rails.cache.write(cache_identifier, http_response.to_json) if http_response.present?
151
+ Rails.cache.write(cache_identifier, @response.to_json) if @response.present?
152
152
  cached_response = Rails.cache.fetch(cache_identifier)
153
153
 
154
- @response = json?(cached_response) ? JSON.parse(cached_response) : cached_response
154
+ if cached_response.present?
155
+ @response = json?(cached_response) ? JSON.parse(cached_response) : cached_response
156
+ end
157
+
155
158
  set_response_attributes!
156
159
  end
157
160
  end
@@ -1,3 +1,3 @@
1
1
  module Editmode
2
- VERSION = "1.3.7"
2
+ VERSION = "1.6.1"
3
3
  end
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.7
4
+ version: 1.6.1
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-22 00:00:00.000000000 Z
11
+ date: 2021-06-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
- rubygems_version: 3.0.3
115
+ rubygems_version: 3.0.3.1
116
116
  signing_key:
117
117
  specification_version: 4
118
118
  summary: Editmode allows you to turn plain text in your rails app into easily inline-editable