Skip to content

Commit 82a4e65

Browse files
committed
App pages
1 parent 84e1d64 commit 82a4e65

File tree

7 files changed

+192
-23
lines changed

7 files changed

+192
-23
lines changed

pom.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45
<parent>
56
<groupId>org.springframework.boot</groupId>
67
<artifactId>spring-boot-starter-parent</artifactId>
78
<version>2.5.6</version>
8-
<relativePath /> <!-- lookup parent from repository -->
9+
<relativePath/> <!-- lookup parent from repository -->
910
</parent>
1011
<groupId>com.github.throyer.common.spring-boot</groupId>
1112
<artifactId>api</artifactId>
@@ -157,7 +158,7 @@
157158
<goal>build-info</goal>
158159
</goals>
159160
</execution>
160-
</executions>
161+
</executions>
161162
</plugin>
162163
<plugin>
163164
<groupId>org.sonarsource.scanner.maven</groupId>

src/main/java/com/github/throyer/common/springboot/middlewares/AuthorizationMiddleware.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import javax.servlet.http.HttpServletRequest;
1212
import javax.servlet.http.HttpServletResponse;
1313

14+
import com.github.throyer.common.springboot.domain.services.security.SecurityService;
1415
import org.springframework.stereotype.Component;
1516
import org.springframework.web.filter.OncePerRequestFilter;
1617

