Commit 030f00c3 authored by Dave Syer's avatar Dave Syer

Convert actuator-ui sample to FreeMarker

See gh-679
parent 50190a4d
...@@ -49,7 +49,6 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver; ...@@ -49,7 +49,6 @@ import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
*/ */
@Configuration @Configuration
@ConditionalOnClass(freemarker.template.Configuration.class) @ConditionalOnClass(freemarker.template.Configuration.class)
@ConditionalOnWebApplication
@AutoConfigureAfter(WebMvcAutoConfiguration.class) @AutoConfigureAfter(WebMvcAutoConfiguration.class)
public class FreeMarkerAutoConfiguration { public class FreeMarkerAutoConfiguration {
...@@ -60,7 +59,7 @@ public class FreeMarkerAutoConfiguration { ...@@ -60,7 +59,7 @@ public class FreeMarkerAutoConfiguration {
public static final String DEFAULT_SUFFIX = ".ftl"; public static final String DEFAULT_SUFFIX = ".ftl";
@Configuration @Configuration
public static class FreemarkerConfigurerConfiguration implements EnvironmentAware { public static class FreeMarkerConfigurerConfiguration implements EnvironmentAware {
@Autowired @Autowired
private final ResourceLoader resourceLoader = new DefaultResourceLoader(); private final ResourceLoader resourceLoader = new DefaultResourceLoader();
...@@ -105,14 +104,15 @@ public class FreeMarkerAutoConfiguration { ...@@ -105,14 +104,15 @@ public class FreeMarkerAutoConfiguration {
@Configuration @Configuration
@ConditionalOnClass(Servlet.class) @ConditionalOnClass(Servlet.class)
public static class FreemarkerViewResolverConfiguration implements EnvironmentAware { @ConditionalOnWebApplication
public static class FreeMarkerViewResolverConfiguration implements EnvironmentAware {
private RelaxedPropertyResolver environment; private RelaxedPropertyResolver environment;
@Override @Override
public void setEnvironment(Environment environment) { public void setEnvironment(Environment environment) {
this.environment = new RelaxedPropertyResolver(environment, this.environment = new RelaxedPropertyResolver(environment,
"spring.freeMarker."); "spring.freemarker.");
} }
@Bean @Bean
...@@ -135,7 +135,7 @@ public class FreeMarkerAutoConfiguration { ...@@ -135,7 +135,7 @@ public class FreeMarkerAutoConfiguration {
resolver.setAllowSessionOverride(this.environment.getProperty( resolver.setAllowSessionOverride(this.environment.getProperty(
"allowSessionOverride", Boolean.class, false)); "allowSessionOverride", Boolean.class, false));
resolver.setExposeSpringMacroHelpers(this.environment.getProperty( resolver.setExposeSpringMacroHelpers(this.environment.getProperty(
"exposeSpringMacroHelpers", Boolean.class, false)); "exposeSpringMacroHelpers", Boolean.class, true));
resolver.setRequestContextAttribute(this.environment resolver.setRequestContextAttribute(this.environment
.getProperty("requestContextAttribute")); .getProperty("requestContextAttribute"));
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId> <artifactId>spring-boot-starter-freemarker</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
......
<#import "/spring.ftl" as spring />
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"> <html>
<head> <head>
<title>Error</title> <title>Error</title>
<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" <#assign home><@spring.url relativeUrl="/"/></#assign>
href="../../css/bootstrap.min.css" /> <#assign bootstrap><@spring.url relativeUrl="/css/bootstrap.min.css"/></#assign>
<link rel="stylesheet" href="${bootstrap}" />
</head> </head>
<body> <body>
<div class="container"> <div class="container">
<div class="navbar"> <div class="navbar">
<div class="navbar-inner"> <div class="navbar-inner">
<a class="brand" href="http://www.thymeleaf.org"> Thymeleaf - <a class="brand" href="http://www.thymeleaf.org"> Freemarker -
Plain </a> Plain </a>
<ul class="nav"> <ul class="nav">
<li><a th:href="@{/}" href="home.html"> Home </a></li> <li><a href="${home}"> Home </a></li>
</ul> </ul>
</div> </div>
</div> </div>
<h1 th:text="${title}">Title</h1> <h1>Error Page</h1>
<div id="created" th:text="${#dates.format(timestamp)}">July 11, <div id="created">${timestamp?datetime}</div>
2012 2:17:16 PM CDT</div>
<div> <div>
There was an unexpected error (type=<span th:text="${error}">Bad</span>, status=<span th:text="${status}">500</span>). There was an unexpected error (type=${error}, status=${status}).
</div> </div>
<div th:text="${message}">Fake content</div> <div>${message}</div>
<div> <div>
Please contact the operator with the above information. Please contact the operator with the above information.
</div> </div>
......
<#import "/spring.ftl" as spring />
<!DOCTYPE html>
<html>
<head>
<title>${title}</title>
<#assign home><@spring.url relativeUrl="/"/></#assign>
<#assign bootstrap><@spring.url relativeUrl="/css/bootstrap.min.css"/></#assign>
<link rel="stylesheet" href="${bootstrap}" />
</head>
<body>
<div class="container">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="http://www.thymeleaf.org"> Freemarker -
Plain </a>
<ul class="nav">
<li><a href="${home}"> Home </a></li>
</ul>
</div>
</div>
<h1>${title}</h1>
<div>${message}</div>
<div id="created">${date?datetime}</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title th:text="${title}">Title</title>
<link rel="stylesheet" th:href="@{/css/bootstrap.min.css}"
href="../../css/bootstrap.min.css" />
</head>
<body>
<div class="container">
<div class="navbar">
<div class="navbar-inner">
<a class="brand" href="http://www.thymeleaf.org"> Thymeleaf -
Plain </a>
<ul class="nav">
<li><a th:href="@{/}" href="home.html"> Home </a></li>
</ul>
</div>
</div>
<h1 th:text="${title}">Title</h1>
<div th:text="${message}">Fake content</div>
<div id="created" th:text="${#dates.format(date)}">July 11,
2012 2:17:16 PM CDT</div>
</div>
</body>
</html>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment