Aggiunge i18n IT/EN/FR/DE/ES, pagine pubbliche squadre e UX archivio.
Il selettore lingua funziona sul web e sulle app native; su Android la preferenza è persistita e applicata al riavvio. Incluse anche eliminazione replay a scope e campi pagina pubblica squadra. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
module Public
|
||||
class LocalesController < SiteBaseController
|
||||
def update
|
||||
locale = LocaleResolver.persist!(cookies, params[:locale])
|
||||
I18n.locale = locale
|
||||
redirect_back fallback_location: root_path
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,14 +5,30 @@ module Public
|
||||
include ::SeoHelper
|
||||
include ::LegalHelper
|
||||
helper ApplicationHelper
|
||||
helper_method :current_user, :logged_in?
|
||||
helper_method :current_user, :logged_in?, :current_locale, :language_options, :current_language_option
|
||||
|
||||
protect_from_forgery with: :exception
|
||||
before_action :set_site_locale
|
||||
|
||||
private
|
||||
|
||||
def set_site_locale
|
||||
I18n.locale = :it
|
||||
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
|
||||
|
||||
@@ -9,11 +9,20 @@ module Public
|
||||
{ loc: "#{base}/pallavolo-giovanile", changefreq: "monthly", priority: "0.85" },
|
||||
{ loc: "#{base}/faq", changefreq: "monthly", priority: "0.8" },
|
||||
{ loc: "#{base}/live", changefreq: "hourly", priority: "0.85" },
|
||||
{ loc: "#{base}/squadre", changefreq: "daily", priority: "0.85" },
|
||||
{ loc: "#{base}/privacy", changefreq: "yearly", priority: "0.3" },
|
||||
{ loc: "#{base}/cookie", changefreq: "yearly", priority: "0.3" },
|
||||
{ loc: "#{base}/termini", changefreq: "yearly", priority: "0.3" }
|
||||
]
|
||||
|
||||
Team.find_each do |team|
|
||||
@entries << {
|
||||
loc: "#{base}/squadre/#{team.slug}",
|
||||
changefreq: "daily",
|
||||
priority: "0.7"
|
||||
}
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.xml { render layout: false }
|
||||
end
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
module Public
|
||||
class TeamPagesController < SiteBaseController
|
||||
include Public::LiveHelper
|
||||
|
||||
layout "marketing_live"
|
||||
|
||||
def index
|
||||
@query = params[:q].to_s.strip
|
||||
@sport = params[:sport].to_s.strip.presence
|
||||
@live_filter = params[:live].present?
|
||||
@replays_filter = params[:replays].present?
|
||||
@entries = Teams::PublicDirectory.call(
|
||||
q: @query,
|
||||
sport: @sport,
|
||||
live: @live_filter,
|
||||
replays: @replays_filter
|
||||
)
|
||||
@sport_options = Sports::Catalog.as_api_list
|
||||
end
|
||||
|
||||
def show
|
||||
@team = Team.includes(:club, roster_members: []).find_by!(slug: params[:slug])
|
||||
@club = @team.club
|
||||
load_live_content!
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_live_content!
|
||||
@online_paths = fetch_online_paths
|
||||
|
||||
@live_sessions = StreamSession
|
||||
.broadcasting
|
||||
.publicly_listed
|
||||
.where(platform: "matchlivetv")
|
||||
.includes(:score_state, match: { team: :club })
|
||||
.joins(:match)
|
||||
.where(matches: { team_id: @team.id })
|
||||
.order(Arel.sql("started_at DESC NULLS LAST"), created_at: :desc)
|
||||
|
||||
broadcasting_match_ids = StreamSession.broadcasting.select(:match_id)
|
||||
@upcoming_matches = @team.matches
|
||||
.scheduled_for_live
|
||||
.where.not(id: broadcasting_match_ids)
|
||||
.order(scheduled_at: :asc)
|
||||
.limit(20)
|
||||
|
||||
@recordings = @team.recordings
|
||||
.ready
|
||||
.publicly_listed
|
||||
.includes(stream_session: :match)
|
||||
.order(recorded_at: :desc, created_at: :desc)
|
||||
.limit(12)
|
||||
|
||||
@roster_by_category = @team.roster_public? ? @team.roster_by_category : nil
|
||||
end
|
||||
|
||||
def fetch_online_paths
|
||||
Mediamtx::Client.new.online_path_names
|
||||
rescue Mediamtx::Client::Error, Errno::ECONNREFUSED, SocketError
|
||||
[]
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -165,7 +165,7 @@ module Public
|
||||
end
|
||||
|
||||
def team_params
|
||||
p = params.require(:team).permit(:name, :sport, :sport_key, :description, :logo_url, :primary_color, :secondary_color)
|
||||
p = params.require(:team).permit(:name, :sport, :sport_key, :description, :logo_url, :primary_color, :secondary_color, :slug, :roster_public)
|
||||
if p[:sport].present? && p[:sport_key].blank?
|
||||
p[:sport_key] = p.delete(:sport)
|
||||
elsif p[:sport_key].present?
|
||||
|
||||
Reference in New Issue
Block a user