- Добавил Bootstrap и настроил внешний вид форм приложения.
https://www.youtube.com/watch?v=a51jGwoTNmI&list=PLU2ftbIeotGpAYRP9Iv2KLIwK36-o_qYk&index=13
This commit is contained in:
@@ -5,10 +5,19 @@
|
||||
<title>Sweater</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
||||
<link href="/static/style.css" rel="stylesheet" type="text/css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<#include "navbar.ftl">
|
||||
<div class="container mt-5">
|
||||
<#nested>
|
||||
</div>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.3/dist/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
<#macro login path>
|
||||
<form action="${path}" method="post">
|
||||
<div><label> User Name : <input type="text" name="username"/> </label></div>
|
||||
<div><label> Password: <input type="password" name="password"/> </label></div>
|
||||
<div><input type="submit" value="Sign in"/></div>
|
||||
<input type="hidden" name="_csrf" value="${_csrf.token}" />
|
||||
<#macro login path isRegistrationForm=false>
|
||||
<form action="${path}" method="post" xmlns="http://www.w3.org/1999/html">
|
||||
<div class="row mb-3">
|
||||
<label class="col-sm-2 col-form-label"> User Name :</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="text" class="form-control" name="username" placeholder="User name"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<label for="inputPassword3" class="col-sm-2 col-form-label"> Password: </label>
|
||||
<div class="col-sm-6">
|
||||
<input type="password" class="form-control" name="password" placeholder="Password">
|
||||
</div>
|
||||
</div>
|
||||
<#if !isRegistrationForm>
|
||||
<a href="/registration" class="btn btn-primary">Add new user</a>
|
||||
</#if>
|
||||
<input class="btn btn-primary" type="submit" <#if isRegistrationForm> value="Create" <#else> value="Sign in"</#if>/>
|
||||
<input type="hidden" name="_csrf" value="${_csrf.token}"/>
|
||||
</form>
|
||||
</#macro>
|
||||
|
||||
<#macro logout>
|
||||
<form action="/logout" method="post">
|
||||
<input type="hidden" name="_csrf" value="${_csrf.token}" />
|
||||
<input type="submit" value="Sign Out"/>
|
||||
<input type="hidden" name="_csrf" value="${_csrf.token}"/>
|
||||
<button type="submit" class="btn btn-primary">Sign Out</button>
|
||||
</form>
|
||||
</#macro>
|
||||
29
src/main/resources/templates/parts/navbar.ftl
Normal file
29
src/main/resources/templates/parts/navbar.ftl
Normal file
@@ -0,0 +1,29 @@
|
||||
<#include "security.ftl">
|
||||
<#import "login.ftl" as l>
|
||||
|
||||
<nav class="navbar navbar-expand-lg bg-body-tertiary">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">Sweater</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" aria-current="page" href="/">Home</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" aria-current="page" href="/main">Messages</a>
|
||||
</li>
|
||||
<#if isAdmin>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" aria-current="page" href="/users">Users</a>
|
||||
</li>
|
||||
</#if>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="navbar-text mr-3" >${name}</div>
|
||||
<div><#if name != "unknown"> <@l.logout /> </#if></div>
|
||||
</div>
|
||||
</nav>
|
||||
16
src/main/resources/templates/parts/security.ftl
Normal file
16
src/main/resources/templates/parts/security.ftl
Normal file
@@ -0,0 +1,16 @@
|
||||
<#assign
|
||||
known = SPRING_SECURITY_CONTEXT??
|
||||
>
|
||||
|
||||
<#if known>
|
||||
<#assign
|
||||
user = SPRING_SECURITY_CONTEXT.authentication.principal
|
||||
name = user.getUsername()
|
||||
isAdmin = user.isAdmin()
|
||||
>
|
||||
<#else>
|
||||
<#assign
|
||||
name = "unknown"
|
||||
isAdmin = false
|
||||
>
|
||||
</#if>
|
||||
Reference in New Issue
Block a user