polivalente 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f64f29b6f512a3d0a252d028648066293adf4ed36a56c4b2b19924e8f529e89
4
- data.tar.gz: 044f17f768a0c1132c182257dfc7a6ea6b5a825b22df8772751f82f5227e6984
3
+ metadata.gz: d4c39a2ec432cd35300b503c8eb600a1b9f93492e66a2ef26328c52877e76ae0
4
+ data.tar.gz: 91edf132daf70b22ba54733529a980d425848f6ef9e4fe30d7d8f8a04d36bccb
5
5
  SHA512:
6
- metadata.gz: b20d5aca11a7dfe9445df9256f86e9ff7cc7b7e7f4e8b5dc2c0ba2cc163adfc68f9ba9d396eee704c9102d777351dde8a403d7d13595cb06a0bfdbdf3fddb9ec
7
- data.tar.gz: c609c2b70bce6a1448dc8b69b923c0424eef481d6214922bef626276cccf571464162bd65080ee6136726dc9dd0270faa8c8543e314e253bb82f44cca6501605
6
+ metadata.gz: 6cb312cbe2dfe93c5b5fee9b2436b3a78dd424cde9a8ae4d31f944a348b85b7719c9f4870b24b81f10b0ff9186ba4e0b8fe074a67522f5b59e910d758d56aab6
7
+ data.tar.gz: 3524ff079fbed9fe37ec87a76499d847e053f9e32c242acf1c0d4e07737e5f59b7ad01888693073cbaf9032033be77c2ad3fe33461c6079dbc09d9cdafa54313
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Polivalente
2
- Short description and motivation.
2
+ Reusable generic features for Rails applications
3
3
 
4
4
  ## Usage
5
5
  How to use my plugin.
@@ -21,11 +21,30 @@ Or install it yourself as:
21
21
  $ gem install polivalente
22
22
  ```
23
23
 
24
- Copy migrations:
24
+ Installation (copies migrations and [initializer](lib/generators/polivalente/polivalente.rb)):
25
25
  ```bash
26
26
  $ rails g polivalente:install
