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,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
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# Adds support for string columns which contain ISO dates
|
4
3
|
module DateAttribute
|
5
4
|
module ClassMethods
|
6
5
|
def date_attribute(*names)
|
7
6
|
names.each do |name|
|
8
|
-
module_eval
|
7
|
+
module_eval %!
|
9
8
|
def #{name}
|
10
9
|
DateAttribute.parse(#{name}_before_type_cast) unless #{name}_before_type_cast.nil?
|
11
10
|
end
|
@@ -24,5 +23,4 @@ module RailsConnector
|
|
24
23
|
raise "The value is not a valid ISO date time: #{iso_date_time.inspect}"
|
25
24
|
end
|
26
25
|
end
|
27
|
-
|
28
|
-
end
|
26
|
+
end
|
@@ -2,9 +2,9 @@ require "rails"
|
|
2
2
|
require "active_record/railtie"
|
3
3
|
require "action_view"
|
4
4
|
|
5
|
-
require
|
5
|
+
require "jquery-rails"
|
6
6
|
|
7
|
-
require
|
7
|
+
require "rails_connector/configuration"
|
8
8
|
|
9
9
|
module ::RailsConnector
|
10
10
|
class Engine < Rails::Engine
|
@@ -12,21 +12,25 @@ module ::RailsConnector
|
|
12
12
|
config.after_initialize { RailsConnector::Configuration.after_initialize }
|
13
13
|
|
14
14
|
# make sure our exceptions cause an adequate error page and http status code
|
15
|
-
config.action_dispatch.rescue_responses
|
15
|
+
config.action_dispatch.rescue_responses["RailsConnector::ResourceNotFound"] = :not_found
|
16
16
|
|
17
|
-
initializer "rails_connector.
|
18
|
-
|
17
|
+
initializer "rails_connector.add_fiona_time_type" do
|
18
|
+
ActiveRecord::Type.register(:fiona_datetime, ::FionaDateTime)
|
19
|
+
end
|
20
|
+
|
21
|
+
initializer "rails_connector.add_cms_routing_paths", after: :add_routing_paths do |app|
|
22
|
+
cms_route = File.expand_path("cms_routes.rb", paths["config"].to_a.first)
|
19
23
|
app.routes_reloader.paths.push(cms_route)
|
20
24
|
end
|
21
25
|
|
22
26
|
initializer "rails_connector.add_assets" do |app|
|
23
|
-
app.config.assets.precompile += %w
|
27
|
+
app.config.assets.precompile += %w(
|
24
28
|
editmarker.css editmarker.js
|
25
|
-
|
29
|
+
)
|
26
30
|
end
|
27
31
|
|
28
32
|
# Expose rails connector runtime to controller for logging.
|
29
|
-
initializer "rails_connector.log_runtime" do |
|
33
|
+
initializer "rails_connector.log_runtime" do |_app|
|
30
34
|
runtime =
|
31
35
|
begin
|
32
36
|
RailsConnector::ControllerRuntime
|
@@ -42,23 +46,20 @@ module ::RailsConnector
|
|
42
46
|
end
|
43
47
|
end
|
44
48
|
|
45
|
-
initializer "rails_connector.configure_database", :
|
49
|
+
initializer "rails_connector.configure_database", before: :load_config_initializers do |_app|
|
46
50
|
RailsConnector::Configuration.configure_cms_database
|
47
51
|
end
|
48
52
|
|
49
53
|
initializer "rails_connector.routing_helpers" do
|
50
|
-
if Rails.env ==
|
51
|
-
ActionDispatch::TestRequest.__send__(:include, RailsConnector::CmsTestRequest)
|
52
|
-
end
|
54
|
+
ActionDispatch::TestRequest.include RailsConnector::CmsTestRequest if Rails.env == "test"
|
53
55
|
|
54
|
-
ActionController::Base.
|
55
|
-
ActionView::Base.
|
56
|
+
ActionController::Base.include CmsRoutingHelper
|
57
|
+
ActionView::Base.include CmsRoutingHelper
|
56
58
|
end
|
57
59
|
|
58
|
-
config.autoload_paths += paths[
|
59
|
-
config.autoload_once_paths += paths[
|
60
|
+
config.autoload_paths += paths["lib"].to_a
|
61
|
+
config.autoload_once_paths += paths["lib"].to_a
|
60
62
|
|
61
63
|
RailsConnector.rack_middlewares.each { |middleware| config.app_middleware.use middleware }
|
62
64
|
end
|
63
65
|
end
|
64
|
-
|
@@ -1,9 +1,8 @@
|
|
1
1
|
module ::RailsConnector
|
2
2
|
class FionaEngine < Rails::Engine
|
3
|
-
initializer
|
4
|
-
|
5
|
-
Dir[Rails.root +
|
3
|
+
initializer "rails_connector.config_local", after: :load_config_initializers,
|
4
|
+
before: :engines_blank_point do
|
5
|
+
Dir[Rails.root + "config/local/*.rb"].map(&method(:require))
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
9
|
-
|
data/lib/rails_connector/link.rb
CHANGED
@@ -3,7 +3,6 @@ module RailsConnector
|
|
3
3
|
# To format a link for rendering in an html page, use the +cms_path+ or +cms_url+ methods.
|
4
4
|
# @api public
|
5
5
|
class Link
|
6
|
-
|
7
6
|
extend ActiveModel::Naming
|
8
7
|
|
9
8
|
def initialize(link_data, destination_object = nil)
|
@@ -67,7 +66,7 @@ module RailsConnector
|
|
67
66
|
end
|
68
67
|
|
69
68
|
def markdown?
|
70
|
-
|
69
|
+
"markdown" == @link_data[:source_format]
|
71
70
|
end
|
72
71
|
|
73
72
|
# Returns the file extension (e.g. zip, pdf) of this link's (internal or external) target.
|
@@ -77,7 +76,11 @@ module RailsConnector
|
|
77
76
|
if internal?
|
78
77
|
destination_object ? destination_object.file_extension : ""
|
79
78
|
else
|
80
|
-
path =
|
79
|
+
path = begin
|
80
|
+
URI.parse(url).path
|
81
|
+
rescue StandardError
|
82
|
+
nil
|
83
|
+
end
|
81
84
|
path.blank? ? "" : File.extname(path)[1..-1] || ""
|
82
85
|
end
|
83
86
|
end
|
@@ -115,7 +118,7 @@ module RailsConnector
|
|
115
118
|
# An external Link is always active.
|
116
119
|
# @api public
|
117
120
|
def active?
|
118
|
-
external? ||
|
121
|
+
external? || destination_object&.active?
|
119
122
|
end
|
120
123
|
|
121
124
|
def external_prefix?
|
@@ -1,8 +1,6 @@
|
|
1
1
|
module RailsConnector
|
2
|
-
|
3
2
|
# @api public
|
4
3
|
class LinkList < Array
|
5
|
-
|
6
4
|
def initialize(link_definitions)
|
7
5
|
if link_definitions.blank?
|
8
6
|
super([])
|
@@ -13,7 +11,7 @@ module RailsConnector
|
|
13
11
|
|
14
12
|
# @api public
|
15
13
|
def destination_objects
|
16
|
-
|
14
|
+
map { |link| link.destination_object }.compact
|
17
15
|
end
|
18
16
|
|
19
17
|
private
|
@@ -26,7 +24,5 @@ module RailsConnector
|
|
26
24
|
links << link if link.active?
|
27
25
|
end
|
28
26
|
end
|
29
|
-
|
30
27
|
end
|
31
|
-
|
32
28
|
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
require
|
1
|
+
require "rsolr"
|
2
2
|
|
3
3
|
module RailsConnector
|
4
|
-
|
5
4
|
# This class provides a basic implementation for accessing a Solr search server.
|
6
5
|
# It can be activated by making it the superclass of SearchRequest
|
7
6
|
# (instead of DefaultSearchRequest).
|
@@ -28,15 +27,15 @@ module RailsConnector
|
|
28
27
|
#
|
29
28
|
# Uses the #filter_query and +options+ given in #new.
|
30
29
|
def fetch_hits
|
31
|
-
solr = RSolr.connect(:
|
32
|
-
solr_result = solr.get("select", :
|
33
|
-
solr_response = solr_result[
|
34
|
-
build_search_result(solr_response[
|
30
|
+
solr = RSolr.connect(url: @options[:solr_url])
|
31
|
+
solr_result = solr.get("select", params: solr_query_parameters)
|
32
|
+
solr_response = solr_result["response"]
|
33
|
+
build_search_result(solr_response["numFound"], solr_response["docs"], solr_response["maxScore"])
|
35
34
|
end
|
36
35
|
|
37
36
|
# Removes unwanted characters from +text+.
|
38
37
|
def self.sanitize(text)
|
39
|
-
text.gsub(/[^\w
|
38
|
+
text.gsub(/[^\w*]/, " ").gsub(/\s+/, " ").strip
|
40
39
|
end
|
41
40
|
|
42
41
|
def solr_query_for_query_string
|
@@ -65,8 +64,8 @@ module RailsConnector
|
|
65
64
|
# end
|
66
65
|
def filter_query_conditions
|
67
66
|
conditions = {}
|
68
|
-
conditions[:object_type] =
|
69
|
-
conditions[:suppress_export] =
|
67
|
+
conditions[:object_type] = "NOT object_type:image"
|
68
|
+
conditions[:suppress_export] = "NOT suppress_export:1"
|
70
69
|
now = Time.now
|
71
70
|
conditions[:valid_from] = "NOT valid_from:[#{(now + 1.second).to_iso} TO *]"
|
72
71
|
conditions[:valid_until] = "NOT valid_until:[* TO #{now.to_iso}]"
|
@@ -77,30 +76,27 @@ module RailsConnector
|
|
77
76
|
|
78
77
|
def solr_query_parameters
|
79
78
|
{
|
80
|
-
:
|
81
|
-
:
|
82
|
-
:
|
83
|
-
:
|
84
|
-
:
|
79
|
+
q: solr_query_for_query_string,
|
80
|
+
fq: filter_query,
|
81
|
+
fl: "id,score",
|
82
|
+
start: @options[:offset],
|
83
|
+
rows: @options[:limit]
|
85
84
|
}.merge(@options[:solr_parameters] || {})
|
86
85
|
end
|
87
86
|
|
88
87
|
def build_search_result(total_hits, docs, max_score)
|
89
88
|
result = SES::SearchResult.new(total_hits)
|
90
89
|
docs.each do |doc|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
result << hit
|
99
|
-
end
|
90
|
+
id = doc["id"]
|
91
|
+
score = doc["score"] / max_score
|
92
|
+
hit = SES::Hit.new(id, score, doc)
|
93
|
+
if @options[:lazy_load].blank? && hit.obj.blank?
|
94
|
+
Rails.logger.warn("OBJ with ID ##{doc["id"]} not found: This search result will not be shown")
|
95
|
+
else
|
96
|
+
result << hit
|
100
97
|
end
|
101
98
|
end
|
102
99
|
result
|
103
100
|
end
|
104
101
|
end
|
105
|
-
|
106
102
|
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
module Meta
|
3
|
+
# This method is an equivalent of Rails.logger.silence, which has been deprecated
|
4
|
+
def self.hello_im_rails_and_im_retarted_so_please_be_patient
|
5
|
+
old_logger_level = Rails.logger.level
|
6
|
+
Rails.logger.level = Logger::ERROR
|
7
|
+
yield self
|
8
|
+
ensure
|
9
|
+
Rails.logger.level = old_logger_level
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.included(base) #:nodoc:
|
13
|
+
# Class enhancements
|
14
|
+
base.extend(ClassMethods)
|
15
|
+
end
|
16
|
+
|
17
|
+
# The RailsConnector::ObjClass object for this file format.
|
18
|
+
# This will always return a proper object, even if no custom
|
19
|
+
# Ruby class exists.
|
20
|
+
def obj_class_definition
|
21
|
+
@obj_class_definition ||= RailsConnector::Meta::EagerLoader.instance.obj_class(obj_class)
|
22
|
+
end
|
23
|
+
alias_method :obj_class_def, :obj_class_definition
|
24
|
+
|
25
|
+
# Returns true, if there is a custom Ruby class defined for the object
|
26
|
+
# or false, if it is represented by RailsConnector::Obj
|
27
|
+
def has_custom_ruby_class?
|
28
|
+
self.class.is_custom_ruby_class?
|
29
|
+
end
|
30
|
+
|
31
|
+
# Returns the custom attributes in the form of a Hash.
|
32
|
+
def custom_attributes
|
33
|
+
obj_class_definition.custom_attributes
|
34
|
+
end
|
35
|
+
|
36
|
+
# Returns true, if the file format has an attribute of the given name.
|
37
|
+
def custom_attribute?(attr)
|
38
|
+
obj_class_definition.custom_attribute?(attr)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns an Array of String of all mandatory attributes, no mather if it's
|
42
|
+
# custom or built-in. Built-in attributes are underscored (valid_from,
|
43
|
+
# not validFrom).
|
44
|
+
# Possible +options+ are:
|
45
|
+
# <tt>:only_custom_attributes</tt>:: Return only custom attributes, omit
|
46
|
+
# built-in attributes like content_type or valid_from.
|
47
|
+
def mandatory_attribute_names(options = {})
|
48
|
+
obj_class_definition.mandatory_attribute_names(options)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns true, if the file format has an mandatory attribute of the given name.
|
52
|
+
def mandatory_attribute?(attr)
|
53
|
+
obj_class_definition.mandatory_attribute?(attr)
|
54
|
+
end
|
55
|
+
|
56
|
+
# Returns the version of this object. This number is increased every time
|
57
|
+
# this object is released.
|
58
|
+
def version
|
59
|
+
load_meta_details
|
60
|
+
@object_with_meta_data.version.presence.to_i || 0
|
61
|
+
end
|
62
|
+
|
63
|
+
# Returns the time of the reminder, if it is set.
|
64
|
+
def reminder_from
|
65
|
+
load_meta_details
|
66
|
+
@object_with_meta_data.reminder_from.presence &&
|
67
|
+
::ActiveModel::Type::DateTime.new.deserialize(@object_with_meta_data.reminder_from)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Returns the reminder comment, if a reminder is set.
|
71
|
+
def reminder_comment
|
72
|
+
load_meta_details
|
73
|
+
@object_with_meta_data.reminder_comment
|
74
|
+
end
|
75
|
+
|
76
|
+
# Return the name of the workflow, that is assigned to this object.
|
77
|
+
def workflow_name
|
78
|
+
load_meta_details
|
79
|
+
@object_with_meta_data.workflow_name
|
80
|
+
end
|
81
|
+
|
82
|
+
# Return the current editor as a String. If there is no edited content,
|
83
|
+
# which is always the case in live mode, an empty String is returned.
|
84
|
+
# The 'contents' table is queried for this information.
|
85
|
+
def editor
|
86
|
+
return @editor if @editor
|
87
|
+
|
88
|
+
load_meta_details
|
89
|
+
|
90
|
+
content_id =
|
91
|
+
if edited?
|
92
|
+
@object_with_meta_data.edited_content_id
|
93
|
+
else
|
94
|
+
@object_with_meta_data.released_cont_id
|
95
|
+
end
|
96
|
+
|
97
|
+
if content_id
|
98
|
+
content = RailsConnector::Content.find(content_id)
|
99
|
+
@editor = content.editor
|
100
|
+
else
|
101
|
+
@editor = ""
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
def committed?
|
106
|
+
load_meta_details
|
107
|
+
!@object_with_meta_data.committed_cont_id.nil?
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
|
112
|
+
# Load the objects details from the `objects' tables.
|
113
|
+
def load_meta_details #:nodoc:
|
114
|
+
return if @object_with_meta_data
|
115
|
+
|
116
|
+
@object_with_meta_data = RailsConnector::ObjectWithMetaData.find(id)
|
117
|
+
|
118
|
+
# reset depending instance variables
|
119
|
+
@editor = nil
|
120
|
+
end
|
121
|
+
|
122
|
+
# the methods in this module will become class methods
|
123
|
+
module ClassMethods
|
124
|
+
# The RailsConnector::ObjClass object for this file format.
|
125
|
+
# This will only return a proper object if a custom Ruby class exists
|
126
|
+
# and will throw a RuntimeError otherwise.
|
127
|
+
def obj_class_definition
|
128
|
+
unless is_custom_ruby_class?
|
129
|
+
raise "Obtaining the obj_class_definition of an Obj without custom Ruby class " \
|
130
|
+
"is logically impossible."
|
131
|
+
end
|
132
|
+
@obj_class_definition ||= RailsConnector::Meta::EagerLoader.instance.obj_class(name)
|
133
|
+
end
|
134
|
+
alias_method :obj_class_def, :obj_class_definition
|
135
|
+
|
136
|
+
# RailsConnector::AbstractObj returns false, everything else true.
|
137
|
+
# TODO: RailsConnector::AbstractObj does not exist here
|
138
|
+
def is_custom_ruby_class?
|
139
|
+
self != RailsConnector::BasicObj
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|