infopark_fiona_connector 7.0.1.5.2.3.rc4 → 7.0.1.5.2.3.rc5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/cms_controller.rb +1 -1
- data/app/controllers/rails_connector/default_cms_controller.rb +0 -2
- 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 +9 -9
- data/lib/rails_connector/attr_dict.rb +26 -18
- data/lib/rails_connector/attribute.rb +18 -21
- data/lib/rails_connector/authenticable.rb +12 -5
- data/lib/rails_connector/basic_obj.rb +64 -57
- data/lib/rails_connector/blob.rb +2 -5
- data/lib/rails_connector/blob_mapping.rb +2 -3
- data/lib/rails_connector/blob_mysql.rb +3 -5
- data/lib/rails_connector/blob_oracle.rb +5 -7
- data/lib/rails_connector/channel.rb +5 -6
- data/lib/rails_connector/cms_accessible.rb +16 -17
- data/lib/rails_connector/cms_base_model.rb +2 -4
- data/lib/rails_connector/cms_dispatch_controller.rb +3 -6
- data/lib/rails_connector/cms_env.rb +4 -7
- data/lib/rails_connector/cms_test_request.rb +1 -1
- data/lib/rails_connector/configuration.rb +12 -16
- data/lib/rails_connector/content.rb +0 -4
- data/lib/rails_connector/core_extensions/time.rb +3 -4
- data/lib/rails_connector/date_attribute.rb +1 -3
- data/lib/rails_connector/default_search_request.rb +1 -1
- data/lib/rails_connector/engine.rb +18 -21
- data/lib/rails_connector/errors.rb +2 -5
- data/lib/rails_connector/fiona_datetime.rb +2 -2
- data/lib/rails_connector/fiona_engine.rb +3 -4
- data/lib/rails_connector/html_string.rb +0 -2
- data/lib/rails_connector/job.rb +0 -3
- 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 +25 -30
- data/lib/rails_connector/meta/eager_loader.rb +14 -12
- data/lib/rails_connector/named_link.rb +12 -16
- data/lib/rails_connector/news.rb +3 -3
- data/lib/rails_connector/obj_class.rb +23 -25
- data/lib/rails_connector/obj_class_attr.rb +1 -1
- data/lib/rails_connector/object_with_meta_data.rb +0 -5
- data/lib/rails_connector/permission.rb +2 -6
- 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 +2 -2
data/lib/rails_connector/blob.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# A binary containing the blob data of a Content or CMS management
|
4
3
|
# data of Attribute (fields), ObjClass (object classes), for example.
|
5
4
|
class Blob < CmsBaseModel
|
@@ -13,7 +12,6 @@ module RailsConnector
|
|
13
12
|
|
14
13
|
alias_method :find_without_excluded_blob_data, :find
|
15
14
|
alias_method :find, :find_with_excluded_blob_data
|
16
|
-
|
17
15
|
end
|
18
16
|
|
19
17
|
def length
|
@@ -25,7 +23,7 @@ module RailsConnector
|
|
25
23
|
end
|
26
24
|
|
27
25
|
def path_of_stored_data(use_cached_file_if_older_than = Time.now)
|
28
|
-
store_data if !File.
|
26
|
+
store_data if !File.exist?(path) || file_size_differs? || stale?(use_cached_file_if_older_than)
|
29
27
|
path
|
30
28
|
end
|
31
29
|
|
@@ -38,7 +36,7 @@ module RailsConnector
|
|
38
36
|
case adapter_name
|
39
37
|
when /mysql$/i
|
40
38
|
raise "Adapter 'mysql' no longer supported. " +
|
41
|
-
|
39
|
+
"Please change adapter in your database.yml to 'mysql2'."
|
42
40
|
when /mysql2/i
|
43
41
|
require "rails_connector/blob_mysql"
|
44
42
|
include BlobMysql
|
@@ -74,5 +72,4 @@ module RailsConnector
|
|
74
72
|
blob_length != File.stat(path).size
|
75
73
|
end
|
76
74
|
end
|
77
|
-
|
78
75
|
end
|
@@ -1,8 +1,7 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
1
|
module RailsConnector
|
3
2
|
class BlobMapping < CmsBaseModel
|
4
3
|
def self.exists?
|
5
|
-
|
4
|
+
table_exists?
|
6
5
|
end
|
7
6
|
|
8
7
|
def self.get_fingerprint(name)
|
@@ -10,7 +9,7 @@ module RailsConnector
|
|
10
9
|
end
|
11
10
|
|
12
11
|
def self.get_fingerprint_map(blob_names)
|
13
|
-
Hash[
|
12
|
+
Hash[where(blob_name: blob_names).select(%i(blob_name fingerprint)).map { |b| [b.blob_name, b.fingerprint] }]
|
14
13
|
end
|
15
14
|
end
|
16
15
|
end
|
@@ -1,13 +1,12 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "mysql2"
|
2
|
+
require "mysql_blob_streaming"
|
3
3
|
|
4
4
|
module RailsConnector
|
5
|
-
|
6
5
|
module BlobMysql
|
7
6
|
def self.included(base)
|
8
7
|
base.instance_eval do
|
9
8
|
define_method :store_data do
|
10
|
-
store_data_atomically {|f| fetch_into_file(f)}
|
9
|
+
store_data_atomically { |f| fetch_into_file(f) }
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -28,5 +27,4 @@ module RailsConnector
|
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
31
|
-
|
32
30
|
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
module BlobOracle
|
4
3
|
def self.included(base)
|
5
4
|
base.instance_eval do
|
6
5
|
define_method :store_data do
|
7
|
-
store_data_atomically {|f| fetch_into_file(f)}
|
6
|
+
store_data_atomically { |f| fetch_into_file(f) }
|
8
7
|
end
|
9
8
|
end
|
10
9
|
end
|
@@ -17,17 +16,17 @@ module RailsConnector
|
|
17
16
|
GC.start
|
18
17
|
end
|
19
18
|
ensure
|
20
|
-
blob
|
19
|
+
blob&.close
|
21
20
|
end
|
22
21
|
|
23
22
|
private
|
24
23
|
|
25
24
|
def sql
|
26
|
-
%
|
25
|
+
%(
|
27
26
|
SELECT blob_data
|
28
27
|
FROM #{self.class.table_name}
|
29
28
|
WHERE #{self.class.primary_key} = :1
|
30
|
-
|
29
|
+
)
|
31
30
|
end
|
32
31
|
|
33
32
|
def blob_handle
|
@@ -35,5 +34,4 @@ module RailsConnector
|
|
35
34
|
con.exec(sql, id).fetch.first
|
36
35
|
end
|
37
36
|
end
|
38
|
-
|
39
|
-
end
|
37
|
+
end
|
@@ -6,14 +6,13 @@ module RailsConnector
|
|
6
6
|
"#{table_name_prefix}" "channels"
|
7
7
|
end
|
8
8
|
|
9
|
-
has_many :news, :
|
9
|
+
has_many :news, class_name: "RailsConnector::News", foreign_key: "channel_name"
|
10
10
|
has_many :active_news,
|
11
|
-
|
12
|
-
|
11
|
+
-> { where(["valid_from <= :now AND valid_until >= :now", { now: Time.now.to_s(:number) }]) },
|
12
|
+
class_name: "RailsConnector::News", foreign_key: "channel_name"
|
13
13
|
|
14
|
-
has_many :objects, :
|
15
|
-
|
16
|
-
scope :with_prefix, -> (prefix) {where(["channel_name LIKE ?", "#{prefix}%"])}
|
14
|
+
has_many :objects, through: :news
|
17
15
|
|
16
|
+
scope :with_prefix, ->(prefix) { where(["channel_name LIKE ?", "#{prefix}%"]) }
|
18
17
|
end
|
19
18
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# @api public
|
4
3
|
module CmsAccessible
|
5
|
-
|
6
|
-
protected
|
4
|
+
protected
|
7
5
|
|
8
6
|
# Filter method to load a CMS object.
|
9
7
|
#
|
@@ -13,6 +11,7 @@ module RailsConnector
|
|
13
11
|
CmsEnv.new(request.env).load
|
14
12
|
loaded_obj = request.env[CmsEnv::OBJ_ENV_KEY]
|
15
13
|
raise loaded_obj if loaded_obj.is_a?(StandardError)
|
14
|
+
|
16
15
|
@obj = loaded_obj
|
17
16
|
end
|
18
17
|
|
@@ -29,7 +28,7 @@ module RailsConnector
|
|
29
28
|
@obj = nil
|
30
29
|
render_obj_error(410, "gone")
|
31
30
|
end
|
32
|
-
|
31
|
+
true
|
33
32
|
end
|
34
33
|
|
35
34
|
# Filter method to check if access to the loaded object is permitted. If it is
|
@@ -43,7 +42,7 @@ module RailsConnector
|
|
43
42
|
@obj = nil
|
44
43
|
render_obj_error(403, "forbidden")
|
45
44
|
end
|
46
|
-
|
45
|
+
true
|
47
46
|
end
|
48
47
|
|
49
48
|
# This method is called when rendering an error caused by either {ensure_object_is_permitted}
|
@@ -54,10 +53,10 @@ module RailsConnector
|
|
54
53
|
def render_obj_error(status, name)
|
55
54
|
force_html_format
|
56
55
|
render(
|
57
|
-
:
|
58
|
-
:
|
59
|
-
:
|
60
|
-
:
|
56
|
+
template: "errors/#{status}_#{name}",
|
57
|
+
layout: false,
|
58
|
+
status: status,
|
59
|
+
content_type: Mime[:html]
|
61
60
|
)
|
62
61
|
end
|
63
62
|
|
@@ -81,7 +80,7 @@ module RailsConnector
|
|
81
80
|
# to the valid_until date of the current object.
|
82
81
|
def set_google_expire_header
|
83
82
|
if @obj && (date = @obj.valid_until)
|
84
|
-
headers[
|
83
|
+
headers["X-Robots-Tag: unavailable_after"] = date.rfc822
|
85
84
|
end
|
86
85
|
end
|
87
86
|
|
@@ -91,20 +90,20 @@ module RailsConnector
|
|
91
90
|
def deliver_file
|
92
91
|
if @obj.body_data_url
|
93
92
|
redirect_to enforce_protocol_from_request(@obj.body_data_url)
|
94
|
-
elsif stale?(:
|
93
|
+
elsif stale?(last_modified: @obj.last_changed.utc)
|
95
94
|
mime_type = @obj.mime_type
|
96
|
-
mime_type +=
|
95
|
+
mime_type += "; charset=utf-8" if %r{^text/}.match?(mime_type)
|
97
96
|
|
98
97
|
if (filepath = @obj.body_data_path).present?
|
99
98
|
send_file(File.expand_path(filepath), {
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
99
|
+
type: mime_type,
|
100
|
+
filename: @obj.filename,
|
101
|
+
disposition: "inline"
|
102
|
+
})
|
104
103
|
else
|
105
104
|
# generics should send its body, empty files should be delivered as
|
106
105
|
# empty files - and not lead to an application error
|
107
|
-
send_data @obj.body ||
|
106
|
+
send_data @obj.body || "", type: mime_type, filename: @obj.filename, disposition: "inline"
|
108
107
|
end
|
109
108
|
end
|
110
109
|
end
|
@@ -1,12 +1,11 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# This is the abstract class from which all CMS models derive.
|
4
3
|
# The database connection is set to "infopark_rails_connector_${RAILS_ENV}" and the table prefix is
|
5
4
|
# determined from the instance_name.
|
6
5
|
#
|
7
6
|
# [instance_name] the name of the CMS instance
|
8
7
|
class CmsBaseModel < ActiveRecord::Base
|
9
|
-
@@instance_name =
|
8
|
+
@@instance_name = "default"
|
10
9
|
cattr_accessor :instance_name
|
11
10
|
self.abstract_class = true
|
12
11
|
|
@@ -46,9 +45,8 @@ module RailsConnector
|
|
46
45
|
#
|
47
46
|
# ActiveRecord::Base::primary_key_prefix_type has no effect here.
|
48
47
|
def table_name_prefix
|
49
|
-
@@instance_name.blank? ?
|
48
|
+
@@instance_name.blank? ? "" : (@@instance_name + "_")
|
50
49
|
end
|
51
50
|
end
|
52
51
|
end
|
53
|
-
|
54
52
|
end
|
@@ -1,14 +1,11 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
class CmsDispatchController < ActionController::Metal
|
4
3
|
def process(action)
|
5
4
|
CmsEnv.new(request.env).load
|
6
5
|
controller = target_controller(request.env)
|
7
6
|
request.env["action_dispatch.request.path_parameters"][:controller] = controller.controller_path
|
8
7
|
|
9
|
-
if !obj_not_found? && action ==
|
10
|
-
action = loaded_obj.controller_action_name
|
11
|
-
end
|
8
|
+
action = loaded_obj.controller_action_name if !obj_not_found? && action == "index"
|
12
9
|
|
13
10
|
request.env["action_dispatch.request.path_parameters"][:action] = action
|
14
11
|
|
@@ -17,8 +14,9 @@ module RailsConnector
|
|
17
14
|
|
18
15
|
private
|
19
16
|
|
20
|
-
def target_controller(
|
17
|
+
def target_controller(_env)
|
21
18
|
return default_controller if obj_not_found?
|
19
|
+
|
22
20
|
controller = "#{loaded_obj.controller_name}Controller".constantize
|
23
21
|
|
24
22
|
if controller.respond_to?(:use_for_obj_dispatch?) && controller.use_for_obj_dispatch?
|
@@ -42,5 +40,4 @@ module RailsConnector
|
|
42
40
|
CmsController
|
43
41
|
end
|
44
42
|
end
|
45
|
-
|
46
43
|
end
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
class CmsEnv
|
4
|
-
|
5
|
-
OBJ_ENV_KEY = "INFOPARK_OBJ"
|
3
|
+
OBJ_ENV_KEY = "INFOPARK_OBJ".freeze
|
6
4
|
|
7
5
|
def initialize(env)
|
8
6
|
@env = env
|
@@ -10,6 +8,7 @@ module RailsConnector
|
|
10
8
|
|
11
9
|
def load
|
12
10
|
return if env[OBJ_ENV_KEY]
|
11
|
+
|
13
12
|
load_object
|
14
13
|
end
|
15
14
|
|
@@ -48,7 +47,7 @@ module RailsConnector
|
|
48
47
|
|
49
48
|
if found_obj.suppressed?
|
50
49
|
raise RailsConnector::ResourceNotFound,
|
51
|
-
|
50
|
+
"Tried to access Obj #{found_obj.inspect}, but it is suppressed (suppress_export is set)!"
|
52
51
|
end
|
53
52
|
|
54
53
|
found_obj
|
@@ -59,10 +58,8 @@ module RailsConnector
|
|
59
58
|
end
|
60
59
|
|
61
60
|
def self.find_permalink_by_param(permalink_param)
|
62
|
-
permalink =
|
61
|
+
permalink = Array(permalink_param).join("/")
|
63
62
|
Obj.find_by_permalink!(permalink)
|
64
63
|
end
|
65
|
-
|
66
64
|
end
|
67
|
-
|
68
65
|
end
|
@@ -1,23 +1,21 @@
|
|
1
1
|
require "helpful_configuration"
|
2
|
-
require
|
2
|
+
require "rails_connector/cms_base_model"
|
3
3
|
require "rails_connector/blob"
|
4
4
|
|
5
5
|
module RailsConnector
|
6
|
-
|
7
6
|
# @api public
|
8
7
|
class Configuration
|
9
8
|
# @api public
|
10
9
|
DEFAULT_MODE = :live
|
11
10
|
|
12
11
|
class << self
|
13
|
-
|
14
12
|
# there are three available modes for the rails connector:
|
15
13
|
# <tt>live</tt> (show released contents only),
|
16
14
|
# <tt>preview</tt> (show edited contents)
|
17
15
|
# <tt>editor</tt> (show edited contents and editor interface (e.g. edit markers))
|
18
16
|
# Default mode is <tt>live</tt>.
|
19
17
|
# @api public
|
20
|
-
attr_accessor :
|
18
|
+
attr_accessor :blob_cache_dir, :choose_homepage_callback
|
21
19
|
|
22
20
|
# default options for {SearchRequest}
|
23
21
|
# @api public
|
@@ -32,12 +30,12 @@ module RailsConnector
|
|
32
30
|
# define a non-default blob cache dir.
|
33
31
|
# +fiona connector+ only. has no effect when used with the +cloud connector+.
|
34
32
|
# @api public
|
35
|
-
attr_accessor :blob_cache_dir
|
36
33
|
|
37
34
|
# @api public
|
38
35
|
def mode=(new_mode)
|
39
36
|
new_mode = new_mode.to_sym
|
40
|
-
raise ArgumentError, "Unknown Mode #{new_mode}" unless
|
37
|
+
raise ArgumentError, "Unknown Mode #{new_mode}" unless %i(editor preview live).include?(new_mode)
|
38
|
+
|
41
39
|
@mode = new_mode
|
42
40
|
end
|
43
41
|
|
@@ -91,8 +89,6 @@ module RailsConnector
|
|
91
89
|
RailsConnector::CmsBaseModel.configure_database(:cms)
|
92
90
|
end
|
93
91
|
|
94
|
-
attr_accessor :choose_homepage_callback
|
95
|
-
|
96
92
|
# Configure a callback to be invoked when the rails connector delivers the homepage.
|
97
93
|
# The given callback will receive the rack env
|
98
94
|
# and must return an Obj to be used as the homepage.
|
@@ -102,15 +98,15 @@ module RailsConnector
|
|
102
98
|
self.choose_homepage_callback = block
|
103
99
|
end
|
104
100
|
|
105
|
-
def cms_routes(*
|
106
|
-
raise <<-EOS.gsub(/\s+/,
|
101
|
+
def cms_routes(*_args)
|
102
|
+
raise <<-EOS.gsub(/\s+/, " ")
|
107
103
|
Calling RailsConnector::Configuration.cms_routes is not needed anymore.
|
108
104
|
Please remove it from config/routes.rb
|
109
105
|
EOS
|
110
106
|
end
|
111
107
|
|
112
|
-
def use_x_sendfile=(
|
113
|
-
raise
|
108
|
+
def use_x_sendfile=(_value)
|
109
|
+
raise "Configuration.use_x_sendfile is now available as Rails configuration:"\
|
114
110
|
' config.action_dispatch.x_sendfile_header = "X-Sendfile"'
|
115
111
|
end
|
116
112
|
|
@@ -130,11 +126,11 @@ module RailsConnector
|
|
130
126
|
protected
|
131
127
|
|
132
128
|
def enable_authentication
|
133
|
-
::ApplicationController.
|
129
|
+
::ApplicationController.include RailsConnector::Authenticable
|
134
130
|
end
|
135
131
|
|
136
132
|
def read_local_config_file
|
137
|
-
contents = YAML.load_file(local_config_file_name) if File.
|
133
|
+
contents = YAML.load_file(local_config_file_name) if File.exist?(local_config_file_name)
|
138
134
|
contents ||= {}
|
139
135
|
|
140
136
|
config = HelpfulConfiguration.new(
|
@@ -161,12 +157,12 @@ module RailsConnector
|
|
161
157
|
"cms_api",
|
162
158
|
"a hash of options that specify access to the cms api"
|
163
159
|
)
|
164
|
-
config.explain
|
160
|
+
config.explain "content_service", "a hash of options that specify access to content service"
|
165
161
|
config
|
166
162
|
end
|
167
163
|
|
168
164
|
def enable_ses
|
169
|
-
require
|
165
|
+
require "rails_connector/ses"
|
170
166
|
|
171
167
|
RailsConnector::SES.enable
|
172
168
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class Time
|
2
|
-
|
3
2
|
# Returns a new Time created from the ISO date format String "YYYYMMDDhhmmss"
|
4
3
|
def self.from_iso(t)
|
5
4
|
return nil unless t
|
5
|
+
|
6
6
|
if t.to_s =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/
|
7
|
-
utc(
|
7
|
+
utc(Regexp.last_match(1).to_i, Regexp.last_match(2).to_i, Regexp.last_match(3).to_i, Regexp.last_match(4).to_i, Regexp.last_match(5).to_i, Regexp.last_match(6).to_i)
|
8
8
|
else
|
9
9
|
raise ArgumentError, "invalid iso time format: #{t}"
|
10
10
|
end
|
@@ -12,7 +12,6 @@ class Time
|
|
12
12
|
|
13
13
|
# Returns the Time as ISO date format String "YYYYMMDDhhmmss"
|
14
14
|
def to_iso
|
15
|
-
getutc.strftime(
|
15
|
+
getutc.strftime("%Y%m%d%H%M%S")
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|