Skip to content

Commit

Permalink
Added login page
Browse files Browse the repository at this point in the history
  • Loading branch information
grahamrhay committed Feb 22, 2015
1 parent bc2655e commit a13b80d
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PROJECT = cowboy_stormpath
DEPS = cowboy
DEPS = cowboy erlydtl
include erlang.mk
40 changes: 40 additions & 0 deletions priv/static/css/login.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
body {
padding-top: 40px;
padding-bottom: 40px;
background-color: #eee;
}

.form-signin {
max-width: 330px;
padding: 15px;
margin: 0 auto;
}
.form-signin .form-signin-heading,
.form-signin .checkbox {
margin-bottom: 10px;
}
.form-signin .checkbox {
font-weight: normal;
}
.form-signin .form-control {
position: relative;
height: auto;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
padding: 10px;
font-size: 16px;
}
.form-signin .form-control:focus {
z-index: 2;
}
.form-signin input[type="email"] {
margin-bottom: -1px;
border-bottom-right-radius: 0;
border-bottom-left-radius: 0;
}
.form-signin input[type="password"] {
margin-bottom: 10px;
border-top-left-radius: 0;
border-top-right-radius: 0;
}
3 changes: 2 additions & 1 deletion src/cowboy_stormpath.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
{applications, [
kernel,
stdlib,
cowboy
cowboy,
erlydtl
]},
{mod, {cowboy_stormpath_app, []}},
{env, []}
Expand Down
1 change: 1 addition & 0 deletions src/cowboy_stormpath_app.erl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
start(_Type, _Args) ->
Dispatch = cowboy_router:compile([
{'_', [
{"/login", login_handler, []},
{"/", cowboy_static, {priv_file, cowboy_stormpath, "static/index.html"}},
{"/[...]", cowboy_static, {priv_dir, cowboy_stormpath, "static/"}}
]}
Expand Down
19 changes: 19 additions & 0 deletions src/login_handler.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-module(login_handler).
-behaviour(cowboy_http_handler).

-export([init/3]).
-export([handle/2]).
-export([terminate/3]).

-record(state, {}).

init(_, Req, _Opts) ->
{ok, Req, #state{}}.

handle(Req, State=#state{}) ->
{ok, Body} = login_dtl:render(),
{ok, Req2} = cowboy_req:reply(200, [{<<"content-type">>, <<"text/html">>}], Body, Req),
{ok, Req2, State}.

terminate(_Reason, _Req, _State) ->
ok.
48 changes: 48 additions & 0 deletions templates/login.dtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">

<title>Log in</title>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" rel="stylesheet">

<link href="css/login.css" rel="stylesheet">

<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>

<body>

<div class="container">

<form class="form-signin" action="/login">
<h2 class="form-signin-heading">Log in</h2>
<label for="inputEmail" class="sr-only">Email address</label>
<input type="email" id="inputEmail" class="form-control" placeholder="Email address" required autofocus>
<label for="inputPassword" class="sr-only">Password</label>
<input type="password" id="inputPassword" class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit">Log in</button>
<button class="btn btn-default" type="submit">Sign up</button>
<button class="btn btn-default" type="submit">Reset password</button>
</form>

</div> <!-- /container -->

</body>

</html>

0 comments on commit a13b80d

Please sign in to comment.