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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/cms_controller.rb +1 -1
  3. data/app/controllers/rails_connector/default_cms_controller.rb +0 -2
  4. data/app/helpers/cms_helper.rb +1 -1
  5. data/app/helpers/cms_routing_helper.rb +1 -1
  6. data/app/helpers/rails_connector/cms_asset_helper.rb +4 -5
  7. data/app/helpers/rails_connector/cms_tag_helper.rb +0 -3
  8. data/app/helpers/rails_connector/default_cms_helper.rb +0 -2
  9. data/app/helpers/rails_connector/default_cms_routing_helper.rb +15 -16
  10. data/app/helpers/rails_connector/display_helper.rb +31 -33
  11. data/app/helpers/rails_connector/editing_helper.rb +2 -8
  12. data/app/helpers/rails_connector/layout_helper.rb +2 -5
  13. data/app/helpers/rails_connector/marker_helper.rb +63 -64
  14. data/app/helpers/rails_connector/table_of_contents_helper.rb +1 -3
  15. data/config/cms_routes.rb +15 -15
  16. data/lib/gem_dependencies.rb +8 -7
  17. data/lib/generators/rails_connector/install/install_generator.rb +6 -6
  18. data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +1 -1
  19. data/lib/infopark_fiona_connector.rb +9 -9
  20. data/lib/rails_connector/attr_dict.rb +26 -18
  21. data/lib/rails_connector/attribute.rb +18 -21
  22. data/lib/rails_connector/authenticable.rb +12 -5
  23. data/lib/rails_connector/basic_obj.rb +64 -57
  24. data/lib/rails_connector/blob.rb +2 -5
  25. data/lib/rails_connector/blob_mapping.rb +2 -3
  26. data/lib/rails_connector/blob_mysql.rb +3 -5
  27. data/lib/rails_connector/blob_oracle.rb +5 -7
  28. data/lib/rails_connector/channel.rb +5 -6
  29. data/lib/rails_connector/cms_accessible.rb +16 -17
  30. data/lib/rails_connector/cms_base_model.rb +2 -4
  31. data/lib/rails_connector/cms_dispatch_controller.rb +3 -6
  32. data/lib/rails_connector/cms_env.rb +4 -7
  33. data/lib/rails_connector/cms_test_request.rb +1 -1
  34. data/lib/rails_connector/configuration.rb +12 -16
  35. data/lib/rails_connector/content.rb +0 -4
  36. data/lib/rails_connector/core_extensions/time.rb +3 -4
  37. data/lib/rails_connector/date_attribute.rb +1 -3
  38. data/lib/rails_connector/default_search_request.rb +1 -1
  39. data/lib/rails_connector/engine.rb +18 -21
  40. data/lib/rails_connector/errors.rb +2 -5
  41. data/lib/rails_connector/fiona_datetime.rb +2 -2
  42. data/lib/rails_connector/fiona_engine.rb +3 -4
  43. data/lib/rails_connector/html_string.rb +0 -2
  44. data/lib/rails_connector/job.rb +0 -3
  45. data/lib/rails_connector/link.rb +7 -4
  46. data/lib/rails_connector/link_list.rb +1 -5
  47. data/lib/rails_connector/link_resolvable.rb +1 -5
  48. data/lib/rails_connector/lucene_search_request.rb +20 -24
  49. data/lib/rails_connector/markdown_string.rb +0 -2
  50. data/lib/rails_connector/meta.rb +25 -30
  51. data/lib/rails_connector/meta/eager_loader.rb +14 -12
  52. data/lib/rails_connector/named_link.rb +12 -16
  53. data/lib/rails_connector/news.rb +3 -3
  54. data/lib/rails_connector/obj_class.rb +23 -25
  55. data/lib/rails_connector/obj_class_attr.rb +1 -1
  56. data/lib/rails_connector/object_with_meta_data.rb +0 -5
  57. data/lib/rails_connector/permission.rb +2 -6
  58. data/lib/rails_connector/ses.rb +3 -8
  59. data/lib/rails_connector/ses/verity_accessor.rb +43 -46
  60. data/lib/rails_connector/string_tagging.rb +0 -3
  61. data/lib/rails_connector/verity_search_request.rb +6 -9
  62. data/lib/search_request.rb +1 -1
  63. data/lib/version.rb +1 -1
  64. metadata +2 -2
