editmode 1.6.0.pre.1 → 1.7.0.pre.2

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: 7025b651a7a15300b25ee1f151a510ccc12ed7f934240b4103b6ec6980b23a85
4
- data.tar.gz: cb4c278ac603a883e7c7a6a8abb84362cda6c374d3dae2ef5ba6d21763468560
3
+ metadata.gz: 639a7a79d9adcdeac5e17b953350f0394b382fcc814be7d3f90e876e73ee4386
4
+ data.tar.gz: fa62f7b43894da4c3cb00bb82061b110d0327d8459c55924e9240be99a920bce
5
5
  SHA512:
6
- metadata.gz: afbb6a9a44136b626e60207ebeab2e54a32249587cf26d7d104aeee78c60a84e5e4386d4e951719d2959b95cb38339dddf608ab5479fbb09b4e3e21820d34d0c
7
- data.tar.gz: 19bafb08bd133a91a2eff430a9c49ea265737ec819d17f5e1d3ebe9e3a76021c6b32145ce514ed13e976b76531192795299bda4ef1772de0af94d5eb490b5fe0
6
+ metadata.gz: c71fc8c8bf0f9346788e62f3e36506861ce0d479a10662cd17be36d32cda9ec4ffc39372efb2f2c931731eb116b977c2fc4a03f84a36854ee4fee0a892453a3a
7
+ data.tar.gz: f397df0a103752539063d9019e445b57efa8431de7734472392285e6b3681c114b4549918e138cbf442cfcd578e2ab2b9eec4921401d26c662a36b0cbb57b23a
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)
@@ -62,21 +63,17 @@ module Editmode
62
63
  end
63
64
 
64
65
  if chunks.any?
65
- content_tag :div, class: "chunks-collection-wrapper #{parent_class}", data: {chunk_collection_identifier: collection_identifier} do
66
+ content_tag :div, class: "chunks-collection-wrapper #{parent_class}", data: {chunk_collection_identifier: collection_identifier, chunk_tags: tags.join("|")} do
66
67
  chunks.each_with_index do |chunk, index|
67
68
  @custom_field_chunk = chunk
68
- if options[:without_item_wrapper].present?
69
+ concat(content_tag(:div, class: "chunks-collection-item--wrapper #{item_class}") do
69
70
  yield(@custom_field_chunk, index)
70
- else
71
- concat(content_tag(:div, class: "chunks-collection-item--wrapper #{item_class}") do
72
- yield(@custom_field_chunk, index)
73
- end)
74
- end
71
+ end)
75
72
  end
76
73
 
77
74
  # Placeholder element for new collection item
78
75
  @custom_field_chunk = chunks.first.merge!({placeholder: true})
79
- concat(content_tag(:div, class: "chunks-hide chunks-col-placeholder-wrapper") do
76
+ concat(content_tag(:template, class: "chunks-hide chunks-col-placeholder-wrapper") do
80
77
  yield(@custom_field_chunk)
81
78
  end)
82
79
  end
@@ -94,7 +91,7 @@ module Editmode
94
91
  def chunk_field_value(parent_chunk_object, custom_field_identifier, options = {})
95
92
  begin
96
93
  chunk_identifier = parent_chunk_object["identifier"]
97
- chunk_value = Editmode::ChunkValue.new(parent_chunk_object["identifier"], options.merge({response: parent_chunk_object}))
94
+ chunk_value = Editmode::ChunkValue.new(parent_chunk_object["identifier"], **options.merge({response: parent_chunk_object}))
98
95
  custom_field_item = chunk_value.field_chunk(custom_field_identifier)
99
96
 
100
97
  options[:field] = custom_field_identifier
@@ -168,7 +165,7 @@ module Editmode
168
165
  begin
169
166
  field = options[:field].presence || ""
170
167
  options[:referrer] = request.present? && request.url || ""
171
- chunk_value = Editmode::ChunkValue.new(identifier, options)
168
+ chunk_value = Editmode::ChunkValue.new(identifier, **options)
172
169
 
173
170
  if field.present? && chunk_value.chunk_type == 'collection_item'
174
171
  chunk_content = chunk_value.field(field)
@@ -4,7 +4,7 @@ module Editmode
4
4
  def e(identifier, *args)
5
5
  field, options = parse_arguments(args)
6
6
  begin
7
- chunk = Editmode::ChunkValue.new(identifier, options.merge({raw: true}))
7
+ chunk = Editmode::ChunkValue.new(identifier, **options.merge({raw: true}))
8
8
 
9
9
  if chunk.chunk_type == 'collection_item'
10
10
  chunk.field(field)
@@ -14,9 +14,25 @@ module Editmode
14
14
  true
15
15
  end
16
16
 
17
+ def has_watermark
18
+ has_watermark = Rails.cache.fetch('chunks_project_has_watermark', expires_in: 1.hour,) do
19
+ project = HTTParty.get(Editmode.api_root_url + "/projects/#{Editmode.project_id}")
20
+ project["has_watermark"]
21
+ end
22
+ end
23
+
24
+ def watermark_tag
25
+ if has_watermark
26
+ '<div style="z-index: 9999; bottom: 8px; right: 8px; position: fixed; opacity: 1; display: flex; align-items: center; background: rgba(255, 255, 255, 0.9); cursor: pointer; border-radius: 5px; padding: 2px 5px 2px 2px; box-shadow: rgba(0, 0, 0, 0.1) 0px 1px 3px 0px, rgba(0, 0, 0, 0.06) 0px 1px 2px 0px;"><svg xmlns="http://www.w3.org/2000/svg" width="25" height="25" viewBox="0 0 548 532" version="1.1" fill="currentColor"><g id="Page-2" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"><g id="Group-2-Copy" fill="#02164B" fill-rule="nonzero"><path d="M355.57238,93.227099 C421.07938,126.760445 463.228656,200.366589 458.662484,275.197013 C456.789183,321.18219 437.646387,365.465318 406.824729,398.879222 C371.729602,436.503458 321.735878,458.271766 270.922584,458.988418 C203.22031,459.764791 137.596229,421.453764 104.754918,360.956382 C83.2997657,322.496052 75.4553171,276.928922 82.5387371,233.302725 C89.0952911,193.767417 107.828303,156.501508 135.840009,128.343052 C167.861751,95.3770553 211.620895,75.6989829 256.902096,72.4143274 C290.88495,70.1150686 325.248318,77.4308922 355.57238,93.227099 Z M302.597364,108.707879 C244.580186,94.7144282 181.478422,121.295874 147.91428,172.136709 C125.753716,204.951046 116.495656,247.175826 123.079165,286.681355 C127.575938,318.48743 142.800303,348.796389 164.461226,371.680876 C195.556552,404.281339 240.406711,421.818983 284.492713,417.297082 C306.976574,415.738859 326.903446,407.153357 347.094835,397.529041 C333.927816,397.406827 321.113485,400.462166 307.975856,399.881651 C293.691992,399.33169 279.114221,397.284614 265.565123,392.487732 C232.823919,381.213532 204.168018,358.573473 185.916413,328.020087 C170.074843,302.721883 162.668395,271.465768 167.841152,241.52345 C172.896347,214.850343 187.297774,190.224314 208.429665,174.061573 C244.874093,144.791428 299.77586,145.463603 335.750037,175.344815 C370.842495,203.117843 385.273313,253.25595 370.783713,296.550099 C362.524936,322.978778 344.831754,343.357887 322.553628,358.145726 C342.069031,355.12094 360.261854,348.643622 375.985862,336.025074 C406.7285,312.315646 423.275446,271.129681 418.043907,231.715813 C408.727065,170.822914 360.320636,120.89868 302.597364,108.707879 Z M322.507627,229.728263 C308.735553,203.164192 276.64924,189.629307 248.46453,198.136949 C218.823998,206.287627 198.529842,236.927037 201.907349,268.072146 C204.498711,292.375445 220.017772,314.804683 242.932407,323.074349 C267.302864,332.68263 295.895205,325.930061 313.510648,306.148306 C331.970469,285.593129 335.813839,254.180297 322.507627,229.728263 Z" id="Combined-Shape"></path></g></g></svg><span style="font-size: 13px; font-weight: 600;">Powered by Editmode</span></div>'
27
+ else
28
+ ""
29
+ end
30
+ end
31
+
17
32
  def output
18
-
19
33
  str = <<-EDITMODE_SCRIPT
34
+ #{watermark_tag}
35
+ <script>window.chunksProjectLoaded = true</script>
20
36
  <script>window.chunksProjectIdentifier = '#{Editmode.project_id}'</script>
21
37
  <script>window.editmodeENV = '#{ENV["EDITMODE_ENV"] || 'production'}'</script>
22
38
  <script src="#{script_url}" async ></script>
@@ -27,7 +43,7 @@ module Editmode
27
43
  end
28
44
 
29
45
  def script_url
30
- ENV["EDITMODE_OVERRIDE_SCRIPT_URL"] || "https://static.editmode.com/editmode@2.0.0/dist/editmode.js"
46
+ ENV["EDITMODE_OVERRIDE_SCRIPT_URL"] || "https://unpkg.com/editmode-magic-editor@^0/dist/magic-editor.js"
31
47
  end
32
48
 
33
49
  end
@@ -1,3 +1,3 @@
1
1
  module Editmode
2
- VERSION = "1.6.0.pre.1"
2
+ VERSION = "1.7.0.pre.2"
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.6.0.pre.1
4
+ version: 1.7.0.pre.2
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-05-04 00:00:00.000000000 Z
11
+ date: 2021-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler