infopark_fiona_connector 7.0.1 → 7.0.1.5.2.3.rc8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/controllers/cms_controller.rb +1 -1
- data/app/controllers/rails_connector/default_cms_controller.rb +4 -6
- data/app/helpers/cms_helper.rb +1 -1
- data/app/helpers/cms_routing_helper.rb +1 -1
- data/app/helpers/rails_connector/cms_asset_helper.rb +4 -5
- data/app/helpers/rails_connector/cms_tag_helper.rb +0 -3
- data/app/helpers/rails_connector/default_cms_helper.rb +0 -2
- data/app/helpers/rails_connector/default_cms_routing_helper.rb +15 -16
- data/app/helpers/rails_connector/display_helper.rb +31 -33
- data/app/helpers/rails_connector/editing_helper.rb +2 -8
- data/app/helpers/rails_connector/layout_helper.rb +2 -5
- data/app/helpers/rails_connector/marker_helper.rb +63 -64
- data/app/helpers/rails_connector/table_of_contents_helper.rb +1 -3
- data/config/cms_routes.rb +15 -15
- data/lib/gem_dependencies.rb +8 -7
- data/lib/generators/rails_connector/install/install_generator.rb +6 -6
- data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +1 -1
- data/lib/infopark_fiona_connector.rb +7 -6
- data/lib/meta_eager_loader.rb +1 -0
- data/lib/rails_connector/attr_dict.rb +54 -31
- data/lib/rails_connector/attribute.rb +93 -0
- data/lib/rails_connector/authenticable.rb +12 -5
- data/lib/rails_connector/basic_obj.rb +126 -132
- data/lib/rails_connector/blob.rb +4 -5
- data/lib/rails_connector/blob_mapping.rb +15 -0
- data/lib/rails_connector/blob_mysql.rb +3 -5
- data/lib/rails_connector/blob_oracle.rb +5 -7
- data/lib/rails_connector/channel.rb +18 -0
- data/lib/rails_connector/cms_accessible.rb +21 -24
- data/lib/rails_connector/cms_base_model.rb +12 -4
- data/lib/rails_connector/cms_dispatch_controller.rb +9 -12
- data/lib/rails_connector/cms_env.rb +4 -7
- data/lib/rails_connector/cms_test_request.rb +1 -16
- data/lib/rails_connector/configuration.rb +14 -16
- data/lib/rails_connector/content.rb +7 -0
- data/lib/rails_connector/core_extensions/time.rb +3 -4
- data/lib/rails_connector/date_attribute.rb +2 -4
- data/lib/rails_connector/default_search_request.rb +1 -1
- data/lib/rails_connector/engine.rb +18 -17
- data/lib/rails_connector/errors.rb +2 -5
- data/lib/rails_connector/fiona_datetime.rb +14 -0
- data/lib/rails_connector/fiona_engine.rb +3 -4
- data/lib/rails_connector/html_string.rb +0 -2
- data/lib/rails_connector/job.rb +10 -0
- data/lib/rails_connector/link.rb +7 -4
- data/lib/rails_connector/link_list.rb +1 -5
- data/lib/rails_connector/link_resolvable.rb +1 -5
- data/lib/rails_connector/lucene_search_request.rb +20 -24
- data/lib/rails_connector/markdown_string.rb +0 -2
- data/lib/rails_connector/meta.rb +143 -0
- data/lib/rails_connector/meta/eager_loader.rb +84 -0
- data/lib/rails_connector/named_link.rb +25 -14
- data/lib/rails_connector/news.rb +8 -4
- data/lib/rails_connector/obj_class.rb +138 -0
- data/lib/rails_connector/obj_class_attr.rb +5 -0
- data/lib/rails_connector/object_with_meta_data.rb +13 -0
- data/lib/rails_connector/permission.rb +2 -6
- data/lib/rails_connector/rack_middlewares.rb +1 -2
- data/lib/rails_connector/ses.rb +3 -8
- data/lib/rails_connector/ses/verity_accessor.rb +43 -46
- data/lib/rails_connector/string_tagging.rb +0 -3
- data/lib/rails_connector/verity_search_request.rb +6 -9
- data/lib/search_request.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +31 -20
@@ -1,11 +1,9 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
#
|
4
3
|
# This module contains a helper that can be used to build a table of contents of an object.
|
5
4
|
#
|
6
5
|
# @api public
|
7
6
|
module TableOfContentsHelper
|
8
|
-
|
9
7
|
#
|
10
8
|
# The <tt>table_of_contents</tt> helper method gets an object as argument and returns an array,
|
11
9
|
# which can be used as the table of contents of the given object.
|
@@ -16,7 +14,7 @@ module RailsConnector
|
|
16
14
|
#
|
17
15
|
# @api public
|
18
16
|
def table_of_contents(obj)
|
19
|
-
obj.sorted_toclist.reject { |o|
|
17
|
+
obj.sorted_toclist.reject { |o| !o.permitted_for_user?(current_user) }
|
20
18
|
end
|
21
19
|
end
|
22
20
|
end
|
data/config/cms_routes.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
root to:
|
3
|
-
match
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
match
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
match
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
2
|
+
root to: "rails_connector/cms_dispatch#index"
|
3
|
+
match ":id(/*slug)",
|
4
|
+
to: "rails_connector/cms_dispatch#index",
|
5
|
+
constraints: { id: /\d+|[0-9a-f]{16}/ },
|
6
|
+
as: "cms_id",
|
7
|
+
via: :all
|
8
|
+
match "toggle_markers/:id",
|
9
|
+
to: "rails_connector/cms_dispatch#toggle_editmarkers",
|
10
|
+
as: "toggle_markers",
|
11
|
+
via: :all
|
12
|
+
match "/*permalink",
|
13
|
+
to: "rails_connector/cms_dispatch#index",
|
14
|
+
as: "cms_permalink",
|
15
|
+
format: false,
|
16
|
+
via: :all
|
17
17
|
end
|
data/lib/gem_dependencies.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
class GemDependencies
|
2
2
|
def self.dependency_for(gem_name)
|
3
|
-
dependencies.detect{ |dep| dep[:name] == gem_name }
|
3
|
+
dependencies.detect { |dep| dep[:name] == gem_name }
|
4
4
|
end
|
5
5
|
|
6
6
|
# generates code that should be included or eval'ed inside a Gemfile.
|
@@ -14,7 +14,7 @@ class GemDependencies
|
|
14
14
|
dependencies_minimum_versions = dependencies.map do |dependency|
|
15
15
|
minimum_version = calculate_minimum_version(dependency[:version])
|
16
16
|
if minimum_version
|
17
|
-
dependency.merge(:
|
17
|
+
dependency.merge(version: "= #{minimum_version}")
|
18
18
|
else
|
19
19
|
dependency.delete(:version)
|
20
20
|
end
|
@@ -23,7 +23,8 @@ class GemDependencies
|
|
23
23
|
|
24
24
|
dependencies_minimum_versions.map do |dependency|
|
25
25
|
gem_name = dependency[:name]
|
26
|
-
next if gem_name ==
|
26
|
+
next if gem_name == "rails"
|
27
|
+
|
27
28
|
gem_options = ""
|
28
29
|
gem_options << ", '#{dependency[:version]}'" if dependency[:version]
|
29
30
|
gem_options <<
|
@@ -41,11 +42,11 @@ class GemDependencies
|
|
41
42
|
end.join("\n")
|
42
43
|
end
|
43
44
|
|
44
|
-
def self.minimum_version_for(gem, version=nil)
|
45
|
-
|
45
|
+
def self.minimum_version_for(gem, version = nil)
|
46
|
+
dependency ||= dependencies.detect do |dep|
|
46
47
|
dep[:name] == gem
|
47
|
-
end
|
48
|
-
|
48
|
+
end
|
49
|
+
version ||= dependency[:version]
|
49
50
|
calculate_minimum_version(version)
|
50
51
|
end
|
51
52
|
|
@@ -6,19 +6,19 @@ module RailsConnector
|
|
6
6
|
# Normally, you'd just call 'source_root' as a class method from here,
|
7
7
|
# but we need to glob the dir ourselves. Hence our own method.
|
8
8
|
def self.source_root
|
9
|
-
@source_root ||= File.expand_path(
|
9
|
+
@source_root ||= File.expand_path("templates", __dir__)
|
10
10
|
end
|
11
11
|
|
12
12
|
def install_configuration
|
13
13
|
copy_file "initializers/rails_connector.rb", "config/initializers/rails_connector.rb"
|
14
|
-
template
|
14
|
+
template "app/models/obj.rb.erb", "app/models/obj.rb"
|
15
15
|
copy_file "local/configuration.rb", "config/local/configuration.rb"
|
16
16
|
end
|
17
17
|
|
18
18
|
def append_asset_manifests
|
19
19
|
append_file("app/assets/javascripts/application.js", "//= require infopark_rails_connector")
|
20
20
|
gsub_file("app/assets/stylesheets/application.css", "*= require_tree .",
|
21
|
-
|
21
|
+
"*= require_tree .\n *= require infopark_rails_connector")
|
22
22
|
end
|
23
23
|
|
24
24
|
def remove_public_index_html
|
@@ -28,10 +28,10 @@ module RailsConnector
|
|
28
28
|
|
29
29
|
def patch_default_application_layout
|
30
30
|
gsub_file("app/views/layouts/application.html.erb", %r{</head>},
|
31
|
-
|
31
|
+
"<%= rails_connector_header_tags %>\n</head>")
|
32
32
|
gsub_file("app/views/layouts/application.html.erb", %r{</body>},
|
33
|
-
|
33
|
+
"<%= rails_connector_after_content_tags %>\n</body>")
|
34
34
|
end
|
35
35
|
end
|
36
36
|
end
|
37
|
-
end
|
37
|
+
end
|
@@ -1,2 +1,2 @@
|
|
1
1
|
# Name of the CMS Fiona Instance to access
|
2
|
-
RailsConnector::Configuration.instance_name =
|
2
|
+
RailsConnector::Configuration.instance_name = "default"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# @api public
|
2
2
|
module ::RailsConnector
|
3
|
-
PLATFORM_CLOUD = :cloud
|
4
|
-
PLATFORM_FIONA = :fiona
|
3
|
+
PLATFORM_CLOUD = :cloud
|
4
|
+
PLATFORM_FIONA = :fiona
|
5
5
|
|
6
6
|
# return either <tt>:fiona</tt> or <tt>:cloud</tt> depending on the app's configuration.
|
7
7
|
# @return [Symbol]
|
@@ -18,15 +18,16 @@ module ::RailsConnector
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require 'rails_connector/core_extensions'
|
21
|
+
require "rails_connector/core_extensions"
|
22
|
+
require "rails_connector/rack_middlewares"
|
24
23
|
require "rails_connector/errors"
|
24
|
+
require "rails_connector/fiona_datetime"
|
25
|
+
ActiveRecord::Type.register(:fiona_datetime, ::FionaDateTime)
|
25
26
|
|
26
27
|
# @api public
|
27
28
|
module RailsConnector
|
28
29
|
def self.autoload_all_sources
|
29
|
-
source_files = Dir.glob(File.expand_path("
|
30
|
+
source_files = Dir.glob(File.expand_path("rails_connector/*.rb", __dir__)).map do |file|
|
30
31
|
File.basename(file)
|
31
32
|
end
|
32
33
|
|
@@ -0,0 +1 @@
|
|
1
|
+
require "rails_connector/meta/eager_loader"
|
@@ -1,16 +1,13 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "mime/types"
|
2
|
+
require "ostruct"
|
3
3
|
|
4
4
|
module RailsConnector
|
5
|
-
|
6
5
|
# The page related and custom data belonging to a CMS object
|
7
6
|
#
|
8
7
|
# [editor] The login of the current editor of the edited content, if set
|
9
8
|
#
|
10
9
|
# Any custom Attribute can be accessed directly or via [].
|
11
10
|
class AttrDict
|
12
|
-
include DateAttribute
|
13
|
-
|
14
11
|
def initialize(object, keys_and_values = {}, defs = {})
|
15
12
|
@object = object
|
16
13
|
@blob_dict = keys_and_values.symbolize_keys
|
@@ -29,13 +26,13 @@ module RailsConnector
|
|
29
26
|
end
|
30
27
|
|
31
28
|
def sort_keys
|
32
|
-
[sort_key1, sort_key2, sort_key3]
|
29
|
+
[sort_key1, sort_key2, sort_key3].compact
|
33
30
|
end
|
34
31
|
|
35
32
|
# The body attribute may contain binary data for Obj.binary? or be an HtmlString.
|
36
33
|
def body
|
37
34
|
if object.binary?
|
38
|
-
binary_body
|
35
|
+
binary_body&.data
|
39
36
|
else
|
40
37
|
StringTagging.tag_as_html(textual_body, self)
|
41
38
|
end
|
@@ -55,7 +52,8 @@ module RailsConnector
|
|
55
52
|
def body_data_path
|
56
53
|
# TODO: Braucht/will jemand Text gestreamt?
|
57
54
|
return nil unless object.binary?
|
58
|
-
|
55
|
+
|
56
|
+
binary_body&.path_of_stored_data(object.last_changed)
|
59
57
|
end
|
60
58
|
|
61
59
|
def [](key)
|
@@ -69,78 +67,103 @@ module RailsConnector
|
|
69
67
|
end
|
70
68
|
|
71
69
|
def permissions
|
72
|
-
@permissions ||= OpenStruct.new({ :
|
70
|
+
@permissions ||= OpenStruct.new({ live: permitted_groups })
|
73
71
|
end
|
74
72
|
|
75
|
-
def respond_to?(method_id, include_private=false)
|
73
|
+
def respond_to?(method_id, include_private = false)
|
76
74
|
super || has_attribute(method_id)
|
77
75
|
end
|
78
76
|
|
79
77
|
private
|
80
78
|
|
81
|
-
|
82
|
-
@object
|
83
|
-
end
|
84
|
-
|
85
|
-
def blob_dict
|
86
|
-
@blob_dict
|
87
|
-
end
|
79
|
+
attr_reader :object, :blob_dict, :attr_defs
|
88
80
|
|
89
|
-
|
90
|
-
@attr_defs
|
91
|
-
end
|
81
|
+
delegate :obj_class_def, to: :object, allow_nil: true
|
92
82
|
|
93
83
|
def textual_body
|
94
84
|
return nil if object.binary?
|
85
|
+
|
95
86
|
blob_dict[:blob]
|
96
87
|
end
|
97
88
|
|
98
89
|
def binary_body
|
99
90
|
return nil unless object.binary? && has_attribute(:blob)
|
91
|
+
|
100
92
|
@binary_body ||= Blob.find(blob)
|
101
93
|
rescue RailsConnector::ResourceNotFound
|
102
94
|
nil
|
103
95
|
end
|
104
96
|
|
105
97
|
def method_missing(method_id, *args)
|
106
|
-
raise NoMethodError
|
107
|
-
|
98
|
+
raise NoMethodError, "missing method - #{method_id}" unless args.empty?
|
99
|
+
|
100
|
+
attribute_value(method_id.to_s)
|
108
101
|
rescue UnknownAttributeError
|
109
|
-
raise NoMethodError
|
102
|
+
raise NoMethodError, "missing method - #{method_id}"
|
110
103
|
end
|
111
104
|
|
112
105
|
def attribute_value(key)
|
113
|
-
raise UnknownAttributeError
|
106
|
+
raise UnknownAttributeError unless has_attribute(key)
|
114
107
|
|
115
108
|
key = key.to_sym
|
116
109
|
raw = blob_dict[key]
|
117
|
-
@attr_cache[key] ||=
|
110
|
+
@attr_cache[key] ||=
|
111
|
+
case type_of(key)
|
118
112
|
when :markdown
|
119
113
|
StringTagging.tag_as_markdown(raw, self)
|
120
114
|
when :html
|
121
|
-
StringTagging.tag_as_html(raw, self)
|
115
|
+
StringTagging.tag_as_html(raw.to_s, self)
|
116
|
+
when :string, :text
|
117
|
+
raw.to_s
|
122
118
|
when :date
|
123
|
-
DateAttribute.parse
|
119
|
+
DateAttribute.parse(raw) if raw
|
124
120
|
when :linklist
|
125
121
|
LinkList.new(raw)
|
122
|
+
when :multienum
|
123
|
+
raw || []
|
126
124
|
else
|
127
125
|
raw
|
128
|
-
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# this attributes are defined by cms
|
130
|
+
# but if not set, are not existend in attr_defs
|
131
|
+
def predefined_attribute?(key)
|
132
|
+
%i(channels sort_key1 sort_key2 sort_key3).include?(key.to_sym)
|
129
133
|
end
|
130
134
|
|
131
135
|
def has_attribute(key)
|
132
136
|
key = key.to_sym
|
133
|
-
|
137
|
+
return true if object.class::PREDEFINED_ATTRIBUTES.include?(key.to_s)
|
138
|
+
|
139
|
+
blob_dict.key?(key) || attr_defs.key?(key) || class_defined_attributes.key?(key)
|
134
140
|
end
|
135
141
|
|
136
142
|
def type_of(key)
|
137
143
|
key = key.to_sym
|
138
144
|
return :linklist if key == :text_links
|
139
|
-
|
145
|
+
return :multienum if key == :channels
|
146
|
+
|
147
|
+
type_from_attr_defs(key) || type_from_class_defined_attributes(key)
|
148
|
+
end
|
149
|
+
|
150
|
+
def type_from_attr_defs(key)
|
151
|
+
attr_defs[key]["type"].to_sym
|
152
|
+
rescue StandardError
|
153
|
+
nil
|
154
|
+
end
|
155
|
+
|
156
|
+
def type_from_class_defined_attributes(key)
|
157
|
+
class_defined_attributes[key].type.to_sym
|
158
|
+
rescue StandardError
|
159
|
+
nil
|
160
|
+
end
|
161
|
+
|
162
|
+
def class_defined_attributes
|
163
|
+
obj_class_def.try(:custom_attributes) || {}
|
140
164
|
end
|
141
165
|
end
|
142
166
|
|
143
167
|
class UnknownAttributeError < StandardError
|
144
168
|
end
|
145
|
-
|
146
169
|
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
# The methods date?, enum?, html?, linklist?, markdown?, multienum?, string? and
|
3
|
+
# text? are created by meta programming have no documentation of their own.
|
4
|
+
# Warning: Dependent on the setup of your DB replication, most tables
|
5
|
+
# with meta information will not be available on your live system!
|
6
|
+
class Attribute < CmsBaseModel
|
7
|
+
# The possible types of an attribute.
|
8
|
+
TYPES = %w(date enum html linklist markdown multienum string text).freeze
|
9
|
+
|
10
|
+
self.primary_key = :attribute_id
|
11
|
+
|
12
|
+
has_and_belongs_to_many :obj_class_definitions, class_name: "::RailsConnector::ObjClass",
|
13
|
+
join_table: "#{table_name_prefix}obj_class_attrs"
|
14
|
+
|
15
|
+
alias_method :obj_class_defs, :obj_class_definitions
|
16
|
+
alias_attribute :name, :attribute_name
|
17
|
+
alias_attribute :type, :attribute_type
|
18
|
+
|
19
|
+
# The (human readable) title.
|
20
|
+
def title(language = :de)
|
21
|
+
blob_data["titles"].presence && blob_data["titles"][language.to_s]
|
22
|
+
end
|
23
|
+
|
24
|
+
# The description of the attribute.
|
25
|
+
def help_text(language = :de)
|
26
|
+
blob_data["helpTexts"].presence && blob_data["helpTexts"][language.to_s]
|
27
|
+
end
|
28
|
+
|
29
|
+
# Searchable in Content Manager.
|
30
|
+
def searchable_in_cm?
|
31
|
+
blob_data["isSearchableInCM"].to_i != 0
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns the possible values if attribute is of type `enum' or `multienum'.
|
35
|
+
def values
|
36
|
+
blob_data["values"]
|
37
|
+
end
|
38
|
+
|
39
|
+
def max_size
|
40
|
+
blob_data["maxSize"]
|
41
|
+
end
|
42
|
+
|
43
|
+
def min_size
|
44
|
+
blob_data["minSize"]
|
45
|
+
end
|
46
|
+
|
47
|
+
def edit_field
|
48
|
+
blob_data["editField"]
|
49
|
+
end
|
50
|
+
|
51
|
+
def callback
|
52
|
+
blob_data["callback"]
|
53
|
+
end
|
54
|
+
|
55
|
+
TYPES.each do |type|
|
56
|
+
class_eval <<EOM, __FILE__, __LINE__ + 1
|
57
|
+
def #{type}?
|
58
|
+
self.attribute_type == "#{type}"
|
59
|
+
end
|
60
|
+
EOM
|
61
|
+
end
|
62
|
+
|
63
|
+
# Convenience method for find_by_attribute_name
|
64
|
+
def self.find_by_name(*args)
|
65
|
+
find_by_attribute_name(*args)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Returns the blob as a JSON object.
|
69
|
+
def self.read_blob_data(name) #:nodoc:
|
70
|
+
blob = RailsConnector::Meta.hello_im_rails_and_im_retarted_so_please_be_patient do # these queries really pollute our logs!
|
71
|
+
blob_name =
|
72
|
+
if RailsConnector::BlobMapping.exists?
|
73
|
+
RailsConnector::BlobMapping.get_fingerprint("#{name}.jsonAttributeDict")
|
74
|
+
else
|
75
|
+
"#{name}.jsonAttributeDict"
|
76
|
+
end
|
77
|
+
|
78
|
+
RailsConnector::Blob.find_without_excluded_blob_data(blob_name)
|
79
|
+
end
|
80
|
+
|
81
|
+
return {} unless blob&.blob_data?
|
82
|
+
|
83
|
+
JSON.parse(blob.blob_data)
|
84
|
+
end
|
85
|
+
|
86
|
+
private
|
87
|
+
|
88
|
+
# load attribute details from blob
|
89
|
+
def blob_data #:nodoc:
|
90
|
+
@blob_data ||= self.class.read_blob_data(attribute_name)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -5,6 +5,7 @@ module RailsConnector
|
|
5
5
|
unless instance_method_defined?(mod, method_name)
|
6
6
|
mod.class_eval do
|
7
7
|
private
|
8
|
+
|
8
9
|
define_method(method_name, InstanceMethods.method(method_name).to_proc)
|
9
10
|
end
|
10
11
|
end
|
@@ -14,12 +15,18 @@ module RailsConnector
|
|
14
15
|
end
|
15
16
|
|
16
17
|
module InstanceMethods
|
17
|
-
def self.logged_in
|
18
|
-
|
19
|
-
|
20
|
-
end
|
18
|
+
def self.logged_in?
|
19
|
+
false
|
20
|
+
end
|
21
21
|
|
22
|
-
|
22
|
+
def self.admin?
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.current_user
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
23
30
|
|
24
31
|
def self.instance_method_defined?(mod, method_name)
|
25
32
|
(
|