Skip to content

Commit

Permalink
Merge branch 'donhuvy-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kolorobot committed Jun 19, 2017
2 parents 4e489e7 + a92ec87 commit e2c9bce
Show file tree
Hide file tree
Showing 26 changed files with 93 additions and 78 deletions.
16 changes: 8 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>pl.codeleak.demos.sbt</groupId>
<artifactId>spring-boot-thymeleaf</artifactId>
<version>1.0</version>
<version>1.0.0-SNAPSHOT</version>
<name>spring-boot-thymeleaf</name>
<packaging>war</packaging>

Expand All @@ -13,7 +13,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<version>1.5.4.RELEASE</version>
</parent>

<!-- Spring IO Platform for dependency management -->
Expand All @@ -38,10 +38,10 @@
<failOnMissingWebXml>false</failOnMissingWebXml>
<!-- Overriding version of selected dependencies -->
<!-- Work when using spring-boot-starter-parent, not platform-bom -->
<thymeleaf.version>3.0.3.RELEASE</thymeleaf.version>
<thymeleaf.version>3.0.6.RELEASE</thymeleaf.version>
<thymeleaf-extras-java8time.version>3.0.0.RELEASE</thymeleaf-extras-java8time.version>
<thymeleaf-layout-dialect.version>2.2.0</thymeleaf-layout-dialect.version>
<assertj.version>3.6.2</assertj.version>
<thymeleaf-layout-dialect.version>2.2.2</thymeleaf-layout-dialect.version>
<assertj.version>3.8.0</assertj.version>
</properties>

<!-- Add typical dependencies for a web application -->
Expand Down Expand Up @@ -74,12 +74,12 @@
<dependency>
<groupId>org.webjars</groupId>
<artifactId>bootstrap</artifactId>
<version>3.3.6</version>
<version>3.3.7</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>jquery</artifactId>
<version>2.2.1</version>
<version>3.2.1</version>
</dependency>
<!-- Test -->
<dependency>
Expand All @@ -90,7 +90,7 @@
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.53.1</version>
<version>3.4.0</version>
<scope>test</scope>
</dependency>
<!-- Provided (for embedded war support) -->
Expand Down
1 change: 1 addition & 0 deletions src/main/java/pl/codeleak/demos/sbt/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class);
}

}
2 changes: 2 additions & 0 deletions src/main/java/pl/codeleak/demos/sbt/ServletInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@
import org.springframework.boot.web.support.SpringBootServletInitializer;

