any_login_multiple 0.1.0 → 0.1.4

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: b0401e670329ebdd24333641ba6cf55aef7e6f1109cae162e68c2d0776fdaad1
4
- data.tar.gz: 8637a30170006164e1f410ebb05451210e1cbd010b3f29ef06db1c5639c5a926
3
+ metadata.gz: 87e86525fe8b0e35c140afdc41cc609c031e50c8485687e19bf6b6798bf8e9f1
4
+ data.tar.gz: 2440c4a9db4d4cccf84b28a399795e11ff0f789775b5f5fcd89248badcaeb646
5
5
  SHA512:
6
- metadata.gz: a6f6808f8fe997c82843558fb6428f09a7f51c94bf407b5ab6322d1d0d1da55f1027f29f0b20e44ddff8874749ed9fdbd0a556e9403446d6d6cef8488e98e839
7
- data.tar.gz: 7e8193f0dbc3f02fc600f6b303710c984e89673deb6715eac634b8146a5210249f8fbfcb4d19ee279fa33e1b67f79557510fffa502c3f0301845b371008e8b0e
6
+ metadata.gz: 9bbe61d9e8cdcf7c926004a9f5695f079923b760909c248bf155b7eabf60fa0774280485dbf606ab1f41f163be59bc410e6a0c28f0cf75f30e5607d25633bdc3
7
+ data.tar.gz: 252bd1d009777fe4ee677106251218e18b2961b03adc3951c1021ece085b6c36b42e2cd464cf55ec4cb1188d4910a5cf540e5eebab697199ffb6e292c003caf9
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # EasyLogin
1
+ # AnyLoginMultiple
2
2
 
3
3
  This gem is inspired by [any_login](https://github.com/igorkasyanchuk/any_login).
4
- This gem supports multiple model support.
4
+ This gem supports multiple models.
5
5
 
6
6
  ## Installation
7
7
 
@@ -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,69 @@
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
+ <% end %>
11
+ <% end %>
12
+ </div>
13
+ </div>
14
+
15
+ <style>
16
+ .any-login-multiple-wrapper {
17
+ position: fixed;
18
+ bottom: 0;
19
+ left: 0;
20
+ background: #5c4383;
21
+ z-index: 100;
22
+ padding: 10px 5px;
23
+ }
24
+ .any-login-multiple-wrapper a, label {
25
+ color: white;
26
+ }
27
+ .any-login-multiple-form {
28
+ margin: 10px 0;
29
+ }
30
+ .any-login-multiple-trigger {
31
+ color: white;
32
+ cursor: pointer;
33
+ }
34
+ </style>
35
+
36
+ <script type="text/javascript" charset="utf-8">
37
+ window.AnyLoginMultiple = window.AnyLoginMultiple || {};
38
+
39
+ window.AnyLoginMultiple.on_select_change = () => {
40
+ const anyLoginMultipleForm = document.querySelectorAll('.any-login-multiple-form');
41
+ anyLoginMultipleForm.forEach(form => {
42
+ const select = form.querySelector('select')
43
+ select.addEventListener('change', () => {
44
+ form.submit();
45
+ })
46
+ })
47
+ }
48
+
49
+ window.AnyLoginMultiple.on_select_change();
50
+
51
+ window.AnyLoginMultiple.display_forms = () => {
52
+ const trigger = document.querySelector('.any-login-multiple-trigger');
53
+ const wrapper = document.querySelector('.any-login-multiple-wrapper')
54
+
55
+ trigger.addEventListener('click', () => {
56
+ const formBox = document.querySelector('.any-login-multiple-forms-container');
57
+ if (formBox.style.display == 'none') {
58
+ formBox.style.display = 'block'
59
+ wrapper.style.opacity = '100%'
60
+ trigger.textContent = 'Hide Form'
61
+ } else {
62
+ formBox.style.display = 'none'
63
+ wrapper.style.opacity = '70%'
64
+ trigger.textContent = 'Display Form'
65
+ }
66
+ })
67
+ }
68
+ window.AnyLoginMultiple.display_forms();
69
+ </script>
data/config/routes.rb CHANGED
@@ -1,7 +1,3 @@
1
- EasyLogin::Engine.routes.draw do
2
- post '/easy_login/sign_in', to: 'application#easy_login', as: :sign_in
3
- end
4
-
5
- Rails.application.routes.draw do
6
- mount_routes
1
+ AnyLoginMultiple::Engine.routes.draw do
2
+ post '/any_login_multiple/sign_in', to: 'application#any_login_multiple', as: :sign_in
7
3
  end
@@ -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.4'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
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.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - kenzo-tanaka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-08-22 00:00:00.000000000 Z
11
+ date: 2021-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: devise
@@ -28,23 +28,17 @@ dependencies:
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 6.1.4
34
31
  - - ">="
35
32
  - !ruby/object:Gem::Version
36
- version: 6.1.4.1
33
+ version: 4.2.7
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - "~>"
42
- - !ruby/object:Gem::Version
43
- version: 6.1.4
44
38
  - - ">="
45
39
  - !ruby/object:Gem::Version
46
- version: 6.1.4.1
47
- description: Easy login with devise, multiple model
40
+ version: 4.2.7
41
+ description: Easy way to login with devise, multiple model
48
42
  email:
49
43
  - kenzou.kenzou104809@gmail.com
50
44
  executables: []
@@ -54,22 +48,21 @@ files:
54
48
  - MIT-LICENSE
55
49
  - README.md
56
50
  - 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
51
+ - app/controllers/any_login_multiple/application_controller.rb
52
+ - app/views/any_login_multiple/_any_login_multiple.html.erb
60
53
  - 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
54
+ - lib/any_login_multiple.rb
55
+ - lib/any_login_multiple/engine.rb
56
+ - lib/any_login_multiple/helpers.rb
57
+ - lib/any_login_multiple/routes.rb
58
+ - lib/any_login_multiple/version.rb
59
+ homepage: https://github.com/kenzo-tanaka/any_login_multiple
67
60
  licenses:
68
61
  - MIT
69
62
  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
63
+ homepage_uri: https://github.com/kenzo-tanaka/any_login_multiple
64
+ source_code_uri: https://github.com/kenzo-tanaka/any_login_multiple
65
+ changelog_uri: https://github.com/kenzo-tanaka/any_login_multiple/blob/main/CHANGELOG.md
73
66
  post_install_message:
74
67
  rdoc_options: []
75
68
  require_paths:
@@ -88,5 +81,5 @@ requirements: []
88
81
  rubygems_version: 3.1.6
89
82
  signing_key:
90
83
  specification_version: 4
91
- summary: Easy login with devise, multiple model
84
+ summary: Easy way to login with devise, multiple model
92
85
  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