Adds Bootstrap and ThymeLeaf managment

This commit is contained in:
fecaille
2016-03-10 12:59:44 +01:00
parent 58a1bd06a1
commit 918f8fb20f
10 changed files with 190 additions and 26 deletions

57
pom.xml
View File

@@ -17,6 +17,7 @@
<properties> <properties>
<java.version>1.8</java.version> <java.version>1.8</java.version>
<jasmine.version>2.4.1</jasmine.version> <jasmine.version>2.4.1</jasmine.version>
<jasmine-ajax.version>3.2.0</jasmine-ajax.version> <jasmine-ajax.version>3.2.0</jasmine-ajax.version>
@@ -38,7 +39,37 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId> <artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency> </dependency>
<!-- Testing --> <!-- Security -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity4</artifactId>
</dependency>
<!-- Persistence -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
</dependency>
<!-- Testing -->
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
@@ -118,7 +149,17 @@
<configuration> <configuration>
<watches> <watches>
<watch> <watch>
<directory>src/main/webapp/js</directory> <excludes>
<exclude>src/main/resources/static/js/bundle</exclude>
<exclude>src/main/resources/static/js/jsx</exclude>
</excludes>
<recursive>false</recursive>
<directory>src/main/resources/static/js</directory>
</watch>
<watch>
<exclude>src/main/resources/static/css/bundle</exclude>
<recursive>false</recursive>
<directory>src/main/resources/static/css</directory>
</watch> </watch>
<watch> <watch>
<directory>src/main/wro</directory> <directory>src/main/wro</directory>
@@ -141,7 +182,9 @@
</goals> </goals>
<configuration> <configuration>
<target> <target>
<delete dir="${project.basedir}/src/main/resources/static" /> <delete dir="${project.basedir}/src/main/resources/static/js/bundle" />
<delete dir="${project.basedir}/src/main/resources/static/js/jsx" />
<delete dir="${project.basedir}/src/main/resources/static/css/bundle" />
<delete dir="${project.basedir}/src/test/resources/static/js/compiled" /> <delete dir="${project.basedir}/src/test/resources/static/js/compiled" />
</target> </target>
</configuration> </configuration>
@@ -185,10 +228,10 @@
<configuration> <configuration>
<extension>jsx</extension> <extension>jsx</extension>
<sourcePath> <sourcePath>
${project.basedir}/src/main/webapp/js ${project.basedir}/src/main/resources/static/js
</sourcePath> </sourcePath>
<targetPath> <targetPath>
${project.basedir}/src/main/resources/static/js ${project.basedir}/src/main/resources/static/js/jsx
</targetPath> </targetPath>
</configuration> </configuration>
</execution> </execution>
@@ -224,8 +267,8 @@
</executions> </executions>
<configuration> <configuration>
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory> <wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
<cssDestinationFolder>${project.basedir}/src/main/resources/static/css</cssDestinationFolder> <cssDestinationFolder>${project.basedir}/src/main/resources/static/css/bundle</cssDestinationFolder>
<jsDestinationFolder>${project.basedir}/src/main/resources/static/js</jsDestinationFolder> <jsDestinationFolder>${project.basedir}/src/main/resources/static/js/bundle</jsDestinationFolder>
<wroFile>${project.build.directory}/wro/wro.xml</wroFile> <wroFile>${project.build.directory}/wro/wro.xml</wroFile>
<extraConfigFile>${project.basedir}/src/main/wro/wro.properties</extraConfigFile> <extraConfigFile>${project.basedir}/src/main/wro/wro.properties</extraConfigFile>
</configuration> </configuration>

View File

@@ -0,0 +1,37 @@
package com.opengroupe.cloud.saas.config;
import org.springframework.context.annotation.Bean;
import org.thymeleaf.extras.springsecurity4.dialect.SpringSecurityDialect;
import org.thymeleaf.spring4.SpringTemplateEngine;
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
import org.thymeleaf.templateresolver.TemplateResolver;
import org.thymeleaf.templateresolver.UrlTemplateResolver;
@org.springframework.context.annotation.Configuration
public class WebMvcConfiguration {
// @Bean
// public TemplateResolver templateResolver() {
// TemplateResolver templateResolver = new ThymeleafViewResolver().;
// templateResolver.setPrefix("/resources/templates");
// templateResolver.setSuffix(".html");
// templateResolver.setTemplateMode("HTML5");
// templateResolver.setCacheable(false);
// return templateResolver;
// }
// @Bean
// public UrlTemplateResolver urlTemplateResolver() {
// return new UrlTemplateResolver();
// }
// @Bean
// public SpringTemplateEngine templateEngine() {
// SpringTemplateEngine templateEngine = new SpringTemplateEngine();
//// templateEngine.addTemplateResolver(templateResolver());
// templateEngine.addTemplateResolver(urlTemplateResolver());
// templateEngine.addDialect(new SpringSecurityDialect());
// return templateEngine;
// }
}

View File

@@ -0,0 +1,15 @@
package com.opengroupe.cloud.saas.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().anyRequest().permitAll();
}
}

View File

@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="footer" th:fragment="header">
<div class="container">
<p>&copy; 2016 Footer</p>
</div>
</div>
</body>
</html>

View File

@@ -0,0 +1,39 @@
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="container" th:fragment="header">
<div class="row">
<div class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse"
data-target=".nav-collapse">
<span class="icon-bar"></span> <span class="icon-bar"></span> <span
class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">My project</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#" th:href="@{/}">Home</a></li>
<li><a href="#" th:href="@{/message}">Messages</a></li>
<li><a href="#" th:href="@{/task}">Tasks</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li th:if="${#authorization.expression('!isAuthenticated()')}">
<a href="/signin" th:href="@{/signin}">Sign in</a>
</li>
<li th:if="${#authorization.expression('isAuthenticated()')}">
<a href="/logout" th:href="@{/logout}">Logout</a>
</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</body>
</html>

View File

@@ -1,17 +1,24 @@
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"> <html xmlns:th="http://www.thymeleaf.org">
<head lang="en"> <head lang="en">
<meta charset="UTF-8"/> <meta charset="UTF-8" />
<title>ReactJS</title> <title>Comments channel</title>
<link rel="stylesheet" href="/css/react-bootstrap.css" /> <link rel="stylesheet" href="/css/bundle/react-bootstrap.css" />
</head> <link rel="stylesheet" href="/css/bundle/comments.css" />
<body> </head>
<body>
<div id="content"></div>
<div th:replace="fragments/header"></div>
<script src="/js/react-bootstrap.js"></script>
<script src="/js/bundle.js"></script> <div class="container">
<script src="/js/app.js"></script> <div id="content"></div>
<script src="/js/app.render.js"></script> </div>
</body>
<div th:replace="fragments/footer"></div>
<script src="/js/bundle/react-bootstrap.js"></script>
<script src="/js/bundle/comments.js"></script>
<script src="/js/jsx/app.js"></script>
<script src="/js/jsx/app.render.js"></script>
</body>
</html> </html>

View File

@@ -0,0 +1,7 @@
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #f5f5f5;
}

View File

@@ -1,8 +1,8 @@
debug=true debug=true
# Available processors : http://wro4j.readthedocs.org/en/stable/AvailableProcessors/ # Available processors : http://wro4j.readthedocs.org/en/stable/AvailableProcessors/
preProcessors=lessCssImport #preProcessors=lessCssImport
postProcessors=less4j,cssMin #postProcessors=less4j,cssMin
# explicitly invalidates the cache each 5 seconds # explicitly invalidates the cache each 5 seconds
cacheUpdatePeriod=5 cacheUpdatePeriod=1
# check for changes each 5 seconds and invalidates the cache only when a change is detected # check for changes each 5 seconds and invalidates the cache only when a change is detected
resourceWatcherUpdatePeriod=5 resourceWatcherUpdatePeriod=1

View File

@@ -2,12 +2,15 @@
<groups xmlns="http://www.isdc.ro/wro"> <groups xmlns="http://www.isdc.ro/wro">
<group name="react-bootstrap"> <group name="react-bootstrap">
<css>webjar:bootstrap/@bootstrap.version@/css/bootstrap.css</css> <css>webjar:bootstrap/@bootstrap.version@/css/bootstrap.css</css>
<js>webjar:jquery/@jquery.version@/jquery.js</js> <js>webjar:jquery/@jquery.version@/jquery.js</js>
<js>webjar:react/@react.version@/react-with-addons.js</js> <js>webjar:react/@react.version@/react-with-addons.js</js>
<js>webjar:react/@react.version@/react-dom.js</js> <js>webjar:react/@react.version@/react-dom.js</js>
</group> </group>
<group name="bundle"> <group name="comments">
<css>file:src/main/resources/static/css/comments.css</css>
<js>webjar:marked/@marked-lib.version@/marked.js</js> <js>webjar:marked/@marked-lib.version@/marked.js</js>
</group> </group>
</groups> </groups>