@@ -26,7 +27,7 @@ protected void doFilterInternal(
2627
throws ServletException, IOException {
2728

2829
ofNullable(authorization(request))
29-
.ifPresent((token) -> authorize(token));
30+
.ifPresent(SecurityService::authorize);
3031

3132
filter.doFilter(request, response);
3233
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<!-- CSS BASE -->
2-
<th:block th:fragment="base-css">
2+
<th:block th:fragment="default-css">
33
<link rel="stylesheet" type="text/css" th:href="@{/webjars/font-awesome/5.15.4/css/all.min.css}"/>
44
<link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/5.1.3/css/bootstrap.min.css}"/>
55
<link rel="stylesheet" type="text/css" th:href="@{/css/styles.css}">
66
</th:block>
77

88
<!-- JAVASCRIPT BASE -->
9-
<th:block th:fragment="base-javascript">
9+
<th:block th:fragment="default-javascript">
1010
<script language="javascript" th:src="@{/webjars/bootstrap/5.1.3/js/bootstrap.min.js}"></script>
1111
<script language="javascript" th:src="@{/js/main.js}"></script>
1212
</th:block>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<html th:fragment="layout(title, links, content, scripts, modals)">
2+
3+
<!-- head -->
4+
<head>
5+
6+
<title th:replace="${title}">
7+
Common API
8+
</title>
9+
10+
<meta charset="UTF-8">
11+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
12+
<base href="/">
13+
14+
<!-- default links -->
15+
<th:block
16+
th:replace="~{app/fragments/imports :: default-css}">
17+
</th:block>
18+
19+
<!-- custom links -->
20+
<th:block
21+
th:replace="${links}">
22+
</th:block>
23+
</head>
24+
25+
<!-- page body -->
26+
<body class="bg-light ">
27+
28+
<!-- navbar default -->
29+
<nav
30+
th:replace="~{app/fragments/navbar :: navbar}">
31+
</nav>
32+
33+
<!-- content container -->
34+
<div class="container">
35+
<div class="row">
36+
<div class="col">
37+
<!-- page content -->
38+
<th:block th:replace="${content}"></th:block>
39+
</div>
40+
</div>
41+
</div>
42+
43+
<!-- modals section -->
44+
<th:block
45+
th:replace="${modals}">
46+
</th:block>
47+
48+
<!-- default scripts -->
49+
<script
50+
th:replace="~{app/fragments/imports :: default-javascript}">
51+
</script>
52+
53+
<!-- custom scripts -->
54+
<th:block
55+
th:replace="${scripts}">
56+
</th:block>
57+
</body>
58+
</html>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<nav th:fragment="navbar" class="py-2 bg-light border-bottom">
2+
<div class="container d-flex flex-wrap">
3+
<ul class="nav me-auto">
4+
<li class="nav-item">
5+
<a
6+
th:href="@{/app}"
7+
class="nav-link link-dark px-2 active"
8+
aria-current="page"
9+
>
10+
Home
11+
</a>
12+
</li>
13+
14+
</ul>
15+
<ul class="nav">
16+
<li class="nav-item">
17+
<a th:href="@{/app/logout}" class="nav-link link-dark px-2">
18+
Sign out
19+
</a>
20+
</li>
21+
</ul>
22+
</div>
23+
</nav>
Lines changed: 101 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,102 @@
1-
<!DOCTYPE html>
2-
<html lang="en">
3-
<head>
4-
<meta charset="UTF-8">
5-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6-
<meta name="viewport" content="width=device-width, initial-scale=1.0">
1+
<layout th:replace="~{app/fragments/layout :: layout(~{::title}, ~{}, ~{::section}, ~{}, ~{})}">
72
<title>Home</title>
8-
</head>
9-
<body>
10-
<h1>Fumegou!</h1>
11-
<a class="dropdown-item" th:href="@{/app/logout}">
12-
<i class="fas fa-sign-out-alt"></i>
13-
sair
14-
</a>
15-
</body>
16-
</html>
3+
<section>
4+
<div class="col-lg-8 mx-auto p-3 py-md-5">
5+
<header class="d-flex align-items-center pb-3 mb-5 border-bottom">
6+
<a th:href="@{/app}" class="d-flex align-items-center text-dark text-decoration-none">
7+
<img class="d-inline-block align-top ml-2"
8+
src="https://github.com/Throyer/springboot-api-crud/raw/master/assets/tecnologias.png">
9+
</a>
10+
</header>
11+
12+
<main>
13+
14+
<h1>Explore the project</h1>
15+
<p class="fs-5 col-md-8">
16+
This is a simple API and Web App (MVC)
17+
project with a crud of users with as
18+
many good practices as I can.
19+
</p>
20+
<ul class="icon-list">
21+
<li>
22+
Swagger
23+
</li>
24+
<li>
25+
Database migrations (java based)
26+
</li>
27+
<li>
28+
JWT and Refresh token
29+
</li>
30+
<li>
31+
Integration with SMTP services (Email)
32+
</li>
33+
</ul>
34+
<p>
35+
It was meant to be used as a base for larger projects.
36+
</p>
37+
38+
<div class="mb-5">
39+
<a href="https://github.com/Throyer/springboot-api-crud#sumario" target="_blank"
40+
class="btn btn-primary btn-lg px-4">See the repository</a>
41+
</div>
42+
43+
<hr class="col-3 col-md-2 mb-5">
44+
45+
<div class="row g-5">
46+
<div class="col-md-6">
47+
<h2>Other projects</h2>
48+
<p>There is a project on nodejs with a similar idea.</p>
49+
<ul class="icon-list">
50+
<li>
51+
<a href="https://github.com/Throyer/nodejs-api-crud#table-of-contents" rel="noopener"
52+
target="_blank">
53+
NodeJs project
54+
</a>
55+
</li>
56+
<li>
57+
<a href="https://github.com/Throyer/quarkus-api-crud#quarkus-api-crud" rel="noopener"
58+
target="_blank">
59+
Quarkus project
60+
</a>
61+
</li>
62+
<li>
63+
<a href="https://github.com/Throyer/products#requisitos" rel="noopener" target="_blank">
64+
Spring boot project but with PostgreSQL
65+
</a>
66+
</li>
67+
<li class="text-muted">.NetCore project (coming soon!)</li>
68+
</ul>
69+
</div>
70+
71+
<div class="col-md-6">
72+
<h2>Project features</h2>
73+
<p>The idea is to have as many good practices and standards as possible, here are some already
74+
implemented</p>
75+
<ul class="icon-list">
76+
<li>JWT</li>
77+
<li>Refresh token</li>
78+
<li>Tests with JUnity</li>
79+
<li>Test coverage report (Jacoco)</li>
80+
<li>Database migrations</li>
81+
<li><a
82+
href="https://github.com/Throyer/java-based-flyway-migrations#migra%C3%A7%C3%B5es-de-banco-de-dados-baseadas-em-arquivos-java">Java
83+
Based migrations</a></li>
84+
<li>Soft delete</li>
85+
<li>Swagger</li>
86+
<li>Email (SMTP)</li>
87+
<li>Lazy load</li>
88+
<li>Audit fields (created_at, updated_at etc)</li>
89+
</ul>
90+
</div>
91+
</div>
92+
</main>
93+
</div>
94+
<footer class="pt-5 my-5 text-muted border-top">
95+
Throyer &middot; &copy; 2021
96+
</footer>
97+
</section>
98+
<!-- <modal
99+
th:replace="~{views/usuario/fragments/modal-usuario :: modal-usuario}">
100+
</modal>
101+
<script language="javascript" th:src="@{/js/modais/modal-usuario.js}"></script> -->
102+
</layout>

src/main/resources/templates/app/login/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<title>Login</title>
44
<meta charset="UTF-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6-
<th:block th:replace="~{app/fragments/imports :: base-css}"></th:block>
6+
<th:block th:replace="~{app/fragments/imports :: default-css}"></th:block>
77
<link rel="stylesheet" type="text/css" th:href="@{/css/login.css}">
88
</head>
99
<body>
@@ -89,6 +89,6 @@ <h1 class="h3 mb-3 font-weight-light text-center mt-2">Fazer login</h1>
8989
</div>
9090
</form>
9191

92-
<th:block th:replace="~{app/fragments/imports :: base-javascript}"></th:block>
92+
<th:block th:replace="~{app/fragments/imports :: default-javascript}"></th:block>
9393
</body>
9494
</html>

0 commit comments

Comments
 (0)