infopark_fiona7 1.5.5.5.1 → 1.6.1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +17 -0
- data/app/assets/javascripts/fiona7/task_list_dialog.js +2 -2
- data/app/assets/javascripts/fiona7/templates.js +1 -16
- data/app/assets/javascripts/fiona7/translations.js +22 -23
- data/app/assets/javascripts/fiona7_ui.js +56 -59
- data/app/assets/javascripts/scrivito_patches/base_obj_path.js +11 -5
- data/app/assets/javascripts/scrivito_patches/binary_request.js +53 -0
- data/app/assets/javascripts/scrivito_patches/client/ajax.js +122 -0
- data/app/assets/javascripts/scrivito_patches/{models/api → client}/basic_obj.js +150 -243
- data/app/assets/javascripts/scrivito_patches/client/cms_rest_api.js +209 -0
- data/app/assets/javascripts/scrivito_patches/components/sidebar/workspaces_panel.js +325 -0
- data/app/assets/javascripts/scrivito_patches/components/sidebar/workspaces_panel.js.jsx +294 -0
- data/app/assets/javascripts/scrivito_patches/models/{obj.js → legacy_obj.js} +27 -54
- data/app/assets/stylesheets/fiona7_ui.css.scss +2 -0
- data/app/controllers/fiona7/release_controller.rb +7 -6
- data/app/controllers/fiona7/sessions_controller.rb +10 -2
- data/app/controllers/fiona7/uploads_controller.rb +22 -0
- data/app/controllers/fiona7_login_page_controller.rb +3 -0
- data/app/controllers/scrivito/obj_class_controller.rb +28 -5
- data/app/views/fiona7/release/preview.html.erb +5 -38
- data/app/views/fiona7_login_page/index.html.erb +6 -0
- data/config/precedence_routes.rb +7 -7
- data/infopark_fiona7.gemspec +2 -2
- data/lib/fiona7/attribute_readers/number_as_string.rb +6 -1
- data/lib/fiona7/attribute_writers/binary_as_binary.rb +4 -2
- data/lib/fiona7/attribute_writers/binary_as_linklist.rb +4 -2
- data/lib/fiona7/builder/container_chain_builder.rb +50 -0
- data/lib/fiona7/builder/indirect_blob_builder.rb +7 -47
- data/lib/fiona7/builder/indirect_blob_builder_for_obj.rb +14 -0
- data/lib/fiona7/builder/lazy_blob_copier.rb +68 -14
- data/lib/fiona7/builder/obj_builder.rb +6 -32
- data/lib/fiona7/builder/obj_updater.rb +12 -4
- data/lib/fiona7/builder/widget_builder.rb +1 -1
- data/lib/fiona7/controllers/rest_api/blob_controller.rb +8 -2
- data/lib/fiona7/controllers/rest_api/obj_controller.rb +12 -8
- data/lib/fiona7/controllers/rest_api/workspace_controller.rb +6 -0
- data/lib/fiona7/engine.rb +49 -3
- data/lib/fiona7/forbidden_obj_classes.rb +14 -3
- data/lib/fiona7/linked_id_finder.rb +44 -0
- data/lib/fiona7/name_and_parent_from_path.rb +11 -0
- data/lib/fiona7/referenced_id_finder.rb +24 -0
- data/lib/fiona7/release_collector.rb +85 -0
- data/lib/fiona7/routers/rest_api.rb +2 -0
- data/lib/fiona7/scrivito_patches/cms_field_tag.rb +1 -0
- data/lib/fiona7/scrivito_patches/cms_rest_api.rb +16 -16
- data/lib/fiona7/scrivito_patches/cms_routing.rb +1 -0
- data/lib/fiona7/scrivito_patches/link_parser.rb +10 -7
- data/lib/fiona7/scrivito_patches/workspace.rb +0 -5
- data/lib/fiona7/super_id_finder.rb +68 -0
- data/lib/fiona7/super_object_finder.rb +5 -20
- data/lib/fiona7/temporary_uploader.rb +33 -0
- data/lib/fiona7/upload_path_selector.rb +17 -0
- data/lib/fiona7/verity_search_engine.rb +25 -12
- data/lib/fiona7/version.rb +1 -1
- metadata +23 -19
- data/app/assets/javascripts/fiona7/task_list_command.js +0 -15
- data/app/assets/javascripts/fiona7/task_list_menu_item.js +0 -30
- data/app/assets/javascripts/scrivito_patches/ajax.js +0 -225
- data/app/assets/javascripts/scrivito_patches/attribute_serializer.js +0 -259
- data/app/assets/javascripts/scrivito_patches/binary_utils.js +0 -33
- data/app/assets/javascripts/scrivito_patches/cms_rest_api.js +0 -371
- data/app/assets/javascripts/scrivito_patches/models/binary_field_element.js +0 -53
- data/app/assets/javascripts/scrivito_patches/obj_serializer.js +0 -91
- data/lib/fiona7/scrivito_patches/attribute_serializer.rb +0 -37
- data/lib/fiona7/scrivito_patches/model_library.rb +0 -19
- data/lib/fiona7/scrivito_patches/obj_params_parser.rb +0 -20
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'fiona7/super_id_finder'
|
2
|
+
require 'fiona7/attribute_names_from_cms'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
class LinkedIdFinder
|
6
|
+
def initialize(fields=[], connection=::Fiona7::WriteObj.connection, instance_name=RailsConnector::CmsBaseModel.instance_name)
|
7
|
+
@fields = fields.map {|f|
|
8
|
+
Fiona7::AttributeNamesFromCms.new(f).attributes
|
9
|
+
}.flatten
|
10
|
+
@instance = instance_name
|
11
|
+
@connection = connection
|
12
|
+
end
|
13
|
+
|
14
|
+
def find(klass, ids)
|
15
|
+
mode = klass == Fiona7::ReleasedObj ? :live : :preview
|
16
|
+
forbidden = Fiona7::ForbiddenObjClasses.new
|
17
|
+
|
18
|
+
# first we find objects linking directly
|
19
|
+
# NOTE: this may return widget objects
|
20
|
+
linking_directly = Fiona7::SuperIdFinder.new(
|
21
|
+
forbidden.system_obj_classes, @fields, @connection, @instance
|
22
|
+
).find(
|
23
|
+
mode, ids
|
24
|
+
)
|
25
|
+
|
26
|
+
# now we resolve widget objects
|
27
|
+
linking_indirectly = Fiona7::SuperIdFinder.new(
|
28
|
+
forbidden.all, ['X_widget_pool'], @connection, @instance
|
29
|
+
).find(
|
30
|
+
mode, linking_directly
|
31
|
+
)
|
32
|
+
|
33
|
+
all_linking = linking_directly + linking_indirectly
|
34
|
+
|
35
|
+
# finally, this removes widget objects from the result
|
36
|
+
# we also remove system classes, just to be extra sure
|
37
|
+
klass.
|
38
|
+
where(obj_id: all_linking).
|
39
|
+
where.not(obj_class: forbidden.all).
|
40
|
+
select(:obj_id).
|
41
|
+
map(&:obj_id)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'fiona7/super_id_finder'
|
2
|
+
require 'fiona7/attribute_names_from_cms'
|
3
|
+
|
4
|
+
module Fiona7
|
5
|
+
class ReferencedIdFinder
|
6
|
+
def initialize(fields=[], connection=::Fiona7::WriteObj.connection, instance_name=RailsConnector::CmsBaseModel.instance_name)
|
7
|
+
fields = fields.map {|f|
|
8
|
+
Fiona7::AttributeNamesFromCms.new(f).attributes
|
9
|
+
}.flatten
|
10
|
+
forbidden = Fiona7::ForbiddenObjClasses.new.call
|
11
|
+
|
12
|
+
@id_finder = Fiona7::SuperIdFinder.new(
|
13
|
+
forbidden, fields, connection, instance_name
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def find(klass, ids)
|
18
|
+
@id_finder.find(
|
19
|
+
klass == Fiona7::ReleasedObj ? :live : :preview,
|
20
|
+
ids
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
require 'fiona7/recursive_object_finder'
|
2
|
+
|
3
|
+
module Fiona7
|
4
|
+
class ReleaseCollector
|
5
|
+
def initialize(obj_id)
|
6
|
+
@obj = Fiona7::WriteObj.find(obj_id)
|
7
|
+
@finder = Fiona7::RecursiveObjectFinder.new(@obj)
|
8
|
+
end
|
9
|
+
|
10
|
+
def call
|
11
|
+
[
|
12
|
+
images,
|
13
|
+
downloads,
|
14
|
+
referenced,
|
15
|
+
linked
|
16
|
+
].compact
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.call(obj_id)
|
20
|
+
self.new(obj_id).call
|
21
|
+
end
|
22
|
+
|
23
|
+
protected
|
24
|
+
def images
|
25
|
+
objs = @finder.images.select {|o| o.really_edited? }
|
26
|
+
|
27
|
+
|
28
|
+
if objs.any?
|
29
|
+
group = {
|
30
|
+
title: t(:"fiona7.release.images"),
|
31
|
+
objs: objs_to_items(objs, true)
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def downloads
|
37
|
+
objs = @finder.downloads.select {|o| o.really_edited? }
|
38
|
+
|
39
|
+
if objs.any?
|
40
|
+
group = {
|
41
|
+
title: t(:"fiona7.release.downloads"),
|
42
|
+
objs: objs_to_items(objs, true)
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def referenced
|
48
|
+
objs = @finder.referenced.select {|o| o.really_edited? }
|
49
|
+
|
50
|
+
if objs.any?
|
51
|
+
group = {
|
52
|
+
title: t(:"fiona7.release.referenced"),
|
53
|
+
objs: objs_to_items(objs, true)
|
54
|
+
}
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def linked
|
59
|
+
objs = @finder.linked.select {|o| o.really_edited? }
|
60
|
+
|
61
|
+
if objs.any?
|
62
|
+
group = {
|
63
|
+
title: t(:"fiona7.release.linked"),
|
64
|
+
objs: objs_to_items(objs, false)
|
65
|
+
}
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
def objs_to_items(objs, checked=true)
|
71
|
+
items = objs.map do |obj|
|
72
|
+
{
|
73
|
+
id: obj.id,
|
74
|
+
title: (obj.title.presence || obj.path),
|
75
|
+
description: obj.obj_class,
|
76
|
+
checked: checked
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def t(key, options={})
|
82
|
+
I18n.t(key, {locale: (Scrivito::Configuration.ui_locale || I18n.locale)}.merge(options))
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -49,6 +49,8 @@ class Scrivito::CmsRestApi
|
|
49
49
|
when /\A\/?workspaces\/[a-zA-Z0-9_-]+\/objs\/search/
|
50
50
|
_, _, workspace_id = *resource_path.split("/")
|
51
51
|
Fiona7::Controllers::RestAPI::ObjController.new.search(workspace_id, payload)
|
52
|
+
when /\A\/?workspaces\/by_modified_obj/
|
53
|
+
Fiona7::Controllers::RestAPI::WorkspaceController.new.by_modified_obj()
|
52
54
|
when /\A\/?workspaces\/[a-zA-Z0-9_-]+\Z/
|
53
55
|
_, _, workspace_id = *resource_path.split("/")
|
54
56
|
Fiona7::Controllers::RestAPI::WorkspaceController.new.fetch(workspace_id)
|
@@ -22,6 +22,7 @@ module Scrivito
|
|
22
22
|
private
|
23
23
|
# add permission checking
|
24
24
|
def authenticated_editor?
|
25
|
+
# NOTE: we check the permissions on the object and not on the widget object itself. It would probaby be better (but slower) to check on the widget object
|
25
26
|
editing_context.authenticated_editor? &&
|
26
27
|
(permitted?(editing_context.editor.id, obj_not_widget_id, :root) ||
|
27
28
|
permitted?(editing_context.editor.id, obj_not_widget_id, :write))
|
@@ -1,26 +1,26 @@
|
|
1
1
|
require 'scrivito/cms_rest_api.rb'
|
2
|
-
require 'fiona7/
|
2
|
+
require 'fiona7/temporary_uploader'
|
3
3
|
|
4
4
|
module Scrivito
|
5
5
|
class CmsRestApi
|
6
|
-
#
|
6
|
+
# uploads are handled differently than in scrivito_sdk
|
7
7
|
def self.upload_future_binary(future_binary, obj_id)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
'X_Image'
|
15
|
-
else
|
16
|
-
'X_Generic'
|
17
|
-
end
|
8
|
+
if future_binary.id_to_copy
|
9
|
+
normalized_id = normalize_path_component(future_binary.id_to_copy)
|
10
|
+
put("blobs/#{normalized_id}/copy", future_binary.to_h.merge(destination_obj_id: obj_id))
|
11
|
+
else
|
12
|
+
file = future_binary.file_to_upload
|
13
|
+
filename = future_binary.filename
|
18
14
|
|
19
|
-
|
15
|
+
if !filename.present? && file
|
16
|
+
ext = ::File.extname(file.path).to_s[1..-1]
|
17
|
+
filename = ::File.basename(file.path, '.' + ext.to_s)
|
18
|
+
end
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
encoded_id = Fiona7::TemporaryUploader.new(file, filename, obj_id).call
|
21
|
+
|
22
|
+
{'id' => encoded_id, 'destination_obj' => obj_id}
|
23
|
+
end
|
24
24
|
end
|
25
25
|
|
26
26
|
def self.activate_upload(*args)
|
@@ -2,14 +2,17 @@ require 'scrivito/link_parser'
|
|
2
2
|
|
3
3
|
module Scrivito
|
4
4
|
class LinkParser
|
5
|
-
#
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
# Handle legacy mode correctly
|
6
|
+
def find_obj_via_id_or_permalink(route_params)
|
7
|
+
return unless route_params[:controller] == SCRIVITO_CMS_DISPATCH ||
|
8
|
+
route_params[:controller] == 'rails_connector/cms_dispatch' # <-- PATCH HERE
|
9
|
+
|
10
|
+
if id = route_params[:id]
|
11
|
+
Obj.find(id)
|
12
|
+
elsif permalink = route_params[:permalink]
|
13
|
+
Obj.find_by_permalink(permalink)
|
12
14
|
end
|
15
|
+
rescue Scrivito::ResourceNotFound
|
13
16
|
end
|
14
17
|
end
|
15
18
|
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module Fiona7
|
2
|
+
class SuperIdFinder
|
3
|
+
def initialize(forbidden_obj_classes=[], fields=[], connection=::Fiona7::WriteObj.connection, instance_name=RailsConnector::CmsBaseModel.instance_name)
|
4
|
+
@instance_name = instance_name
|
5
|
+
@forbidden = forbidden_obj_classes
|
6
|
+
@fields = fields
|
7
|
+
@conn = connection
|
8
|
+
end
|
9
|
+
|
10
|
+
def find(type=:preview, obj_ids)
|
11
|
+
case type
|
12
|
+
when :preview
|
13
|
+
preview(obj_ids)
|
14
|
+
when :live
|
15
|
+
live(obj_ids)
|
16
|
+
else
|
17
|
+
raise ArgumentError, "Uknown type #{type.inspect} expected :preview or :live"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def preview(obj_ids)
|
22
|
+
query = "SELECT #{objects_table}.object_id FROM #{links_table} INNER JOIN #{objects_table} ON #{links_table}.content_id = #{objects_table}.edited_content_id WHERE #{links_table}.sub_object_id IN #{obj_ids_array(obj_ids)} #{self.obj_class_condition} UNION SELECT #{objects_table}.object_id FROM #{links_table} INNER JOIN #{objects_table} ON #{links_table}.content_id = #{objects_table}.committed_cont_id WHERE #{links_table}.sub_object_id IN #{obj_ids_array(obj_ids)} #{self.obj_class_condition} UNION SELECT #{objects_table}.object_id FROM #{links_table} INNER JOIN #{objects_table} ON #{links_table}.content_id = #{objects_table}.released_cont_id WHERE #{links_table}.sub_object_id IN #{obj_ids_array(obj_ids)} AND #{objects_table}.committed_cont_id IS NULL AND #{objects_table}.edited_content_id IS NULL #{self.obj_class_condition} #{self.field_condition}"
|
23
|
+
ids = self.sql_query(query).to_a.flatten
|
24
|
+
end
|
25
|
+
|
26
|
+
def live(obj_ids)
|
27
|
+
query = "SELECT #{objects_table}.object_id FROM #{links_table} INNER JOIN #{objects_table} ON #{links_table}.content_id = #{objects_table}.released_cont_id WHERE #{links_table}.sub_object_id IN #{obj_ids_array(obj_ids)} #{self.obj_class_condition} #{self.field_condition}"
|
28
|
+
ids = self.sql_query(query).to_a.flatten
|
29
|
+
end
|
30
|
+
|
31
|
+
protected
|
32
|
+
def links_table
|
33
|
+
"#{@instance_name}_links"
|
34
|
+
end
|
35
|
+
|
36
|
+
def obj_ids_array(obj_ids)
|
37
|
+
obj_ids = obj_ids.presence || [0]
|
38
|
+
values = obj_ids.map {|obj_id| @conn.quote(obj_id) }.join(", ")
|
39
|
+
" (#{values}) "
|
40
|
+
end
|
41
|
+
|
42
|
+
def obj_class_condition
|
43
|
+
if @forbidden.present?
|
44
|
+
values = @forbidden.map { |f| @conn.quote(f) }.join(", ")
|
45
|
+
" AND #{objects_table}.obj_class NOT IN (#{values}) "
|
46
|
+
else
|
47
|
+
""
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def field_condition
|
52
|
+
if @fields.present?
|
53
|
+
values = @fields.map { |f| @conn.quote(f) }.join(", ")
|
54
|
+
" AND #{links_table}.attribute_name IN (#{values}) "
|
55
|
+
else
|
56
|
+
""
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def objects_table
|
61
|
+
"#{@instance_name}_objects"
|
62
|
+
end
|
63
|
+
|
64
|
+
def sql_query(query, *args)
|
65
|
+
@conn.execute(query, *args)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fiona7/super_id_finder'
|
2
|
+
|
1
3
|
# This class allows to access objects linking to
|
2
4
|
# given object, i.e. super objects
|
3
5
|
#
|
@@ -8,6 +10,7 @@ module Fiona7
|
|
8
10
|
@instance_name = instance_name
|
9
11
|
@conn = connection || model.connection
|
10
12
|
@model = model
|
13
|
+
@id_finder = SuperIdFinder.new([], [], @conn, @instance_name)
|
11
14
|
end
|
12
15
|
|
13
16
|
def find(type=:preview, obj)
|
@@ -27,8 +30,7 @@ module Fiona7
|
|
27
30
|
# This means that all objects that are reachable in preview
|
28
31
|
# are returned (unreleased, commited etc.)
|
29
32
|
def preview(obj)
|
30
|
-
|
31
|
-
ids = self.sql_query(query).to_a.flatten
|
33
|
+
ids = @id_finder.preview([obj.obj_id])
|
32
34
|
@model.find(ids).select(&:exportable?)
|
33
35
|
end
|
34
36
|
|
@@ -38,26 +40,9 @@ module Fiona7
|
|
38
40
|
# This means that only the objects that are reachable in
|
39
41
|
# live are returned, i.e. avaiable for outside world
|
40
42
|
def live(obj)
|
41
|
-
|
42
|
-
ids = self.sql_query(query).to_a.flatten
|
43
|
+
ids = @id_finder.live([obj.obj_id])
|
43
44
|
@model.find(ids).select(&:exportable?)
|
44
45
|
end
|
45
46
|
|
46
|
-
protected
|
47
|
-
def links_table
|
48
|
-
"#{@instance_name}_links"
|
49
|
-
end
|
50
|
-
|
51
|
-
def obj_class_condition
|
52
|
-
""
|
53
|
-
end
|
54
|
-
|
55
|
-
def objects_table
|
56
|
-
"#{@instance_name}_objects"
|
57
|
-
end
|
58
|
-
|
59
|
-
def sql_query(query, *args)
|
60
|
-
@conn.execute(query, *args)
|
61
|
-
end
|
62
47
|
end
|
63
48
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'fiona7/builder/indirect_blob_builder'
|
2
|
+
require 'fiona7/upload_path_selector'
|
3
|
+
require 'fiona7/blob_id_generator'
|
4
|
+
|
5
|
+
module Fiona7
|
6
|
+
# This class uploads a file into a temporary location to be reused later.
|
7
|
+
# It returns the blob id of the uploaded file.
|
8
|
+
class TemporaryUploader
|
9
|
+
def initialize(file, filename, obj_id=nil)
|
10
|
+
@file = file
|
11
|
+
@filename = filename
|
12
|
+
@obj_id = obj_id
|
13
|
+
end
|
14
|
+
|
15
|
+
def call
|
16
|
+
obj = Builder::IndirectBlobBuilder.new(upload_path, @filename, @file).call
|
17
|
+
BlobIdGenerator.new(obj.obj_id, obj.last_changed).call
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
def upload_path
|
22
|
+
if Fiona7.mode == :standalone
|
23
|
+
dest_obj = Fiona7::WriteObj.find(@obj_id) rescue nil
|
24
|
+
if dest_obj
|
25
|
+
return UploadPathSelector.new(dest_obj).call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# TODO: legacy
|
30
|
+
'/_uploads/temp'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Fiona7
|
2
|
+
class UploadPathSelector
|
3
|
+
def initialize(obj)
|
4
|
+
@obj = obj
|
5
|
+
end
|
6
|
+
|
7
|
+
def call
|
8
|
+
# only publication type can contain children (code = "5")
|
9
|
+
# for uploads on root object we should use the general container aswell
|
10
|
+
if @obj.obj_type_code != "5" || @obj.id == 2001
|
11
|
+
"/_uploads/#{@obj.id}"
|
12
|
+
else
|
13
|
+
"#{@obj.path}/_uploads"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|