5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-10-11 14:16:55 +00:00

Merge branch 'issue-15109-1' of https://0xacab.org/sutty/sutty into production.panel.sutty.nl

This commit is contained in:
Sutty 2024-03-14 14:46:20 +00:00
commit 3b0e8c9cb9
4 changed files with 21 additions and 17 deletions

View file

@ -12,10 +12,6 @@ class ApplicationController < ActionController::Base
before_action :notify_unconfirmed_email, unless: :devise_controller? before_action :notify_unconfirmed_email, unless: :devise_controller?
around_action :set_locale around_action :set_locale
rescue_from Pundit::NilPolicyError, with: :page_not_found
rescue_from ActionController::RoutingError, with: :page_not_found
rescue_from ActionController::ParameterMissing, with: :page_not_found
before_action do before_action do
Rack::MiniProfiler.authorize_request if current_usuarie&.email&.ends_with?('@' + ENV.fetch('SUTTY', 'sutty.nl')) Rack::MiniProfiler.authorize_request if current_usuarie&.email&.ends_with?('@' + ENV.fetch('SUTTY', 'sutty.nl'))
end end
@ -75,18 +71,6 @@ class ApplicationController < ActionController::Base
I18n.with_locale(current_locale, &action) I18n.with_locale(current_locale, &action)
end end
# Muestra una página 404
#
# @see {https://github.com/rails/rails/issues/25106}
def page_not_found
self.response_body = nil
@_response_body = nil
headers.delete('Location')
render 'application/page_not_found', status: :not_found
end
# Necesario para poder acceder a Blazer. Solo les usuaries de este # Necesario para poder acceder a Blazer. Solo les usuaries de este
# sitio pueden acceder al panel. # sitio pueden acceder al panel.
def require_usuarie def require_usuarie

View file

@ -12,13 +12,31 @@ module ExceptionHandler
rescue_from PageNotFound, with: :page_not_found rescue_from PageNotFound, with: :page_not_found
rescue_from ActionController::RoutingError, with: :page_not_found rescue_from ActionController::RoutingError, with: :page_not_found
rescue_from Pundit::NilPolicyError, with: :page_not_found rescue_from Pundit::NilPolicyError, with: :page_not_found
rescue_from Pundit::NilPolicyError, with: :page_not_found
rescue_from ActionController::RoutingError, with: :page_not_found
rescue_from ActionController::ParameterMissing, with: :page_not_found
end end
def site_not_found def site_not_found
reset_response!
flash[:error] = I18n.t('errors.site_not_found')
redirect_to sites_path redirect_to sites_path
end end
def page_not_found def page_not_found
send_file Rails.root.join('public', '404.html') reset_response!
render 'application/page_not_found', status: :not_found
end
private
def reset_response!
self.response_body = nil
@_response_body = nil
headers.delete('Location')
end end
end end

View file

@ -386,6 +386,7 @@ en:
lang: lang:
not_available: "This language is not yet available, would you help us by translating Sutty into it?" not_available: "This language is not yet available, would you help us by translating Sutty into it?"
errors: errors:
site_not_found: "Site not found, or maybe you don't have access to it."
argument_error: 'Argument `%{argument}` must be an instance of %{class}' argument_error: 'Argument `%{argument}` must be an instance of %{class}'
unknown_locale: 'Unknown %{locale} locale' unknown_locale: 'Unknown %{locale} locale'
posts: posts:

View file

@ -385,6 +385,7 @@ es:
lang: lang:
not_available: "Este idioma todavía no está disponible, ¿nos ayudas a agregarlo y mantenerlo?" not_available: "Este idioma todavía no está disponible, ¿nos ayudas a agregarlo y mantenerlo?"
errors: errors:
site_not_found: "No encontramos ese sitio o quizás no tengas acceso."
argument_error: 'El argumento `%{argument}` debe ser una instancia de %{class}' argument_error: 'El argumento `%{argument}` debe ser una instancia de %{class}'
unknown_locale: 'El idioma %{locale} es desconocido' unknown_locale: 'El idioma %{locale} es desconocido'
posts: posts: