any_login_multiple 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b0401e670329ebdd24333641ba6cf55aef7e6f1109cae162e68c2d0776fdaad1
4
- data.tar.gz: 8637a30170006164e1f410ebb05451210e1cbd010b3f29ef06db1c5639c5a926
3
+ metadata.gz: e84bdaed139698dc7af4dea06cd4b854c67b05b3658daa997f5f070049234bc0
4
+ data.tar.gz: 2911e27a1caac2c4626e94e5a3abf2d76994556eb06e0f504b309a706eed3560
5
5
  SHA512:
6
- metadata.gz: a6f6808f8fe997c82843558fb6428f09a7f51c94bf407b5ab6322d1d0d1da55f1027f29f0b20e44ddff8874749ed9fdbd0a556e9403446d6d6cef8488e98e839
7
- data.tar.gz: 7e8193f0dbc3f02fc600f6b303710c984e89673deb6715eac634b8146a5210249f8fbfcb4d19ee279fa33e1b67f79557510fffa502c3f0301845b371008e8b0e
6
+ metadata.gz: 25f50f917a32e1eff194617cf223d2e8313067213dbffe16193b218a5b49c079da59b6f506f313d40aa8c603f7fcfc820b255bbd41e3a019261cc8d7bdf3d2d9
7
+ data.tar.gz: ec4b7641c825feda970270d72264d53221a6f668cb63f46628dad57b6e1f767721f5b33ec0d97572b898a80c88d95d84a8be2da44a09194a6744c9d8568364c9
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # EasyLogin
1
+ # AnyLoginMultiple
2
2
 
