Skip to content

Commit aeaf501

Browse files
committed
removing devise login page template, providing integration docs instead
1 parent 34a6cad commit aeaf501

File tree

4 files changed

+114
-52
lines changed

4 files changed

+114
-52
lines changed

docs/api/templates/devise/README.md

Lines changed: 0 additions & 2 deletions
This file was deleted.

docs/api/templates/devise/login.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

docs/integrations/devise.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Devise integration
2+
3+
Please review the general guide on how to integrate `Devise` into Matestack within the docs of `matestack-ui-core`.
4+
5+
Below you find examples implementing typical Devise views with `matestack-ui-bootstrap`
6+
7+
## Login Page
8+
9+
```ruby
10+
class Devise::Pages::SignIn < Matestack::Ui::Page
11+
12+
def response
13+
bs_container class: "mt-5" do
14+
bs_row class: "mt-5", vertical: :center, horizontal: :center do
15+
bs_col md:4 do
16+
login_form_partial
17+
end
18+
end
19+
end
20+
end
21+
22+
private
23+
24+
def login_form_partial
25+
section class: "mt-5 rounded shadow-sm p-4 mb-4" do
26+
heading size: 2, text: 'Sign in'
27+
form form_config do
28+
div class: "mb-3 mt-4" do
29+
bs_form_input label: 'Email', key: :email, type: :email
30+
end
31+
div class: "mb-3" do
32+
bs_form_input label: 'Password', key: :password, type: :password
33+
end
34+
div class: "mb-3" do
35+
bs_form_submit text: "Sign in"
36+
end
37+
end
38+
toggle show_on: 'sign_in_failure' do
39+
plain 'Your email or password is not valid.'
40+
end
41+
end
42+
end
43+
44+
def form_config
45+
{
46+
for: :admin,
47+
method: :post,
48+
path: admin_session_path,
49+
delay: 500,
50+
success: {
51+
redirect: {
52+
follow_response: true
53+
}
54+
},
55+
failure: {
56+
emit: 'sign_in_failure'
57+
}
58+
}
59+
end
60+
61+
end
62+
63+
```
Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,56 @@
1-
class Devise::Pages::SignIn < Matestack::Ui::Bootstrap::Pages::Devise::SignIn
1+
class Devise::Pages::SignIn < Matestack::Ui::Page
22

3-
def form_config
4-
{
5-
for: :admin,
6-
method: :post,
7-
path: admin_session_path,
8-
delay: 500,
9-
success: {
10-
redirect: {
11-
follow_response: true
3+
def response
4+
bs_container class: "mt-5" do
5+
bs_row class: "mt-5", vertical: :center, horizontal: :center do
6+
bs_col md:4 do
7+
login_form_partial
8+
end
9+
end
10+
end
11+
end
12+
13+
private
14+
15+
def login_form_partial
16+
section class: "mt-5 rounded shadow-sm p-4 mb-4" do
17+
heading size: 2, text: 'Sign in'
18+
form form_config do
19+
div class: "mb-3 mt-4" do
20+
bs_form_input label: 'Email', key: :email, type: :email
21+
end
22+
div class: "mb-3" do
23+
bs_form_input label: 'Password', key: :password, type: :password
24+
end
25+
div class: "mb-3" do
26+
bs_form_submit text: "Sign in"
27+
end
28+
end
29+
toggle show_on: 'sign_in_failure' do
30+
plain 'Your email or password is not valid.'
31+
end
32+
br
33+
small text: "Dummy user: admin@matestack.io"
34+
br
35+
small text: "Dummy password: password"
36+
end
37+
end
38+
39+
def form_config
40+
{
41+
for: :admin,
42+
method: :post,
43+
path: admin_session_path,
44+
delay: 500,
45+
success: {
46+
redirect: {
47+
follow_response: true
48+
}
49+
},
50+
failure: {
51+
emit: 'sign_in_failure'
1252
}
13-
},
14-
failure: {
15-
emit: 'sign_in_failure'
1653
}
17-
}
18-
end
54+
end
1955

2056
end

0 commit comments

Comments
 (0)