Skip to content

Commit 38174b0

Browse files
committed
Add login form
1 parent b8289cf commit 38174b0

File tree

5 files changed

+182
-2
lines changed

5 files changed

+182
-2
lines changed

config/stagefront.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
return [
44

5+
/**
6+
* Set an optional URL of the live version of the website.
7+
* This will be displayed on the login screen if set.
8+
* For example: 'https://www.site.com'
9+
*
10+
* Default: null
11+
*/
12+
'live_site' => env('STAGEFRONT_LIVE_SITE', null),
13+
514
/**
615
* Enable StageFront to prevent anyone from accessing the website
716
* without first entering a login and password.

resources/lang/en/form.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
return [
4+
5+
'intro' => 'Please log in to access our website.',
6+
'live' => 'Or visit our live site:<br><a href=":url">:host</a>',
7+
8+
'labels' => [
9+
'login' => 'Login',
10+
'password' => 'Password',
11+
],
12+
13+
'buttons' => [
14+
'submit' => 'Continue',
15+
],
16+
17+
];

resources/lang/nl/form.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
return [
4+
5+
'intro' => 'Log in om toegang te krijgen tot onze website.',
6+
'live' => 'Of bezoek onze live site:<br><a href=":url">:host</a>',
7+
8+
'labels' => [
9+
'login' => 'Login',
10+
'password' => 'Wachtwoord',
11+
],
12+
13+
'buttons' => [
14+
'submit' => 'Doorgaan',
15+
],
16+
17+
];

resources/views/login.blade.php

Lines changed: 129 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,137 @@
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
66
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7-
<title>Document</title>
7+
<title>{{ config('app.name') }}</title>
8+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:300,700">
9+
<style>
10+
html, body {
11+
height: 100%;
12+
margin: 0;
13+
}
14+
body {
15+
display: flex;
16+
flex-direction: row;
17+
align-items: center;
18+
justify-content: center;
19+
font-family: 'Lato', sans-serif;
20+
text-align: center;
21+
font-size: 20px;
22+
}
23+
.stagefront-form > div {
24+
display: flex;
25+
flex-direction: column;
26+
padding: .5em 1em;
27+
}
28+
.stagefront-form input, .stagefront-form button {
29+
flex-grow: 1;
30+
}
31+
.stagefront-live-link {
32+
font-size: .7em;
33+
}
34+
input, button {
35+
line-height: 1.5em;
36+
padding: .5em;
37+
font-size: 1rem;
38+
box-shadow: none;
39+
}
40+
input:focus, button:focus {
41+
outline: none;
42+
box-shadow: none;
43+
border: 1px solid #212121;
44+
}
45+
input {
46+
border: 1px solid #cccccc;
47+
}
48+
button {
49+
background: #212121;
50+
color: #ffffff;
51+
border: 1px solid #212121;
52+
cursor: pointer;
53+
}
54+
input::-webkit-input-placeholder {
55+
color: #cccccc;
56+
}
57+
input:-moz-placeholder {
58+
color: #cccccc;
59+
opacity: 1;
60+
}
61+
input::-moz-placeholder {
62+
color: #cccccc;
63+
opacity: 1;
64+
}
65+
input:-ms-input-placeholder {
66+
color: #cccccc;
67+
}
68+
a, a:visited, a:active {
69+
color: #00a7ed;
70+
text-decoration: none;
71+
}
72+
a:hover {
73+
text-decoration: underline;
74+
}
75+
.error {
76+
color: #ea000d;
77+
margin: 1em 0 0;
78+
font-size: .7em;
79+
}
80+
.sr-only {
81+
display: none;
82+
}
83+
.caps {
84+
text-transform: uppercase;
85+
}
86+
</style>
887
</head>
988
<body>
1089

90+
<section class="stagefront-screen">
91+
92+
<h1 class="stagefront-title caps">{{ config('app.name') }}</h1>
93+
94+
<p>{{ trans('stagefront::form.intro') }}</p>
95+
96+
<form action="{{ config('stagefront.url') }}" method="post" class="stagefront-form">
97+
{{ csrf_field() }}
98+
99+
<div>
100+
<label class="sr-only">
101+
{{ trans('stagefront::form.labels.login') }}
102+
</label>
103+
<input name="login"
104+
value="{{ old('login') }}"
105+
placeholder="{{ trans('stagefront::form.labels.login') }}"
106+
autocomplete="off"
107+
autofocus
108+
required>
109+
{!! $errors->first('login', '<p class="error">&cross; :message</p>') !!}
110+
</div>
111+
112+
<div>
113+
<label class="sr-only">
114+
{{ trans('stagefront::form.labels.password') }}
115+
</label>
116+
<input name="password"
117+
type="password"
118+
placeholder="{{ trans('stagefront::form.labels.password') }}"
119+
required>
120+
{!! $errors->first('password', '<p class="error">&cross; :message</p>') !!}
121+
</div>
122+
123+
<div>
124+
<button type="submit" class="caps">
125+
{{ trans('stagefront::form.buttons.submit') }} &rangle;
126+
</button>
127+
</div>
128+
129+
@if ($liveSite)
130+
<div class="stagefront-live-link">
131+
{!! trans('stagefront::form.live', $liveSite) !!}
132+
</div>
133+
@endif
134+
135+
</form>
136+
137+
</section>
138+
11139
</body>
12140
</html>

src/Controllers/StageFrontController.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@ class StageFrontController extends Controller
1414
*/
1515
public function create()
1616
{
17-
return view('stagefront::login');
17+
$liveSite = config('stagefront.live_site');
18+
19+
if ($liveSite) {
20+
$liveSite = [
21+
'url' => $liveSite,
22+
'host' => parse_url($liveSite, PHP_URL_HOST),
23+
];
24+
}
25+
26+
return view('stagefront::login', compact('liveSite'));
1827
}
1928

2029
/**

0 commit comments

Comments
 (0)