mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-28 16:26:22 +00:00
1c96e0b0ff
cada metadato tiene su plantilla de solo lectura para generar una tabla de metadatos dinámica :D
52 lines
995 B
Ruby
52 lines
995 B
Ruby
# frozen_string_literal: true
|
|
|
|
# Forma de ingreso a Sutty
|
|
class ApplicationController < ActionController::Base
|
|
include ExceptionHandler
|
|
|
|
protect_from_forgery with: :exception
|
|
|
|
before_action :configure_permitted_parameters, if: :devise_controller?
|
|
before_action :set_locale
|
|
|
|
layout :layout_by_usuarie
|
|
|
|
# No tenemos índice de sutty, vamos directamente a ver el listado de
|
|
# sitios
|
|
def index
|
|
redirect_to sites_path
|
|
end
|
|
|
|
def markdown; end
|
|
|
|
private
|
|
|
|
def layout_by_usuarie
|
|
if current_usuarie
|
|
'application'
|
|
else
|
|
'devise'
|
|
end
|
|
end
|
|
|
|
# Encontrar un sitio por su nombre
|
|
def find_site
|
|
id = params[:site_id] || params[:id]
|
|
|
|
unless (site = current_usuarie.sites.find_by_name(id))
|
|
raise SiteNotFound
|
|
end
|
|
|
|
site
|
|
end
|
|
|
|
def set_locale
|
|
I18n.locale = current_usuarie.lang if current_usuarie
|
|
end
|
|
|
|
protected
|
|
|
|
def configure_permitted_parameters
|
|
devise_parameter_sanitizer.permit(:account_update, keys: %i[lang])
|
|
end
|
|
end
|