public class ServletInitializer extends SpringBootServletInitializer {

@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ String index(Model model) {
java.util.Properties properties() {
return System.getProperties();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public void onAuditEvent(AuditApplicationEvent event) {
AuditEvent actualAuditEvent = event.getAuditEvent();

LOG.info("On audit application event: timestamp: {}, principal: {}, type: {}, data: {}",
actualAuditEvent.getTimestamp(),
actualAuditEvent.getPrincipal(),
actualAuditEvent.getType(),
actualAuditEvent.getData()
actualAuditEvent.getTimestamp(),
actualAuditEvent.getPrincipal(),
actualAuditEvent.getType(),
actualAuditEvent.getData()
);
applicationEventPublisher.publishEvent(
new AuditApplicationEvent(
new AuditEvent(actualAuditEvent.getPrincipal(), "CUSTOM_AUDIT_EVENT")
)
new AuditApplicationEvent(
new AuditEvent(actualAuditEvent.getPrincipal(), "CUSTOM_AUDIT_EVENT")
)
);
}

Expand All @@ -47,4 +47,5 @@ public void onAuditEvent(AuditApplicationEvent event) {
public void onCustomAuditEvent(AuditApplicationEvent event) {
LOG.info("Handling custom audit event ...");
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ public AuditEventListener(AuditEventRepository auditEventRepository) {
protected void onAuditEvent(AuditEvent event) {

LOG.info("On audit event: timestamp: {}, principal: {}, type: {}, data: {}",
event.getTimestamp(),
event.getPrincipal(),
event.getType(),
event.getData()
event.getTimestamp(),
event.getPrincipal(),
event.getType(),
event.getData()
);

auditEventRepository.add(event);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,5 @@ public UrlService urlService() {
public interface UrlService {
String getApplicationUrl();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

/**
* Using text templates with Thymeleaf.
*
* <p>
* See http://blog.codeleak.pl/2017/03/getting-started-with-thymeleaf-3-text.html
*/
@Controller
Expand Down Expand Up @@ -101,4 +101,5 @@ public void setTags(String tags) {
this.tags = tags;
}
}

}
4 changes: 0 additions & 4 deletions src/main/resources/application-dev.properties
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#
# Development profile with templates and static resources reloading: http://blog.codeleak.pl/2016/12/thymeleaf-reload-templates-and-static-resources.html
#

# Path to project
project.base-dir=file:///C:/Projects/github/spring-boot-thymeleaf

# Templates reloading during development
spring.thymeleaf.prefix=${project.base-dir}/src/main/resources/templates/
spring.thymeleaf.cache=false

# Static resources reloading during development
spring.resources.static-locations=${project.base-dir}/src/main/resources/static/
spring.resources.cache-period=0

4 changes: 1 addition & 3 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
spring.thymeleaf.cache=true

security.basic.enabled=false
security.user.name=user
security.user.password=demo

management.security.enabled=${security.basic.enabled}
management.security.enabled=${security.basic.enabled}
3 changes: 2 additions & 1 deletion src/main/resources/static/css/core.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ body {
margin: 0 auto;
list-style: none;
}

.social-links > li {
width: 30%;
text-align: center;
vertical-align: middle;
display: inline-block;
margin: auto;
}
}
12 changes: 6 additions & 6 deletions src/main/resources/templates/fragments/alert.html
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.6/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.2.0/js/bootstrap.min.js"
th:href="@{/webjars/bootstrap/3.3.6/js/bootstrap.min.js}"
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/js/bootstrap.min.js"
th:href="@{/webjars/bootstrap/3.3.7/js/bootstrap.min.js}"
rel="stylesheet" media="screen" />
<script src="http://cdn.jsdelivr.net/webjars/jquery/2.1.1/jquery.min.js"
th:src="@{/webjars/jquery/2.2.1/jquery.min.js}"></script>
<script src="http://cdn.jsdelivr.net/webjars/jquery/3.2.1/jquery.min.js"
th:src="@{/webjars/jquery/3.2.1/jquery.min.js}"></script>
</head>
<body>
<div th:fragment="alert (type, message)" class="alert alert-dismissable" th:classappend="'alert-' + ${type}">
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/fragments/footer.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.6/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
</head>
<body>
Expand Down
14 changes: 7 additions & 7 deletions src/main/resources/templates/fragments/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<html xmlns:th="http://www.thymeleaf.org">

<head>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.6/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.6/js/bootstrap.min.js"
th:href="@{/webjars/bootstrap/3.3.6/js/bootstrap.min.js}"
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/js/bootstrap.min.js"
th:href="@{/webjars/bootstrap/3.3.7/js/bootstrap.min.js}"
rel="stylesheet" media="screen" />
<script src="http://cdn.jsdelivr.net/webjars/jquery/2.2.1/jquery.min.js"
th:src="@{/webjars/jquery/2.2.1/jquery.min.js}"></script>
<script src="http://cdn.jsdelivr.net/webjars/jquery/3.2.1/jquery.min.js"
th:src="@{/webjars/jquery/3.2.1/jquery.min.js}"></script>
</head>
<body>

Expand All @@ -33,4 +33,4 @@
</div>
</div>
</body>
</html>
</html>
10 changes: 5 additions & 5 deletions src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<head>
<title>Hello Spring Boot!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.6/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
<link href="../static/css/core.css"
th:href="@{/css/core.css}"
rel="stylesheet" media="screen" />
<script src="http://cdn.jsdelivr.net/webjars/jquery/2.2.1/jquery.min.js"
th:src="@{/webjars/jquery/2.2.1/jquery.min.js}"></script>
<script src="http://cdn.jsdelivr.net/webjars/jquery/3.2.1/jquery.min.js"
th:src="@{/webjars/jquery/3.2.1/jquery.min.js}"></script>
</head>
<body>
<!-- Header -->
Expand Down Expand Up @@ -154,4 +154,4 @@ <h1>Spring Actuator</h1>
</div>
</th:block>
</body>
</html>
</html>
10 changes: 5 additions & 5 deletions src/main/resources/templates/layouts/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
<head>
<title>Hello Spring Boot!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.6/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
<link href="../../static/css/core.css"
th:href="@{/css/core.css}"
rel="stylesheet" media="screen" />
<script src="http://cdn.jsdelivr.net/webjars/jquery/2.2.1/jquery.min.js"
th:src="@{/webjars/jquery/2.2.1/jquery.min.js}"></script>
<script src="http://cdn.jsdelivr.net/webjars/jquery/3.2.1/jquery.min.js"
th:src="@{/webjars/jquery/3.2.1/jquery.min.js}"></script>
</head>
<body>
<!-- Header -->
Expand Down Expand Up @@ -44,4 +44,4 @@
</footer>
</div>
</body>
</html>
</html>
6 changes: 3 additions & 3 deletions src/main/resources/templates/th-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<head>
<title>Hello Spring Boot!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.6/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}" rel="stylesheet" media="screen"/>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/css/bootstrap.min.css" th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}" rel="stylesheet" media="screen"/>
<link href="../static/css/core.css" th:href="@{/css/core.css}" rel="stylesheet" media="screen"/>
<script src="http://cdn.jsdelivr.net/webjars/jquery/2.2.1/jquery.min.js" th:src="@{/webjars/jquery/2.2.1/jquery.min.js}"></script>
<script src="http://cdn.jsdelivr.net/webjars/jquery/3.2.1/jquery.min.js" th:src="@{/webjars/jquery/2.2.1/jquery.min.js}"></script>
</head>
<body>
<!-- Insert content into the layouts/layout.html -->
Expand Down Expand Up @@ -37,4 +37,4 @@ <h2>Processed text template</h2>
</div>
</th:block>
</body>
</html>
</html>
22 changes: 11 additions & 11 deletions src/main/resources/templates/th-objects.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
<head>
<title>Hello Spring Boot!</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.6/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
<link href="http://cdn.jsdelivr.net/webjars/bootstrap/3.3.7/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}"
rel="stylesheet" media="screen" />
<link href="../static/css/core.css"
th:href="@{/css/core.css}"
rel="stylesheet" media="screen" />
<script src="http://cdn.jsdelivr.net/webjars/jquery/2.2.1/jquery.min.js"
th:src="@{/webjars/jquery/2.2.1/jquery.min.js}"></script>
<script src="http://cdn.jsdelivr.net/webjars/jquery/3.2.1/jquery.min.js"
th:src="@{/webjars/jquery/3.2.1/jquery.min.js}"></script>
</head>
<body>
<!-- Insert content into the layouts/layout.html -->
Expand All @@ -26,20 +26,20 @@ <h1>Model Attributes</h1>
<h1>Flash Attribute</h1>
<p th:text="${flash}">None</p>
</section>

<section id="query-params">
<h1>Query Params</h1>
<p th:text="${param.q}">Test</p>
<p th:text="${param.q[0]}" th:unless="${param.q == null}">Test</p>
<p th:text="${#request.getParameter('q')}" th:unless="${#request.getParameter('q') == null}">Test</p>
</section>

<section id="session-attributes">
<h1>Session Attributes</h1>
<p th:text="${session.mySessionAttribute}" th:unless="${session == null}">[...]</p>
<p th:text="${#session.getAttribute('mySessionAttribute')}" th:unless="${#session == null}">[...]</p>
</section>

<section id="servlet-context-attributes">
<h1>Servlet Context</h1>
<table>
Expand All @@ -54,13 +54,13 @@ <h1>Servlet Context</h1>
</tr>
</table>
</section>

<section id="spring-beans">
<h1>Spring Beans</h1>

<p th:text="${@urlService.getApplicationUrl()}">...</p>
</section>

</th:block>
</body>
</html>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ public class HomeControllerClassicTest {
@Test
public void verifiesHomePageLoads() throws Exception {
mockMvc.perform(MockMvcRequestBuilders.get("/"))
.andExpect(MockMvcResultMatchers.model().hasNoErrors())
.andExpect(MockMvcResultMatchers.model().attributeExists("now"))
.andExpect(MockMvcResultMatchers.view().name("index"))
.andExpect(MockMvcResultMatchers.status().isOk());
.andExpect(MockMvcResultMatchers.model().hasNoErrors())
.andExpect(MockMvcResultMatchers.model().attributeExists("now"))
.andExpect(MockMvcResultMatchers.view().name("index"))
.andExpect(MockMvcResultMatchers.status().isOk());
}
}

}
Loading

0 comments on commit e2c9bce

Please sign in to comment.