promethee 2.0.9 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f1fb7feeef8b939218cbbc2bd2644ccb3b76b0521c37baeceee9cca88c29d4d
|
4
|
+
data.tar.gz: b69b7bfd8d5d3be2b84d67dfacebc25b0bc5605e53b85c2bf7653b2e50722317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26dbfc8ec99d7fd08d3cdfd8cff440fbd57a793ba68b8d412122f74c419fd4ed202c48c96623f6f3a3813764a1d735deb6c9074f126fa16cc8aab39463af510f
|
7
|
+
data.tar.gz: 7e5afc38246c53b7b2f5c484e37c0db6d5c780f5cf60e05675788b3c4ab193a7f5633cda23d68085ef195a96b7c6edfb73979d5f4857f374a032742a785c215b
|
@@ -17,7 +17,17 @@ class PrometheeController < ApplicationController
|
|
17
17
|
|
18
18
|
def blob_show
|
19
19
|
# as this is called only from promethee preview it sends an image resized to 720
|
20
|
-
|
20
|
+
blob_id = params[:id]
|
21
|
+
if blob_id.to_i.to_s == blob_id
|
22
|
+
blob = ActiveStorage::Blob.find(blob_id)
|
23
|
+
else
|
24
|
+
begin
|
25
|
+
blob = ActiveStorage::Blob.find_signed(blob_id)
|
26
|
+
rescue
|
27
|
+
raise ActiveRecord::RecordNotFound
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
21
31
|
if blob.image? && blob.variable?
|
22
32
|
redirect_to url_for(blob.variant(resize: '720>'))
|
23
33
|
elsif blob.video?
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Promethee
|
2
|
+
class BlobUpgradeService
|
3
|
+
attr_accessor :objects
|
4
|
+
|
5
|
+
def initialize(model_name)
|
6
|
+
begin
|
7
|
+
model_class = model_name.constantize
|
8
|
+
objects = model_class.all
|
9
|
+
rescue
|
10
|
+
puts 'Please provide a valid model name (e.g. `rake promethee:upgrade_blob_data[Page]`)'
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
@objects = objects
|
14
|
+
end
|
15
|
+
|
16
|
+
def start
|
17
|
+
puts '= START BLOB UPGRADE ='
|
18
|
+
puts "Number of objects: #{@objects.count}"
|
19
|
+
@objects.each do |object|
|
20
|
+
puts "Processing object ##{object.id}"
|
21
|
+
|
22
|
+
object.data = upgrade_component(object.data.deep_symbolize_keys)
|
23
|
+
object.save
|
24
|
+
puts "End processing object ##{object.id}"
|
25
|
+
end
|
26
|
+
puts '====== END UPGRADER ========'
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def upgrade_component(component)
|
32
|
+
component[:attributes] = upgrade_attribute(component[:attributes]) unless component[:attributes].nil?
|
33
|
+
component[:children].map { |child_component|
|
34
|
+
upgrade_component(child_component)
|
35
|
+
} unless component[:children].nil?
|
36
|
+
|
37
|
+
component
|
38
|
+
end
|
39
|
+
|
40
|
+
def upgrade_attribute(attribute_value)
|
41
|
+
return upgrade_blob_data(attribute_value) if is_blob_data?(attribute_value)
|
42
|
+
|
43
|
+
if attribute_value.is_a? Array
|
44
|
+
attribute_value.map { |item| upgrade_attribute(item) }
|
45
|
+
elsif attribute_value.is_a? Hash
|
46
|
+
attribute_value.map { |key, value| [key, upgrade_attribute(value)] }.to_h
|
47
|
+
else
|
48
|
+
attribute_value
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def upgrade_blob_data(blob_data)
|
53
|
+
new_blob_data = blob_data.dup
|
54
|
+
blob_id = new_blob_data[:id]
|
55
|
+
return new_blob_data unless blob_id.present? && blob_id.is_a?(Integer)
|
56
|
+
|
57
|
+
blob = ActiveStorage::Blob.find_by(id: blob_id)
|
58
|
+
new_blob_data[:id] = blob.signed_id unless blob.nil?
|
59
|
+
|
60
|
+
new_blob_data
|
61
|
+
end
|
62
|
+
|
63
|
+
def is_blob_data?(hash)
|
64
|
+
hash.is_a?(Hash) && hash.keys == [:id, :name]
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -7,7 +7,7 @@ module Promethee
|
|
7
7
|
model_class = model_name.constantize
|
8
8
|
objects = model_class.all.select { |page| page.data&.to_json&.include? '"type":"table"' }
|
9
9
|
rescue
|
10
|
-
puts 'Please provide a valid model name (e.g. `rake promethee:
|
10
|
+
puts 'Please provide a valid model name (e.g. `rake promethee:upgrade_table[Page]`)'
|
11
11
|
exit
|
12
12
|
end
|
13
13
|
@objects = objects
|
@@ -23,7 +23,7 @@ module Promethee
|
|
23
23
|
object.save
|
24
24
|
puts "End processing object ##{object.id}"
|
25
25
|
end
|
26
|
-
puts '====== END
|
26
|
+
puts '====== END UPGRADER ========'
|
27
27
|
end
|
28
28
|
|
29
29
|
private
|
@@ -12,4 +12,10 @@ namespace :promethee do
|
|
12
12
|
service.start
|
13
13
|
end
|
14
14
|
|
15
|
+
desc "Upgrade blob data from IDs to signed IDs"
|
16
|
+
task :upgrade_blob_data, [:model_name] => :environment do |task, args|
|
17
|
+
service = Promethee::BlobUpgradeService.new(args[:model_name])
|
18
|
+
service.start
|
19
|
+
end
|
20
|
+
|
15
21
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promethee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sébastien Gaya
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2019-10-
|
17
|
+
date: 2019-10-03 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: rails
|
@@ -191,6 +191,7 @@ files:
|
|
191
191
|
- app/assets/stylesheets/promethee.sass
|
192
192
|
- app/controllers/promethee_controller.rb
|
193
193
|
- app/models/concerns/promethee_data.rb
|
194
|
+
- app/services/promethee/blob_upgrade_service.rb
|
194
195
|
- app/services/promethee/localize_clean_service.rb
|
195
196
|
- app/services/promethee/table_upgrade_service.rb
|
196
197
|
- app/views/promethee/_edit.html.erb
|