infopark_fiona_connector 7.0.1.5.2.3.rc7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.yardopts +5 -0
- data/app/assets/images/admin/minus.gif +0 -0
- data/app/assets/images/bg80.png +0 -0
- data/app/assets/images/edit.png +0 -0
- data/app/assets/images/icons/mm_generic.png +0 -0
- data/app/assets/images/icons/mm_menu.png +0 -0
- data/app/assets/javascripts/editmarker.js +240 -0
- data/app/assets/javascripts/infopark_rails_connector.js.erb +0 -0
- data/app/assets/stylesheets/editmarker.css +70 -0
- data/app/assets/stylesheets/infopark_rails_connector.css.erb +0 -0
- data/app/controllers/cms_controller.rb +7 -0
- data/app/controllers/rails_connector/default_cms_controller.rb +41 -0
- data/app/helpers/cms_helper.rb +7 -0
- data/app/helpers/cms_routing_helper.rb +7 -0
- data/app/helpers/rails_connector/cms_asset_helper.rb +54 -0
- data/app/helpers/rails_connector/cms_tag_helper.rb +4 -0
- data/app/helpers/rails_connector/default_cms_helper.rb +21 -0
- data/app/helpers/rails_connector/default_cms_routing_helper.rb +119 -0
- data/app/helpers/rails_connector/display_helper.rb +124 -0
- data/app/helpers/rails_connector/editing_helper.rb +7 -0
- data/app/helpers/rails_connector/layout_helper.rb +26 -0
- data/app/helpers/rails_connector/marker_helper.rb +371 -0
- data/app/helpers/rails_connector/table_of_contents_helper.rb +20 -0
- data/app/models/named_link.rb +2 -0
- data/app/views/cms/_index.html.erb +7 -0
- data/app/views/cms/index.html.erb +1 -0
- data/app/views/errors/403_forbidden.html.erb +3 -0
- data/app/views/errors/410_gone.html.erb +7 -0
- data/config/cms_routes.rb +17 -0
- data/config/locales/de.rails_connector.errors.yml +11 -0
- data/config/locales/de.rails_connector.lib.yml +6 -0
- data/config/locales/de.rails_connector.views.yml +9 -0
- data/config/locales/en.rails_connector.errors.yml +10 -0
- data/config/locales/en.rails_connector.lib.yml +6 -0
- data/config/locales/en.rails_connector.views.yml +9 -0
- data/lib/gem_dependencies.rb +68 -0
- data/lib/generators/rails_connector/install/install_generator.rb +37 -0
- data/lib/generators/rails_connector/install/templates/app/models/obj.rb.erb +5 -0
- data/lib/generators/rails_connector/install/templates/initializers/rails_connector.rb +2 -0
- data/lib/generators/rails_connector/install/templates/local/configuration.rb +2 -0
- data/lib/infopark_fiona_connector.rb +44 -0
- data/lib/meta_eager_loader.rb +1 -0
- data/lib/obj.rb +3 -0
- data/lib/rails_connector/attr_dict.rb +169 -0
- data/lib/rails_connector/attr_value_provider.bundle +0 -0
- data/lib/rails_connector/attr_value_provider.so +0 -0
- data/lib/rails_connector/attr_value_provider64.so +0 -0
- data/lib/rails_connector/attribute.rb +93 -0
- data/lib/rails_connector/authenticable.rb +37 -0
- data/lib/rails_connector/basic_obj.rb +571 -0
- data/lib/rails_connector/blob.rb +75 -0
- data/lib/rails_connector/blob_mapping.rb +15 -0
- data/lib/rails_connector/blob_mysql.rb +30 -0
- data/lib/rails_connector/blob_oracle.rb +37 -0
- data/lib/rails_connector/cache_middleware.rb +13 -0
- data/lib/rails_connector/channel.rb +18 -0
- data/lib/rails_connector/cms_accessible.rb +111 -0
- data/lib/rails_connector/cms_base_model.rb +62 -0
- data/lib/rails_connector/cms_dispatch_controller.rb +43 -0
- data/lib/rails_connector/cms_env.rb +65 -0
- data/lib/rails_connector/cms_test_request.rb +8 -0
- data/lib/rails_connector/configuration.rb +174 -0
- data/lib/rails_connector/content.rb +7 -0
- data/lib/rails_connector/core_extensions.rb +1 -0
- data/lib/rails_connector/core_extensions/time.rb +17 -0
- data/lib/rails_connector/date_attribute.rb +26 -0
- data/lib/rails_connector/default_search_request.rb +6 -0
- data/lib/rails_connector/engine.rb +65 -0
- data/lib/rails_connector/errors.rb +6 -0
- data/lib/rails_connector/fiona_datetime.rb +14 -0
- data/lib/rails_connector/fiona_engine.rb +8 -0
- data/lib/rails_connector/html_string.rb +17 -0
- data/lib/rails_connector/job.rb +10 -0
- data/lib/rails_connector/link.rb +148 -0
- data/lib/rails_connector/link_list.rb +28 -0
- data/lib/rails_connector/link_resolvable.rb +5 -0
- data/lib/rails_connector/lucene_search_request.rb +102 -0
- data/lib/rails_connector/markdown_string.rb +17 -0
- 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 +90 -0
- data/lib/rails_connector/news.rb +20 -0
- 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 +37 -0
- data/lib/rails_connector/rack_middlewares.rb +5 -0
- data/lib/rails_connector/ses.rb +78 -0
- data/lib/rails_connector/ses/verity_accessor.rb +127 -0
- data/lib/rails_connector/string_tagging.rb +26 -0
- data/lib/rails_connector/verity_search_request.rb +86 -0
- data/lib/search_request.rb +2 -0
- data/lib/version.rb +7 -0
- metadata +277 -0
@@ -0,0 +1,20 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
#
|
3
|
+
# This module contains a helper that can be used to build a table of contents of an object.
|
4
|
+
#
|
5
|
+
# @api public
|
6
|
+
module TableOfContentsHelper
|
7
|
+
#
|
8
|
+
# The <tt>table_of_contents</tt> helper method gets an object as argument and returns an array,
|
9
|
+
# which can be used as the table of contents of the given object.
|
10
|
+
#
|
11
|
+
# The returned array consists of the child objects of the given object.
|
12
|
+
# The array is sorted according to the configured sort order and the sort keys.
|
13
|
+
# It also contains only objects which the current user is permitted to view.
|
14
|
+
#
|
15
|
+
# @api public
|
16
|
+
def table_of_contents(obj)
|
17
|
+
obj.sorted_toclist.reject { |o| !o.permitted_for_user?(current_user) }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= render :partial => 'index' %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<h1><%= t(:'rails_connector.lib.cms_accessible.not_released') %></h1>
|
2
|
+
|
3
|
+
<% if @valid_until && @valid_until < Time.now %>
|
4
|
+
<%= raw t(:"rails_connector.views.errors.gone.not_released_anymore", :valid_until => "<strong>#{l @valid_until}</strong>") %>
|
5
|
+
<% elsif @valid_from && Time.now < @valid_from %>
|
6
|
+
<%= raw t(:"rails_connector.views.errors.gone.not_yet_released", :valid_from => "<strong>#{l @valid_from}</strong>") %>
|
7
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Rails.application.routes.draw do
|
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
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
de:
|
2
|
+
rails_connector:
|
3
|
+
errors:
|
4
|
+
messages:
|
5
|
+
blank: "darf nicht leer sein"
|
6
|
+
forbidden:
|
7
|
+
no_permissions: "Sie haben nicht die notwendigen Zugriffsrechte"
|
8
|
+
gone:
|
9
|
+
not_released_anymore: "Die Datei war nur bis zum %{valid_until} veröffentlicht."
|
10
|
+
not_yet_released: "Die Datei wird erst am %{valid_from} veröffentlicht."
|
11
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
de:
|
2
|
+
rails_connector:
|
3
|
+
views:
|
4
|
+
errors:
|
5
|
+
forbidden:
|
6
|
+
no_permissions: "Sie haben nicht die notwendigen Zugriffsrechte"
|
7
|
+
gone:
|
8
|
+
not_released_anymore: "Die Datei war nur bis zum %{valid_until} veröffentlicht."
|
9
|
+
not_yet_released: "Die Datei wird erst am %{valid_from} veröffentlicht."
|
@@ -0,0 +1,10 @@
|
|
1
|
+
en:
|
2
|
+
rails_connector:
|
3
|
+
errors:
|
4
|
+
messages:
|
5
|
+
blank: "cannot be blank"
|
6
|
+
forbidden:
|
7
|
+
no_permissions: "You don't have the required permissions"
|
8
|
+
gone:
|
9
|
+
not_released_anymore: "The file was released only until %{valid_until}"
|
10
|
+
not_yet_released: "The file will be released on %{valid_from}"
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class GemDependencies
|
2
|
+
def self.dependency_for(gem_name)
|
3
|
+
dependencies.detect { |dep| dep[:name] == gem_name }
|
4
|
+
end
|
5
|
+
|
6
|
+
# generates code that should be included or eval'ed inside a Gemfile.
|
7
|
+
# for every rc dependency, a 'gem' statement is generated.
|
8
|
+
# this statement specifies that dependency using the _minimum_ allowed version.
|
9
|
+
#
|
10
|
+
# example:
|
11
|
+
# if the RC depends on "json", "~> 1.2.3", the following statement will be generated:
|
12
|
+
# gem "json", "= 1.2.3"
|
13
|
+
def self.minimum_version_gemfile_code(options = {})
|
14
|
+
dependencies_minimum_versions = dependencies.map do |dependency|
|
15
|
+
minimum_version = calculate_minimum_version(dependency[:version])
|
16
|
+
if minimum_version
|
17
|
+
dependency.merge(version: "= #{minimum_version}")
|
18
|
+
else
|
19
|
+
dependency.delete(:version)
|
20
|
+
end
|
21
|
+
dependency
|
22
|
+
end
|
23
|
+
|
24
|
+
dependencies_minimum_versions.map do |dependency|
|
25
|
+
gem_name = dependency[:name]
|
26
|
+
next if gem_name == "rails"
|
27
|
+
|
28
|
+
gem_options = ""
|
29
|
+
gem_options << ", '#{dependency[:version]}'" if dependency[:version]
|
30
|
+
gem_options <<
|
31
|
+
if options[:internal] && dependency[:git]
|
32
|
+
", :git => '#{dependency[:git]}', :ref => '#{dependency[:ref]}', :submodules => true"
|
33
|
+
elsif options[:internal] && dependency[:path]
|
34
|
+
", :path => '#{dependency[:path]}'"
|
35
|
+
else
|
36
|
+
""
|
37
|
+
end
|
38
|
+
# do not require the gems here, the rails connector gem needs to do that on it's own.
|
39
|
+
# if these gems were loaded without :require => false,
|
40
|
+
# the tests would not detect a failure of the rails connector to require them.
|
41
|
+
"gem '#{gem_name}'#{gem_options}, :require => false"
|
42
|
+
end.join("\n")
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.minimum_version_for(gem, version = nil)
|
46
|
+
dependency ||= dependencies.detect do |dep|
|
47
|
+
dep[:name] == gem
|
48
|
+
end
|
49
|
+
version ||= dependency[:version]
|
50
|
+
calculate_minimum_version(version)
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.calculate_minimum_version(version)
|
54
|
+
gem_requirement = Gem::Requirement.new(version)
|
55
|
+
|
56
|
+
minimum_requirements = gem_requirement.requirements.select do |requirement|
|
57
|
+
["=", ">=", "~>"].include?(requirement[0])
|
58
|
+
end
|
59
|
+
|
60
|
+
if minimum_requirements.length > 1
|
61
|
+
raise "multiple minimum version requirements found for version requirement #{version}"
|
62
|
+
elsif minimum_requirements.length < 1
|
63
|
+
return nil
|
64
|
+
end
|
65
|
+
|
66
|
+
minimum_requirements[0][1]
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
desc "Copy Infopark Rails Connector files to your application."
|
5
|
+
|
6
|
+
# Normally, you'd just call 'source_root' as a class method from here,
|
7
|
+
# but we need to glob the dir ourselves. Hence our own method.
|
8
|
+
def self.source_root
|
9
|
+
@source_root ||= File.expand_path("templates", __dir__)
|
10
|
+
end
|
11
|
+
|
12
|
+
def install_configuration
|
13
|
+
copy_file "initializers/rails_connector.rb", "config/initializers/rails_connector.rb"
|
14
|
+
template "app/models/obj.rb.erb", "app/models/obj.rb"
|
15
|
+
copy_file "local/configuration.rb", "config/local/configuration.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
def append_asset_manifests
|
19
|
+
append_file("app/assets/javascripts/application.js", "//= require infopark_rails_connector")
|
20
|
+
gsub_file("app/assets/stylesheets/application.css", "*= require_tree .",
|
21
|
+
"*= require_tree .\n *= require infopark_rails_connector")
|
22
|
+
end
|
23
|
+
|
24
|
+
def remove_public_index_html
|
25
|
+
remove_file "public/index.html"
|
26
|
+
remove_file "app/assets/images/rails.png"
|
27
|
+
end
|
28
|
+
|
29
|
+
def patch_default_application_layout
|
30
|
+
gsub_file("app/views/layouts/application.html.erb", %r{</head>},
|
31
|
+
"<%= rails_connector_header_tags %>\n</head>")
|
32
|
+
gsub_file("app/views/layouts/application.html.erb", %r{</body>},
|
33
|
+
"<%= rails_connector_after_content_tags %>\n</body>")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# @api public
|
2
|
+
module ::RailsConnector
|
3
|
+
PLATFORM_CLOUD = :cloud
|
4
|
+
PLATFORM_FIONA = :fiona
|
5
|
+
|
6
|
+
# return either <tt>:fiona</tt> or <tt>:cloud</tt> depending on the app's configuration.
|
7
|
+
# @return [Symbol]
|
8
|
+
def self.platform
|
9
|
+
PLATFORM_FIONA
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.platform_cloud?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.platform_fiona?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
require "rails_connector/core_extensions"
|
22
|
+
require "rails_connector/rack_middlewares"
|
23
|
+
require "rails_connector/errors"
|
24
|
+
require "rails_connector/fiona_datetime"
|
25
|
+
ActiveRecord::Type.register(:fiona_datetime, ::FionaDateTime)
|
26
|
+
|
27
|
+
# @api public
|
28
|
+
module RailsConnector
|
29
|
+
def self.autoload_all_sources
|
30
|
+
source_files = Dir.glob(File.expand_path("rails_connector/*.rb", __dir__)).map do |file|
|
31
|
+
File.basename(file)
|
32
|
+
end
|
33
|
+
|
34
|
+
source_files.each do |file|
|
35
|
+
name = file.gsub(".rb", "")
|
36
|
+
autoload name.camelcase, "rails_connector/#{name}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
autoload_all_sources
|
41
|
+
end
|
42
|
+
|
43
|
+
require "rails_connector/engine" if defined?(Rails)
|
44
|
+
require "rails_connector/fiona_engine" if defined?(Rails)
|
@@ -0,0 +1 @@
|
|
1
|
+
require "rails_connector/meta/eager_loader"
|
data/lib/obj.rb
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
require "mime/types"
|
2
|
+
require "ostruct"
|
3
|
+
|
4
|
+
module RailsConnector
|
5
|
+
# The page related and custom data belonging to a CMS object
|
6
|
+
#
|
7
|
+
# [editor] The login of the current editor of the edited content, if set
|
8
|
+
#
|
9
|
+
# Any custom Attribute can be accessed directly or via [].
|
10
|
+
class AttrDict
|
11
|
+
def initialize(object, keys_and_values = {}, defs = {})
|
12
|
+
@object = object
|
13
|
+
@blob_dict = keys_and_values.symbolize_keys
|
14
|
+
@attr_defs = defs.symbolize_keys
|
15
|
+
@attr_cache = {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def empty?
|
19
|
+
@blob_dict.empty? && @attr_defs.empty?
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the title of the content - an HtmlString
|
23
|
+
def title
|
24
|
+
raw = @blob_dict[:title]
|
25
|
+
StringTagging.tag_as_html(raw, self)
|
26
|
+
end
|
27
|
+
|
28
|
+
def sort_keys
|
29
|
+
[sort_key1, sort_key2, sort_key3].compact
|
30
|
+
end
|
31
|
+
|
32
|
+
# The body attribute may contain binary data for Obj.binary? or be an HtmlString.
|
33
|
+
def body
|
34
|
+
if object.binary?
|
35
|
+
binary_body&.data
|
36
|
+
else
|
37
|
+
StringTagging.tag_as_html(textual_body, self)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def body_length
|
42
|
+
if binary_body
|
43
|
+
binary_body.length
|
44
|
+
elsif body
|
45
|
+
body.length
|
46
|
+
else
|
47
|
+
0
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Ensures the body data is in a file and returns its file system path.
|
52
|
+
def body_data_path
|
53
|
+
# TODO: Braucht/will jemand Text gestreamt?
|
54
|
+
return nil unless object.binary?
|
55
|
+
|
56
|
+
binary_body&.path_of_stored_data(object.last_changed)
|
57
|
+
end
|
58
|
+
|
59
|
+
def [](key)
|
60
|
+
send key
|
61
|
+
end
|
62
|
+
|
63
|
+
def permitted_groups
|
64
|
+
permission_live_server_read
|
65
|
+
rescue NoMethodError
|
66
|
+
[]
|
67
|
+
end
|
68
|
+
|
69
|
+
def permissions
|
70
|
+
@permissions ||= OpenStruct.new({ live: permitted_groups })
|
71
|
+
end
|
72
|
+
|
73
|
+
def respond_to?(method_id, include_private = false)
|
74
|
+
super || has_attribute(method_id)
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
attr_reader :object, :blob_dict, :attr_defs
|
80
|
+
|
81
|
+
delegate :obj_class_def, to: :object, allow_nil: true
|
82
|
+
|
83
|
+
def textual_body
|
84
|
+
return nil if object.binary?
|
85
|
+
|
86
|
+
blob_dict[:blob]
|
87
|
+
end
|
88
|
+
|
89
|
+
def binary_body
|
90
|
+
return nil unless object.binary? && has_attribute(:blob)
|
91
|
+
|
92
|
+
@binary_body ||= Blob.find(blob)
|
93
|
+
rescue RailsConnector::ResourceNotFound
|
94
|
+
nil
|
95
|
+
end
|
96
|
+
|
97
|
+
def method_missing(method_id, *args)
|
98
|
+
raise NoMethodError, "missing method - #{method_id}" unless args.empty?
|
99
|
+
|
100
|
+
attribute_value(method_id.to_s)
|
101
|
+
rescue UnknownAttributeError
|
102
|
+
raise NoMethodError, "missing method - #{method_id}"
|
103
|
+
end
|
104
|
+
|
105
|
+
def attribute_value(key)
|
106
|
+
raise UnknownAttributeError unless has_attribute(key)
|
107
|
+
|
108
|
+
key = key.to_sym
|
109
|
+
raw = blob_dict[key]
|
110
|
+
@attr_cache[key] ||=
|
111
|
+
case type_of(key)
|
112
|
+
when :markdown
|
113
|
+
StringTagging.tag_as_markdown(raw, self)
|
114
|
+
when :html
|
115
|
+
StringTagging.tag_as_html(raw.to_s, self)
|
116
|
+
when :string, :text
|
117
|
+
raw.to_s
|
118
|
+
when :date
|
119
|
+
DateAttribute.parse(raw) if raw
|
120
|
+
when :linklist
|
121
|
+
LinkList.new(raw)
|
122
|
+
when :multienum
|
123
|
+
raw || []
|
124
|
+
else
|
125
|
+
raw
|
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)
|
133
|
+
end
|
134
|
+
|
135
|
+
def has_attribute(key)
|
136
|
+
key = key.to_sym
|
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)
|
140
|
+
end
|
141
|
+
|
142
|
+
def type_of(key)
|
143
|
+
key = key.to_sym
|
144
|
+
return :linklist if key == :text_links
|
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) || {}
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
class UnknownAttributeError < StandardError
|
168
|
+
end
|
169
|
+
end
|