Class: MetadataPresenter::EngineController
- Inherits:
-
Object
- Object
- MetadataPresenter::EngineController
show all
- Defined in:
- app/controllers/metadata_presenter/engine_controller.rb
Instance Method Summary
collapse
Instance Method Details
#allow_analytics? ⇒ Boolean
88
89
90
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 88
def allow_analytics?
cookies[analytics_cookie_name] == 'accepted'
end
|
#analytics_cookie_name ⇒ Object
83
84
85
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 83
def analytics_cookie_name
@analytics_cookie_name ||= "analytics-#{service.service_name.parameterize}"
end
|
105
106
107
108
109
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 105
def analytics_tags_present?
Rails.application.config.supported_analytics.values.flatten.any? do |analytic|
ENV[analytic].present?
end
end
|
#answered?(component_id) ⇒ Boolean
78
79
80
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 78
def answered?(component_id)
@page_answers.send(component_id).present?
end
|
#authorised_session! ⇒ Object
137
138
139
140
141
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 137
def authorised_session!
cookies.signed[:_fb_authorised] = {
value: 1, same_site: :strict, httponly: true
}
end
|
#back_link ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 57
def back_link
if use_external_start_page? && first_page?
return external_start_page_url
end
previous_page = PreviousPage.new(
service:,
user_data: load_user_data,
current_page: @page,
referrer: request.referrer
).page
if previous_page
@back_link ||= File.join(
request.script_name,
previous_page.url
)
end
end
|
#external_or_relative_link(link) ⇒ Object
143
144
145
146
147
148
149
150
151
152
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 143
def external_or_relative_link(link)
uri = URI.parse(link)
return link if uri.scheme.present? && uri.host.present?
if editor_preview?
File.join(request.script_name, link)
else
link.starts_with?('/') ? link : link.prepend('/')
end
end
|
#get_saved_progress(uuid) ⇒ Object
33
34
35
36
37
38
39
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 33
def get_saved_progress(uuid)
if defined? super
super(uuid)
end
end
|
#increment_record_counter(uuid) ⇒ Object
41
42
43
44
45
46
47
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 41
def increment_record_counter(uuid)
if defined? super
super(uuid)
end
end
|
#invalidate_record(uuid) ⇒ Object
49
50
51
52
53
54
55
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 49
def invalidate_record(uuid)
if defined? super
super(uuid)
end
end
|
#load_autocomplete_items ⇒ Object
112
113
114
115
116
117
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 112
def load_autocomplete_items
if @page.autocomplete_component_present?
items = autocomplete_items(@page.components)
@page.assign_autocomplete_items(items)
end
end
|
#load_page_content ⇒ Object
119
120
121
122
123
124
125
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 119
def load_page_content
if single_page_preview?
@page.load_all_content
else
@page.load_conditional_content(service, @user_data)
end
end
|
#maintenance_mode? ⇒ Boolean
127
128
129
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 127
def maintenance_mode?
ENV['MAINTENANCE_MODE'].present? && ENV['MAINTENANCE_MODE'] == '1'
end
|
#reload_user_data ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 15
def reload_user_data
if defined? super
super
else
load_user_data
end
end
|
#require_basic_auth ⇒ Object
11
12
13
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 11
def require_basic_auth
redirect_to auth_path unless session_authorised?
end
|
25
26
27
28
29
30
31
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 25
def save_form_progress
if defined? super
super
end
end
|
#session_authorised? ⇒ Boolean
131
132
133
134
135
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 131
def session_authorised?
return true if ENV['BASIC_AUTH_USER'].blank? || ENV['BASIC_AUTH_PASS'].blank?
!!cookies.signed[:_fb_authorised]
end
|
#show_cookie_confirmation? ⇒ Boolean
98
99
100
101
102
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 98
def show_cookie_confirmation?
unless no_analytics_cookie?
(Rails.application.config.respond_to?(:global_ga4) || analytics_tags_present?) && params[:analytics].present?
end
end
|
#show_cookie_request? ⇒ Boolean
93
94
95
|
# File 'app/controllers/metadata_presenter/engine_controller.rb', line 93
def show_cookie_request?
(Rails.application.config.respond_to?(:global_ga4) || analytics_tags_present?) && no_analytics_cookie?
end
|