Include admin/API/banner nativi, form contatti e reset copertina standard con layout edit più ampio. Co-authored-by: Cursor <cursoragent@cursor.com>
68 lines
1.6 KiB
Ruby
68 lines
1.6 KiB
Ruby
module Public
|
|
class SiteBaseController < ActionController::Base
|
|
layout "marketing"
|
|
|
|
include ::SeoHelper
|
|
include ::LegalHelper
|
|
helper ApplicationHelper
|
|
helper_method :current_user, :logged_in?, :current_locale, :language_options, :current_language_option
|
|
|
|
protect_from_forgery with: :exception
|
|
before_action :set_site_locale
|
|
before_action :load_site_announcements
|
|
|
|
private
|
|
|
|
def set_site_locale
|
|
I18n.locale = LocaleResolver.resolve(
|
|
cookie_jar: request.cookie_jar,
|
|
accept_language: request.get_header("HTTP_ACCEPT_LANGUAGE")
|
|
)
|
|
end
|
|
|
|
def current_locale
|
|
I18n.locale
|
|
end
|
|
|
|
def language_options
|
|
LocaleResolver.language_options
|
|
end
|
|
|
|
def current_language_option
|
|
LocaleResolver.current_language_option
|
|
end
|
|
|
|
def current_user
|
|
return @current_user if defined?(@current_user)
|
|
|
|
@current_user = User.find_by(id: session[:user_id]) if session[:user_id]
|
|
end
|
|
|
|
def logged_in?
|
|
current_user.present?
|
|
end
|
|
|
|
PRIVATE_WEB_CONTROLLERS = %w[
|
|
accounts clubs teams club_recordings club_billing
|
|
club_matches matches team_roster_members
|
|
].freeze
|
|
|
|
def load_site_announcements
|
|
@site_announcements = if skip_site_announcements?
|
|
AppAnnouncement.none
|
|
else
|
|
channel = private_web_area? ? :web_private : :web_public
|
|
AppAnnouncement.for_channel(channel).newest
|
|
end
|
|
end
|
|
|
|
def skip_site_announcements?
|
|
controller_name == "regia"
|
|
end
|
|
|
|
def private_web_area?
|
|
PRIVATE_WEB_CONTROLLERS.include?(controller_name)
|
|
end
|
|
end
|
|
end
|