3
3
  This gem is inspired by [any_login](https://github.com/igorkasyanchuk/any_login).
4
4
  This gem supports multiple model support.
@@ -12,7 +12,7 @@ Add this line to your application's Gemfile:
12
12
 
13
13
  ```ruby
14
14
  group :development do
15
- gem 'easy_login'
15
+ gem 'any_login_multiple'
16
16
  end
17
17
  ```
18
18
 
@@ -21,10 +21,10 @@ And then execute:
21
21
  $ bundle install
22
22
  ```
23
23
 
24
- Add `config/initializers/easy_login.rb` and set `klass_names`:
24
+ Add `config/initializers/any_login_multiple.rb` and set `klass_names`:
25
25
 
26
26
  ```rb
27
- EasyLogin.klass_names = ['User', 'Staff']
27
+ AnyLoginMultiple.klass_names = ['User', 'Staff']
28
28
  ```
29
29
 
30
30
  ## Usage
@@ -32,7 +32,7 @@ EasyLogin.klass_names = ['User', 'Staff']
32
32
  Add this line to `application.html.erb`:
33
33
 
34
34
  ```erb
35
- <%= easy_login_here if Rails.env.development? %>
35
+ <%= any_login_multiple_here if Rails.env.development? %>
36
36
  ```
37
37
 
38
38
  ## License
@@ -1,6 +1,6 @@
1
- module EasyLogin
1
+ module AnyLoginMultiple
2
2
  class ApplicationController < ActionController::Base
3
- def easy_login
3
+ def any_login_multiple
4
4
  reset_session
5
5
 
6
6
  klass_string = params[:as]
@@ -0,0 +1,65 @@
1
+ <div class="any-login-multiple-wrapper" style="opacity: 70%;">
2
+ <a class="any-login-multiple-trigger">Display Form</a>
3
+ <div class="any-login-multiple-forms-container" style='display: none;'>
4
+ <% AnyLoginMultiple.klass_names.each do |klass_name| %>
5
+ <%= form_with url: any_login_multiple.sign_in_path(as: klass_name), class: 'any-login-multiple-form', method: :post do |form| %>
6
+ <label>
7
+ <%= klass_name %>
8
+ </label>
9
+ <%= form.select :id, klass_name.constantize.pluck(:email, :id) %>
10
+ <%= form.submit 'Submit' %>
11
+ <% end %>
12
+ <% end %>
13
+ </div>
14
+ </div>
15
+
16
+ <style>
17
+ .any-login-multiple-wrapper {
18
+ position: fixed;
19
+ bottom: 0;
20
+ left: 0;
21
+ background: #5c4383;
22
+ color: white;
23
+ z-index: 100;
24
+ padding: 5px 10px;
25
+ }
26
+ .any-login-multiple-trigger {
27
+ color: white;
28
+ cursor: pointer;
29
+ }
30
+ </style>
31
+
32
+ <script type="text/javascript" charset="utf-8">
33
+ window.AnyLoginMultiple = window.AnyLoginMultiple || {};
34
+
35
+ window.AnyLoginMultiple.on_select_change = () => {
36
+ const anyLoginMultipleForm = document.querySelectorAll('.any-login-multiple-form');
37
+ anyLoginMultipleForm.forEach(form => {
38
+ const select = form.querySelector('select')
39
+ select.addEventListener('change', () => {
40
+ form.submit();
41
+ })
42
+ })
43
+ }
44
+
45
+ window.AnyLoginMultiple.on_select_change();
46
+
47
+ window.AnyLoginMultiple.display_forms = () => {
48
+ const trigger = document.querySelector('.any-login-multiple-trigger');
49
+ const wrapper = document.querySelector('.any-login-multiple-wrapper')
50
+
51
+ trigger.addEventListener('click', () => {
52
+ const formBox = document.querySelector('.any-login-multiple-forms-container');
53
+ if (formBox.style.display == 'none') {
54
+ formBox.style.display = 'block'
55
+ wrapper.style.opacity = '100%'
56
+ trigger.textContent = 'Hide Form'
57
+ } else {
58
+ formBox.style.display = 'none'
59
+ wrapper.style.opacity = '70%'
60
+ trigger.textContent = 'Display Form'
61
+ }
62
+ })
63
+ }
64
+ window.AnyLoginMultiple.display_forms();
65
+ </script>
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
- EasyLogin::Engine.routes.draw do
2
- post '/easy_login/sign_in', to: 'application#easy_login', as: :sign_in
1
+ AnyLoginMultiple::Engine.routes.draw do
2
+ post '/any_login_multiple/sign_in', to: 'application#any_login_multiple', as: :sign_in
3
3
  end
4
4
 
5
5
  Rails.application.routes.draw do
@@ -0,0 +1,16 @@
1
+ require "any_login_multiple/version"
2
+ require "any_login_multiple/engine"
3
+
4
+ module AnyLoginMultiple
5
+ extend ActiveSupport::Autoload
6
+ autoload :Helpers
7
+
8
+ mattr_accessor :klass_names
9
+ @@klass_names = ['User']
10
+
11
+ def self.klasses
12
+ @@klasses = AnyLoginMultiple.klass_names.map(&:constantize)
13
+ end
14
+ end
15
+
16
+ require 'any_login_multiple/routes'
@@ -0,0 +1,11 @@
1
+ module AnyLoginMultiple
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace AnyLoginMultiple
4
+
5
+ initializer 'any_login_multiple.helpers' do
6
+ ActiveSupport.on_load :action_view do
7
+ include AnyLoginMultiple::Helpers
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,9 @@
1
+ module AnyLoginMultiple
2
+ module Helpers
3
+ # extend ActiveSupport::Concern
4
+
5
+ def any_login_multiple_here
6
+ render 'any_login_multiple/any_login_multiple'
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ module ActionDispatch::Routing
2
+ class Mapper
3
+ def mount_routes
4
+ mount AnyLoginMultiple::Engine => '/any_login_multiple', as: 'any_login_multiple'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,3 @@
1
+ module AnyLoginMultiple
2
+ VERSION = '0.1.1'
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: any_login_multiple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - kenzo-tanaka
@@ -44,7 +44,7 @@ dependencies:
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
46
  version: 6.1.4.1
47
- description: Easy login with devise, multiple model
47
+ description: Easy way to login with devise, multiple model
48
48
  email:
49
49
  - kenzou.kenzou104809@gmail.com
50
50
  executables: []
@@ -54,22 +54,21 @@ files:
54
54
  - MIT-LICENSE
55
55
  - README.md
56
56
  - Rakefile
57
- - app/controllers/easy_login/application_controller.rb
58
- - app/helpers/easy_login/application_helper.rb
59
- - app/views/easy_login/_easy_login.html.erb
57
+ - app/controllers/any_login_multiple/application_controller.rb
58
+ - app/views/any_login_multiple/_any_login_multiple.html.erb
60
59
  - config/routes.rb
61
- - lib/easy_login.rb
62
- - lib/easy_login/engine.rb
63
- - lib/easy_login/helpers.rb
64
- - lib/easy_login/routes.rb
65
- - lib/easy_login/version.rb
66
- homepage: https://github.com/kenzo-tanaka/easy_login
60
+ - lib/any_login_multiple.rb
61
+ - lib/any_login_multiple/engine.rb
62
+ - lib/any_login_multiple/helpers.rb
63
+ - lib/any_login_multiple/routes.rb
64
+ - lib/any_login_multiple/version.rb
65
+ homepage: https://github.com/kenzo-tanaka/any_login_multiple
67
66
  licenses:
68
67
  - MIT
69
68
  metadata:
70
- homepage_uri: https://github.com/kenzo-tanaka/easy_login
71
- source_code_uri: https://github.com/kenzo-tanaka/easy_login
72
- changelog_uri: https://github.com/kenzo-tanaka/easy_login/blob/main/CHANGELOG.md
69
+ homepage_uri: https://github.com/kenzo-tanaka/any_login_multiple
70
+ source_code_uri: https://github.com/kenzo-tanaka/any_login_multiple
71
+ changelog_uri: https://github.com/kenzo-tanaka/any_login_multiple/blob/main/CHANGELOG.md
73
72
  post_install_message:
74
73
  rdoc_options: []
75
74
  require_paths:
@@ -88,5 +87,5 @@ requirements: []
88
87
  rubygems_version: 3.1.6
89
88
  signing_key:
90
89
  specification_version: 4
91
- summary: Easy login with devise, multiple model
90
+ summary: Easy way to login with devise, multiple model
92
91
  test_files: []
@@ -1,7 +0,0 @@
1
- module EasyLogin
2
- module ApplicationHelper
3
- def render_easy_login
4
- render 'easy_login/easy_login'
5
- end
6
- end
7
- end
@@ -1,65 +0,0 @@
1
- <div class="easy-login-wrapper" style="opacity: 70%;">
2
- <a class="easy-login-trigger">Display Form</a>
3
- <div class="easy-login-forms-container" style='display: none;'>
4
- <% EasyLogin.klass_names.each do |klass_name| %>
5
- <%= form_with url: easy_login.sign_in_path(as: klass_name), class: 'easy-login-form', method: :post do |form| %>
6
- <label>
7
- <%= klass_name %>
8
- </label>
9
- <%= form.select :id, klass_name.constantize.pluck(:email, :id) %>
10
- <%= form.submit 'Submit' %>
11
- <% end %>
12
- <% end %>
13
- </div>
14
- </div>
15
-
16
- <style>
17
- .easy-login-wrapper {
18
- position: fixed;
19
- bottom: 0;
20
- left: 0;
21
- background: #5c4383;
22
- color: white;
23
- z-index: 100;
24
- padding: 5px 10px;
25
- }
26
- .easy-login-trigger {
27
- color: white;
28
- cursor: pointer;
29
- }
30
- </style>
31
-
32
- <script type="text/javascript" charset="utf-8">
33
- window.EasyLogin = window.EasyLogin || {};
34
-
35
- window.EasyLogin.on_select_change = () => {
36
- const easyLoginForm = document.querySelectorAll('.easy-login-form');
37
- easyLoginForm.forEach(form => {
38
- const select = form.querySelector('select')
39
- select.addEventListener('change', () => {
40
- form.submit();
41
- })
42
- })
43
- }
44
-
45
- window.EasyLogin.on_select_change();
46
-
47
- window.EasyLogin.display_forms = () => {
48
- const trigger = document.querySelector('.easy-login-trigger');
49
- const wrapper = document.querySelector('.easy-login-wrapper')
50
-
51
- trigger.addEventListener('click', () => {
52
- const formBox = document.querySelector('.easy-login-forms-container');
53
- if (formBox.style.display == 'none') {
54
- formBox.style.display = 'block'
55
- wrapper.style.opacity = '100%'
56
- trigger.textContent = 'Hide Form'
57
- } else {
58
- formBox.style.display = 'none'
59
- wrapper.style.opacity = '70%'
60
- trigger.textContent = 'Display Form'
61
- }
62
- })
63
- }
64
- window.EasyLogin.display_forms();
65
- </script>
data/lib/easy_login.rb DELETED
@@ -1,16 +0,0 @@
1
- require "easy_login/version"
2
- require "easy_login/engine"
3
-
4
- module EasyLogin
5
- extend ActiveSupport::Autoload
6
- autoload :Helpers
7
-
8
- mattr_accessor :klass_names
9
- @@klass_names = ['User']
10
-
11
- def self.klasses
12
- @@klasses = EasyLogin.klass_names.map(&:constantize)
13
- end
14
- end
15
-
16
- require 'easy_login/routes'
@@ -1,11 +0,0 @@
1
- module EasyLogin
2
- class Engine < ::Rails::Engine
3
- isolate_namespace EasyLogin
4
-
5
- initializer 'easy_login.helpers' do
6
- ActiveSupport.on_load :action_view do
7
- include EasyLogin::Helpers
8
- end
9
- end
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- module EasyLogin
2
- module Helpers
3
- # extend ActiveSupport::Concern
4
-
5
- def easy_login_here
6
- render 'easy_login/easy_login'
7
- end
8
- end
9
- end
@@ -1,7 +0,0 @@
1
- module ActionDispatch::Routing
2
- class Mapper
3
- def mount_routes
4
- mount EasyLogin::Engine => '/easy_login', as: 'easy_login'
5
- end
6
- end
7
- end
@@ -1,3 +0,0 @@
1
- module EasyLogin
2
- VERSION = '0.1.0'
3
- end