diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index d27b7197..b7e9338f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -5,8 +5,12 @@ 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 @@ -17,6 +21,14 @@ class ApplicationController < ActionController::Base 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] @@ -50,6 +62,12 @@ class ApplicationController < ActionController::Base end def set_locale - I18n.locale = session[:lang] if session[:lang].present? + I18n.locale = current_usuarie.lang + end + + protected + + def configure_permitted_parameters + devise_parameter_sanitizer.permit(:account_update, keys: %i[lang]) end end diff --git a/app/views/devise/registrations/edit.haml b/app/views/devise/registrations/edit.haml index d81fff97..31fcb347 100644 --- a/app/views/devise/registrations/edit.haml +++ b/app/views/devise/registrations/edit.haml @@ -1,42 +1,65 @@ +.row + .col + = render 'layouts/breadcrumb', + crumbs: [link_to(t('.index'), sites_path), t('.title')] + .row.align-items-center.justify-content-center.full-height .col-md-6.align-self-center - %h2= t('.title', resource: resource.model_name.human) - = form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| + %h2= t('.title') + = form_for(resource, + as: resource_name, + url: registration_path(resource_name), + html: { method: :put }) do |f| + = render 'devise/shared/error_messages', resource: resource + .form-group = f.label :email = f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control' - if devise_mapping.confirmable? && resource.pending_reconfirmation? - %div= t('.currently_waiting_confirmation_for_email', email: resource.unconfirmed_email) + %div + = t('.currently_waiting_confirmation_for_email', + email: resource.unconfirmed_email) + + .form-group + = f.label :lang + = f.select :lang, + I18n.available_locales.map { |lang| [t(lang), lang] }, {}, + class: 'form-control' + .form-group = f.label :password - %i - (#{t('.leave_blank_if_you_don_t_want_to_change_it')}) = f.password_field :password, autocomplete: 'new-password', - class: 'form-control' - - if @minimum_password_length - %em= t('devise.shared.minimum_password_length', count: @minimum_password_length) + class: 'form-control', 'aria-describedby': 'password-help' + %small.text-muted.form-text#password-help + = t('.leave_blank_if_you_don_t_want_to_change_it') + - if @minimum_password_length + = t('devise.shared.minimum_password_length', + count: @minimum_password_length) + .form-group = f.label :password_confirmation = f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control' + .form-group = f.label :current_password - %i - (#{t('.we_need_your_current_password_to_confirm_your_changes')}) = f.password_field :current_password, autocomplete: 'current-password', - class: 'form-control' + required: true, + class: 'form-control', + 'aria-describedby': 'current-password-help' + %small.text-muted.form-text#current-password-help + = t('.we_need_your_current_password_to_confirm_your_changes') .actions = f.submit t('.update'), class: 'btn btn-lg btn-primary btn-block' + %hr/ %h3= t('.cancel_my_account') %p - = t('.unhappy') = button_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, - method: :delete - = link_to t('devise.shared.links.back'), :back + method: :delete, class: 'btn btn-danger btn-block' diff --git a/app/views/layouts/_breadcrumb.haml b/app/views/layouts/_breadcrumb.haml index 01484ac6..322f4164 100644 --- a/app/views/layouts/_breadcrumb.haml +++ b/app/views/layouts/_breadcrumb.haml @@ -1,17 +1,20 @@ -%nav{'aria-label': 'breadcrumb', role: 'navigation'} +%nav{ 'aria-label': 'breadcrumb', role: 'navigation' } %ol.breadcrumb %li.breadcrumb-item = link_to destroy_usuarie_session_path, method: :delete, data: { toggle: 'tooltip' }, title: t('help.logout'), role: 'button', class: 'btn-text' do = fa_icon 'sign-out', title: t('help.logout') + %li.breadcrumb-item + = link_to edit_usuarie_registration_path, + data: { toggle: 'tooltip' }, title: t('help.usuarie.edit') do + = current_usuarie.email + - if @site.try(:persisted?) && (help = @site.try(:config).try(:dig, 'help')) %li.breadcrumb-item= link_to t('.help'), help, target: '_blank' + - crumbs.compact.each do |crumb| - - if current_user.is_a? Invitadx - - if /\/sites/ =~ crumb - - next - if crumb == crumbs.last - %li.breadcrumb-item.active{'aria-current': 'page'}= crumb + %li.breadcrumb-item.active{ 'aria-current': 'page' }= crumb - else %li.breadcrumb-item= crumb diff --git a/config/initializers/locale.rb b/config/initializers/locale.rb index 056f48ab..e9753dca 100644 --- a/config/initializers/locale.rb +++ b/config/initializers/locale.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true Rails.application.configure do - config.i18n.available_locales = %i[es en ar] + config.i18n.available_locales = %i[es en] config.i18n.default_locale = :es end diff --git a/config/locales/devise.views.en.yml b/config/locales/devise.views.en.yml index aa0697c2..d4c60db0 100644 --- a/config/locales/devise.views.en.yml +++ b/config/locales/devise.views.en.yml @@ -93,14 +93,14 @@ en: registrations: destroyed: Bye! Your account has been successfully cancelled. We hope to see you again soon. edit: + index: 'Back to sites' are_you_sure: Are you sure? cancel_my_account: Cancel my account currently_waiting_confirmation_for_email: 'Currently waiting confirmation for: %{email}' - leave_blank_if_you_don_t_want_to_change_it: leave blank if you don't want to change it - title: Edit %{resource} - unhappy: Unhappy? + leave_blank_if_you_don_t_want_to_change_it: Leave empty if you don't want to change it. + title: Edit my account update: Update - we_need_your_current_password_to_confirm_your_changes: we need your current password to confirm your changes + we_need_your_current_password_to_confirm_your_changes: We need your current password to confirm your changes new: sign_up: Sign up signed_up: Welcome! You have signed up successfully. @@ -126,8 +126,8 @@ en: sign_in_with_provider: Sign in with %{provider} sign_up: Sign up minimum_password_length: - one: "(%{count} character minimum)" - other: "(%{count} characters minimum)" + one: "%{count} character minimum." + other: "%{count} characters minimum." unlocks: new: resend_unlock_instructions: Resend unlock instructions diff --git a/config/locales/devise.views.es.yml b/config/locales/devise.views.es.yml index 0db4db7d..affad804 100644 --- a/config/locales/devise.views.es.yml +++ b/config/locales/devise.views.es.yml @@ -93,14 +93,14 @@ es: registrations: destroyed: "¡Adiós! Tu cuenta ha sido cancelada correctamente. Esperamos verte pronto." edit: - are_you_sure: "¿Estás segura?" - cancel_my_account: Anular mi cuenta + index: 'Volver a sitios' + are_you_sure: "¿Estás segure?" + cancel_my_account: Eliminar mi cuenta currently_waiting_confirmation_for_email: 'Actualmente esperando la confirmacion de: %{email} ' - leave_blank_if_you_don_t_want_to_change_it: dejar en blanco si no desea cambiarlo - title: Editar %{resource} - unhappy: "¿Disconforme?" - update: Actualizar - we_need_your_current_password_to_confirm_your_changes: necesitamos tu contraseña actual para confirmar los cambios + leave_blank_if_you_don_t_want_to_change_it: Deja este campo vacío si no deseas cambiarla. + title: Editar mi cuenta + update: Actualizar mi perfil + we_need_your_current_password_to_confirm_your_changes: Necesitamos tu contraseña actual para confirmar los cambios. new: sign_up: Registrarme por primera vez email: O simplemente continuar con tu dirección de correo y contraseña @@ -110,7 +110,6 @@ es: signed_up_but_unconfirmed: Para recibir actualizaciones, se ha enviado un mensaje con un enlace de confirmación a tu correo electrónico. Abre el enlace para activar tu cuenta. update_needs_confirmation: Has actualizado tu cuenta correctamente, pero es necesario confirmar tu nuevo correo electrónico. Por favor, comprueba tu correo y sigue el enlace de confirmación para finalizar la comprobación del nuevo correo electrónico. updated: Tu cuenta se ha actualizado. - updated_but_not_signed_in: sessions: already_signed_out: Sesión finalizada. new: @@ -129,8 +128,8 @@ es: i_dont_have_account: ¿Nunca te registraste en LUNAR? i_have_account: ¿Ya tenés cuenta? minimum_password_length: - one: "(%{count} caracter como mínimo)" - other: "(%{count} caracteres como mínimo)" + one: "%{count} caracter como mínimo." + other: "%{count} caracteres como mínimo." unlocks: new: resend_unlock_instructions: Reenviar instrucciones para desbloquear diff --git a/config/locales/en.yml b/config/locales/en.yml index 6ad6eb9a..8db358cf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,4 +1,6 @@ en: + es: Castillian Spanish + en: English seconds: '%{seconds} seconds' deploy_mailer: deployed: @@ -29,6 +31,8 @@ en: email: 'E-mail address' password: 'Password' password_confirmation: 'Password confirmation' + current_password: 'Current password' + lang: 'Main language' site: name: 'Name' errors: @@ -66,6 +70,8 @@ en: posts: reorder: 'The articles have been reordered!' help: + usuarie: + edit: Edit my profile category: 'Category' logout: 'Close the session' breadcrumbs: "What you see up here are the bread crumbs for this site. When you enter a new section, you will see the previous ones and also have a path for where you're standing." diff --git a/config/locales/es.yml b/config/locales/es.yml index 0a65b29f..56210ab6 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -1,4 +1,6 @@ es: + es: Castellano + en: Inglés seconds: '%{seconds} segundos' deploy_mailer: deployed: @@ -29,6 +31,8 @@ es: email: 'Correo electrónico' password: 'Contraseña' password_confirmation: 'Confirmación de contraseña' + current_password: 'Contraseña actual' + lang: Idioma principal site: name: 'Nombre' title: 'Título' @@ -68,6 +72,8 @@ es: posts: reorder: "¡Los artículos fueron reordenados!" help: + usuarie: + edit: Editar mi perfil category: 'Categoría' logout: 'Cierra la sesión' breadcrumbs: 'Lo que ves arriba son las migas de pan de este sitio. diff --git a/doc/crear_sitios.md b/doc/crear_sitios.md index 9155b002..ed06e77f 100644 --- a/doc/crear_sitios.md +++ b/doc/crear_sitios.md @@ -216,6 +216,7 @@ tengamos tiempo de hacerlo realmente. # TODO +* aplicar la licencia al sitio! * ver las estadisticas de compilación en lugar del log (el log también) agrupar los build stats para poder ver todos los pasos de una @@ -224,4 +225,3 @@ tengamos tiempo de hacerlo realmente. * link a visitar sitio * editor de opciones * forkear gemas -* que les usuaries elijan su propio idioma