infopark_rails_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 +9 -20
- data/app/controllers/cms_controller.rb +3 -2
- data/app/controllers/comments_controller.rb +2 -2
- data/app/controllers/crm_form_controller.rb +5 -0
- data/app/controllers/pdf_controller.rb +1 -0
- data/app/controllers/rails_connector/default_cms_controller.rb +8 -4
- data/app/controllers/rails_connector/default_comments_controller.rb +1 -2
- data/app/controllers/rails_connector/default_crm_form_controller.rb +13 -0
- data/app/controllers/rails_connector/default_pdf_controller.rb +2 -0
- data/app/controllers/rails_connector/default_rss_controller.rb +4 -1
- data/app/controllers/rails_connector/default_search_controller.rb +2 -0
- data/app/controllers/rails_connector/default_user_controller.rb +10 -0
- data/app/controllers/rails_connector/pdf_external_controller.rb +2 -1
- data/app/controllers/rails_connector/time_machine_controller.rb +1 -1
- data/app/controllers/rss_controller.rb +1 -0
- data/app/controllers/search_controller.rb +5 -0
- data/app/controllers/seo_sitemap_controller.rb +2 -0
- data/app/controllers/user_controller.rb +5 -0
- data/app/helpers/cms_helper.rb +2 -1
- data/app/helpers/cms_routing_helper.rb +2 -1
- data/app/helpers/crm_form_helper.rb +4 -0
- data/app/helpers/rails_connector/cms_asset_helper.rb +3 -0
- data/app/helpers/rails_connector/default_cms_helper.rb +1 -1
- data/app/helpers/rails_connector/default_cms_routing_helper.rb +10 -5
- data/app/helpers/rails_connector/default_crm_form_helper.rb +4 -0
- data/app/helpers/rails_connector/default_user_helper.rb +7 -1
- data/app/helpers/rails_connector/display_helper.rb +7 -5
- data/app/helpers/rails_connector/layout_helper.rb +3 -0
- data/app/helpers/rails_connector/link_helper.rb +3 -0
- data/app/helpers/rails_connector/mandatory_label_helper.rb +1 -1
- data/app/helpers/rails_connector/menu_helper.rb +2 -1
- data/app/helpers/rails_connector/micronav_helper.rb +2 -0
- data/app/helpers/rails_connector/seo_helper.rb +2 -0
- data/app/helpers/rails_connector/table_of_contents_helper.rb +2 -0
- data/app/helpers/rails_connector/time_machine_helper.rb +2 -0
- data/app/helpers/rails_connector/tracking_helper.rb +2 -0
- data/app/helpers/ratings_helper.rb +1 -1
- data/app/helpers/user_helper.rb +4 -0
- data/app/mailers/confirmation_mailer.rb +5 -0
- data/app/models/crm_form.rb +1 -0
- data/app/models/rails_connector/default_comment.rb +1 -1
- data/app/models/rails_connector/link_list.rb +3 -1
- data/lib/generators/rails_connector/comments/comments_generator.rb +0 -1
- data/lib/generators/rails_connector/comments/templates/migration.rb +0 -1
- data/lib/generators/rails_connector/install/install_generator.rb +0 -1
- data/lib/generators/rails_connector/install/templates/obj_extensions.rb +2 -1
- data/lib/generators/rails_connector/ratings/ratings_generator.rb +0 -1
- data/lib/generators/rails_connector/ratings/templates/migration.rb +0 -1
- data/lib/infopark_rails_connector.rb +4 -2
- data/lib/rails_connector/authenticable.rb +2 -2
- data/lib/rails_connector/cms_accessible.rb +14 -10
- data/lib/rails_connector/cms_dispatch_controller.rb +0 -1
- data/lib/rails_connector/cms_env.rb +0 -1
- data/lib/rails_connector/cms_test_request.rb +1 -1
- data/lib/rails_connector/commentable.rb +2 -2
- data/lib/rails_connector/configuration/google_analytics.rb +7 -4
- data/lib/rails_connector/configuration/pdf_generator.rb +3 -0
- data/lib/rails_connector/configuration/rss.rb +8 -2
- data/lib/rails_connector/configuration.rb +56 -27
- data/lib/rails_connector/core_extensions/time.rb +1 -1
- data/lib/rails_connector/crm.rb +54 -46
- data/lib/rails_connector/engine.rb +1 -1
- data/lib/rails_connector/fop.rb +2 -2
- data/lib/rails_connector/fop_on_rails/document/dom_tree.rb +1 -1
- data/lib/rails_connector/fop_on_rails/document/images.rb +1 -1
- data/lib/rails_connector/fop_on_rails/document/tables.rb +1 -1
- data/lib/rails_connector/fop_on_rails/document.rb +1 -1
- data/lib/rails_connector/fop_on_rails.rb +2 -2
- data/lib/rails_connector/googlebot_checker.rb +0 -1
- data/lib/rails_connector/html_string.rb +2 -2
- data/lib/rails_connector/link_resolvable.rb +1 -1
- data/lib/rails_connector/liquid_support/field_value_drop.rb +1 -1
- data/lib/rails_connector/liquid_support/link_drop.rb +1 -1
- data/lib/rails_connector/liquid_support/liquid_template_handler.rb +6 -6
- data/lib/rails_connector/liquid_support/named_object_drop.rb +1 -1
- data/lib/rails_connector/liquid_support/obj_drop.rb +1 -1
- data/lib/rails_connector/liquid_support/obj_filters.rb +1 -1
- data/lib/rails_connector/liquid_support.rb +4 -2
- data/lib/rails_connector/markdown_string.rb +2 -2
- data/lib/rails_connector/rateable.rb +1 -1
- data/lib/rails_connector/seo.rb +15 -7
- data/lib/rails_connector/ses.rb +13 -5
- data/lib/rails_connector/string_tagging.rb +1 -1
- data/lib/rails_connector/syndicateable.rb +3 -1
- data/lib/search_request.rb +1 -0
- metadata +15 -66
@@ -5,19 +5,23 @@ require "rails_connector/blob"
|
|
5
5
|
|
6
6
|
module RailsConnector
|
7
7
|
|
8
|
-
# RailsConnector::Configuration is used to en/disable and initialize addons.
|
8
|
+
# {RailsConnector::Configuration} is used to en/disable and initialize addons.
|
9
|
+
# @api public
|
9
10
|
class Configuration
|
11
|
+
# @api public
|
10
12
|
DEFAULT_MODE = :live
|
11
13
|
|
12
14
|
#
|
13
|
-
# Default fields which the
|
15
|
+
# Default fields which the {DefaultUserController} will store in the session.
|
14
16
|
#
|
17
|
+
# @api public
|
15
18
|
DEFAULT_STORE_USER_ATTRS_IN_SESSION = [:login, :first_name, :last_name, :email, :id]
|
16
19
|
|
17
20
|
@features = {}
|
18
21
|
|
19
22
|
class << self
|
20
23
|
# Automatically generate editmarkers when rendering liquid templates in editor mode.
|
24
|
+
# @api public
|
21
25
|
attr_accessor :auto_liquid_editmarkers
|
22
26
|
|
23
27
|
# there are three available modes for the rails connector:
|
@@ -25,77 +29,98 @@ module RailsConnector
|
|
25
29
|
# <tt>preview</tt> (show edited contents)
|
26
30
|
# <tt>editor</tt> (show edited contents and editor interface (e.g. edit markers))
|
27
31
|
# Default mode is <tt>live</tt>.
|
32
|
+
# @api public
|
28
33
|
attr_accessor :mode
|
29
34
|
|
30
|
-
# default options for SearchRequest
|
35
|
+
# default options for {SearchRequest}
|
36
|
+
# @api public
|
31
37
|
attr_writer :search_options
|
32
38
|
|
33
39
|
# default options for CMS API
|
40
|
+
# @api public
|
34
41
|
attr_writer :cms_api_options
|
35
42
|
|
36
43
|
# Cache also editable workspaces.
|
37
44
|
# Editable workspaces will be cached until the cache is cleared manually.
|
38
45
|
# Should never be used in a production environment.
|
46
|
+
# @api public
|
39
47
|
attr_accessor :cache_editable_workspaces
|
40
48
|
|
41
49
|
# Include ReCaptcha tags in user registration form and validate the captcha
|
42
50
|
# when creating a new user registration (default: true).
|
51
|
+
# @api public
|
43
52
|
attr_accessor :use_recaptcha_on_user_registration
|
44
53
|
|
45
54
|
# define a non-default blob cache dir.
|
46
|
-
#
|
55
|
+
# +fiona connector+ only. has no effect when used with the +cloud connector+.
|
56
|
+
# @api public
|
47
57
|
attr_accessor :blob_cache_dir
|
48
58
|
|
49
59
|
# Configuration for Content Read Service API.
|
60
|
+
# @api public
|
50
61
|
attr_reader :content_service
|
51
62
|
|
63
|
+
# default options for {SearchRequest}
|
64
|
+
# @api public
|
52
65
|
def search_options
|
53
66
|
@search_options || local_config_file["search"].symbolize_keys
|
54
67
|
end
|
55
68
|
|
69
|
+
# default options for CMS API
|
70
|
+
# @api public
|
56
71
|
def cms_api_options
|
57
72
|
@cms_api_options || local_config_file["cms_api"].symbolize_keys
|
58
73
|
end
|
59
74
|
|
60
|
-
|
75
|
+
# @api public
|
76
|
+
def mode=(new_mode)
|
61
77
|
new_mode = new_mode.to_sym
|
62
78
|
raise ArgumentError, "Unknown Mode #{new_mode}" unless [:editor, :preview, :live].include?(new_mode)
|
63
79
|
@mode = new_mode
|
64
80
|
end
|
65
81
|
|
66
|
-
|
82
|
+
# there are three available modes for the rails connector:
|
83
|
+
# <tt>live</tt> (show released contents only),
|
84
|
+
# <tt>preview</tt> (show edited contents)
|
85
|
+
# <tt>editor</tt> (show edited contents and editor interface (e.g. edit markers))
|
86
|
+
# Default mode is <tt>live</tt>.
|
87
|
+
# @api public
|
88
|
+
def mode
|
67
89
|
@mode || DEFAULT_MODE
|
68
90
|
end
|
69
91
|
|
70
92
|
#
|
71
93
|
# Sets the array of fields which the +DefaultUserController+ will store in the session.
|
72
|
-
# Defaults to
|
94
|
+
# Defaults to {DEFAULT_STORE_USER_ATTRS_IN_SESSION}.
|
73
95
|
#
|
96
|
+
# @api public
|
74
97
|
attr_writer :store_user_attrs_in_session
|
75
98
|
|
76
99
|
#
|
77
|
-
# Returns fields which the
|
100
|
+
# Returns fields which the {DefaultUserController} stores in the session.
|
101
|
+
# Defaults to {DEFAULT_STORE_USER_ATTRS_IN_SESSION}.
|
78
102
|
#
|
103
|
+
# @api public
|
79
104
|
def store_user_attrs_in_session
|
80
105
|
@store_user_attrs_in_session || DEFAULT_STORE_USER_ATTRS_IN_SESSION
|
81
106
|
end
|
82
107
|
|
83
|
-
def editor_interface_enabled?
|
108
|
+
def editor_interface_enabled?
|
84
109
|
mode == :editor
|
85
110
|
end
|
86
111
|
|
87
|
-
def use_edited_content?
|
112
|
+
def use_edited_content?
|
88
113
|
mode == :preview || mode == :editor
|
89
114
|
end
|
90
115
|
|
91
|
-
def register_features(*features)
|
116
|
+
def register_features(*features)
|
92
117
|
features.each do |f|
|
93
118
|
@features.merge!(f.to_sym => false)
|
94
119
|
end
|
95
120
|
end
|
96
121
|
alias :register_feature :register_features
|
97
122
|
|
98
|
-
def registered_features
|
123
|
+
def registered_features
|
99
124
|
@features.keys
|
100
125
|
end
|
101
126
|
|
@@ -108,6 +133,7 @@ module RailsConnector
|
|
108
133
|
# :crm
|
109
134
|
# )
|
110
135
|
#
|
136
|
+
# @api public
|
111
137
|
def enable(*features)
|
112
138
|
features.each do |f|
|
113
139
|
assert_feature_is_known(f)
|
@@ -126,11 +152,12 @@ module RailsConnector
|
|
126
152
|
#
|
127
153
|
# Example call as to be used in <tt>rails_connector.rb</tt>:
|
128
154
|
# RailsConnector::Configuration.instance_name = 'internet'
|
155
|
+
# @api public
|
129
156
|
def instance_name=(name)
|
130
157
|
RailsConnector::CmsBaseModel.instance_name = name
|
131
158
|
end
|
132
159
|
|
133
|
-
def after_initialize
|
160
|
+
def after_initialize
|
134
161
|
enable_authentication
|
135
162
|
# Hier muss explizit der Namespace verwendet werden, da diese Methode von Rails
|
136
163
|
# während der Initialisierung aufgerufen wird.
|
@@ -139,7 +166,7 @@ module RailsConnector
|
|
139
166
|
)
|
140
167
|
end
|
141
168
|
|
142
|
-
def to_prepare
|
169
|
+
def to_prepare
|
143
170
|
unless Rails.configuration.cache_classes
|
144
171
|
after_initialize
|
145
172
|
NamedLink.reset_cache
|
@@ -152,6 +179,7 @@ module RailsConnector
|
|
152
179
|
CmsBaseModel.configure_database("cms")
|
153
180
|
elsif local_config_file.configured? 'content_service'
|
154
181
|
@content_service = local_config_file['content_service']
|
182
|
+
Blob.configure(:type => 'service')
|
155
183
|
else
|
156
184
|
CmsBaseModel.configure_database(local_config_file["cms_database"])
|
157
185
|
blob_storage_config = local_config_file["cms_blob_storage"]
|
@@ -168,41 +196,42 @@ module RailsConnector
|
|
168
196
|
end
|
169
197
|
end
|
170
198
|
|
171
|
-
attr_accessor :choose_homepage_callback
|
199
|
+
attr_accessor :choose_homepage_callback
|
172
200
|
|
173
201
|
# Configure a callback to be invoked when the rails connector delivers the homepage.
|
174
202
|
# The given callback will receive the rack env
|
175
203
|
# and must return an Obj to be used as the homepage.
|
176
204
|
# If no callback is configured, Obj.homepage will be used as the default.
|
205
|
+
# @api public
|
177
206
|
def choose_homepage(&block)
|
178
207
|
self.choose_homepage_callback = block
|
179
208
|
end
|
180
209
|
|
181
|
-
def license
|
210
|
+
def license
|
182
211
|
license_file.read
|
183
212
|
end
|
184
213
|
|
185
|
-
def license_file
|
214
|
+
def license_file
|
186
215
|
@license_file.presence || Rails.root + "config" + "license.xml"
|
187
216
|
end
|
188
217
|
|
189
|
-
def license_file=(license_file)
|
218
|
+
def license_file=(license_file)
|
190
219
|
@license_file = license_file.presence && Pathname(license_file)
|
191
220
|
end
|
192
221
|
|
193
|
-
def cms_routes(*args)
|
222
|
+
def cms_routes(*args)
|
194
223
|
raise <<-EOS.gsub(/\s+/, ' ')
|
195
224
|
Calling RailsConnector::Configuration.cms_routes is not needed anymore.
|
196
225
|
Please remove it from config/routes.rb
|
197
226
|
EOS
|
198
227
|
end
|
199
228
|
|
200
|
-
def use_x_sendfile=(value)
|
229
|
+
def use_x_sendfile=(value)
|
201
230
|
raise 'Configuration.use_x_sendfile is now available as Rails configuration:'\
|
202
231
|
' config.action_dispatch.x_sendfile_header = "X-Sendfile"'
|
203
232
|
end
|
204
233
|
|
205
|
-
def initialize_addon_mixins
|
234
|
+
def initialize_addon_mixins
|
206
235
|
::ApplicationController.__send__(:helper, :cms)
|
207
236
|
if enabled?(:search)
|
208
237
|
require "rails_connector/ses"
|
@@ -214,16 +243,16 @@ module RailsConnector
|
|
214
243
|
::Obj.__send__(:include, RailsConnector::Rateable) if enabled?(:ratings)
|
215
244
|
end
|
216
245
|
|
217
|
-
def local_config_file
|
246
|
+
def local_config_file
|
218
247
|
@local_config_file ||= read_local_config_file
|
219
248
|
end
|
220
249
|
|
221
|
-
def local_config_file_name
|
250
|
+
def local_config_file_name
|
222
251
|
(Rails.root + "config/rails_connector.yml").expand_path
|
223
252
|
end
|
224
253
|
|
225
254
|
# for test purposes only
|
226
|
-
def reset_local_config_file_cache
|
255
|
+
def reset_local_config_file_cache
|
227
256
|
@local_config_file = nil
|
228
257
|
end
|
229
258
|
|
@@ -261,11 +290,11 @@ module RailsConnector
|
|
261
290
|
config
|
262
291
|
end
|
263
292
|
|
264
|
-
def assert_feature_is_known(f)
|
293
|
+
def assert_feature_is_known(f)
|
265
294
|
raise ArgumentError, "unknown feature: #{f.inspect}" unless @features.keys.include?(f.to_sym)
|
266
295
|
end
|
267
296
|
|
268
|
-
def enable_authentication
|
297
|
+
def enable_authentication
|
269
298
|
# Wenn das OMC-Features an ist, dann braucht man keine Standardimplementierung
|
270
299
|
# für die Authentifizierung.
|
271
300
|
unless enabled?(:crm)
|
@@ -285,6 +314,6 @@ module RailsConnector
|
|
285
314
|
)
|
286
315
|
end
|
287
316
|
|
288
|
-
class ConfigurationError < StandardError
|
317
|
+
class ConfigurationError < StandardError
|
289
318
|
end
|
290
319
|
end
|
data/lib/rails_connector/crm.rb
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
module RailsConnector
|
2
2
|
|
3
|
-
# This module provides high-level access to the Infopark
|
3
|
+
# This module provides high-level access to the Infopark WebCRM.
|
4
4
|
#
|
5
|
-
# Methods from the
|
5
|
+
# Methods from the {AuthenticationSupport} module are included
|
6
6
|
# in all controllers when enabling the Crm feature in your RailsConnector configuration:
|
7
7
|
#
|
8
8
|
# RailsConnector::Configuration.enable(
|
9
9
|
# :crm
|
10
10
|
# )
|
11
|
+
# @api public
|
11
12
|
module Crm
|
12
13
|
|
13
|
-
# This method requires the
|
14
|
+
# This method requires the infopark_crm_connector gem.
|
14
15
|
#
|
15
16
|
# If the gem is available, it does the following:
|
16
17
|
# * require it
|
@@ -19,32 +20,31 @@ module RailsConnector
|
|
19
20
|
# * adds a class-inheritable array to +ApplicationController+ for convenience
|
20
21
|
# (see +session_attributes_for+)
|
21
22
|
#
|
22
|
-
# If not, it raises a
|
23
|
-
def self.enable
|
23
|
+
# If not, it raises a {LoadError}.
|
24
|
+
def self.enable
|
24
25
|
require 'infopark_crm_connector'
|
25
26
|
ApplicationController.__send__(:include, AuthenticationSupport)
|
26
27
|
end
|
27
28
|
|
29
|
+
# @api public
|
28
30
|
module AuthenticationSupport
|
29
31
|
|
30
32
|
protected
|
31
33
|
|
32
|
-
def self.included(base)
|
34
|
+
def self.included(base)
|
33
35
|
base.helper_method :logged_in?, :current_user, :admin?
|
34
36
|
end
|
35
37
|
|
36
|
-
#
|
37
38
|
# Returns a hash of attributes for the given user that are to be stored in the session.
|
38
39
|
#
|
39
|
-
# Uses the array
|
40
|
+
# Uses the array {RailsConnector::Configuration.store_user_attrs_in_session} to determine which
|
40
41
|
# fields to store.
|
41
42
|
# Because the field <tt>:id</tt> must always be stored in the session, it is always in the array
|
42
|
-
# returned by
|
43
|
-
#
|
43
|
+
# returned by {session_attributes_for}, independent on the fields specified by
|
44
|
+
# {RailsConnector::Configuration.store_user_attrs_in_session}.
|
44
45
|
#
|
45
46
|
# User live_server_groups are stored in the session by default.
|
46
|
-
|
47
|
-
def session_attributes_for(user) # :nodoc:
|
47
|
+
def session_attributes_for(user)
|
48
48
|
attributes = {}
|
49
49
|
serialized_attributes = \
|
50
50
|
user.attributes.merge(:live_server_groups => user.live_server_groups).symbolize_keys
|
@@ -57,16 +57,18 @@ module RailsConnector
|
|
57
57
|
|
58
58
|
# Determines if the user is logged in.
|
59
59
|
# Defined as helper method in +ApplicationController+ when enabling the Crm feature.
|
60
|
+
# @return bool
|
61
|
+
# @api public
|
60
62
|
def logged_in?
|
61
63
|
!session[:user].blank?
|
62
64
|
end
|
63
65
|
|
64
|
-
#
|
65
66
|
# Returns a +Contact+ object with attributes stored in the session.
|
66
67
|
#
|
67
|
-
# To change which fields
|
68
|
-
#
|
69
|
-
#
|
68
|
+
# To change which fields {DefaultUserController} stores in the session use
|
69
|
+
# {RailsConnector::Configuration.store_user_attrs_in_session}.
|
70
|
+
# @return [Infopark::Crm::Contact]
|
71
|
+
# @api public
|
70
72
|
def current_user
|
71
73
|
@current_user ||= if logged_in?
|
72
74
|
user_session = session[:user].dup
|
@@ -80,6 +82,9 @@ module RailsConnector
|
|
80
82
|
# Takes a +Contact+ object and stores its user attributes in the session.
|
81
83
|
#
|
82
84
|
# This can be helpful if you want to set a user for e.g. Googlebot.
|
85
|
+
# @param [Infopark::Crm::Contact] user
|
86
|
+
# @return [void]
|
87
|
+
# @api public
|
83
88
|
def current_user=(user)
|
84
89
|
@current_user = user
|
85
90
|
session[:user] = user.nil? ? nil : session_attributes_for(user)
|
@@ -87,6 +92,8 @@ module RailsConnector
|
|
87
92
|
|
88
93
|
# Reloads the +Contact+ object in +current_user+ from the WebCRM,
|
89
94
|
# and updates the user attribute cached in the session.
|
95
|
+
# @return [void]
|
96
|
+
# @api public
|
90
97
|
def reload_current_user
|
91
98
|
user = current_user
|
92
99
|
user.reload
|
@@ -94,10 +101,10 @@ module RailsConnector
|
|
94
101
|
end
|
95
102
|
|
96
103
|
# Determines if the current user is admin (+false+ by default).
|
97
|
-
# Being admin
|
104
|
+
# Being admin enables to user to delete comments and reset ratings.
|
98
105
|
# Defined as helper method in +ApplicationController+ when enabling the CRM feature.
|
99
106
|
#
|
100
|
-
# To change the default behavior
|
107
|
+
# To change the default behavior overwrite <tt>admin?</tt> in your ApplicationController:
|
101
108
|
#
|
102
109
|
# class ApplicationController < ActionController::Base
|
103
110
|
#
|
@@ -108,13 +115,14 @@ module RailsConnector
|
|
108
115
|
# end
|
109
116
|
#
|
110
117
|
# end
|
118
|
+
# @return bool
|
119
|
+
# @api public
|
111
120
|
def admin?
|
112
121
|
false
|
113
122
|
end
|
114
123
|
|
115
124
|
end
|
116
125
|
|
117
|
-
# :stopdoc:
|
118
126
|
module Localizable
|
119
127
|
# --------------------------------------------
|
120
128
|
# This module can be included in controllers
|
@@ -131,9 +139,7 @@ module RailsConnector
|
|
131
139
|
Infopark::Crm.configure {|config| config.locale = I18n.locale.to_s }
|
132
140
|
end
|
133
141
|
end
|
134
|
-
# :startdoc:
|
135
142
|
|
136
|
-
# :stopdoc:
|
137
143
|
module Sanitization
|
138
144
|
# --------------------------------------------
|
139
145
|
# This module is included in controllers to
|
@@ -159,85 +165,88 @@ module RailsConnector
|
|
159
165
|
source_hash.reject { |key, value| !allowed_keys.include?(key) }
|
160
166
|
end
|
161
167
|
end
|
162
|
-
# :startdoc:
|
163
168
|
|
164
|
-
# This module is included in
|
169
|
+
# This module is included in {DefaultUserController} to provide callbacks for user functionality.
|
165
170
|
#
|
166
171
|
# If you want to add behavior before or after authentication, logout or register, override any of
|
167
|
-
# the methods included in this module in your
|
172
|
+
# the methods included in this module in your {UserController}.
|
173
|
+
# @api public
|
168
174
|
module Callbacks
|
169
175
|
|
170
|
-
# :stopdoc:
|
171
|
-
# --------------------------------------------
|
172
|
-
# This module is documented in sections
|
173
|
-
# because RDoc orders methods alphabetically,
|
174
|
-
# which doesn't make sense here.
|
175
|
-
# --------------------------------------------
|
176
|
-
# :startdoc:
|
177
|
-
|
178
176
|
private
|
179
177
|
|
180
|
-
#
|
178
|
+
# @!group Callbacks
|
181
179
|
|
182
|
-
# Called by
|
180
|
+
# Called by {DefaultUserController} on POST requests before a user is authenticated,
|
183
181
|
# i.e. the user has already provided credentials in a form.
|
184
182
|
#
|
185
183
|
# By default, it doesn't do anything.
|
184
|
+
# @return [void]
|
185
|
+
# @api public
|
186
186
|
def before_authenticate
|
187
187
|
end
|
188
188
|
|
189
|
-
# Called by
|
189
|
+
# Called by {DefaultUserController} before a user is logged out,
|
190
190
|
# i.e. the session is reset.
|
191
191
|
#
|
192
192
|
# By default, it doesn't do anything.
|
193
|
+
# @return [void]
|
194
|
+
# @api public
|
193
195
|
def before_logout
|
194
196
|
end
|
195
197
|
|
196
|
-
# Called by
|
198
|
+
# Called by {DefaultUserController} on POST requests before a user is created,
|
197
199
|
# i.e. the user has already provided name, e-mail etc. in a form.
|
198
200
|
#
|
199
201
|
# By default, it doesn't do anything.
|
202
|
+
# @return [void]
|
203
|
+
# @api public
|
200
204
|
def before_register
|
201
205
|
end
|
202
206
|
|
203
|
-
#
|
204
|
-
|
205
|
-
# Called by +DefaultUserController+ on POST requests after a user is authenticated,
|
207
|
+
# Called by {DefaultUserController} on POST requests after a user is authenticated,
|
206
208
|
# i.e. the user has already provided correct credentials but the session has not yet been set.
|
207
209
|
#
|
208
210
|
# By default, it doesn't do anything.
|
211
|
+
# @return [void]
|
212
|
+
# @api public
|
209
213
|
def after_authenticate
|
210
214
|
end
|
211
215
|
|
212
|
-
# Called by
|
216
|
+
# Called by {DefaultUserController} after a user is logged out,
|
213
217
|
# i.e. the session is reset.
|
214
218
|
#
|
215
219
|
# By default, it doesn't do anything.
|
220
|
+
# @return [void]
|
221
|
+
# @api public
|
216
222
|
def after_logout
|
217
223
|
end
|
218
224
|
|
219
|
-
# Called by
|
225
|
+
# Called by {DefaultUserController} on POST requests after a user is created,
|
220
226
|
# i.e. a WebCRM activity has been created or the user has been created directly in the WebCRM.
|
221
227
|
#
|
222
228
|
# By default, it doesn't do anything.
|
229
|
+
# @return [void]
|
230
|
+
# @api public
|
223
231
|
def after_register
|
224
232
|
end
|
225
233
|
|
226
|
-
#
|
227
|
-
|
228
|
-
# Called by +DefaultUserController+ whenever requests to the WebCRM fail.
|
234
|
+
# Called by {DefaultUserController} whenever requests to the WebCRM fail.
|
229
235
|
# This includes <tt>Errno::ECONNREFUSED</tt> or the ActiveResource errors +ForbiddenAccess+,
|
230
236
|
# +UnauthorizedAccess+, and +BadRequest+.
|
231
237
|
#
|
232
238
|
# By default, it raises an error so that administrators are notified immediately
|
233
239
|
# if the WebCRM is down or not configured properly.
|
240
|
+
# @return [void]
|
241
|
+
# @api public
|
234
242
|
def on_crm_error(exception)
|
235
243
|
raise exception
|
236
244
|
end
|
237
245
|
|
246
|
+
# @!endgroup
|
247
|
+
|
238
248
|
end
|
239
249
|
|
240
|
-
# :stopdoc:
|
241
250
|
# Default attributes for WebCRM's Contact.
|
242
251
|
#
|
243
252
|
# Helpers like +form_for+ will fail on +ActiveResource+ attributes
|
@@ -275,7 +284,6 @@ module RailsConnector
|
|
275
284
|
:want_phonecall => 0,
|
276
285
|
:want_snailmail => 0
|
277
286
|
}.stringify_keys
|
278
|
-
# :startdoc:
|
279
287
|
|
280
288
|
end
|
281
289
|
|
@@ -7,7 +7,7 @@ require 'jquery-rails'
|
|
7
7
|
require 'rails_connector/configuration'
|
8
8
|
|
9
9
|
module ::RailsConnector
|
10
|
-
class Engine < Rails::Engine
|
10
|
+
class Engine < Rails::Engine
|
11
11
|
config.to_prepare { RailsConnector::Configuration.to_prepare }
|
12
12
|
config.after_initialize { RailsConnector::Configuration.after_initialize }
|
13
13
|
|
data/lib/rails_connector/fop.rb
CHANGED
@@ -6,9 +6,9 @@ module RailsConnector
|
|
6
6
|
#
|
7
7
|
class GenerationFailed < RuntimeError; end
|
8
8
|
|
9
|
-
CMD = 'fop -xml "%s" -xsl "%s" -pdf "%s" 2>&1'
|
9
|
+
CMD = 'fop -xml "%s" -xsl "%s" -pdf "%s" 2>&1'
|
10
10
|
|
11
|
-
def self.generate_pdf(xml, xsl, pdf)
|
11
|
+
def self.generate_pdf(xml, xsl, pdf)
|
12
12
|
output = `#{CMD % [xml, xsl, pdf]}`
|
13
13
|
unless `file -pb "#{pdf}"`.include?('PDF')
|
14
14
|
raise GenerationFailed, output
|
@@ -19,12 +19,12 @@ module RailsConnector
|
|
19
19
|
# the PDF is generated.
|
20
20
|
#
|
21
21
|
# If the download of <code>xml_location</code> or <code>xsl_location</code> fails, then
|
22
|
-
# the
|
22
|
+
# the {RailsConnector::FopOnRails::DownloadError} is raised.
|
23
23
|
#
|
24
24
|
# To generate a PDF, the given XML <b>must</b> be valid. If for some reasons it is not, then you can use the
|
25
25
|
# <code>tidy</code> option to repair it.
|
26
26
|
#
|
27
|
-
# If the PDF generation fails, then the
|
27
|
+
# If the PDF generation fails, then the {RailsConnector::Fop::GenerationFailed} error
|
28
28
|
# is raised.
|
29
29
|
#
|
30
30
|
# Example:
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module RailsConnector
|
2
2
|
|
3
3
|
# Include this module in order to tag the string as one with HTML content
|
4
|
-
module HtmlString
|
4
|
+
module HtmlString
|
5
5
|
include LinkResolvable
|
6
6
|
# Returns whether the String contains HTML (default to true, overrides String.html?).
|
7
7
|
def html?
|
@@ -11,7 +11,7 @@ module RailsConnector
|
|
11
11
|
|
12
12
|
end
|
13
13
|
|
14
|
-
class String
|
14
|
+
class String
|
15
15
|
# Returns whether the String contains HTML (default to false).
|
16
16
|
def html?
|
17
17
|
false
|