infopark_fiona_connector 6.9.2.1.125136549 → 6.9.3.1.36404185
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/app/helpers/rails_connector/display_helper.rb +126 -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/rails_connector/configuration.rb +176 -0
- metadata +25 -3
@@ -0,0 +1,126 @@
|
|
1
|
+
module RailsConnector
|
2
|
+
|
3
|
+
# This module contains a helper that can be used to render attributes of the CMS models.
|
4
|
+
# @api public
|
5
|
+
module DisplayHelper
|
6
|
+
|
7
|
+
# For a consistent look of your site and easy maintenance, only the display helpers
|
8
|
+
# should be used to render an attribute <em>value</em> of a CMS model.
|
9
|
+
#
|
10
|
+
# <%= display_value @obj.title %>
|
11
|
+
# Renders the value, taking its type into account.
|
12
|
+
# * An HtmlString will be exported by converting its links
|
13
|
+
# * A Time will be exported in an international form: Year-Month-Day Hour:Minutes
|
14
|
+
# * A non-HTML String will be quoted
|
15
|
+
# * other values will be rendered unchanged
|
16
|
+
#
|
17
|
+
# @api public
|
18
|
+
def display_value(value)
|
19
|
+
case value
|
20
|
+
when MarkdownString then markdown(convert_links(value)).html_safe
|
21
|
+
when HtmlString then convert_links(value).html_safe
|
22
|
+
when String then h(value)
|
23
|
+
when Time then h(l(value))
|
24
|
+
else value
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def display_original_value(value)
|
29
|
+
case value
|
30
|
+
when HtmlString then convert_links(value, :ignore_body_data_url => true).html_safe
|
31
|
+
else display_value(value)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Renders a field from the CMS, including an edit marker for the preview
|
36
|
+
# If the option :marker is +false+, no edit marker will be rendered.
|
37
|
+
#
|
38
|
+
# <%= display_field @obj, :title %>
|
39
|
+
#
|
40
|
+
# When creating an edit marker, all options except :marker are passed to {MarkerHelper#edit_marker}.
|
41
|
+
#
|
42
|
+
# @api public
|
43
|
+
def display_field(obj, attr, options = {})
|
44
|
+
options.reverse_merge!({
|
45
|
+
:marker => ![:id, :path, :created, :last_changed, :version].include?(attr.to_sym)
|
46
|
+
})
|
47
|
+
if options.delete :marker
|
48
|
+
edit_marker(obj, attr, options) do |obj, attr|
|
49
|
+
display_value obj[attr]
|
50
|
+
end
|
51
|
+
else
|
52
|
+
display_value obj[attr]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# Legacy method - deprecated
|
57
|
+
#
|
58
|
+
# Use display_value and display_field instead
|
59
|
+
def display(*args)
|
60
|
+
if args.last.kind_of? Hash
|
61
|
+
options = args.pop
|
62
|
+
else
|
63
|
+
options = {}
|
64
|
+
end
|
65
|
+
return display_value(args.first) if args.size == 1
|
66
|
+
display_field(args[0], args[1], options)
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def markdown(string)
|
72
|
+
require 'maruku'
|
73
|
+
Maruku.new(string).to_html
|
74
|
+
end
|
75
|
+
|
76
|
+
LINK_PATTERN = '<?\binternallink:(\d+)\b>?'
|
77
|
+
LINK_EXPRESSION = %r(#{LINK_PATTERN})
|
78
|
+
|
79
|
+
def convert_links(content_attribute, cms_path_options = {})
|
80
|
+
return content_attribute unless content_attribute =~ LINK_EXPRESSION
|
81
|
+
link_map = content_attribute.source.text_links.each_with_object({}) do |link, map|
|
82
|
+
map[link.id.to_s] = link
|
83
|
+
end
|
84
|
+
content_attribute.gsub(%r(#{LINK_PATTERN}(['"]?))) do
|
85
|
+
link = link_map[$1.to_s]
|
86
|
+
if link.blank?
|
87
|
+
"#{CmsRoutingHelper::LINK_TO_UNREACHABLE}#{$2}"
|
88
|
+
else
|
89
|
+
uri = "#{cms_path(link, cms_path_options)}#{$2}"
|
90
|
+
if link.markdown?
|
91
|
+
markdown_link(link, uri)
|
92
|
+
else
|
93
|
+
html_link(link, uri)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def html_link(link, uri)
|
100
|
+
subst = uri
|
101
|
+
name, value =
|
102
|
+
case link.tag_name
|
103
|
+
when 'img', 'input'
|
104
|
+
['alt', link.title || ""]
|
105
|
+
when 'a', 'link'
|
106
|
+
['title', begin link.title unless link.title.blank? end]
|
107
|
+
end
|
108
|
+
if value
|
109
|
+
subst << %( #{name}="#{h(value)}")
|
110
|
+
end
|
111
|
+
subst << %( target="#{h(link.target)}") unless link.target.blank?
|
112
|
+
subst
|
113
|
+
end
|
114
|
+
|
115
|
+
def markdown_link(link, uri)
|
116
|
+
subst = "<#{uri}>"
|
117
|
+
unless link.title.blank?
|
118
|
+
case link.markdown_type
|
119
|
+
when 'inline', 'reference'
|
120
|
+
subst << %( "#{h(link.title)}")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
subst
|
124
|
+
end
|
125
|
+
end
|
126
|
+
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', __FILE__)
|
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,176 @@
|
|
1
|
+
require "helpful_configuration"
|
2
|
+
require 'rails_connector/cms_base_model'
|
3
|
+
require "rails_connector/blob"
|
4
|
+
|
5
|
+
module RailsConnector
|
6
|
+
|
7
|
+
# @api public
|
8
|
+
class Configuration
|
9
|
+
# @api public
|
10
|
+
DEFAULT_MODE = :live
|
11
|
+
|
12
|
+
class << self
|
13
|
+
|
14
|
+
# there are three available modes for the rails connector:
|
15
|
+
# <tt>live</tt> (show released contents only),
|
16
|
+
# <tt>preview</tt> (show edited contents)
|
17
|
+
# <tt>editor</tt> (show edited contents and editor interface (e.g. edit markers))
|
18
|
+
# Default mode is <tt>live</tt>.
|
19
|
+
# @api public
|
20
|
+
attr_accessor :mode
|
21
|
+
|
22
|
+
# default options for {SearchRequest}
|
23
|
+
# @api public
|
24
|
+
attr_writer :search_options
|
25
|
+
|
26
|
+
# default options for {SearchRequest}
|
27
|
+
# @api public
|
28
|
+
def search_options
|
29
|
+
@search_options || local_config_file["search"].symbolize_keys
|
30
|
+
end
|
31
|
+
|
32
|
+
# define a non-default blob cache dir.
|
33
|
+
# +fiona connector+ only. has no effect when used with the +cloud connector+.
|
34
|
+
# @api public
|
35
|
+
attr_accessor :blob_cache_dir
|
36
|
+
|
37
|
+
# @api public
|
38
|
+
def mode=(new_mode)
|
39
|
+
new_mode = new_mode.to_sym
|
40
|
+
raise ArgumentError, "Unknown Mode #{new_mode}" unless [:editor, :preview, :live].include?(new_mode)
|
41
|
+
@mode = new_mode
|
42
|
+
end
|
43
|
+
|
44
|
+
# there are three available modes for the rails connector:
|
45
|
+
# <tt>live</tt> (show released contents only),
|
46
|
+
# <tt>preview</tt> (show edited contents)
|
47
|
+
# <tt>editor</tt> (show edited contents and editor interface (e.g. edit markers))
|
48
|
+
# Default mode is <tt>live</tt>.
|
49
|
+
# @api public
|
50
|
+
def mode
|
51
|
+
@mode || DEFAULT_MODE
|
52
|
+
end
|
53
|
+
|
54
|
+
def editor_interface_enabled?
|
55
|
+
mode == :editor
|
56
|
+
end
|
57
|
+
|
58
|
+
def use_edited_content?
|
59
|
+
mode == :preview || mode == :editor
|
60
|
+
end
|
61
|
+
|
62
|
+
# Configures your CMS instance name.
|
63
|
+
#
|
64
|
+
# Example call as to be used in <tt>rails_connector.rb</tt>:
|
65
|
+
# RailsConnector::Configuration.instance_name = 'internet'
|
66
|
+
# @api public
|
67
|
+
def instance_name=(name)
|
68
|
+
RailsConnector::CmsBaseModel.instance_name = name if RailsConnector.platform_fiona?
|
69
|
+
end
|
70
|
+
|
71
|
+
def after_initialize
|
72
|
+
enable_ses
|
73
|
+
enable_authentication
|
74
|
+
::RailsConnector::BasicObj.configure_for_content(
|
75
|
+
::RailsConnector::Configuration.use_edited_content? ? :edited : :released
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
def to_prepare
|
80
|
+
unless Rails.configuration.cache_classes
|
81
|
+
after_initialize
|
82
|
+
NamedLink.reset_cache
|
83
|
+
BasicObj.reset_type_cache
|
84
|
+
::ApplicationController.__send__(:helper, :cms)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def configure_cms_database
|
89
|
+
RailsConnector::CmsBaseModel.configure_database('cms')
|
90
|
+
end
|
91
|
+
|
92
|
+
attr_accessor :choose_homepage_callback
|
93
|
+
|
94
|
+
# Configure a callback to be invoked when the rails connector delivers the homepage.
|
95
|
+
# The given callback will receive the rack env
|
96
|
+
# and must return an Obj to be used as the homepage.
|
97
|
+
# If no callback is configured, Obj.homepage will be used as the default.
|
98
|
+
# @api public
|
99
|
+
def choose_homepage(&block)
|
100
|
+
self.choose_homepage_callback = block
|
101
|
+
end
|
102
|
+
|
103
|
+
def cms_routes(*args)
|
104
|
+
raise <<-EOS.gsub(/\s+/, ' ')
|
105
|
+
Calling RailsConnector::Configuration.cms_routes is not needed anymore.
|
106
|
+
Please remove it from config/routes.rb
|
107
|
+
EOS
|
108
|
+
end
|
109
|
+
|
110
|
+
def use_x_sendfile=(value)
|
111
|
+
raise 'Configuration.use_x_sendfile is now available as Rails configuration:'\
|
112
|
+
' config.action_dispatch.x_sendfile_header = "X-Sendfile"'
|
113
|
+
end
|
114
|
+
|
115
|
+
def local_config_file
|
116
|
+
@local_config_file ||= read_local_config_file
|
117
|
+
end
|
118
|
+
|
119
|
+
def local_config_file_name
|
120
|
+
(Rails.root + "config/rails_connector.yml").expand_path
|
121
|
+
end
|
122
|
+
|
123
|
+
# for test purposes only
|
124
|
+
def reset_local_config_file_cache
|
125
|
+
@local_config_file = nil
|
126
|
+
end
|
127
|
+
|
128
|
+
protected
|
129
|
+
|
130
|
+
def enable_authentication
|
131
|
+
::ApplicationController.__send__(:include, RailsConnector::Authenticable)
|
132
|
+
end
|
133
|
+
|
134
|
+
def read_local_config_file
|
135
|
+
contents = YAML.load_file(local_config_file_name) if File.exists?(local_config_file_name)
|
136
|
+
contents ||= {}
|
137
|
+
|
138
|
+
config = HelpfulConfiguration.new(
|
139
|
+
contents,
|
140
|
+
local_config_file_name
|
141
|
+
)
|
142
|
+
config.explain(
|
143
|
+
"cms_database",
|
144
|
+
"a hash of options, including type, that specify the database configuration"
|
145
|
+
)
|
146
|
+
config.explain(
|
147
|
+
"cms_blob_storage",
|
148
|
+
"a hash of options, including type, that specify the cms blob storage configuration"
|
149
|
+
)
|
150
|
+
config.explain(
|
151
|
+
"cms_dict_storage",
|
152
|
+
"a hash of options, including type, that specify the cms dict storage configuration"
|
153
|
+
)
|
154
|
+
config.explain(
|
155
|
+
"search",
|
156
|
+
"a hash of options that specify access to the search server"
|
157
|
+
)
|
158
|
+
config.explain(
|
159
|
+
"cms_api",
|
160
|
+
"a hash of options that specify access to the cms api"
|
161
|
+
)
|
162
|
+
config.explain 'content_service', 'a hash of options that specify access to content service'
|
163
|
+
config
|
164
|
+
end
|
165
|
+
|
166
|
+
def enable_ses
|
167
|
+
require 'rails_connector/ses'
|
168
|
+
|
169
|
+
RailsConnector::SES.enable
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
class ConfigurationError < StandardError
|
175
|
+
end
|
176
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infopark_fiona_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.9.
|
4
|
+
version: 6.9.3.1.36404185
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-09-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mime-types
|
@@ -59,6 +59,22 @@ dependencies:
|
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: 1.0.0
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: helpful_configuration
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.1.0
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 0.1.0
|
62
78
|
description: The Fiona Connector for Infopark CMS Fiona enables you to develop modern,
|
63
79
|
dynamic Web 2.0 applications using Ruby on Rails and at the same time display CMS
|
64
80
|
managed content.
|
@@ -71,8 +87,13 @@ files:
|
|
71
87
|
- README
|
72
88
|
- app/helpers/rails_connector/cms_asset_helper.rb
|
73
89
|
- app/helpers/rails_connector/cms_tag_helper.rb
|
90
|
+
- app/helpers/rails_connector/display_helper.rb
|
74
91
|
- app/helpers/rails_connector/editing_helper.rb
|
75
92
|
- app/helpers/rails_connector/marker_helper.rb
|
93
|
+
- lib/generators/rails_connector/install/install_generator.rb
|
94
|
+
- lib/generators/rails_connector/install/templates/app/models/obj.rb.erb
|
95
|
+
- lib/generators/rails_connector/install/templates/initializers/rails_connector.rb
|
96
|
+
- lib/generators/rails_connector/install/templates/local/configuration.rb
|
76
97
|
- lib/infopark_fiona_connector.rb
|
77
98
|
- lib/rails_connector/attr_dict.rb
|
78
99
|
- lib/rails_connector/attr_value_provider.bundle
|
@@ -84,6 +105,7 @@ files:
|
|
84
105
|
- lib/rails_connector/blob_oracle.rb
|
85
106
|
- lib/rails_connector/cache_middleware.rb
|
86
107
|
- lib/rails_connector/cms_base_model.rb
|
108
|
+
- lib/rails_connector/configuration.rb
|
87
109
|
- lib/rails_connector/date_attribute.rb
|
88
110
|
- lib/rails_connector/default_search_request.rb
|
89
111
|
- lib/rails_connector/errors.rb
|
@@ -112,7 +134,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
112
134
|
version: '0'
|
113
135
|
segments:
|
114
136
|
- 0
|
115
|
-
hash: -
|
137
|
+
hash: -246534353
|
116
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
139
|
none: false
|
118
140
|
requirements:
|