@@ -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 %Q!
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
26
  end
@@ -3,4 +3,4 @@ module RailsConnector
3
3
  # It is used by {DefaultSearchController}.
4
4
  class DefaultSearchRequest < VeritySearchRequest
5
5
  end
6
- end
6
+ end
@@ -1,10 +1,10 @@
1
- require 'rails'
2
- require 'active_record/railtie'
3
- require 'action_view'
1
+ require "rails"
2
+ require "active_record/railtie"
3
+ require "action_view"
4
4
 
5
- require 'jquery-rails'
5
+ require "jquery-rails"
6
6
 
7
- require 'rails_connector/configuration'
7
+ require "rails_connector/configuration"
8
8
 
9
9
  module ::RailsConnector
10
10
  class Engine < Rails::Engine
@@ -12,25 +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.merge!("RailsConnector::ResourceNotFound" => :not_found)
15
+ config.action_dispatch.rescue_responses["RailsConnector::ResourceNotFound"] = :not_found
16
16
 
17
- initializer 'rails_connector.add_fiona_time_type' do
17
+ initializer "rails_connector.add_fiona_time_type" do
18
18
  ActiveRecord::Type.register(:fiona_datetime, ::FionaDateTime)
19
19
  end
20
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)
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)
23
23
  app.routes_reloader.paths.push(cms_route)
24
24
  end
25
25
 
26
26
  initializer "rails_connector.add_assets" do |app|
27
- app.config.assets.precompile += %w[
27
+ app.config.assets.precompile += %w(
28
28
  editmarker.css editmarker.js
29
- ]
29
+ )
30
30
  end
31
31
 
32
32
  # Expose rails connector runtime to controller for logging.
33
- initializer "rails_connector.log_runtime" do |app|
33
+ initializer "rails_connector.log_runtime" do |_app|
34
34
  runtime =
35
35
  begin
36
36
  RailsConnector::ControllerRuntime
@@ -46,22 +46,19 @@ module ::RailsConnector
46
46
  end
47
47
  end
48
48
 
49
- initializer "rails_connector.configure_database", :before => :load_config_initializers do |app|
49
+ initializer "rails_connector.configure_database", before: :load_config_initializers do |_app|
50
50
  RailsConnector::Configuration.configure_cms_database
51
51
  end
52
52
 
53
53
  initializer "rails_connector.routing_helpers" do
54
- if Rails.env == 'test'
55
- ActionDispatch::TestRequest.__send__(:include, RailsConnector::CmsTestRequest)
56
- end
54
+ ActionDispatch::TestRequest.include RailsConnector::CmsTestRequest if Rails.env == "test"
57
55
 
58
- ActionController::Base.__send__(:include, CmsRoutingHelper)
59
- ActionView::Base.__send__(:include, CmsRoutingHelper)
56
+ ActionController::Base.include CmsRoutingHelper
57
+ ActionView::Base.include CmsRoutingHelper
60
58
  end
61
59
 
62
-
63
- config.autoload_paths += paths['lib'].to_a
64
- config.autoload_once_paths += paths['lib'].to_a
60
+ config.autoload_paths += paths["lib"].to_a
61
+ config.autoload_once_paths += paths["lib"].to_a
65
62
 
66
63
  RailsConnector.rack_middlewares.each { |middleware| config.app_middleware.use middleware }
67
64
  end
@@ -1,9 +1,6 @@
1
1
  require "active_record/errors"
2
2
 
3
3
  module RailsConnector
4
-
5
- # @api public
6
- ResourceNotFound = ActiveRecord::RecordNotFound
7
-
4
+ # @api public
5
+ ResourceNotFound = ActiveRecord::RecordNotFound
8
6
  end # module RailsConnector
9
-
@@ -1,11 +1,11 @@
1
- require 'active_record/type'
1
+ require "active_record/type"
2
2
  class FionaDateTime < ActiveRecord::Type::Time
3
3
  def type
4
4
  :fiona_datetime
5
5
  end
6
6
 
7
7
  def serialize(value)
8
- value.to_iso if value
8
+ value&.to_iso
9
9
  end
10
10
 
11
11
  def deserialize(value)
@@ -1,9 +1,8 @@
1
1
  module ::RailsConnector
2
2
  class FionaEngine < Rails::Engine
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)
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
-
@@ -1,5 +1,4 @@
1
1
  module RailsConnector
2
-
3
2
  # Include this module in order to tag the string as one with HTML content
4
3
  module HtmlString
5
4
  include LinkResolvable
@@ -8,7 +7,6 @@ module RailsConnector
8
7
  true
9
8
  end
10
9
  end
11
-
12
10
  end
13
11
 
14
12
  class String
@@ -1,13 +1,10 @@
1
1
  module RailsConnector
2
-
3
2
  # This class allows us to read out basic information about jobs
4
3
  class Job < CmsBaseModel
5
-
6
4
  self.primary_key = "job_id"
7
5
 
8
6
  def self.table_name
9
7
  "#{table_name_prefix}" "jobs"
10
8
  end
11
9
  end
12
-
13
10
  end
@@ -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
- 'markdown' == @link_data[:source_format]
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 = URI.parse(url).path rescue nil
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? || (destination_object && destination_object.active?)
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
- self.map {|link| link.destination_object}.compact
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,9 +1,5 @@
1
1
  module RailsConnector
2
-
3
2
  module LinkResolvable
4
3
  attr_accessor :source
5
-
6
4
  end
7
-
8
-
9
- end
5
+ end
@@ -1,7 +1,6 @@
1
- require 'rsolr'
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(:url => @options[:solr_url])
32
- solr_result = solr.get("select", :params => solr_query_parameters)
33
- solr_response = solr_result['response']
34
- build_search_result(solr_response['numFound'], solr_response['docs'], solr_response['maxScore'])
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\*]/, ' ').gsub(/\s+/, ' ').strip
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] = 'NOT object_type:image'
69
- conditions[:suppress_export] = 'NOT suppress_export:1'
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
- :q => solr_query_for_query_string,
81
- :fq => filter_query,
82
- :fl => 'id,score',
83
- :start => @options[:offset],
84
- :rows => @options[:limit]
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
- begin
92
- id = doc['id']
93
- score = doc['score'] / max_score
94
- hit = SES::Hit.new(id, score, doc)
95
- if @options[:lazy_load].blank? && hit.obj.blank?
96
- Rails.logger.warn("OBJ with ID ##{doc['id']} not found: This search result will not be shown")
97
- else
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
@@ -1,5 +1,4 @@
1
1
  module RailsConnector
2
-
3
2
  # Include this module in order to tag the string as one with Markdown content
4
3
  module MarkdownString
5
4
  include LinkResolvable
@@ -8,7 +7,6 @@ module RailsConnector
8
7
  true
9
8
  end
10
9
  end
11
-
12
10
  end
13
11
 
14
12
  class String
@@ -1,15 +1,12 @@
1
1
  module RailsConnector
2
-
3
2
  module Meta
4
-
5
3
  # This method is an equivalent of Rails.logger.silence, which has been deprecated
6
- def self.hello_im_rails_and_im_retarted_so_please_be_patient(&block)
7
- begin
8
- old_logger_level, Rails.logger.level = Rails.logger.level, Logger::ERROR
9
- yield self
10
- ensure
11
- Rails.logger.level = old_logger_level
12
- end
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
13
10
  end
14
11
 
15
12
  def self.included(base) #:nodoc:
@@ -21,7 +18,7 @@ module RailsConnector
21
18
  # This will always return a proper object, even if no custom
22
19
  # Ruby class exists.
23
20
  def obj_class_definition
24
- @obj_class_definition ||= RailsConnector::Meta::EagerLoader.instance.obj_class(self.obj_class)
21
+ @obj_class_definition ||= RailsConnector::Meta::EagerLoader.instance.obj_class(obj_class)
25
22
  end
