mirror of
https://github.com/Febbweiss/springboot-react-webpack.git
synced 2026-03-05 06:35:36 +00:00
Optim: populate html template with resource links and hash
This commit is contained in:
@@ -2,7 +2,8 @@ package com.opengroupe.cloud.saas;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.security.oauth2.client.EnableOAuth2Sso;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.thymeleaf.templateresolver.ServletContextTemplateResolver;
|
||||
|
||||
//@EnableOAuth2Sso
|
||||
@SpringBootApplication
|
||||
@@ -11,4 +12,14 @@ public class Application {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(Application.class, args);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ServletContextTemplateResolver templateResolver() {
|
||||
ServletContextTemplateResolver resolver = new ServletContextTemplateResolver();
|
||||
resolver.setPrefix("/templates/");
|
||||
resolver.setSuffix(".html");
|
||||
resolver.setTemplateMode("LEGACYHTML5");
|
||||
resolver.setCacheable(false);
|
||||
return resolver;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import ReactDOMServer from 'react-dom/server';
|
||||
import App from './app.jsx';
|
||||
import $ from 'jquery';
|
||||
|
||||
|
||||
require('bootstrap/dist/css/bootstrap.css');
|
||||
@@ -25,3 +26,6 @@ global.renderServer = function (comments) {
|
||||
);
|
||||
};
|
||||
|
||||
if( !global.nashorn ) {
|
||||
renderClient(initialData);
|
||||
};
|
||||
@@ -1,5 +1,7 @@
|
||||
var global = window = this;
|
||||
|
||||
global.nashorn = true;
|
||||
|
||||
var console = {
|
||||
debug: print,
|
||||
warn: print,
|
||||
|
||||
20
src/main/resources/templates/index-template.html
Normal file
20
src/main/resources/templates/index-template.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns:th="http://www.thymeleaf.org">
|
||||
<head lang="en">
|
||||
<meta charset="UTF-8" />
|
||||
<title>Comments channel</title>
|
||||
</head>
|
||||
<body>
|
||||
<div th:replace="fragments/header"></div>
|
||||
|
||||
<div class="container">
|
||||
<div id="content" th:utext="${markup}"></div>
|
||||
</div>
|
||||
|
||||
<div th:replace="fragments/footer"></div>
|
||||
|
||||
<script th:inline="javascript">
|
||||
var initialData = JSON.parse(/*[[${data}]]*/ '[]');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user