infopark_cloud_connector 6.9.5 → 7.0.0

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.
Files changed (37) hide show
  1. checksums.yaml +8 -8
  2. data/app/controllers/rails_connector/default_cms_controller.rb +0 -1
  3. data/app/controllers/rails_connector/objs_controller.rb +31 -27
  4. data/app/helpers/rails_connector/cms_tag_helper.rb +20 -12
  5. data/app/views/rails_connector/objs/show_widget.html.erb +1 -0
  6. data/config/ca-bundle.crt +1 -1
  7. data/config/locales/de.rails_connector.views.yml +0 -3
  8. data/config/locales/en.rails_connector.views.yml +0 -3
  9. data/config/routes.rb +2 -1
  10. data/lib/assets/fonts/infopark_icons-webfont.eot +0 -0
  11. data/lib/assets/fonts/infopark_icons-webfont.ttf +0 -0
  12. data/lib/assets/fonts/infopark_icons-webfont.woff +0 -0
  13. data/lib/assets/javascripts/infopark_editing.js +84 -35
  14. data/lib/assets/stylesheets/infopark_editing.css +227 -33
  15. data/lib/generators/cms/migration/migration_generator.rb +1 -1
  16. data/lib/generators/cms/migration/templates/{migration.rb → migration.erb} +0 -0
  17. data/lib/rails_connector/attribute_content.rb +39 -40
  18. data/lib/rails_connector/basic_obj.rb +64 -56
  19. data/lib/rails_connector/basic_widget.rb +2 -0
  20. data/lib/rails_connector/cms_accessible.rb +0 -17
  21. data/lib/rails_connector/cms_backend.rb +2 -2
  22. data/lib/rails_connector/cms_env.rb +0 -5
  23. data/lib/rails_connector/cms_rest_api.rb +62 -30
  24. data/lib/rails_connector/configuration.rb +3 -3
  25. data/lib/rails_connector/connection_manager.rb +98 -0
  26. data/lib/rails_connector/content_service.rb +12 -94
  27. data/lib/rails_connector/content_state_caching.rb +3 -5
  28. data/lib/rails_connector/deprecation.rb +21 -0
  29. data/lib/rails_connector/link.rb +12 -22
  30. data/lib/rails_connector/migrations/cms_backend.rb +1 -1
  31. data/lib/rails_connector/migrations/migration.rb +1 -1
  32. data/lib/rails_connector/migrations/migration_dsl.rb +10 -101
  33. data/lib/rails_connector/named_link.rb +1 -1
  34. data/lib/rails_connector/obj_search_enumerator.rb +37 -49
  35. metadata +6 -5
  36. data/app/views/errors/410_gone.html.erb +0 -7
  37. data/app/views/rails_connector/objs/show.html.erb +0 -1
@@ -31,7 +31,7 @@ module RailsConnector
31
31
  return nil
32
32
  end
33
33
 
34
- # This method will be called to retrieve the NamedLink Obj.
34
+ # This method will be called to retrieve the NamedLink {BasicObj Obj}.
35
35
  # By default it will look for the Obj at the path "_named_links".
36
36
  # Overwrite this method only if you know what you are doing.
37
37
  # @api public
@@ -4,30 +4,30 @@ module RailsConnector
4
4
  # This is done using the {http://ruby-doc.org/core-1.8.7/Enumerable.html <code>Enumerable</code> mixin},
5
5
  # which provides methods such as <code>map</code>, <code>select</code> or <code>take</code>.
6
6
  #
7
- # This enumerator is lazy. If for example you are looking for Objs with the ObjClass "Publication",
7
+ # This enumerator is lazy. If for example you are looking for {BasicObj Obj}s with the ObjClass "Publication",
8
8
  # and there are 93 objs in total, than <code>enum.take(10)</code> will fetch the first 10 objs only,
9
9
  # ignoring the other 83 objs.
10
10
  # This also means, that iterating multiple times over this enumerator causes the search results and objs to be fetched again.
11
11
  # If you want to get all objs at once, use <code>enum.to_a</code>.
12
12
  #
13
- # To start searching use one of the {Obj} methods that returns an {ObjSearchEnumerator}. The preferred way is to start with {Obj.where}.
13
+ # To start searching use one of the {BasicObj Obj} methods that returns an {ObjSearchEnumerator}. The preferred way is to start with {BasicObj.where Obj.where}.
14
14
  #
15
15
  # == Currently available fields and their values
16
16
  #
17
17
  # [+:*+] Searches all fields.
18
18
  # This is only possible with the operators +contais+ or +starts_with+.
19
- # [+:id+] Id of an {Obj}. This is a +string+ field.
20
- # [+:_path+] Path of an {Obj}. This is a +string+ field.
21
- # [+:_name+] Name of an {Obj}. This is a +string+ field.
22
- # [+:title+] Title of an {Obj}. This is a +string+ field.
23
- # [+:body+] Body of an {Obj}. This is an +html+ field. Thus, only the +contains+ and
19
+ # [+:id+] Id of an {BasicObj Obj}. This is a +string+ field.
20
+ # [+:_path+] Path of an {BasicObj Obj}. This is a +string+ field.
21
+ # [+:_name+] Name of an {BasicObj Obj}. This is a +string+ field.
22
+ # [+:title+] Title of an {BasicObj Obj}. This is a +string+ field.
23
+ # [+:body+] Body of an {BasicObj Obj}. This is an +html+ field. Thus, only the +contains+ and
24
24
  # +contains_prefix+ operators can be applied to this field.
25
- # [+:_obj_class+] ObjClass of an {Obj}. This is a +string+ field.
26
- # [+:_permalink+] Permalink of an {Obj}. This is a +string+ field.
27
- # [+:_valid_from+] The valid-from date of an {Obj}.
28
- # [+:_valid_until+] The valid-until date of an {Obj}.
29
- # [+:_last_changed+] Date of last change of an {Obj}.
30
- # [every <em><code>:custom_attribute</code></em>] Custom attribute of an {Obj}. Note that
25
+ # [+:_obj_class+] ObjClass of an {BasicObj Obj}. This is a +string+ field.
26
+ # [+:_permalink+] Permalink of an {BasicObj Obj}. This is a +string+ field.
27
+ # [+:_valid_from+] The valid-from date of an {BasicObj Obj}.
28
+ # [+:_valid_until+] The valid-until date of an {BasicObj Obj}.
29
+ # [+:_last_changed+] Date of last change of an {BasicObj Obj}.
30
+ # [every <em><code>:custom_attribute</code></em>] Custom attribute of an {BasicObj Obj}. Note that
31
31
  # depending on the attribute type (e.g. an
32
32
  # +html+ field), some operators can not be applied.
33
33
  #
@@ -111,23 +111,9 @@ module RailsConnector
111
111
  include Enumerable
112
112
 
113
113
  attr_reader :query
114
- attr_reader :options
115
- attr_reader :initial_offset
116
-
117
- # For all possible <code>query</code>'s and <code>options</code> have a look at the cms api documentation about objs/search.
118
- # There is one exception: To adjust how many search results should be fetch with one chunk, use the option <code>:batch_size</code>. The default is <code>10</code>. The <code>:size</code> option will be silently ignored.
119
- #
120
- # @example All objs, which are Publications
121
- # enum = ObjSearchEnumerator([{:field => '_obj_class', :operator => 'equal', :value => 'Publication'}])
122
- # enum.each { |obj| puts obj.path }
123
- #
124
- # @param [Array<Hash>] query
125
- # @param [Hash] options
126
- # @param [Integer] initial_offset
127
- def initialize(query, options = {}, initial_offset = 0)
114
+ def initialize(query)
128
115
  @query = query
129
- @options = options.symbolize_keys
130
- @initial_offset = initial_offset
116
+ @options = {}
131
117
  end
132
118
 
133
119
  # @group Chainable methods
@@ -196,57 +182,53 @@ module RailsConnector
196
182
  # @return [ObjSearchEnumerator]
197
183
  # @api public
198
184
  def order(field_name)
199
- @options[:sort_by] = field_name.to_sym
185
+ options[:sort_by] = field_name
200
186
 
201
187
  self
202
188
  end
203
189
 
204
- # Reverses the order of the results.
190
+ # Reverses the order of the results. Requires {#order} to be specified before.
205
191
  # @return [ObjSearchEnumerator]
206
192
  # @api public
207
193
  def reverse_order
208
- @options[:sort_order] = case options[:sort_order]
209
- when :asc
210
- :desc
211
- when :desc
212
- :asc
213
- else
214
- options[:sort_by].present? ? :desc : :asc
215
- end
194
+ options[:sort_by].present? or raise "A search order has to be specified"\
195
+ " before reverse_order can be applied."
196
+ @reverse_order = !@reverse_order
216
197
 
217
198
  self
218
199
  end
219
200
 
220
- # Sets the internal batch_size to +size+.
221
- # The default is +10+, the maximum is +100+.
201
+ # Number of search results to be returned by each of the internal search requests.
202
+ # The default is +10+. The server may limit a large batch size to a reasonable value.
222
203
  # @param [Integer] size A value in the range from +1+ to +100+.
223
204
  # @return [ObjSearchEnumerator]
224
205
  # @api public
225
206
  def batch_size(size)
226
- @options[:size] = size
207
+ options[:size] = size
227
208
 
228
209
  self
229
210
  end
230
211
 
231
212
 
232
- # Omits the first +amount+ number of {Obj}s from the results. The default is +0+.
213
+ # Omits the first +amount+ number of {BasicObj Obj}s from the results. The default is +0+.
233
214
  # @param [Integer] amount
234
215
  # @return [ObjSearchEnumerator]
235
216
  # @api public
236
217
  def offset(amount)
237
- @initial_offset += amount
218
+ options[:offset] ||= 0
219
+ options[:offset] += amount
238
220
 
239
221
  self
240
222
  end
241
223
 
242
224
  # @!endgroup
243
225
 
244
- # Iterates over the search result.
226
+ # Iterates over the search result, yielding {BasicObj Obj}.
245
227
  # @yield [Obj]
246
228
  # @return [void]
247
229
  # @api public
248
230
  def each
249
- offset = @initial_offset
231
+ offset = options[:offset] || 0
250
232
  current_batch, total = fetch_next_batch(offset)
251
233
  loop do
252
234
  if current_batch.size == 0
@@ -278,6 +260,8 @@ module RailsConnector
278
260
 
279
261
  private
280
262
 
263
+ attr_reader :options
264
+
281
265
  def convert_value(value)
282
266
  if value.kind_of?(Array)
283
267
  value.map{ |v| convert_single_value(v) }
@@ -320,14 +304,18 @@ module RailsConnector
320
304
  end
321
305
 
322
306
  def resource_path
323
- "revisions/#{Workspace.current.revision_id}/objs/search"
307
+ "workspaces/#{Workspace.current.id}/objs/search"
324
308
  end
325
309
 
326
310
  def search_dsl(offset)
327
- options.merge({
311
+ patches = {
328
312
  :offset => offset,
329
313
  :query => query,
330
- })
314
+ }
315
+ if @reverse_order
316
+ patches[:sort_order] = options[:sort_by].present? ? :desc : :asc
317
+ end
318
+ options.merge(patches)
331
319
  end
332
320
  end
333
321
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_cloud_connector
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.9.5
4
+ version: 7.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Infopark AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-24 00:00:00.000000000 Z
11
+ date: 2013-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -146,10 +146,9 @@ files:
146
146
  - app/views/cms/_index.html.erb
147
147
  - app/views/cms/index.html.erb
148
148
  - app/views/errors/403_forbidden.html.erb
149
- - app/views/errors/410_gone.html.erb
150
149
  - app/views/rails_connector/_editing_javascript.html.erb
151
150
  - app/views/rails_connector/objs/create_widget.html.erb
152
- - app/views/rails_connector/objs/show.html.erb
151
+ - app/views/rails_connector/objs/show_widget.html.erb
153
152
  - config/ca-bundle.crt
154
153
  - config/cms_routes.rb
155
154
  - config/locales/de.rails_connector.errors.yml
@@ -173,7 +172,7 @@ files:
173
172
  - lib/assets/stylesheets/infopark_editing.css
174
173
  - lib/generators/cms/migration/USAGE
175
174
  - lib/generators/cms/migration/migration_generator.rb
176
- - lib/generators/cms/migration/templates/migration.rb
175
+ - lib/generators/cms/migration/templates/migration.erb
177
176
  - lib/infopark_cloud_connector.rb
178
177
  - lib/obj.rb
179
178
  - lib/rails_connector/access_denied.rb
@@ -195,6 +194,7 @@ files:
195
194
  - lib/rails_connector/cms_rest_api.rb
196
195
  - lib/rails_connector/cms_test_request.rb
197
196
  - lib/rails_connector/configuration.rb
197
+ - lib/rails_connector/connection_manager.rb
198
198
  - lib/rails_connector/content_conversion.rb
199
199
  - lib/rails_connector/content_service.rb
200
200
  - lib/rails_connector/content_state.rb
@@ -204,6 +204,7 @@ files:
204
204
  - lib/rails_connector/core_extensions.rb
205
205
  - lib/rails_connector/core_extensions/time.rb
206
206
  - lib/rails_connector/date_attribute.rb
207
+ - lib/rails_connector/deprecation.rb
207
208
  - lib/rails_connector/engine.rb
208
209
  - lib/rails_connector/errors.rb
209
210
  - lib/rails_connector/html_string.rb
@@ -1,7 +0,0 @@
1
- <h1><%= t(:'rails_connector.lib.cms_accessible.not_released') %></h1>
2
-
3
- <% if @valid_until && @valid_until < Time.now %>
4
- <%= raw t(:"rails_connector.views.errors.gone.not_released_anymore", :valid_until => "<strong>#{l @valid_until}</strong>") %>
5
- <% elsif @valid_from && Time.now < @valid_from %>
6
- <%= raw t(:"rails_connector.views.errors.gone.not_yet_released", :valid_from => "<strong>#{l @valid_from}</strong>") %>
7
- <% end %>
@@ -1 +0,0 @@
1
- <%= render_widget @obj, current_page, params[:field_name], @obj.widget_container %>