26
23
  alias_method :obj_class_def, :obj_class_definition
27
24
 
@@ -33,12 +30,12 @@ module RailsConnector
33
30
 
34
31
  # Returns the custom attributes in the form of a Hash.
35
32
  def custom_attributes
36
- self.obj_class_definition.custom_attributes
33
+ obj_class_definition.custom_attributes
37
34
  end
38
35
 
39
36
  # Returns true, if the file format has an attribute of the given name.
40
37
  def custom_attribute?(attr)
41
- self.obj_class_definition.custom_attribute?(attr)
38
+ obj_class_definition.custom_attribute?(attr)
42
39
  end
43
40
 
44
41
  # Returns an Array of String of all mandatory attributes, no mather if it's
@@ -48,12 +45,12 @@ module RailsConnector
48
45
  # <tt>:only_custom_attributes</tt>:: Return only custom attributes, omit
49
46
  # built-in attributes like content_type or valid_from.
50
47
  def mandatory_attribute_names(options = {})
51
- self.obj_class_definition.mandatory_attribute_names(options)
48
+ obj_class_definition.mandatory_attribute_names(options)
52
49
  end
53
50
 
54
51
  # Returns true, if the file format has an mandatory attribute of the given name.
55
52
  def mandatory_attribute?(attr)
56
- self.obj_class_definition.mandatory_attribute?(attr)
53
+ obj_class_definition.mandatory_attribute?(attr)
57
54
  end
58
55
 
59
56
  # Returns the version of this object. This number is increased every time
@@ -67,7 +64,7 @@ module RailsConnector
67
64
  def reminder_from
68
65
  load_meta_details
69
66
  @object_with_meta_data.reminder_from.presence &&
70
- ::ActiveModel::Type::DateTime.new.deserialize(@object_with_meta_data.reminder_from)
67
+ ::ActiveModel::Type::DateTime.new.deserialize(@object_with_meta_data.reminder_from)
71
68
  end
72
69
 
73
70
  # Returns the reminder comment, if a reminder is set.
@@ -90,17 +87,18 @@ module RailsConnector
90
87
 
91
88
  load_meta_details
92
89
 
93
- content_id = if self.edited?
94
- @object_with_meta_data.edited_content_id
95
- else
96
- @object_with_meta_data.released_cont_id
97
- end
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
98
96
 
99
97
  if content_id
100
98
  content = RailsConnector::Content.find(content_id)
101
99
  @editor = content.editor
102
100
  else
103
- @editor = ''
101
+ @editor = ""
104
102
  end
105
103
  end
106
104
 
@@ -115,23 +113,23 @@ module RailsConnector
115
113
  def load_meta_details #:nodoc:
116
114
  return if @object_with_meta_data
117
115
 
118
- @object_with_meta_data = RailsConnector::ObjectWithMetaData.find(self.id)
116
+ @object_with_meta_data = RailsConnector::ObjectWithMetaData.find(id)
119
117
 
120
118
  # reset depending instance variables
121
119
  @editor = nil
122
120
  end
123
121
 
124
-
125
122
  # the methods in this module will become class methods
126
123
  module ClassMethods
127
-
128
124
  # The RailsConnector::ObjClass object for this file format.
129
125
  # This will only return a proper object if a custom Ruby class exists
130
126
  # and will throw a RuntimeError otherwise.
131
127
  def obj_class_definition
132
- raise "Obtaining the obj_class_definition of an Obj without custom Ruby class " \
133
- "is logically impossible." unless is_custom_ruby_class?
134
- @obj_class_definition ||= RailsConnector::Meta::EagerLoader.instance.obj_class(self.name)
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)
135
133
  end
136
134
  alias_method :obj_class_def, :obj_class_definition
137
135
 
@@ -140,9 +138,6 @@ module RailsConnector
140
138
  def is_custom_ruby_class?
141
139
  self != RailsConnector::BasicObj
142
140
  end
143
-
144
141
  end
145
-
146
142
  end
147
-
148
143
  end