infopark_cloud_connector 6.8.0.210.ed204b0 → 6.8.0.322.c003f11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.yardopts +5 -0
- data/README +5 -0
- data/app/helpers/rails_connector/marker_helper.rb +1 -1
- data/lib/infopark_cloud_connector.rb +1 -0
- data/lib/rails_connector/blob.rb +50 -33
- data/lib/rails_connector/cache.rb +0 -1
- data/lib/rails_connector/cache_middleware.rb +0 -1
- data/lib/rails_connector/chain.rb +0 -1
- data/lib/rails_connector/cloud_engine.rb +1 -1
- data/lib/rails_connector/cms_api_search_request.rb +3 -0
- data/lib/rails_connector/cms_base_model.rb +2 -3
- data/lib/rails_connector/cms_rest_api.rb +0 -2
- data/lib/rails_connector/content_cache.rb +0 -1
- data/lib/rails_connector/content_service.rb +9 -0
- data/lib/rails_connector/date_attribute.rb +1 -1
- data/lib/rails_connector/default_search_request.rb +2 -1
- data/lib/rails_connector/dict_storage.rb +1 -1
- data/lib/rails_connector/errors.rb +2 -0
- data/lib/rails_connector/link.rb +22 -8
- data/lib/rails_connector/named_link.rb +11 -8
- data/lib/rails_connector/obj.rb +113 -25
- data/lib/rails_connector/obj_data.rb +4 -7
- data/lib/rails_connector/obj_data_from_database.rb +0 -1
- data/lib/rails_connector/obj_data_from_hash.rb +0 -1
- data/lib/rails_connector/obj_data_from_service.rb +6 -1
- data/lib/rails_connector/path_conversion.rb +1 -1
- data/lib/rails_connector/revision.rb +0 -1
- data/lib/rails_connector/s3_blob.rb +17 -12
- data/lib/rails_connector/service_blob.rb +48 -0
- data/lib/rails_connector/service_cms_backend.rb +24 -19
- data/lib/rails_connector/version.rb +0 -1
- data/lib/rails_connector/workspace.rb +0 -1
- data/lib/rails_connector/workspace_data_from_database.rb +0 -1
- data/lib/rails_connector/workspace_data_from_service.rb +0 -1
- data/lib/rails_connector/workspace_selection_middleware.rb +0 -1
- metadata +23 -23
- data/lib/rails_connector/obj_body.rb +0 -60
data/.yardopts
ADDED
data/README
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
= Infopark Cloud Connector
|
2
|
+
|
3
|
+
Infopark Cloud Connector integrates the {https://rubygems.org/gems/infopark_rails_connector Infopark Rails Connector} with the Infopark Cloud Express CMS.
|
4
|
+
|
5
|
+
For more information about Infopark Rails and Cloud Connector, please visit {http://kb.infopark.de/ Infopark’s Knowledge Base}.
|
data/lib/rails_connector/blob.rb
CHANGED
@@ -4,41 +4,50 @@ module RailsConnector
|
|
4
4
|
|
5
5
|
class Blob
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
class << self
|
8
|
+
def find(id)
|
9
|
+
new(blob_class.find(id))
|
10
|
+
end
|
11
|
+
|
12
|
+
def config
|
13
|
+
@config or raise "Blob storage has not been configured yet"
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure(spec)
|
17
|
+
@config = spec.symbolize_keys
|
18
|
+
@blob_class = nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def blob_class
|
22
|
+
@blob_class ||= blob_class_from_config
|
23
|
+
end
|
24
|
+
|
25
|
+
# for testing purposes
|
26
|
+
def reset_blob_class_cache
|
27
|
+
@blob_class = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def unconfigure
|
31
|
+
@config = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def blob_class_from_config
|
37
|
+
blob_class =
|
38
|
+
case config[:type].to_sym
|
39
|
+
when :s3
|
40
|
+
S3Blob
|
41
|
+
when :service
|
42
|
+
ServiceBlob
|
43
|
+
else
|
44
|
+
raise "Unsupported blob storage type #{config[:type]}"
|
45
|
+
end
|
46
|
+
blob_class.configure(config)
|
47
|
+
blob_class
|
48
|
+
end
|
9
49
|
end
|
10
50
|
|
11
|
-
def self.config
|
12
|
-
@config or raise "Blob storage has not been configured yet"
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.configure(spec)
|
16
|
-
@config = spec.symbolize_keys
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.blob_class
|
20
|
-
@blob_class ||= blob_class_from_config
|
21
|
-
end
|
22
|
-
|
23
|
-
# for testing purposes
|
24
|
-
def self.reset_blob_class_cache # :nodoc:
|
25
|
-
@blob_class = nil
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.blob_class_from_config
|
29
|
-
blob_class =
|
30
|
-
case config[:type]
|
31
|
-
when "s3"
|
32
|
-
S3Blob
|
33
|
-
else
|
34
|
-
raise "Unsupported blob storage type #{config[:type]}"
|
35
|
-
end
|
36
|
-
blob_class.configure(config)
|
37
|
-
blob_class
|
38
|
-
end
|
39
|
-
|
40
|
-
attr_reader :instance
|
41
|
-
|
42
51
|
def initialize(blob_instance)
|
43
52
|
@instance = blob_instance
|
44
53
|
end
|
@@ -51,6 +60,10 @@ class Blob
|
|
51
60
|
instance.url
|
52
61
|
end
|
53
62
|
|
63
|
+
def meta_url
|
64
|
+
instance.meta_url
|
65
|
+
end
|
66
|
+
|
54
67
|
def content_type
|
55
68
|
instance.content_type
|
56
69
|
end
|
@@ -59,6 +72,10 @@ class Blob
|
|
59
72
|
instance.length
|
60
73
|
end
|
61
74
|
|
75
|
+
private
|
76
|
+
|
77
|
+
attr_reader :instance
|
78
|
+
|
62
79
|
end
|
63
80
|
|
64
81
|
end # module RailsConnector
|
@@ -3,6 +3,7 @@ module RailsConnector
|
|
3
3
|
# This class provides a basic implementation for accessing the search using the cms api.
|
4
4
|
# It can be activated by making it the superclass of SearchRequest.
|
5
5
|
# It should be customized by subclassing.
|
6
|
+
# @api public
|
6
7
|
class CmsApiSearchRequest
|
7
8
|
|
8
9
|
# Takes +query_string+ and +options+ for accessing Cms Api Search.
|
@@ -11,12 +12,14 @@ module RailsConnector
|
|
11
12
|
#
|
12
13
|
# <tt>:limit</tt>:: The maximum number of hits
|
13
14
|
# <tt>:offset</tt>:: The search offset
|
15
|
+
# @api public
|
14
16
|
def initialize(query_string, options = {})
|
15
17
|
@query_string = query_string
|
16
18
|
@options = Configuration.cms_api_options.merge(options)
|
17
19
|
end
|
18
20
|
|
19
21
|
# Accesses Cms Api Search using #query and fetches search hits.
|
22
|
+
# @api public
|
20
23
|
def fetch_hits
|
21
24
|
hits = CmsRestApi.get(resource_path, {
|
22
25
|
:query => query,
|
@@ -3,10 +3,9 @@ require "kvom"
|
|
3
3
|
module RailsConnector
|
4
4
|
|
5
5
|
# This is the abstract class from which all CMS models derive.
|
6
|
-
|
7
|
-
class CmsBaseModel < Kvom::Model::Base #:nodoc:
|
6
|
+
class CmsBaseModel < Kvom::Model::Base
|
8
7
|
class << self
|
9
|
-
def instance_name=(ignore)
|
8
|
+
def instance_name=(ignore)
|
10
9
|
# this method is here only for compatibility with the fiona connector.
|
11
10
|
end
|
12
11
|
|
@@ -6,6 +6,7 @@ class ContentService
|
|
6
6
|
:headers => {
|
7
7
|
:content_type => :json,
|
8
8
|
:accept => :json,
|
9
|
+
:user_agent => user_agent,
|
9
10
|
},
|
10
11
|
:payload => MultiJson.dump(payload)
|
11
12
|
))
|
@@ -19,4 +20,12 @@ class ContentService
|
|
19
20
|
"#{config['login']}:#{config['api_key']}@#{config['url']}"
|
20
21
|
end
|
21
22
|
end
|
23
|
+
|
24
|
+
def self.user_agent
|
25
|
+
@user_agent ||= (
|
26
|
+
gem_info = Gem.loaded_specs["infopark_cloud_connector"]
|
27
|
+
"#{gem_info.name}-#{gem_info.version}"
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
22
31
|
end
|
@@ -1,6 +1,7 @@
|
|
1
1
|
module RailsConnector
|
2
2
|
# This class provides a default implementation for accessing the search server.
|
3
|
-
# It is used by DefaultSearchController.
|
3
|
+
# It is used by {DefaultSearchController}.
|
4
|
+
# @api public
|
4
5
|
class DefaultSearchRequest < CmsApiSearchRequest
|
5
6
|
end
|
6
7
|
end
|
data/lib/rails_connector/link.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
module RailsConnector
|
2
2
|
# This class provides an interfaces for handling CMS Links.
|
3
3
|
# To format a link for rendering in an html page, use the +cms_path+ or +cms_url+ methods.
|
4
|
+
# @api public
|
4
5
|
class Link
|
5
6
|
|
6
7
|
extend ActiveModel::Naming
|
7
8
|
|
8
|
-
def initialize(link_data, destination_object = nil)
|
9
|
+
def initialize(link_data, destination_object = nil)
|
9
10
|
@link_data = link_data.symbolize_keys
|
10
11
|
@destination_object = destination_object
|
11
12
|
end
|
@@ -13,17 +14,20 @@ module RailsConnector
|
|
13
14
|
# The link's external url. Only available for external links.
|
14
15
|
# Warning: Do not output the url directly unless you know what you are doing.
|
15
16
|
# Normally you want to use the +cms_path+ or +cms_url+ methods to format a link.
|
17
|
+
# @api public
|
16
18
|
def url
|
17
19
|
@link_data[:url]
|
18
20
|
end
|
19
21
|
|
20
22
|
# The link's title.
|
23
|
+
# @api public
|
21
24
|
def title
|
22
25
|
@link_data[:title]
|
23
26
|
end
|
24
27
|
|
25
28
|
# Returns the link's query string as in "index.html?query_string".
|
26
29
|
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
30
|
+
# @api public
|
27
31
|
def query
|
28
32
|
@link_data[:query]
|
29
33
|
end
|
@@ -31,40 +35,44 @@ module RailsConnector
|
|
31
35
|
# Depricated: use Link#query instead.
|
32
36
|
# Returns the link's query string as in "index.html?query_string".
|
33
37
|
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
38
|
+
# @api public
|
34
39
|
def search
|
35
40
|
query
|
36
41
|
end
|
37
42
|
|
38
43
|
# Returns the link's anchor as in "index.html#anchor".
|
39
44
|
# See RFC3986 for details (http://www.ietf.org/rfc/rfc3986.txt).
|
45
|
+
# @api public
|
40
46
|
def fragment
|
41
47
|
@link_data[:fragment]
|
42
48
|
end
|
43
49
|
|
44
50
|
# Returns the browser window or browser frame to be used as a target for this link.
|
45
51
|
# Example: Links that should be opened in a new window will return "_blank" as their target.
|
52
|
+
# @api public
|
46
53
|
def target
|
47
54
|
@link_data[:target]
|
48
55
|
end
|
49
56
|
|
50
|
-
def id
|
57
|
+
def id
|
51
58
|
@link_data[:link_id]
|
52
59
|
end
|
53
60
|
|
54
|
-
def tag_name
|
61
|
+
def tag_name
|
55
62
|
@link_data[:tag_name]
|
56
63
|
end
|
57
64
|
|
58
|
-
def markdown_type
|
65
|
+
def markdown_type
|
59
66
|
@link_data[:markdown_type]
|
60
67
|
end
|
61
68
|
|
62
|
-
def markdown?
|
69
|
+
def markdown?
|
63
70
|
'markdown' == @link_data[:source_format]
|
64
71
|
end
|
65
72
|
|
66
73
|
# Returns the file extension (e.g. zip, pdf) of this link's (internal or external) target.
|
67
74
|
# Returns an empty string if the file extension is can not be determined.
|
75
|
+
# @api public
|
68
76
|
def file_extension
|
69
77
|
if internal?
|
70
78
|
destination_object ? destination_object.file_extension : ""
|
@@ -75,6 +83,7 @@ module RailsConnector
|
|
75
83
|
end
|
76
84
|
|
77
85
|
# Returns the id of the Links' destination_object.
|
86
|
+
# @api public
|
78
87
|
def destination_object_id
|
79
88
|
destination
|
80
89
|
end
|
@@ -82,6 +91,7 @@ module RailsConnector
|
|
82
91
|
# Returns the title of this Link if it is set.
|
83
92
|
# Otherwise it returns the display_title of the destination object for internal Links
|
84
93
|
# or the URL for external Links.
|
94
|
+
# @api public
|
85
95
|
def display_title
|
86
96
|
dt = title
|
87
97
|
dt = destination_object.display_title if dt.blank? && !external?
|
@@ -90,38 +100,42 @@ module RailsConnector
|
|
90
100
|
end
|
91
101
|
|
92
102
|
# Returns true this Link links to a CMS Object.
|
103
|
+
# @api public
|
93
104
|
def internal?
|
94
105
|
url.nil?
|
95
106
|
end
|
96
107
|
|
97
108
|
# Returns true if this Link links to an external URL.
|
109
|
+
# @api public
|
98
110
|
def external?
|
99
111
|
!internal?
|
100
112
|
end
|
101
113
|
|
102
114
|
# An internal Link is active if it's destination object is active.
|
103
115
|
# An external Link is always active.
|
116
|
+
# @api public
|
104
117
|
def active?
|
105
118
|
external? || (destination_object && destination_object.active?)
|
106
119
|
end
|
107
120
|
|
108
|
-
def external_prefix?
|
121
|
+
def external_prefix?
|
109
122
|
nil != (url =~ /\s?external:/)
|
110
123
|
end
|
111
124
|
|
112
|
-
def resolved?
|
125
|
+
def resolved?
|
113
126
|
external? || resolved_internal?
|
114
127
|
end
|
115
128
|
|
116
129
|
# Returns the destination object (+Obj+) of this Link. May be nil if the
|
117
130
|
# link is external or internal without an existing destination object.
|
131
|
+
# @api public
|
118
132
|
def destination_object
|
119
133
|
@destination_object ||= Obj.find(destination) if resolved_internal?
|
120
134
|
rescue RailsConnector::ResourceNotFound
|
121
135
|
nil
|
122
136
|
end
|
123
137
|
|
124
|
-
def to_liquid
|
138
|
+
def to_liquid
|
125
139
|
LiquidSupport::LinkDrop.new(self)
|
126
140
|
end
|
127
141
|
|
@@ -2,9 +2,10 @@ module RailsConnector
|
|
2
2
|
|
3
3
|
# This class provides methods used to retrieve objects from CMS based an entry
|
4
4
|
# in CMS of the obj_class <tt>NamedLink</tt>.
|
5
|
+
# @api public
|
6
|
+
class NamedLink
|
5
7
|
|
6
|
-
|
7
|
-
|
8
|
+
# @api public
|
8
9
|
class NotFound < StandardError
|
9
10
|
end
|
10
11
|
|
@@ -12,7 +13,7 @@ module RailsConnector
|
|
12
13
|
|
13
14
|
# Generates a cache of named links based on the CMS objects related link list.
|
14
15
|
# Raises exceptions if zero or more than one objects have this obj_class
|
15
|
-
def self.generate_named_links_cache
|
16
|
+
def self.generate_named_links_cache
|
16
17
|
return if @@named_links_cache
|
17
18
|
|
18
19
|
found_object = find_named_link_obj
|
@@ -33,37 +34,39 @@ module RailsConnector
|
|
33
34
|
# This method will be called to retrieve the NamedLink Obj.
|
34
35
|
# By default it will look for the Obj at the path "_named_links".
|
35
36
|
# Overwrite this method only if you know what you are doing.
|
37
|
+
# @api public
|
36
38
|
def self.find_named_link_obj
|
37
39
|
Obj.find_by_path("/_named_links")
|
38
40
|
end
|
39
41
|
|
40
|
-
def self.cache_expiry_time=(value)
|
42
|
+
def self.cache_expiry_time=(value)
|
41
43
|
raise "NamedLink.cache_expiry_time is deprecated. NamedLink no longer has a separate cache."
|
42
44
|
end
|
43
45
|
|
44
|
-
def self.cache_expired?
|
46
|
+
def self.cache_expired?
|
45
47
|
true
|
46
48
|
end
|
47
49
|
|
48
50
|
# Returns the CMS object mapped to the given title or nil.
|
49
51
|
# The title can be a string of symbol.
|
52
|
+
# @api public
|
50
53
|
def self.get_object(title, options = {})
|
51
54
|
object = named_links[title.to_s]
|
52
55
|
raise NotFound, "The NamedLink '#{title.to_s}' does not exist" if object.nil?
|
53
56
|
object
|
54
57
|
end
|
55
58
|
|
56
|
-
def self.reset_cache
|
59
|
+
def self.reset_cache
|
57
60
|
@@named_links_cache = nil
|
58
61
|
end
|
59
62
|
|
60
|
-
def self.named_links
|
63
|
+
def self.named_links
|
61
64
|
reset_cache if cache_expired?
|
62
65
|
generate_named_links_cache unless named_links_cache
|
63
66
|
named_links_cache
|
64
67
|
end
|
65
68
|
|
66
|
-
def self.named_links_cache
|
69
|
+
def self.named_links_cache
|
67
70
|
@@named_links_cache
|
68
71
|
end
|
69
72
|
|