infopark_fiona7 1.6.1.1.1 → 1.6.1.1.5

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
  SHA1:
3
- metadata.gz: 8619bcb34e8b06c4499cce99ce0cad5609cc5691
4
- data.tar.gz: 2d10b5a8e74cfc9139ff9d10f27e7a478da66645
3
+ metadata.gz: 80b1c27d1b674276a829a3cb2fcb5320426af57b
4
+ data.tar.gz: 48a1c5073d802b1fe7af7cd8e376697efc1d1ffa
5
5
  SHA512:
6
- metadata.gz: 2da3e5d4a375674f33e7f8003eb5bdf85e6a1a48c83c74abcd92fcacbbe7d152ba8f4b2b49d76d80bfa8e60d5f59e30861992f3afcd7d6a4288e5ea56fd987b2
7
- data.tar.gz: 81be495b06b82580e67a75c229d0eca2d8162813068b900b78e19b8119a1db931530fb51be78ee6701445869045de8e8d85bdf3086da9eb36d0bb3a16899d578
6
+ metadata.gz: ba4897faefd1d314ba41862e9805ffb6ae001aa7f0094293230d5a775cd744febfe1f909d0afd249e68b68e202601d01e6d8b8e452d42566cdd5efbfa6eaf47f
7
+ data.tar.gz: 3586cdf2d048de46b7d8a220dcb72aec6e1e57cce85de06f2a69e061a380c286ad50d10538d8509214388425ed241100166d3be9b448b8e1be7a5a09f468e974
@@ -149,6 +149,32 @@
149
149
  });
150
150
  };
151
151
 
152
+ var enable_workflow_buttons = function(document, obj, buttons, source_frame){
153
+ // TODO: add special handling for scrivito_details_dialog and scrivito_inspector
154
+ var button;
155
+
156
+ // remove redundant buttons
157
+ $.each(actions, function (idx, action) {
158
+ if (buttons.indexOf(action) === -1) {
159
+ $('[data-fiona7-private-workflow-button="' + action + '"]', document).addClass('disabled').hide();
160
+ } else {
161
+ $('[data-fiona7-private-workflow-button="' + action + '"]', document).removeClass('disabled').show();
162
+ }
163
+ });
164
+
165
+ // conditionally enable release button
166
+ // find the release button
167
+ button = $('[data-fiona7-private-workflow-button="release"]', document);
168
+ if (obj.has_restriction() || ( buttons.length > 0 && buttons.indexOf("release") === -1) ) {
169
+ // release impossible
170
+ button.attr('disabled');
171
+ button.addClass('disabled');
172
+ } else if( obj.modification() || ( buttons.length > 0 && buttons.indexOf("release") !== -1) ) {
173
+ button.removeAttr('disabled');
174
+ button.removeClass('disabled');
175
+ }
176
+ }
177
+
152
178
  scrivito.gui.on('document', function(cms_document) {
153
179
  var page_config = (cms_document.page_config() || {})['current_page'] || {};
154
180
  var obj = cms_document.page();
@@ -158,51 +184,40 @@
158
184
  var source_frame = cms_document.browser_window();
159
185
 
160
186
  if (source_frame.name !== 'scrivito_application') {
161
- // TODO: add special handling for scrivito_details_dialog and scrivito_inspector
162
- var button;
163
-
164
- // enable workflow buttons
165
- $.each(buttons, function (idx, action) {
166
- // release is handled differently
167
- if (action === 'release') {
168
- return;
169
- }
170
-
171
- // find the workflow button
172
- button = $('[data-fiona7-private-workflow-button="' + action + '"]', cms_document.browser_window().document);
173
-
174
- // enable given workflow button
175
- button.removeAttr('disabled');
176
- button.removeClass('disabled');
177
- button.click(function () {
178
- workflowAction(action, obj.id(), reloadGivenWindow(source_frame));
179
- });
180
-
181
- });
182
-
183
187
  // remove redundant buttons
184
188
  $.each(actions, function (idx, action) {
185
- if (buttons.indexOf(action) === -1) {
186
- $('[data-fiona7-private-workflow-button="' + action + '"]', cms_document.browser_window().document).remove();
187
- }
189
+ $('[data-fiona7-private-workflow-button="' + action + '"]', cms_document.browser_window().document).click(function () {
190
+ if (buttons.indexOf(action) !== -1) {
191
+ workflowAction(action, obj.id(), reloadGivenWindow(source_frame));
192
+ }
193
+ });
188
194
  });
189
195
 
190
196
  // conditionally enable release button
191
197
  // find the release button
192
- button = $('[data-fiona7-private-workflow-button="release"]', cms_document.browser_window().document);
193
- if (obj.modification()) {
194
- if (obj.has_restriction()) {
195
- // release impossibru
196
- button.attr('title', obj.restriction_messages().join("; "));
197
- } else {
198
- button.removeAttr('disabled');
199
- button.removeClass('disabled');
200
- button.click(function () {
201
- releaseAction(obj.id(), reloadGivenWindow(source_frame));
202
- });
198
+ $('[data-fiona7-private-workflow-button="release"]', cms_document.browser_window().document).click(function () {
199
+ if( obj.modification() || ( buttons.length > 0 && buttons.indexOf("release") !== -1) ) {
200
+ releaseAction(obj.id(), reloadGivenWindow(source_frame));
203
201
  }
202
+ });
203
+
204
+ enable_workflow_buttons( cms_document.browser_window().document, obj, buttons, source_frame );
205
+
206
+ var check_actions = function(){
207
+ scrivito.ajax('GET', 'objs/' + obj.id() + '/workflow/list').then( function( data ) {
208
+ if( !data || data.error ) {
209
+ return;
210
+ }
211
+ enable_workflow_buttons(cms_document.browser_window().document, obj, data.actions, source_frame );
212
+ buttons = data.actions;
213
+ });
204
214
  }
205
215
 
216
+ scrivito.write_monitor.on('end_write', function() {
217
+ if (!scrivito.write_monitor.is_writing()) {
218
+ check_actions();
219
+ }
220
+ });
206
221
  return;
207
222
  }
208
223
 
@@ -266,6 +281,14 @@
266
281
  });
267
282
  });
