editmode 1.3.6 → 1.6.0.pre.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: 32d49f4215168d36260f8b3f363c12d7ba6948fd7e9f97e8dae1e1b58ddb7ef8
4
- data.tar.gz: ed1cf4a9c60ae63973ed9e3f98b5c2a7e66eb4b273e1a392509574aa7ae3f86a
3
+ metadata.gz: 7025b651a7a15300b25ee1f151a510ccc12ed7f934240b4103b6ec6980b23a85
4
+ data.tar.gz: cb4c278ac603a883e7c7a6a8abb84362cda6c374d3dae2ef5ba6d21763468560
5
5
  SHA512:
6
- metadata.gz: b2036241a90a7d9eff95d2da0553918d278f37c5336b181bcf62d076bb7a4184f87b8dac5a286026dc88f5beaf46e54db5020f6228877d88b0a72592bd85ee2c
7
- data.tar.gz: 6f0354be4a33de404b01f0b1611a87e95c4916b59f0034356cc647192b99f77b113424c5b463d1542c6e405306c959a4477c93949d92392e382c9f7fa98000f1
6
+ metadata.gz: afbb6a9a44136b626e60207ebeab2e54a32249587cf26d7d104aeee78c60a84e5e4386d4e951719d2959b95cb38339dddf608ab5479fbb09b4e3e21820d34d0c
7
+ data.tar.gz: 19bafb08bd133a91a2eff430a9c49ea265737ec819d17f5e1d3ebe9e3a76021c6b32145ce514ed13e976b76531192795299bda4ef1772de0af94d5eb490b5fe0
@@ -63,11 +63,15 @@ module Editmode
63
63
 
64
64
  if chunks.any?
65
65
  content_tag :div, class: "chunks-collection-wrapper #{parent_class}", data: {chunk_collection_identifier: collection_identifier} do
66
- chunks.each do |chunk|
66
+ chunks.each_with_index do |chunk, index|
67
67
  @custom_field_chunk = chunk
68
- concat(content_tag(:div, class: "chunks-collection-item--wrapper #{item_class}") do
69
- yield(@custom_field_chunk)
70
- end)
68
+ if options[:without_item_wrapper].present?
69
+ 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
75
  end
72
76
 
73
77
  # Placeholder element for new collection item
@@ -163,7 +167,7 @@ module Editmode
163
167
  # prevent the page from loading.
164
168
  begin
165
169
  field = options[:field].presence || ""
166
- options[:referrer] = request.url
170
+ options[:referrer] = request.present? && request.url || ""
167
171
  chunk_value = Editmode::ChunkValue.new(identifier, options)
168
172
 
169
173
  if field.present? && chunk_value.chunk_type == 'collection_item'
@@ -182,11 +186,12 @@ module Editmode
182
186
  render_chunk_content(identifier, chunk_content, chunk_type, options)
183
187
 
184
188
  rescue => error
189
+ puts error
185
190
  # Show fallback content by default
186
191
  return content_tag("em-span", &block) if block_given?
187
192
  # Otherwise show a span with no content to
188
193
  # maintain layout
189
- content_tag("em-span", "&nbsp".html_safe)
194
+ content_tag("em-span", "&nbsp".html_safe)
190
195
  end
191
196
  end
192
197
  alias_method :chunk, :chunk_display
@@ -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
@@ -5,7 +5,7 @@ module Editmode
5
5
  field, options = parse_arguments(args)
6
6
  begin
7
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)
11
11
  else
@@ -13,6 +13,7 @@ module Editmode
13
13
  end
14
14
  rescue => er
15
15
  Rails.logger.info "#{er}: We can't render content for #{identifier}"
16
+ return ""
16
17
  end
17
18
  end
18
19
 
@@ -1,3 +1,3 @@
1
1
  module Editmode
2
- VERSION = "1.3.6"
2
+ VERSION = "1.6.0.pre.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.6
4
+ version: 1.6.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Ennis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-15 00:00:00.000000000 Z
11
+ date: 2021-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,7 +97,7 @@ homepage: https://github.com/tonyennis145/editmode-rails
97
97
  licenses:
98
98
  - MIT
99
99
  metadata: {}
100
- post_install_message:
100
+ post_install_message:
101
101
  rdoc_options: []
102
102
  require_paths:
103
103
  - lib
@@ -108,12 +108,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  required_rubygems_version: !ruby/object:Gem::Requirement
110
110
  requirements:
111
- - - ">="
111
+ - - ">"
112
112
  - !ruby/object:Gem::Version
113
- version: '0'
113
+ version: 1.3.1
114
114
  requirements: []
115
- rubygems_version: 3.2.4
116
- signing_key:
115
+ rubygems_version: 3.0.3.1
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
119
119
  bits of content that can be managed by anyone with no technical knowledge