27
27
  ```
28
28
 
29
+ Copy default `User` model:
30
+ ```bash
31
+ $ rails g polivalente:user
32
+ ```
33
+
34
+ Alternatively, set the `user_class` in `config`:
35
+ ```ruby
36
+ Polivalente.configure do |config|
37
+ # ...
38
+ config.user_class = "MyUser"
39
+ end
40
+ ```
41
+
42
+ Setup `devise`:
43
+ ```bash
44
+ $ rails g devise:install
45
+ ```
46
+
47
+
29
48
  ## Contributing
30
49
  Contribution directions go here.
31
50
 
@@ -1,7 +1,4 @@
1
1
  module Polivalente
2
- class ApplicationController < ActionController::Base
3
- before_action do
4
- ActiveStorage::Current.url_options = { host: "localhost:3000" }
5
- end
2
+ class ApplicationController < Polivalente.config.base_controller.constantize
6
3
  end
7
4
  end
@@ -8,7 +8,9 @@ module Polivalente
8
8
  end
9
9
 
10
10
  def users
11
- @users = User.all.latest
11
+ user_class = Polivalente.config.user_class.constantize
12
+
13
+ @users = user_class.all.latest
12
14
  render json: @users, status: 200
13
15
  end
14
16
 
@@ -1,5 +1,5 @@
1
1
  module Polivalente
2
- class PingController < ActionController::Base
2
+ class PingController < ApplicationController
3
3
  def index
4
4
  render json: { status: 'OK' }, status: :ok
5
5
  end
@@ -10,7 +10,7 @@ module Polivalente
10
10
  self.table_name = :trash
11
11
 
12
12
  # Stale records are those that have been in the trash for `T` amount of time
13
- scope :stale, -> { where("created_at <= ?", Time.zone.now - Polivalente::trash_ttl) }
13
+ scope :stale, -> { where("created_at <= ?", Time.zone.now - Polivalente.config.trash_ttl) }
14
14
 
15
15
  def self.clean_stale!
16
16
  stale.destroy_all
@@ -25,7 +25,7 @@ module Polivalente
25
25
  # Schedule the deletion of this and parent record
26
26
  def schedule_deletion
27
27
  CleanTrashJob
28
- .set(wait_until: Polivalente::trash_ttl.from_now)
28
+ .set(wait_until: Polivalente.config.trash_ttl.from_now)
29
29
  .perform_later(self)
30
30
  end
31
31
  end
@@ -0,0 +1,79 @@
1
+ en:
2
+ devise:
3
+ confirmations:
4
+ confirmed: "Your email address has been successfully confirmed."
5
+ send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
6
+ send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
7
+ failure:
8
+ already_authenticated: "You are already signed in."
9
+ inactive: "Your account is not activated yet."
10
+ invalid: "Invalid %{authentication_keys} or password."
11
+ locked: "Your account is locked."
12
+ last_attempt: "You have one more attempt before your account is locked."
13
+ not_found_in_database: "Invalid %{authentication_keys} or password."
14
+ timeout: "Your session expired. Please sign in again to continue."
15
+ unauthenticated: "You need to sign in or sign up before continuing."
16
+ unconfirmed: "You have to confirm your email address before continuing."
17
+ mailer:
18
+ confirmation_instructions:
19
+ subject: "Confirmation instructions"
20
+ reset_password_instructions:
21
+ subject: "Reset password instructions"
22
+ unlock_instructions:
23
+ subject: "Unlock instructions"
24
+ email_changed:
25
+ subject: "Email Changed"
26
+ password_change:
27
+ subject: "Password Changed"
28
+ omniauth_callbacks:
29
+ failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
30
+ success: "Successfully authenticated from %{kind} account."
31
+ passwords:
32
+ no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
33
+ send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
34
+ send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
35
+ updated: "Your password has been changed successfully. You are now signed in."
36
+ updated_not_active: "Your password has been changed successfully."
37
+ registrations:
38
+ destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
39
+ signed_up: "Welcome! You have signed up successfully."
40
+ signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
41
+ signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
42
+ signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
43
+ update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address."
44
+ updated: "Your account has been updated successfully."
45
+ updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again."
46
+ sessions:
47
+ signed_in: "Signed in successfully."
48
+ signed_out: "Signed out successfully."
49
+ already_signed_out: "Signed out successfully."
50
+ shared:
51
+ links:
52
+ back:
53
+ didn_t_receive_confirmation_instructions: Didn't receive confirmation instructions?
54
+ didn_t_receive_unlock_instructions: Didn't receive unlock instructions?
55
+ forgot_your_password: Forgot your password?
56
+ sign_in: Sign in
57
+ sign_in_with_provider: Sign in with %{provider}
58
+ sign_up: Sign up
59
+ unlocks:
60
+ send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
61
+ send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
62
+ unlocked: "Your account has been unlocked successfully. Please sign in to continue."
63
+ errors:
64
+ messages:
65
+ already_confirmed: "was already confirmed, please try signing in"
66
+ confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
67
+ expired: "has expired, please request a new one"
68
+ not_found: "not found"
69
+ not_locked: "was not locked"
70
+ not_saved:
71
+ one: "1 error prohibited this %{resource} from being saved:"
72
+ other: "%{count} errors prohibited this %{resource} from being saved:"
73
+ configuration: "Application Settings"
74
+ current_locale: "Current Locale"
75
+ available_locales: "Available locales"
76
+ trash:
77
+ time_to_live: "Trash TTL"
78
+ key: "key"
79
+ value: "value"
@@ -0,0 +1,111 @@
1
+ es:
2
+ devise:
3
+ confirmations:
4
+ confirmed: Tu cuenta ha sido confirmada satisfactoriamente.
5
+ new:
6
+ resend_confirmation_instructions: Reenviar instrucciones de confirmación
7
+ send_instructions: Vas a recibir un correo con instrucciones sobre cómo confirmar tu cuenta en unos minutos.
8
+ send_paranoid_instructions: Si tu correo existe en nuestra base de datos, en unos minutos recibirás un correo con instrucciones sobre cómo confirmar tu cuenta.
9
+ failure:
10
+ already_authenticated: Ya has iniciado sesión.
11
+ inactive: Tu cuenta aún no ha sido activada.
12
+ invalid: Email o contraseña no válidos.
13
+ last_attempt: Tienes un intento más antes de que tu cuenta sea bloqueada.
14
+ locked: Tu cuenta está bloqueada.
15
+ not_found_in_database: Email o contraseña no válidos.
16
+ timeout: Tu sesión expiró. Por favor, inicia sesión nuevamente para continuar.
17
+ unauthenticated: Tienes que iniciar sesión o registrarte para poder continuar.
18
+ unconfirmed: Tienes que confirmar tu cuenta para poder continuar.
19
+ mailer:
20
+ confirmation_instructions:
21
+ action: Confirmar mi cuenta
22
+ greeting: "¡Bienvenido %{recipient}!"
23
+ instruction: 'Usted puede confirmar el correo electrónico de su cuenta a través de este enlace:'
24
+ subject: Instrucciones de confirmación
25
+ reset_password_instructions:
26
+ action: Cambiar mi contraseña
27
+ greeting: "¡Hola %{recipient}!"
28
+ instruction: Alguien ha solicitado un enlace para cambiar su contraseña, lo que se puede realizar a través del siguiente enlace.
29
+ instruction_2: Si usted no lo ha solicitado, por favor ignore este correo electrónico.
30
+ instruction_3: Su contraseña no será cambiada hasta que usted acceda el enlace y cree uno nuevo.
31
+ subject: Instrucciones de recuperación de contraseña
32
+ unlock_instructions:
33
+ action: Desbloquear mi cuenta
34
+ greeting: "¡Hola %{recipient}!"
35
+ instruction: 'Haga click en el siguiente enlace para desbloquear su cuenta:'
36
+ message: Su cuenta ha sido bloqueada debido a una cantidad excesiva de intentos infructuosos para ingresar.
37
+ subject: Instrucciones para desbloquear
38
+ omniauth_callbacks:
39
+ failure: No has sido autorizado en la cuenta %{kind} porque "%{reason}".
40
+ success: Has sido autorizado satisfactoriamente en la cuenta %{kind}.
41
+ passwords:
42
+ edit:
43
+ change_my_password: Cambiar mi contraseña
44
+ change_your_password: Cambie su contraseña
45
+ confirm_new_password: Confirme la nueva contraseña
46
+ new_password: Nueva contraseña
47
+ new:
48
+ forgot_your_password: "¿Ha olvidado su contraseña?"
49
+ send_me_reset_password_instructions: Envíeme las instrucciones para resetear mi contraseña
50
+ no_token: No puedes acceder a esta página si no es a través de un enlace para resetear tu contraseña. Si has llegado hasta aquí desde el email para resetear tu contraseña, por favor asegúrate de que la URL introducida está completa.
51
+ send_instructions: Recibirás un correo con instrucciones sobre cómo resetear tu contraseña en unos pocos minutos.
52
+ send_paranoid_instructions: Si tu correo existe en nuestra base de datos, recibirás un correo con instrucciones sobre cómo resetear tu contraseña en tu bandeja de entrada.
53
+ updated: Se ha cambiado tu contraseña. Ya iniciaste sesión.
54
+ updated_not_active: Tu contraseña fue cambiada.
55
+ registrations:
56
+ destroyed: Fue grato tenerte con nosotros. Tu cuenta fue cancelada.
57
+ edit:
58
+ are_you_sure: "¿Está usted seguro?"
59
+ cancel_my_account: Anular mi cuenta
60
+ currently_waiting_confirmation_for_email: 'Actualmente esperando la confirmacion de: %{email} '
61
+ leave_blank_if_you_don_t_want_to_change_it: dejar en blanco si no desea cambiarlo
62
+ title: Editar %{resource}
63
+ unhappy: Infeliz
64
+ update: Actualizar
65
+ we_need_your_current_password_to_confirm_your_changes: necesitamos su contraseña actual para confirmar los cambios
66
+ new:
67
+ sign_up: Registrarse
68
+ signed_up: Bienvenido. Tu cuenta fue creada.
69
+ signed_up_but_inactive: Tu cuenta ha sido creada correctamente. Sin embargo, no hemos podido iniciar la sesión porque tu cuenta aún no está activada.
70
+ signed_up_but_locked: Tu cuenta ha sido creada correctamente. Sin embargo, no hemos podido iniciar la sesión porque que tu cuenta está bloqueada.
71
+ signed_up_but_unconfirmed: Se ha enviado un mensaje con un enlace de confirmación a tu correo electrónico. Abre el enlace para activar tu cuenta.
72
+ 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 eletrónico.
73
+ updated: Tu cuenta se ha actualizada.
74
+ sessions:
75
+ already_signed_out: Sesión finalizada.
76
+ new:
77
+ sign_in: Iniciar sesión
78
+ signed_in: Sesión iniciada.
79
+ signed_out: Sesión finalizada.
80
+ shared:
81
+ links:
82
+ back: Atrás
83
+ didn_t_receive_confirmation_instructions: "¿No ha recibido las instrucciones de confirmación?"
84
+ didn_t_receive_unlock_instructions: "¿No ha recibido instrucciones para desbloquear?"
85
+ forgot_your_password: "¿Ha olvidado su contraseña?"
86
+ sign_in: Iniciar sesión
87
+ sign_in_with_provider: Iniciar sesión con %{provider}
88
+ sign_up: Registrarse
89
+ unlocks:
90
+ new:
91
+ resend_unlock_instructions: Reenviar instrucciones para desbloquear
92
+ send_instructions: Vas a recibir instrucciones para desbloquear tu cuenta en unos pocos minutos.
93
+ send_paranoid_instructions: Si tu cuenta existe, vas a recibir instrucciones para desbloquear tu cuenta en unos pocos minutos.
94
+ unlocked: Tu cuenta ha sido desbloqueada. Ya puedes iniciar sesión.
95
+ errors:
96
+ messages:
97
+ already_confirmed: ya ha sido confirmada, por favor intenta iniciar sesión
98
+ confirmation_period_expired: necesita confirmarse dentro de %{period}, por favor solicita una nueva
99
+ expired: ha expirado, por favor solicita una nueva
100
+ not_found: no se ha encontrado
101
+ not_locked: no estaba bloqueada
102
+ not_saved:
103
+ one: 'Ocurrió un error al tratar de guardar %{resource}:'
104
+ other: 'Ocurrieron %{count} errores al tratar de guardar %{resource}:'
105
+ configuration: "Configuración"
106
+ current_locale: "Local atual"
107
+ available_locales: "Locales disponibles"
108
+ trash:
109
+ time_to_live: "Duración de basura"
110
+ key: "llave"
111
+ value: "valor"
@@ -0,0 +1,111 @@
1
+ fr:
2
+ devise:
3
+ confirmations:
4
+ confirmed: Votre compte a été confirmé avec succès.
5
+ new:
6
+ resend_confirmation_instructions: Renvoyer les instructions de confirmation
7
+ send_instructions: Vous allez recevoir sous quelques minutes un email comportant des instructions pour confirmer votre compte.
8
+ send_paranoid_instructions: Si votre email existe sur notre base de données, vous recevrez sous quelques minutes un message avec des instructions pour confirmer votre compte.
9
+ failure:
10
+ already_authenticated: Vous êtes déjà connecté(e).
11
+ inactive: Votre compte n’est pas encore activé.
12
+ invalid: Email ou mot de passe incorrect.
13
+ last_attempt: Il vous reste une chance avant que votre compte soit bloqué.
14
+ locked: Votre compte est verrouillé.
15
+ not_found_in_database: Email ou mot de passe incorrect.
16
+ timeout: Votre session est périmée, veuillez vous reconnecter pour continuer.
17
+ unauthenticated: Vous devez vous connecter ou vous enregistrer pour continuer.
18
+ unconfirmed: Vous devez confirmer votre compte par email.
19
+ mailer:
20
+ confirmation_instructions:
21
+ action: Confirmer mon email
22
+ greeting: Bienvenue %{recipient}!
23
+ instruction: 'Vous pouvez confirmer votre email grâce au lien ci-dessous:'
24
+ subject: Instructions de confirmation
25
+ reset_password_instructions:
26
+ action: Changer mon mot de passe
27
+ greeting: Bonjour %{recipient}!
28
+ instruction: "Quelqu'un a demandé un lien pour changer votre mot de passe, le voici :"
29
+ instruction_2: "Si vous n'avez pas émis cette demande, merci d'ignorer ce email."
30
+ instruction_3: Votre mot de passe ne changera pas tant que vous n'aurez pas cliqué sur ce lien et renseigné un nouveau mot de passe.
31
+ subject: Instructions pour changer de mot de passe
32
+ unlock_instructions:
33
+ action: Débloquer mon compte
34
+ greeting: Bonjour %{recipient}!
35
+ instruction: 'Suivez ce lien pour débloquer votre compte:'
36
+ message: Votre compte a été bloqué suite à un nombre d'essais de connexions manquées trop important
37
+ subject: Instructions pour déverrouiller le compte
38
+ omniauth_callbacks:
39
+ failure: 'Nous ne pouvons pas vous authentifier depuis %{kind} pour la raison suivante : ''%{reason}''.'
40
+ success: Autorisé avec succès par votre compte %{kind}.
41
+ passwords:
42
+ edit:
43
+ change_my_password: Changer mon mot de passe
44
+ change_your_password: Changer votre mot de passe
45
+ confirm_new_password: Confirmez votre nouveau mot de passe
46
+ new_password: Nouveau mot de passe
47
+ new:
48
+ forgot_your_password: Mot de passe oublié ?
49
+ send_me_reset_password_instructions: Envoyez-moi des instructions pour réinitialiser mon mot de passe
50
+ no_token: "Vous ne pouvez pas accéder à cette page si vous n’y accédez pas depuis un email de réinitialisation de mot de passe. Si vous venez en effet d’un tel email, vérifiez que vous avez copié l’adresse URL en entier."
51
+ send_instructions: Vous allez recevoir sous quelques minutes un email vous indiquant comment réinitialiser votre mot de passe.
52
+ send_paranoid_instructions: Si votre email existe dans notre base de données, vous recevrez un lien vous permettant de récupérer votre mot de passe.
53
+ updated: Votre mot de passe a été modifié avec succès. Vous êtes maintenant connecté(e).
54
+ updated_not_active: Votre mot de passe a été modifié avec succès.
55
+ registrations:
56
+ destroyed: Au revoir ! Votre compte a été supprimé avec succès. Nous espérons vous revoir bientôt.
57
+ edit:
58
+ are_you_sure: "Êtes-vous sûr ?"
59
+ cancel_my_account: Supprimer mon compte
60
+ currently_waiting_confirmation_for_email: 'Confirmation en attente pour: %{email}'
61
+ leave_blank_if_you_don_t_want_to_change_it: laissez ce champ vide pour le laisser inchangé
62
+ title: "Éditer %{resource}"
63
+ unhappy: 'Pas content '
64
+ update: Modifier
65
+ we_need_your_current_password_to_confirm_your_changes: nous avons besoin de votre mot de passe actuel pour valider ces modifications
66
+ new:
67
+ sign_up: Inscription
68
+ signed_up: Bienvenue ! Vous vous êtes enregistré(e) avec succès.
69
+ signed_up_but_inactive: "Vous vous êtes enregistré(e) avec succès. Cependant, nous n’avons pas pu vous connecter car votre compte n’a pas encore été activé."
70
+ signed_up_but_locked: "Vous vous êtes enregistré(e) avec succès. Cependant, nous n’avons pas pu vous connecter car votre compte est verrouillé."
71
+ signed_up_but_unconfirmed: "Un message avec un lien de confirmation vous a été envoyé par mail. Veuillez suivre ce lien pour activer votre compte."
72
+ update_needs_confirmation: "Vous avez modifié votre compte avec succès, mais nous devons vérifier votre nouvelle adresse de email. Veuillez consulter vos emails et cliquer sur le lien de confirmation pour confirmer votre nouvelle adresse."
73
+ updated: Votre compte a été modifié avec succès.
74
+ sessions:
75
+ already_signed_out: Déconnecté(e).
76
+ new:
77
+ sign_in: Connexion
78
+ signed_in: Connecté(e) avec succès.
79
+ signed_out: Déconnecté(e) avec succès.
80
+ shared:
81
+ links:
82
+ back: Retour
83
+ didn_t_receive_confirmation_instructions: Vous n'avez pas reçu le email de confirmation ?
84
+ didn_t_receive_unlock_instructions: Vous n'avez pas reçu le email de déblocage ?
85
+ forgot_your_password: Mot de passe oublié ?
86
+ sign_in: Connexion
87
+ sign_in_with_provider: Connexion avec %{provider}
88
+ sign_up: Inscription
89
+ unlocks:
90
+ new:
91
+ resend_unlock_instructions: Renvoyer les instructions de déblocage
92
+ send_instructions: Vous allez recevoir sous quelques minutes un email comportant des instructions pour déverrouiller votre compte.
93
+ send_paranoid_instructions: Si votre email existe sur notre base de données, vous recevrez sous quelques minutes un message avec des instructions pour déverrouiller votre compte.
94
+ unlocked: Votre compte a été déverrouillé avec succès. Veuillez vous connecter.
95
+ errors:
96
+ messages:
97
+ already_confirmed: a déjà été confirmé(e)
98
+ confirmation_period_expired: doit être confirmé(e) en %{period}, veuillez en demander un(e) autre
99
+ expired: est périmé, veuillez en demander un autre
100
+ not_found: n’a pas été trouvé(e)
101
+ not_locked: n’était pas verrouillé(e)
102
+ not_saved:
103
+ one: 'une erreur a empêché ce (cet ou cette) %{resource} d’être enregistré(e) :'
104
+ other: "%{count} erreurs ont empêché ce (cet ou cette) %{resource} d’être enregistré(e) :"
105
+ configuration: "Reglages"
106
+ current_locale: "Local"
107
+ available_locales: "Locales disponibles"
108
+ trash:
109
+ time_to_live: "Duration de poubelle"
110
+ key: "clé"
111
+ value: "valeur"
@@ -0,0 +1,111 @@
1
+ pt:
2
+ devise:
3
+ confirmations:
4
+ confirmed: A sua conta foi confirmada com sucesso.
5
+ new:
6
+ resend_confirmation_instructions: Reenviar instruções de confirmação
7
+ send_instructions: Dentro de alguns minutos irá receber um email com instruções para confirmar a sua conta.
8
+ send_paranoid_instructions: Se o seu email existir na nossa base de dados, irá receber dentro de alguns minutos um email com instruções para confirmar a sua conta.
9
+ failure:
10
+ already_authenticated: Já se encontra autenticado.
11
+ inactive: A sua conta ainda não foi activada.
12
+ invalid: O endereço de email ou a palavra-passe são inválidos.
13
+ last_attempt: Tem mais uma tentativa antes da sua conta ser bloqueada.
14
+ locked: A sua conta está bloqueada.
15
+ not_found_in_database: O endereço de email ou a palavra-passe são inválidos.
16
+ timeout: A sua sessão expirou, por favor autentique-se novamente para continuar.
17
+ unauthenticated: Antes de continuar tem de se autenticar ou efectuar um registo.
18
+ unconfirmed: Tem de confirmar a sua conta antes de continuar.
19
+ mailer:
20
+ confirmation_instructions:
21
+ action: Confirmar a minha conta
22
+ greeting: Bem-vindo %{recipient}!
23
+ instruction: 'Pode confirmar a sua conta através do link:'
24
+ subject: Instruções de confirmação
25
+ reset_password_instructions:
26
+ action: Repor a minha senha
27
+ greeting: Olá %{recipient}!
28
+ instruction: Foi efectuado um pedido para repor a sua palavra-passe. Para o fazer click no link abaixo.
29
+ instruction_2: Se não fez este pedido, por favor ignore este e-mail.
30
+ instruction_3: A sua palavra-passe só será alterada quando aceder ao link abaixo para a alterar.
31
+ subject: Instruções de recuperação de palavra-passe
32
+ unlock_instructions:
33
+ action: Desbloquear a minha conta
34
+ greeting: Olá %{recipient}!
35
+ instruction: 'Clique no seguinte link para desbloquear a sua conta:'
36
+ message: A sua conta foi bloqueada devido a um número excessivo de tentativas de acesso inválidas.
37
+ subject: Instruções de desbloqueio
38
+ omniauth_callbacks:
39
+ failure: Não foi possível autenticar a sua conta por %{kind} porque "%{reason}".
40
+ success: A sua conta foi autenticada por %{kind} com sucesso.
41
+ passwords:
42
+ edit:
43
+ change_my_password:
44
+ change_your_password:
45
+ confirm_new_password:
46
+ new_password:
47
+ new:
48
+ forgot_your_password: Esqueceu a sua senha?
49
+ send_me_reset_password_instructions: Enviar-me instruções para repor a senha
50
+ no_token: Não pode aceder a esta página sem vir do email de redefinição da senha. Se vem dum email para redefinir a senha, por favor certifique-se que usou o URL completo que foi enviado.
51
+ send_instructions: Dentro de alguns minutos irá receber um email com instruções de reinicialização da palavra-passe.
52
+ send_paranoid_instructions: Se o seu e-mail existir na nossa base de dados, irá receber dentro de alguns minutos um e-mail com instruções para recuperar a sua senha.
53
+ updated: A sua palavra-passe foi alterada com sucesso. Agora está autenticado.
54
+ updated_not_active: A sua password foi alterada com sucesso.
55
+ registrations:
56
+ destroyed: A sua conta foi cancelada com sucesso.
57
+ edit:
58
+ are_you_sure: Tem a certeza?
59
+ cancel_my_account: Cancelar a minha conta
60
+ currently_waiting_confirmation_for_email:
61
+ leave_blank_if_you_don_t_want_to_change_it: deixe em branco caso não queira alterar
62
+ title: Editar %{resource}
63
+ unhappy:
64
+ update:
65
+ we_need_your_current_password_to_confirm_your_changes: precisamos da sua senha actual para confirmar as alterações
66
+ new:
67
+ sign_up: Criar Conta
68
+ signed_up: Bemvindo! A autenticação foi efectuada com sucesso.
69
+ signed_up_but_inactive: Registou-se com sucesso. No entanto, não podemos iniciar a sua sessão porque ainda não confirmou a sua conta.
70
+ signed_up_but_locked: Registou-se com sucesso. No entanto, não podemos iniciar a sua sessão porque a sua conta encontra-se bloqueada.
71
+ signed_up_but_unconfirmed: Foi enviado um email com um link para confirmar o seu email. Por favor abra o link para activar a sua conta.
72
+ update_needs_confirmation: A sua conta foi actualizada com sucesso, mas precisamos de confirmar o seu email. Por favor veja o seu email e clique no link para finalizar a confirmação do seu email.
73
+ updated: A sua conta foi actualizada com sucesso.
74
+ sessions:
75
+ already_signed_out: Sessão terminada com sucesso.
76
+ new:
77
+ sign_in: Entrar
78
+ signed_in: Autenticação efectuada com sucesso.
79
+ signed_out: Saiu da sessão com sucesso.
80
+ shared:
81
+ links:
82
+ back:
83
+ didn_t_receive_confirmation_instructions: Não recebeu instruções de confirmação?
84
+ didn_t_receive_unlock_instructions: Não recebeu instruções de desbloqueio?
85
+ forgot_your_password: Equeceu a palavra-passe?
86
+ sign_in: Login
87
+ sign_in_with_provider: Entrar com %{provider}
88
+ sign_up: Criar conta
89
+ unlocks:
90
+ new:
91
+ resend_unlock_instructions: Renviar instruções de desbloqueio
92
+ send_instructions: Dentro de alguns minutos irá receber um email com as instruções para desbloquear a sua conta.
93
+ send_paranoid_instructions: Se a sua conta existir, irá receber dentro de alguns minutos um email com instruções para a desbloquear.
94
+ unlocked: A sua conta foi desbloqueada com sucesso. Por favor autentique-se para continuar.
95
+ errors:
96
+ messages:
97
+ already_confirmed: já foi confirmado, por favor tente efectuar a autenticação
98
+ confirmation_period_expired: necessitava de confirmação até %{period}, por favor faça um novo pedido
99
+ expired: expirou, por favor solicite um novo
100
+ not_found: não foi encontrado
101
+ not_locked: não foi bloqueado
102
+ not_saved:
103
+ one: '1 erro impediu %{resource} de ser gravado:'
104
+ other: "%{count} erros impediram %{resource} de ser gravado:"
105
+ configuration: "Configuração"
106
+ current_locale: "Locação atual"
107
+ available_locales: "Locações disponíveis"
108
+ trash:
109
+ time_to_live: "Duração de lixeira"
110
+ key: "chave"
111
+ value: "valor"
data/config/routes.rb CHANGED
@@ -2,8 +2,6 @@ Polivalente::Engine.routes.draw do
2
2
  # Health check
3
3
  resources :ping, only: [:index]
4
4
 
5
- devise_for :users, class_name: "Polivalente::User"
6
-
7
5
  namespace :autocomplete, defaults: { format: :json } do
8
6
  get 'tags', as: :tag_completion
9
7
  get 'users', as: :user_completion
@@ -1,9 +1,37 @@
1
1
  module Polivalente
2
2
  module Generators
3
3
  class InstallGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
4
6
  def copy_migrations
5
7
  rails_command "railties:install:migrations FROM=polivalente", inline: true
6
8
  end
9
+
10
+ def copy_locales
11
+ copy_file "../../../../config/locales/en.yml", "config/locales/en.yml"
12
+ copy_file "../../../../config/locales/es.yml", "config/locales/es.yml"
13
+ copy_file "../../../../config/locales/fr.yml", "config/locales/fr.yml"
14
+ copy_file "../../../../config/locales/pt.yml", "config/locales/pt.yml"
15
+ end
16
+
17
+ def copy_initializer
18
+ template "polivalente.rb", "config/initializers/polivalente.rb"
19
+ end
20
+
21
+ def copy_initializer
22
+ template "active_model_serializers.rb", "config/initializers/active_model_serializers.rb"
23
+ end
24
+
25
+ def add_route
26
+ devise_class = Polivalente.config.user_class.constantize
27
+
28
+ route "mount Polivalente::Engine => ''"
29
+ route "devise_for :users"
30
+ end
31
+
32
+ def show_readme
33
+ readme "README" if behavior == :invoke
34
+ end
7
35
  end
8
36
  end
9
37
  end
@@ -0,0 +1,10 @@
1
+ ===============================================================================
2
+
3
+ Now that you've installed the Polivalente, run `rails g polivalente:user` to
4
+ copy the default user model or set the `user_class` attribute in
5
+ the gem's initializer.
6
+
7
+ Then, proceed to run the installer for Devise.
8
+
9
+ For help, please check this gem's README on GitHub. Available at:
10
+ https://github.com/oleoneto/polivalente
@@ -0,0 +1 @@
1
+ ActiveModelSerializers.config.adapter = :json_api
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ Polivalente.configure do |config|
4
+ # ==> User configuration
5
+ config.user_class = "::User"
6
+
7
+ # ==> Controller configuration
8
+ config.base_controller = "::ApplicationController"
9
+ config.base_api_controller = "::ApplicationController"
10
+
11
+ # ==> Account configuration
12
+ config.inactive_account_ttl = 60.days
13
+ config.spam_account_ttl = 4.days
14
+
15
+ # ==> Locales configuration
16
+ config.supported_locales = [:en]
17
+
18
+ # ==> Trash configuration
19
+ config.trash_ttl = 30.days
20
+ end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ class User < ApplicationRecord
4
+ include Polivalente::Archiver
5
+ include Polivalente::Commentator
6
+ include Polivalente::Reactor
7
+ include Polivalente::Sortable
8
+ include Polivalente::Trasher
9
+
10
+ # Include default devise modules. Others available are:
11
+ # :registerable, :validatable,
12
+ # :timeoutable, and :omniauthable
13
+
14
+ devise :database_authenticatable,
15
+ :confirmable,
16
+ :rememberable,
17
+ :recoverable,
18
+ :lockable,
19
+ :trackable
20
+
21
+ has_one_attached :photo
22
+
23
+ validates_length_of :first_name, minimum: 2, maximum: 20
24
+ validates_length_of :last_name, minimum: 2, maximum: 20
25
+ validates :email, format: { with: URI::MailTo::EMAIL_REGEXP }
26
+ validates_uniqueness_of :email
27
+ validates_length_of :password, minimum: 8
28
+
29
+ # A user account is considered spam/abandoned if:
30
+ # - The account has existed for at least N days
31
+ # - The account was never confirmed/activated
32
+ # - The the user never signed in to their account
33
+ #
34
+ # These records should be deleted from the database periodically
35
+ scope :spam, -> {
36
+ where("created_at <= ? AND sign_in_count <= 1 AND confirmed_at IS NULL", Time.zone.now - spam_account_ttl)
37
+ }
38
+
39
+ # A user account is inactive if:
40
+ # - The account has not been signed in to for more than X days
41
+ # These users should be notified about their account state
42
+ scope :inactive, -> {
43
+ where("current_sign_in_at <= ?", Time.zone.now - inactive_account_ttl)
44
+ }
45
+
46
+ scope :unconfirmed, -> { where(:confirmed_at => nil)}
47
+
48
+ def name
49
+ "#{first_name} #{last_name}"
50
+ end
51
+
52
+ module ClassMethods
53
+ def inactive_account_ttl
54
+ Polivalente.config.inactive_account_ttl.days
55
+ end
56
+
57
+ def spam_account_ttl
58
+ Polivalente.config.spam_account_ttl.days
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,11 @@
1
+ module Polivalente
2
+ module Generators
3
+ class UserGenerator < ::Rails::Generators::Base
4
+ source_root File.expand_path("../../templates", __FILE__)
5
+
6
+ def copy_user_model
7
+ template "user.rb", "app/models/user.rb"
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module Polivalente
2
+ class Configuration
3
+ attr_accessor :base_controller
4
+ attr_accessor :base_api_controller
5
+ attr_accessor :inactive_account_ttl
6
+ attr_accessor :spam_account_ttl
7
+ attr_accessor :supported_locales
8
+ attr_accessor :trash_ttl
9
+ attr_accessor :user_class
10
+ end
11
+ end
@@ -10,12 +10,15 @@ module Polivalente
10
10
  g.factory_bot dir: "spec/factories"
11
11
  end
12
12
 
13
- initializer "polivalente.factories", after: "factory_bot.set_factory_paths" do
14
- FactoryBot.definition_file_paths << File.expand_path('../../../spec/factories', __FILE__) if defined?(FactoryBot)
13
+ # Loads engine helpers in main application
14
+ initializer "local_helper.action_controller" do
15
+ ActiveSupport.on_load :action_controller do
16
+ helper Polivalente::Engine.helpers
17
+ end
15
18
  end
16
- end
17
19
 
18
- # Do not prefix table names with `polivantente_`
19
- def self.table_name_prefix
20
+ # Do not prefix table names with `polivantente_`
21
+ def self.table_name_prefix
22
+ end
20
23
  end
21
24
  end
@@ -1,3 +1,3 @@
1
1
  module Polivalente
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/polivalente.rb CHANGED
@@ -1,25 +1,24 @@
1
1
  require "polivalente/version"
2
2
  require "polivalente/railtie"
3
3
  require "polivalente/engine"
4
+ require "polivalente/configuration"
4
5
 
5
6
  # Third-party
6
7
 
7
8
  require "active_model_serializers"
8
9
  require "devise"
9
10
  require "discard"
10
- require "factory_bot_rails"
11
11
 
12
12
  module Polivalente
13
- # Attributes
14
- mattr_accessor :inactive_account_ttl
15
- mattr_accessor :spam_account_ttl
16
- mattr_accessor :supported_locales
17
- mattr_accessor :trash_ttl
13
+ class << self
14
+ attr_reader :config
18
15
 
19
- self.inactive_account_ttl = 60.days
20
- self.spam_account_ttl = 4.days
21
- self.supported_locales = [:en]
22
- self.trash_ttl = 30.days
16
+ def configure
17
+ @config = Configuration.new
18
+ yield config
19
+ end
20
+ end
21
+
23
22
 
24
23
  # Modules
25
24
  autoload :UserLocale, "polivalente/user_locale"
@@ -29,8 +28,4 @@ module Polivalente
29
28
  # do not prefix table names with `polivantente_`
30
29
  def self.table_name_prefix
31
30
  end
32
-
33
- def self.setup
34
- yield self
35
- end
36
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polivalente
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo Neto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-07 00:00:00.000000000 Z
11
+ date: 2022-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -114,7 +114,7 @@ dependencies:
114
114
  - - "~>"
115
115
  - !ruby/object:Gem::Version
116
116
  version: '5.0'
117
- description: Reusable generic features extracted out of our Rails apps
117
+ description: Reusable generic features for Rails applications
118
118
  email:
119
119
  - leo@ekletik.com
120
120
  executables: []
@@ -158,7 +158,6 @@ files:
158
158
  - app/models/polivalente/tag.rb
159
159
  - app/models/polivalente/tagging.rb
160
160
  - app/models/polivalente/trash.rb
161
- - app/models/polivalente/user.rb
162
161
  - app/serializers/polivalente/comment_serializer.rb
163
162
  - app/serializers/polivalente/reaction_serializer.rb
164
163
  - app/serializers/polivalente/tag_serializer.rb
@@ -167,6 +166,10 @@ files:
167
166
  - app/views/layouts/polivalente/application.html.erb
168
167
  - config/initializers/devise.rb
169
168
  - config/locales/devise.en.yml
169
+ - config/locales/en.yml
170
+ - config/locales/es.yml
171
+ - config/locales/fr.yml
172
+ - config/locales/pt.yml
170
173
  - config/routes.rb
171
174
  - db/migrate/20220124153504_create_users.rb
172
175
  - db/migrate/20220125040905_create_tags.rb
@@ -179,6 +182,11 @@ files:
179
182
  - db/migrate/20220125144342_create_trash.rb
180
183
  - db/migrate/20220130033524_create_archives.rb
181
184
  - lib/generators/polivalente/install/install_generator.rb
185
+ - lib/generators/polivalente/templates/README
186
+ - lib/generators/polivalente/templates/active_model_serializers.rb
187
+ - lib/generators/polivalente/templates/polivalente.rb
188
+ - lib/generators/polivalente/templates/user.rb
189
+ - lib/generators/polivalente/user/user_generator.rb
182
190
  - lib/generators/rails/concern/USAGE
183
191
  - lib/generators/rails/concern/concern_generator.rb
184
192
  - lib/generators/rails/concern/templates/concern.rb
@@ -189,6 +197,7 @@ files:
189
197
  - lib/generators/rails/validator/templates/validator.rb
190
198
  - lib/generators/rails/validator/validator_generator.rb
191
199
  - lib/polivalente.rb
200
+ - lib/polivalente/configuration.rb
192
201
  - lib/polivalente/engine.rb
193
202
  - lib/polivalente/railtie.rb
194
203
  - lib/polivalente/user_locale.rb
@@ -200,7 +209,7 @@ licenses:
200
209
  metadata:
201
210
  homepage_uri: https://github.com/oleoneto/polivalente
202
211
  source_code_uri: https://github.com/oleoneto/polivalente
203
- changelog_uri: https://github.com/oleoneto/polivalente/blob/master/CHANGELOG.md
212
+ changelog_uri: https://github.com/oleoneto/polivalente/blob/main/CHANGELOG.md
204
213
  post_install_message:
205
214
  rdoc_options: []
206
215
  require_paths:
@@ -1,47 +0,0 @@
1
- module Polivalente
2
- class User < ApplicationRecord
3
- include Sortable
4
-
5
- # Include default devise modules. Others available are:
6
- # :registerable, :validatable,
7
- # :timeoutable, and :omniauthable
8
-
9
- devise :database_authenticatable,
10
- :confirmable,
11
- :rememberable,
12
- :recoverable,
13
- :lockable,
14
- :trackable
15
-
16
- has_one_attached :photo
17
-
18
- validates_length_of :first_name, minimum: 2, maximum: 20
19
- validates_length_of :last_name, minimum: 2, maximum: 20
20
- validates :email, format: { with: URI::MailTo::EMAIL_REGEXP }
21
- validates_uniqueness_of :email
22
- validates_length_of :password, minimum: 8
23
-
24
- # A user account is considered spam/abandoned if:
25
- # - The account has existed for at least N days
26
- # - The account was never confirmed/activated
27
- # - The the user never signed in to their account
28
- #
29
- # These records should be deleted from the database periodically
30
- scope :spam, -> {
31
- where("created_at <= ? AND sign_in_count <= 1 AND confirmed_at IS NULL", Time.zone.now - Polivalente::spam_account_ttl.days)
32
- }
33
-
34
- # A user account is inactive if:
35
- # - The account has not been signed in to for more than X days
36
- # These users should be notified about their account state
37
- scope :inactive, -> {
38
- where("current_sign_in_at <= ?", Time.zone.now - Polivalente::inactive_account_ttl.days)
39
- }
40
-
41
- scope :unconfirmed, -> { where(:confirmed_at => nil)}
42
-
43
- def name
44
- "#{first_name} #{last_name}"
45
- end
46
- end
47
- end