editmode 0.0.10.15 → 1.0.22

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: feb3922328fd985e4aec3156ba98021dbd194c3fdf58a9b51b63de2b7f7dc535
4
- data.tar.gz: f52847ef24647300e4bde80f71a90f557e67e7caa40b55ded07fe1276ca759e2
3
+ metadata.gz: 98935fb2e9c9e599ba4dde0dfc6331211932cfddec983bb7b7327ae3acbb255f
4
+ data.tar.gz: 315beb50a0c8b829be8d6e78aa4f181f7e564418ab77c2d0a888c0bdeaf1661e
5
5
  SHA512:
6
- metadata.gz: 573b7952ccdb805057e3cdeffe11f9d19af12fc578d166916a95f14e0d3508b868b8c4f37348a2550bc1563abba2bd218b53d416f628c9422a19db6c08e656c2
7
- data.tar.gz: 3a690c5d2a0427596f29fdf1154f1715da067611c27ad95dbe86a8ef4c5a296e5cbc6c96e170ce0442f9f32c9fea835233ab276a5cc28be98e7f7caa2e84c8ee
6
+ metadata.gz: 4370f2a10ebb61fd87eed89ffd31c919d7f51e2adf363021135676624048bbbcc3941d7a643e8c9520a830cb943ddbce4a27e3a8ef50d1bac94bb440024885c0
7
+ data.tar.gz: fdcca7d3fa91637b3c41f3b14af29e7c1cb2839d5dd9db06c9edfb4c4b415d7e80f5899621f829c6a7ee9607895349681f54df576dd0b581d07361917dafbaa6
@@ -33,7 +33,6 @@ module Editmode
33
33
 
34
34
  def chunk_value(identifier, **options)
35
35
  begin
36
- options.merge!(project_id: project_id)
37
36
  Editmode::ChunkValue.new(identifier, **options )
38
37
  rescue => er
39
38
  raise er
@@ -77,7 +77,7 @@ module Editmode
77
77
  display_type = options[:display_type] || "span"
78
78
  end
79
79
 
80
- chunk_data = { :chunk => chunk_identifier, :chunk_editable => false }
80
+ chunk_data = { :chunk => chunk_identifier, :chunk_editable => false, :chunk_type => chunk_type }
81
81
 
82
82
  if options[:parent_identifier].present?
83
83
  chunk_data.merge!({parent_identifier: options[:parent_identifier]})
@@ -86,7 +86,7 @@ module Editmode
86
86
  case display_type
87
87
  when "span"
88
88
  if chunk_type == "rich_text"
89
- content_tag("em-span", :class => css_class, :data => chunk_data ) do
89
+ content_tag("em-span", :class => "editmode-richtext-editor #{css_class}", :data => chunk_data.merge!({:chunk_editable => true}) ) do
90
90
  chunk_content.html_safe
91
91
  end
92
92
  else
@@ -165,7 +165,7 @@ module Editmode
165
165
  end
166
166
 
167
167
  def no_response_received(id = "")
168
- "Sorry, we can't find a content using this identifier: \"#{id}\""
168
+ "Sorry, we can't find a chunk using this identifier: \"#{id}\". This can happen if you've deleted a chunk on editmode.com or if your local cache is out of date. If it persists, try running Rails.cache clear."
169
169
  end
170
170
 
171
171
  def require_field_id
@@ -4,12 +4,11 @@ module Editmode
4
4
 
5
5
  attr_accessor :identifier, :variable_values, :branch_id,
6
6
  :variable_fallbacks, :chunk_type, :project_id,
7
- :content
7
+ :response, :content
8
8
 
9
9
  def initialize(identifier, **options)
10
10
  @identifier = identifier
11
11
  @branch_id = options[:branch_id].presence
12
- @project_id = options[:project_id].presence
13
12
  @variable_values = options[:values].presence || {}
14
13
  get_content
15
14
  end
@@ -18,7 +17,8 @@ module Editmode
18
17
  # Field ID can be a slug or field_name
19
18
  if chunk_type == 'collection_item'
20
19
  if field.present?
21
- field_content = content.detect {|f| f["custom_field_identifier"] == field || f["custom_field_name"] == field }
20
+ field.downcase!
21
+ field_content = content.detect {|f| f["custom_field_identifier"].downcase == field || f["custom_field_name"].downcase == field }
22
22
  if field_content.present?
23
23
  result = field_content['content']
24
24
  result = variable_parse!(result, variable_fallbacks, variable_values)
@@ -39,28 +39,24 @@ module Editmode
39
39
  branch_params = branch_id.present? ? "branch_id=#{branch_id}" : ""
40
40
  url = "#{api_root_url}/chunks/#{identifier}?#{branch_params}"
41
41
 
42
- cache_identifier = "chunk_#{identifier}#{branch_id}"
42
+ cache_identifier = "chunk_value_#{identifier}#{branch_id}"
43
43
  cached_content_present = Rails.cache.exist?(cache_identifier)
44
- cached_content_present = Rails.cache.exist?("chunk_#{project_id}_variables") if cached_content_present
45
44
 
46
45
  if !cached_content_present
47
- response = HTTParty.get(url)
48
- response_received = true if response.code == 200
46
+ http_response = HTTParty.get(url)
47
+ response_received = true if http_response.code == 200
49
48
  end
50
49
 
51
50
  if !cached_content_present && !response_received
52
51
  raise no_response_received(identifier)
53
52
  else
54
- @content = Rails.cache.fetch(cache_identifier) do
55
- response['content']
53
+ @response = Rails.cache.fetch(cache_identifier) do
54
+ http_response
56
55
  end
57
56
 
58
- @chunk_type = Rails.cache.fetch("#{cache_identifier}_type") do
59
- response['chunk_type']
60
- end
61
-
62
- # Since variables are defined in the project level,
63
- # We use project_id as cache identifier
57
+ @content = response['content']
58
+ @chunk_type = response['chunk_type']
59
+ @project_id = response['project_id']
64
60
  @variable_fallbacks = Rails.cache.fetch("chunk_#{project_id}_variables") do
65
61
  response['variable_fallbacks']
66
62
  end
@@ -26,7 +26,7 @@ module Editmode
26
26
  end
27
27
 
28
28
  def script_url
29
- ENV["EDITMODE_OVERRIDE_SCRIPT_URL"] || "https://static.editmode.com/editmode@1.0.0/dist/editmode.js"
29
+ ENV["EDITMODE_OVERRIDE_SCRIPT_URL"] || "https://static.editmode.com/editmode@^1.0.0/dist/editmode.js"
30
30
  end
31
31
 
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module Editmode
2
- VERSION = "0.0.10.15"
2
+ VERSION = "1.0.22"
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: 0.0.10.15
4
+ version: 1.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Ennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-30 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler