infopark_cloud_connector 7.0.2 → 7.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +8 -8
  2. data/app/controllers/rails_connector/objs_controller.rb +29 -37
  3. data/app/helpers/rails_connector/cms_asset_helper.rb +1 -1
  4. data/app/helpers/rails_connector/cms_tag_helper.rb +1 -1
  5. data/app/helpers/rails_connector/default_cms_routing_helper.rb +1 -3
  6. data/app/helpers/rails_connector/display_helper.rb +5 -1
  7. data/app/views/rails_connector/_editing_javascript.html.erb +3 -2
  8. data/config/ca-bundle.crt +2 -2
  9. data/config/routes.rb +3 -0
  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/images/apple-touch-icon.jpg +0 -0
  14. data/lib/assets/images/favicon.ico +0 -0
  15. data/lib/assets/images/ip_logo.svg +50 -0
  16. data/lib/assets/javascripts/infopark_editing.js +903 -164
  17. data/lib/assets/stylesheets/infopark_editing.css +222 -271
  18. data/lib/infopark_cloud_connector.rb +0 -1
  19. data/lib/rails_connector/attribute_content.rb +25 -74
  20. data/lib/rails_connector/backend_error.rb +4 -0
  21. data/lib/rails_connector/basic_obj.rb +173 -20
  22. data/lib/rails_connector/basic_widget.rb +42 -1
  23. data/lib/rails_connector/blob.rb +1 -1
  24. data/lib/rails_connector/cache_middleware.rb +2 -2
  25. data/lib/rails_connector/cms_backend.rb +51 -33
  26. data/lib/rails_connector/cms_rest_api.rb +13 -8
  27. data/lib/rails_connector/cms_rest_api/attribute_serializer.rb +62 -0
  28. data/lib/rails_connector/cms_rest_api/blob_uploader.rb +18 -0
  29. data/lib/rails_connector/communication_error.rb +17 -0
  30. data/lib/rails_connector/configuration.rb +28 -0
  31. data/lib/rails_connector/connection_manager.rb +2 -2
  32. data/lib/rails_connector/content_conversion.rb +16 -62
  33. data/lib/rails_connector/content_service.rb +2 -2
  34. data/lib/rails_connector/engine.rb +2 -1
  35. data/lib/rails_connector/html_string.rb +0 -1
  36. data/lib/rails_connector/link.rb +41 -33
  37. data/lib/rails_connector/link_parser.rb +72 -0
  38. data/lib/rails_connector/migrations/migration_dsl.rb +13 -0
  39. data/lib/rails_connector/{backend_not_available.rb → network_error.rb} +1 -6
  40. data/lib/rails_connector/obj_data.rb +4 -0
  41. data/lib/rails_connector/obj_data_from_hash.rb +6 -0
  42. data/lib/rails_connector/obj_data_from_service.rb +37 -3
  43. data/lib/rails_connector/obj_params_parser.rb +50 -0
  44. data/lib/rails_connector/obj_search_builder.rb +62 -0
  45. data/lib/rails_connector/obj_search_enumerator.rb +60 -5
  46. data/lib/rails_connector/rate_limit_exceeded.rb +5 -0
  47. data/lib/rails_connector/revision.rb +9 -0
  48. data/lib/rails_connector/string_tagging.rb +1 -12
  49. data/lib/rails_connector/text_link.rb +52 -0
  50. data/lib/rails_connector/text_link_conversion.rb +50 -0
  51. data/lib/rails_connector/workspace.rb +125 -3
  52. data/lib/rails_connector/workspace_data_from_service.rb +30 -31
  53. data/lib/rails_connector/workspace_selection_middleware.rb +62 -20
  54. data/lib/tasks/cache.rake +2 -0
  55. data/lib/tasks/rails_connector/cache_garbage_collector_task.rb +98 -0
  56. metadata +24 -17
  57. data/lib/assets/images/ip_logo_app.png +0 -0
  58. data/lib/assets/images/ip_logo_app2x.png +0 -0
  59. data/lib/assets/images/irongrip.png +0 -0
  60. data/lib/rails_connector/link_resolvable.rb +0 -9
  61. data/lib/rails_connector/rack_middlewares.rb +0 -6
@@ -1,45 +1,42 @@
1
1
  module RailsConnector
2
2
 
3
3
  class WorkspaceDataFromService
4
- # Fetches a workspace data previously store in cache storage.
5
- # Returns nil if not found.
6
- def self.find_from_cache(id)
7
- if data = CmsCacheStorage.read_workspace_data(id)
8
- new(data)
4
+ class << self
5
+ # Fetches a workspace data previously store in cache storage.
6
+ # Returns nil if not found.
7
+ def find_from_cache(id)
8
+ if data = CmsCacheStorage.read_workspace_data(id)
9
+ new(data)
10
+ end
9
11
  end
10
- end
11
12
 
12
- def initialize(data)
13
- @data = data
14
- end
13
+ private
15
14
 
16
- def revision_id
17
- @data["revision_id"]
18
- end
19
-
20
- def id
21
- @data["id"]
22
- end
23
-
24
- def title
25
- @data["title"]
15
+ def data_attr_reader(attr_name)
16
+ define_method(attr_name) { @data[attr_name.to_s] }
17
+ end
26
18
  end
27
19
 
28
- # remove this method after DynamoCmsBackend has been removed from the Cloud Connector
29
- def content_cache_id=(id)
30
- # ignore, since not using content caches
31
- end
20
+ data_attr_reader :id
21
+ data_attr_reader :title
22
+ data_attr_reader :revision_id
23
+ data_attr_reader :content_state_id
24
+ data_attr_reader :base_revision_id
25
+ data_attr_reader :base_content_state_id
26
+ data_attr_reader :diff
32
27
 
33
- def content_state_id
34
- @data['content_state_id']
28
+ def initialize(data)
29
+ @data = data
35
30
  end
36
31
 
37
32
  def content_state
38
33
  @content_state ||= ContentState.find_or_create(content_state_id) if content_state_id
39
34
  end
40
35
 
41
- def diff
42
- @data['diff']
36
+ def base_content_state
37
+ if base_content_state_id
38
+ @base_content_state ||= ContentState.find_or_create(base_content_state_id)
39
+ end
43
40
  end
44
41
 
45
42
  def changes
@@ -65,10 +62,12 @@ class WorkspaceDataFromService
65
62
 
66
63
  def to_hash
67
64
  {
68
- 'id' => id,
69
- 'revision_id' => revision_id,
70
- 'title' => title,
71
- 'content_state_id' => content_state_id,
65
+ 'id' => id,
66
+ 'revision_id' => revision_id,
67
+ 'title' => title,
68
+ 'content_state_id' => content_state_id,
69
+ 'base_revision_id' => base_revision_id,
70
+ 'base_content_state_id' => base_content_state_id,
72
71
  }
73
72
  end
74
73
 
@@ -1,16 +1,74 @@
1
1
  module RailsConnector
2
2
 
3
3
  class WorkspaceSelectionMiddleware
4
- CURRENT_WORKSPACE_SESSION_KEY = '_rc-ws'
5
- CURRENT_WORKSPACE_PARAMS_KEY = '_rc-ws'
6
4
 
7
5
  def initialize(app)
8
6
  @app = app
9
7
  end
10
8
 
11
9
  def call(env)
12
- handle_workspace_parameter(env)
13
- workspace_id = session(env)[CURRENT_WORKSPACE_SESSION_KEY]
10
+ handler = WorkspaceParameterHandler.new(env)
11
+ handler.handle_params
12
+ set_current_workspace(handler.workspace_id)
13
+
14
+ @app.call(env)
15
+ end
16
+
17
+ private
18
+
19
+ class WorkspaceParameterHandler < Struct.new(:env)
20
+ WS_KEYS = {
21
+ current: '_rc-ws',
22
+ compare: '_rc-compare-ws',
23
+ base: '_rc-compare-base',
24
+ reverse: '_rc-compare-reverse'
25
+ }.freeze
26
+
27
+ def handle_params
28
+ if params_workspace_id.present?
29
+ remember_compare_workspace_params
30
+ elsif params_workspace_id == '' # empty param means "forget it"
31
+ forget_compare_workspace_params
32
+ end
33
+ end
34
+
35
+ def workspace_id
36
+ session[WS_KEYS[:current]]
37
+ end
38
+
39
+ private
40
+
41
+ def params_workspace_id
42
+ params[WS_KEYS[:current]]
43
+ end
44
+
45
+ def remember_compare_workspace_params
46
+ WS_KEYS.each do |_, value|
47
+ session[value] = params[value]
48
+ end
49
+ end
50
+
51
+ def forget_compare_workspace_params
52
+ WS_KEYS.each do |_, value|
53
+ session.delete(value)
54
+ end
55
+ end
56
+
57
+ def params
58
+ request.params
59
+ end
60
+
61
+ def request
62
+ Rack::Request.new(env)
63
+ end
64
+
65
+ def session
66
+ @session ||= env[Rack::Session::Abstract::ENV_SESSION_KEY]
67
+ end
68
+
69
+ end
70
+
71
+ def set_current_workspace(workspace_id)
14
72
  Workspace.current = proc do
15
73
  if workspace_id
16
74
  begin
@@ -22,24 +80,8 @@ class WorkspaceSelectionMiddleware
22
80
  Workspace.default
23
81
  end
24
82
  end
25
- @app.call(env)
26
83
  end
27
84
 
28
- private
29
-
30
- def handle_workspace_parameter(env)
31
- workspace_id = Rack::Request.new(env).params[CURRENT_WORKSPACE_PARAMS_KEY]
32
- return unless workspace_id
33
- if workspace_id.present?
34
- session(env)[CURRENT_WORKSPACE_SESSION_KEY] = workspace_id
35
- else
36
- session(env).delete(CURRENT_WORKSPACE_SESSION_KEY)
37
- end
38
- end
39
-
40
- def session(env)
41
- env[Rack::Session::Abstract::ENV_SESSION_KEY]
42
- end
43
85
  end
44
86
 
45
87
  end # module RailsConnector
@@ -0,0 +1,2 @@
1
+ require_relative 'rails_connector/cache_garbage_collector_task'
2
+ RailsConnector::CacheGarbageCollectorTask.new
@@ -0,0 +1,98 @@
1
+ require 'rake'
2
+ require 'rake/tasklib'
3
+
4
+ module RailsConnector
5
+ # The CacheGarbageCollectorTask allows to remove old cache files from the Rails Connector cache
6
+ # storage path. By default, a maximum of +DEFAULT_MAX_FILE_INODES+ file inodes that were accessed
7
+ # lately are kept in the cache directory. All other files and empty directories are removed. Log
8
+ # output is written to the Rails environment log file.
9
+ #
10
+ # @example Running the garbage collector with default settings
11
+ #
12
+ # bundle exec rake infopark:cache:gc
13
+ #
14
+ # @example Changing the maximum number of file inodes
15
+ #
16
+ # bundle exec rake infopark:cache:gc MAX_FILE_INODES=5000
17
+ class CacheGarbageCollectorTask < ::Rake::TaskLib
18
+ DEFAULT_MAX_FILE_INODES = 100000
19
+
20
+ attr_accessor :max_file_inodes
21
+
22
+ def initialize
23
+ @max_file_inodes = (ENV['MAX_FILE_INODES'] || DEFAULT_MAX_FILE_INODES).to_i
24
+
25
+ namespace :infopark do
26
+ namespace :cache do
27
+ desc "Cap number of cache file inodes at #{@max_file_inodes}. Use MAX_FILE_INODES to specify the
28
+ maximum. (default: #{DEFAULT_MAX_FILE_INODES})"
29
+ task gc: :environment do
30
+ run_gc
31
+ end
32
+ end
33
+ end
34
+ end
35
+
36
+ private
37
+
38
+ def run_gc
39
+ announce "Cap number of cache file inodes at #{max_file_inodes} in #{cache_path}."
40
+
41
+ directories = []
42
+ file_inode_count = 0
43
+ delta_disk_space = 0
44
+ delta_count = 0
45
+
46
+ cache_entries.each do |cache_entry|
47
+ begin
48
+ stat = File.stat(cache_entry)
49
+
50
+ if stat.file?
51
+ file_inode_count += 1
52
+ next if file_inode_count <= max_file_inodes
53
+
54
+ File.delete(cache_entry)
55
+
56
+ delta_disk_space += stat.size
57
+ delta_count += 1
58
+ elsif stat.directory?
59
+ directories << cache_entry
60
+ end
61
+ rescue Errno::ENOENT
62
+ end
63
+ end
64
+
65
+ directories.sort.reverse_each do |dirname|
66
+ begin
67
+ Dir.rmdir(dirname)
68
+ delta_count += 1
69
+ rescue Errno::ENOTEMPTY, Errno::ENOENT
70
+ end
71
+ end
72
+
73
+ announce "Done. Removed #{delta_count} entries. Saved at least #{delta_disk_space} Bytes."
74
+ end
75
+
76
+ def cache_path
77
+ CmsCacheStorage.backend_cache.cache_path
78
+ end
79
+
80
+ def cache_entries
81
+ Dir["#{cache_path}/**/*"].sort_by do |file|
82
+ begin
83
+ -File.atime(file).to_i
84
+ rescue Errno::ENOENT
85
+ # If such file or directory does not exist, sort it as if the last
86
+ # access time is very long ago.
87
+ 0
88
+ end
89
+ end
90
+ end
91
+
92
+ def announce(message)
93
+ message = "[#{Time.now.iso8601}] #{message}"
94
+
95
+ Rails.logger.info(message)
96
+ end
97
+ end
98
+ 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: 7.0.2
4
+ version: 7.1.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-11-21 00:00:00.000000000 Z
11
+ date: 2014-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,16 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
- version: !binary |-
34
- MC45LjIuMg==
33
+ version: 0.9.2.2
35
34
  type: :runtime
36
35
  prerelease: false
37
36
  version_requirements: !ruby/object:Gem::Requirement
38
37
  requirements:
39
38
  - - ! '>='
40
39
  - !ruby/object:Gem::Version
41
- version: !binary |-
42
- MC45LjIuMg==
40
+ version: 0.9.2.2
43
41
  - !ruby/object:Gem::Dependency
44
42
  name: json
45
43
  requirement: !ruby/object:Gem::Requirement
@@ -88,16 +86,14 @@ dependencies:
88
86
  requirements:
89
87
  - - ~>
90
88
  - !ruby/object:Gem::Version
91
- version: !binary |-
92
- MS41LjY=
89
+ version: 1.5.6
93
90
  type: :runtime
94
91
  prerelease: false
95
92
  version_requirements: !ruby/object:Gem::Requirement
96
93
  requirements:
97
94
  - - ~>
98
95
  - !ruby/object:Gem::Version
99
- version: !binary |-
100
- MS41LjY=
96
+ version: 1.5.6
101
97
  - !ruby/object:Gem::Dependency
102
98
  name: addressable
103
99
  requirement: !ruby/object:Gem::Requirement
@@ -160,9 +156,9 @@ files:
160
156
  - lib/assets/fonts/infopark_icons-webfont.ttf
161
157
  - lib/assets/fonts/infopark_icons-webfont.woff
162
158
  - lib/assets/images/180x120.gif
163
- - lib/assets/images/ip_logo_app.png
164
- - lib/assets/images/ip_logo_app2x.png
165
- - lib/assets/images/irongrip.png
159
+ - lib/assets/images/apple-touch-icon.jpg
160
+ - lib/assets/images/favicon.ico
161
+ - lib/assets/images/ip_logo.svg
166
162
  - lib/assets/images/rails_connector/image_placeholder.png
167
163
  - lib/assets/javascripts/infopark_editing.js
168
164
  - lib/assets/stylesheets/infopark_editing.css
@@ -173,7 +169,7 @@ files:
173
169
  - lib/obj.rb
174
170
  - lib/rails_connector/access_denied.rb
175
171
  - lib/rails_connector/attribute_content.rb
176
- - lib/rails_connector/backend_not_available.rb
172
+ - lib/rails_connector/backend_error.rb
177
173
  - lib/rails_connector/basic_obj.rb
178
174
  - lib/rails_connector/basic_widget.rb
179
175
  - lib/rails_connector/blob.rb
@@ -187,7 +183,10 @@ files:
187
183
  - lib/rails_connector/cms_dispatch_controller.rb
188
184
  - lib/rails_connector/cms_env.rb
189
185
  - lib/rails_connector/cms_rest_api.rb
186
+ - lib/rails_connector/cms_rest_api/attribute_serializer.rb
187
+ - lib/rails_connector/cms_rest_api/blob_uploader.rb
190
188
  - lib/rails_connector/cms_test_request.rb
189
+ - lib/rails_connector/communication_error.rb
191
190
  - lib/rails_connector/configuration.rb
192
191
  - lib/rails_connector/connection_manager.rb
193
192
  - lib/rails_connector/content_conversion.rb
@@ -204,7 +203,7 @@ files:
204
203
  - lib/rails_connector/errors.rb
205
204
  - lib/rails_connector/html_string.rb
206
205
  - lib/rails_connector/link.rb
207
- - lib/rails_connector/link_resolvable.rb
206
+ - lib/rails_connector/link_parser.rb
208
207
  - lib/rails_connector/log_subscriber.rb
209
208
  - lib/rails_connector/migration.rb
210
209
  - lib/rails_connector/migrations.rb
@@ -216,17 +215,25 @@ files:
216
215
  - lib/rails_connector/migrations/workspace_lock.rb
217
216
  - lib/rails_connector/model_identity.rb
218
217
  - lib/rails_connector/named_link.rb
218
+ - lib/rails_connector/network_error.rb
219
219
  - lib/rails_connector/obj_data.rb
220
220
  - lib/rails_connector/obj_data_from_hash.rb
221
221
  - lib/rails_connector/obj_data_from_service.rb
222
+ - lib/rails_connector/obj_params_parser.rb
223
+ - lib/rails_connector/obj_search_builder.rb
222
224
  - lib/rails_connector/obj_search_enumerator.rb
223
- - lib/rails_connector/rack_middlewares.rb
225
+ - lib/rails_connector/rate_limit_exceeded.rb
226
+ - lib/rails_connector/revision.rb
224
227
  - lib/rails_connector/string_tagging.rb
228
+ - lib/rails_connector/text_link.rb
229
+ - lib/rails_connector/text_link_conversion.rb
225
230
  - lib/rails_connector/type_computer.rb
226
231
  - lib/rails_connector/workspace.rb
227
232
  - lib/rails_connector/workspace_data_from_service.rb
228
233
  - lib/rails_connector/workspace_selection_middleware.rb
234
+ - lib/tasks/cache.rake
229
235
  - lib/tasks/migration.rake
236
+ - lib/tasks/rails_connector/cache_garbage_collector_task.rb
230
237
  - lib/widget.rb
231
238
  homepage: http://www.infopark.de
232
239
  licenses: []
@@ -247,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
254
  version: 1.3.5
248
255
  requirements: []
249
256
  rubyforge_project:
250
- rubygems_version: 2.1.5
257
+ rubygems_version: 2.2.2
251
258
  signing_key:
252
259
  specification_version: 4
253
260
  summary: Infopark Cloud Connector
@@ -1,9 +0,0 @@
1
- module RailsConnector
2
-
3
- module LinkResolvable
4
- attr_accessor :source
5
-
6
- end
7
-
8
-
9
- end
@@ -1,6 +0,0 @@
1
- module RailsConnector
2
- def self.rack_middlewares
3
- ["RailsConnector::CacheMiddleware", "RailsConnector::WorkspaceSelectionMiddleware"]
4
- end
5
- end
6
-