268
283
 
284
+ scrivito.on('load', function() {
285
+ scrivito.page_menu(cms_document).update("scrivito.sdk.save_obj_to_clipboard",{
286
+ disabled: function disabled() {
287
+ return false;
288
+ }
289
+ });
290
+ });
291
+
269
292
  });
270
293
 
271
294
  return;
@@ -15,6 +15,10 @@
15
15
  scrivito.write_monitor.start_write();
16
16
  }
17
17
  }
18
+ // perform link resolving synchronous
19
+ if (path == 'resolve_paths') {
20
+ options.async = false;
21
+ }
18
22
 
19
23
  var ajaxPromise = singleAjax(type, path, options).then(function (result) {
20
24
  if (result && result.task && _.size(result) === 1) {
@@ -82,6 +82,9 @@ module Fiona7
82
82
  errors << error
83
83
  end
84
84
  end
85
+ if Fiona7.mode == :standalone
86
+ complex_object.check_binaries
87
+ end
85
88
  #complex_object.binaries.each do |widget_obj|
86
89
  # widget_obj.take
87
90
  # widget_obj.release!(comment)
@@ -24,6 +24,20 @@ module Fiona7
24
24
  workflow_action('reject')
25
25
  end
26
26
 
27
+ def list
28
+ @obj = WriteObj.find(params[:id])
29
+ actions = []
30
+ if ::Fiona7.workflows_enabled? and @obj.workflow.present?
31
+ actions = @obj.send(:crul_obj).valid_actions
32
+ else
33
+ actions = @obj.send(:crul_obj).valid_actions.select{ |a| ["release","edit"].include? a }
34
+ end
35
+ render json: { actions: actions }
36
+ rescue => e
37
+ Rails.logger.error("Error #{e.inspect} when executing valid_actions on #{@obj.id}")
38
+ render json: {message: e.message, message_for_editor: e.message}, status: 412
39
+ end
40
+
27
41
  protected
28
42
  def workflow_action(action)
29
43
  @obj = WriteObj.find(params[:id])
@@ -22,6 +22,7 @@ Fiona7::Engine.routes.draw do
22
22
  put '/__scrivito/objs/workflow/commit(.:format)', to: 'fiona7/workflow#commit', as: :fiona7_workflow_commit
23
23
  put '/__scrivito/objs/workflow/sign(.:format)', to: 'fiona7/workflow#sign', as: :fiona7_workflow_sign
24
24
  put '/__scrivito/objs/workflow/reject(.:format)', to: 'fiona7/workflow#reject', as: :fiona7_workflow_reject
25
+ get '/__scrivito/objs/:id/workflow/list(.:format)', to: 'fiona7/workflow#list', as: :fiona7_workflow_list
25
26
 
26
27
 
27
28
  get '/__scrivito/objs/:id/release/preview(.:format)', to: 'fiona7/release#preview', as: :fiona7_release_preview
@@ -8,11 +8,11 @@ require "fiona7/version"
8
8
  Gem::Specification.new do |s|
9
9
  s.name = "infopark_fiona7"
10
10
  s.version = Fiona7::VERSION
11
- s.authors = ["Tomasz Przedmojski"]
12
- s.email = ["tomasz.przedmojski@infopark.de"]
11
+ s.authors = ["Infopark AG"]
12
+ s.email = ["support@infopark.de"]
13
13
  s.homepage = "https://www.infopark.de"
14
- s.summary = "scrivito-compatible interface for classic Fiona"
15
- s.description = "scrivito-compatible interface for classic Fiona"
14
+ s.summary = "scrivito-compatible interface for Infopark CMS Fiona 7"
15
+ s.description = "scrivito-compatible interface for Infopark CMS Fiona 7"
16
16
 
17
17
  s.files = Dir["{app,config,db,lib}/**/*", "Rakefile", "README.md", "infopark_fiona7.gemspec"].reject do |f|
18
18
  /^app\/assets.*\.es6\.js$/ =~ f ||
@@ -24,7 +24,7 @@ Gem::Specification.new do |s|
24
24
  s.add_dependency "scrivito_sdk"
25
25
  s.add_dependency "scrivito_editors"
26
26
  s.add_dependency "infopark_fiona_connector", "= 7.0.1.beta2"
27
- s.add_dependency "infopark_reactor", ">= 1.25.0"
27
+ s.add_dependency "infopark_reactor", ">= 1.26.1"
28
28
  s.add_dependency "mini_magick"
29
29
  #s.add_development_dependency "ruby-prof"
30
30
  s.add_development_dependency "scrivito_development"
@@ -0,0 +1,29 @@
1
+ module Fiona7
2
+ module BinaryFilesCleaner
3
+
4
+ def delete_unused(binary)
5
+ perform_with_unused(binary, "delete!")
6
+ end
7
+ def unrelease_unused(binary)
8
+ perform_with_unused(binary, "unrelease!")
9
+ end
10
+
11
+ private
12
+ def perform_with_unused(binary, action)
13
+ blob_objs = Fiona7::WriteObj.where(obj_class: binary.obj_class, parent_obj_id: binary.parent_obj_id)
14
+ blob_objs.each do |blob_obj|
15
+ Rails.logger.info("Checking binary obj #{blob_obj.obj_id}")
16
+ if (!blob_obj.has_super_links? && blob_obj.obj_id != binary.obj_id)
17
+ # perform delete! without to check released?
18
+ if action == "delete!" || blob_obj.released?
19
+ Rails.logger.info("#{action} binary obj #{blob_obj.obj_id}")
20
+ Reactor::Sudo.su(Fiona7.root) do
21
+ blob_obj.send(:crul_obj).send(action)
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ end
29
+ end
@@ -3,6 +3,7 @@ require 'fiona7/blob_id_generator'
3
3
  require 'fiona7/builder/indirect_blob_builder_for_obj'
4
4
  require 'fiona7/builder/container_chain_builder'
5
5
  require 'fiona7/upload_path_selector'
6
+ require 'fiona7/binary_files_cleaner'
6
7
 
7
8
  module Fiona7
8
9
  module Builder
@@ -22,6 +23,8 @@ module Fiona7
22
23
  # NOTE: there is an exception to the above:
23
24
  # renaming a blob in standalone mode executes immediately
24
25
  class LazyBlobCopier
26
+ include Fiona7::BinaryFilesCleaner
27
+
25
28
  def initialize(attrs={})
26
29
  @destination_obj = attrs[:destination_obj]
27
30
  @attribute = attrs[:attr_name]
@@ -49,7 +49,7 @@ module Fiona7
49
49
  # we first have to make sure that the new parent exists
50
50
  # FIXME: moving the object and changing the obj class
51
51
  # will not move the object
52
- @obj.parent = ContainerChainBuilder.new(parent_path).call
52
+ @obj.send(:set_parent, ContainerChainBuilder.new(parent_path).call )
53
53
  end
54
54
  end
55
55
 
@@ -1,5 +1,9 @@
1
+ require 'fiona7/binary_files_cleaner'
2
+
1
3
  module Fiona7
2
4
  class ComplexObject
5
+ include Fiona7::BinaryFilesCleaner
6
+
3
7
  def initialize(obj)
4
8
  @obj = obj
5
9
  end
@@ -11,14 +15,24 @@ module Fiona7
11
15
  end
12
16
 
13
17
  def binaries
18
+ referenced = []
14
19
  type_definition = Fiona7::TypeRegister.instance.read_mangled(@obj.obj_class)
15
20
  type_definition.attrs.each do |attribute|
16
21
  if attribute.type == :binary && attribute.real_name != "blob"
17
- (obj[attribute.real_name] || []).each do |link|
22
+ (@obj[attribute.real_name] || []).each do |link|
18
23
  referenced << link.destination_object
24
+ Rails.logger.debug("referenced #{referenced}")
19
25
  end
20
26
  end
21
27
  end
28
+ referenced
22
29
  end
30
+
31
+ def check_binaries
32
+ binaries.each do |binary|
33
+ unrelease_unused(binary)
34
+ end
35
+ end
36
+
23
37
  end
24
38
  end
@@ -271,7 +271,13 @@ module Fiona7
271
271
  meta_binary = MetaBinary.new(binary_id, transformation)
272
272
 
273
273
  if !meta_binary.present?
274
- not_found
274
+ if Fiona7.mode == :standalone &&
275
+ (current_binary = get_current_binary_url(binary_id))
276
+ Rails.logger.info("Redirect to #{current_binary}")
277
+ redirect_to current_binary, status: 301
278
+ else
279
+ not_found
280
+ end
275
281
  elsif !meta_binary.valid?
276
282
  bad_request
277
283
  elsif stale?(:last_modified => meta_binary.last_changed) && true
@@ -317,6 +323,18 @@ module Fiona7
317
323
  def head_ok
318
324
  head 200
319
325
  end
326
+
327
+ def get_current_binary_url(binary_id)
328
+ current_binary_url = nil
329
+ blob_obj = Fiona7::WriteObj.find(binary_id.to_i) rescue nil
330
+ if blob_obj
331
+ binary_obj = blob_obj.parent.parent rescue nil
332
+ if binary_obj
333
+ current_binary_url = Obj.find(binary_obj.obj_id).blob.url rescue nil
334
+ end
335
+ end
336
+ current_binary_url
337
+ end
320
338
  end
321
339
 
322
340
 
@@ -10,7 +10,7 @@ module Scrivito
10
10
  path: obj.path,
11
11
  obj_class: obj.obj_class,
12
12
  description_for_editor: obj.description_for_editor,
13
- has_children: obj.children.any?,
13
+ has_children: obj.children.reject(&:binary?).any?,
14
14
  has_conflict: obj.has_conflict?,
15
15
  has_details_view: obj_has_details_view?,
16
16
  modification: modification(obj),
@@ -1,3 +1,3 @@
1
1
  module Fiona7
2
- VERSION = "1.6.1.1.1"
2
+ VERSION = "1.6.1.1.5"
3
3
  end
@@ -25,6 +25,7 @@ module Fiona7
25
25
  protected
26
26
  attr_accessor :object, :widget_resolver
27
27
  def revert!(widget_object)
28
+ widget_object.take! if widget_object.really_edited?
28
29
  widget_object.revert! if widget_object.really_edited?
29
30
  end
30
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: infopark_fiona7
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1.1.1
4
+ version: 1.6.1.1.5
5
5
  platform: ruby
6
6
  authors:
7
- - Tomasz Przedmojski
7
+ - Infopark AG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-05 00:00:00.000000000 Z
11
+ date: 2018-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: 1.25.0
89
+ version: 1.26.1
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: 1.25.0
96
+ version: 1.26.1
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: mini_magick
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,9 +122,9 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- description: scrivito-compatible interface for classic Fiona
125
+ description: scrivito-compatible interface for Infopark CMS Fiona 7
126
126
  email:
127
- - tomasz.przedmojski@infopark.de
127
+ - support@infopark.de
128
128
  executables: []
129
129
  extensions: []
130
130
  extra_rdoc_files: []
@@ -238,6 +238,7 @@ files:
238
238
  - lib/fiona7/attribute_writers/simple.rb
239
239
  - lib/fiona7/attribute_writers/stringlist_as_text.rb
240
240
  - lib/fiona7/attribute_writers/widgetlist_as_linklist.rb
241
+ - lib/fiona7/binary_files_cleaner.rb
241
242
  - lib/fiona7/blob_id_generator.rb
242
243
  - lib/fiona7/builder/batch_widget_writer.rb
243
244
  - lib/fiona7/builder/container_chain_builder.rb
@@ -365,8 +366,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
365
366
  version: '0'
366
367
  requirements: []
367
368
  rubyforge_project:
368
- rubygems_version: 2.5.2
369
+ rubygems_version: 2.6.13
369
370
  signing_key:
370
371
  specification_version: 4
371
- summary: scrivito-compatible interface for classic Fiona
372
+ summary: scrivito-compatible interface for Infopark CMS Fiona 7
372
373
  test_files: []