Adding versioning for js files

This commit is contained in:
BrokenFire 2018-02-16 14:18:28 +01:00
parent 969159a525
commit bfd1203536
7 changed files with 70 additions and 23 deletions

View File

@ -1,10 +1,10 @@
package net.Broken;
import net.Broken.RestApi.ApiCommandLoader;
import net.Broken.Tools.Command.CommandParser;
import net.Broken.Tools.EmbedMessageUtils;
import net.Broken.Tools.UserManager.UserRegister;
import net.Broken.Tools.UserSpamUtils;
import net.Broken.RestApi.ApiCommandLoader;
import net.dv8tion.jda.core.JDA;
import net.dv8tion.jda.core.entities.ChannelType;
import net.dv8tion.jda.core.entities.Message;
@ -18,7 +18,6 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Controller;
import java.security.SecureRandom;
import java.util.ArrayList;
import java.util.HashMap;

View File

@ -0,0 +1,13 @@
package net.Broken.webView;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class GeneralWebView {
@RequestMapping("/")
public String music(Model model){
return "index";
}
}

View File

@ -0,0 +1,33 @@
package net.Broken.webView;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.resource.ContentVersionStrategy;
import org.springframework.web.servlet.resource.ResourceUrlEncodingFilter;
import org.springframework.web.servlet.resource.VersionResourceResolver;
@Configuration
public class MvcApplication extends WebMvcConfigurerAdapter {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
VersionResourceResolver versionResourceResolver = new VersionResourceResolver()
.addVersionStrategy(new ContentVersionStrategy(), "/**");
registry.addResourceHandler("/js/*.js")
.addResourceLocations("classpath:/static/js/")
.setCachePeriod(60 * 60 * 24 * 365) /* one year */
.resourceChain(true)
.addResolver(versionResourceResolver);
}
@Bean
public ResourceUrlEncodingFilter resourceUrlEncodingFilter() {
return new ResourceUrlEncodingFilter();
}
}

View File

@ -3,18 +3,19 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
<title>Discord Bot</title>
<title>Music Control - Discord Bot</title>
<link rel="icon"
type="image/x-icon"
href="favicon.png"/>
href="/favicon.png"/>
<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
<link href="css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="/css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/>
<link href="/css/style.css" type="text/css" rel="stylesheet" media="screen,projection"/>
</head>
<body class="blue-grey lighten-5" >
<!--__________________________________________________________-->
<!-- NAV BAR -->
<!-- AND -->
@ -25,10 +26,10 @@
<a id="logo-container" href="/" class="brand-logo">Discord Bot</a>
<ul class="right hide-on-med-and-down">
<li class="active">
<li class="">
<a class="waves-effect waves-light sidenav-trigger" href="/" data-target="slide-out">Home</a>
</li>
<li>
<li class="active">
<a class="waves-effect waves-light" href="/music" >Music Control</a>
</li>
<li id="nav-bar-account">
@ -44,6 +45,8 @@
<li>
<a class="waves-effect waves-light sidenav-trigger" href="/music" data-target="slide-out" >Music Control</a>
</li>
<!--TODO Connection mobile-->
</ul>
<a href="#" data-activates="nav-mobile" class="button-navbar-mobile button-collapse"><i class="material-icons">menu</i></a>
</div>
@ -115,19 +118,17 @@
<!-- -->
<!--__________________________________________________________-->
<div class="section no-pad-bot main" id="index-banner">
</div>
<!-- Scripts-->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/materialize.js"></script>
<script src="js/navabar.js"></script>
<script src="js/js.cookie.js"></script>
<!--<script src="js/init.js"></script>-->
<script th:src="@{/js/materialize.js}"></script>
<script th:src="@{/js/navabar.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script>
</body>
</html>

View File

@ -290,13 +290,14 @@
<!-- Scripts-->
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/materialize.js"></script>
<script src="js/init.js"></script>
<script>
var needLogin = true;
</script>
<script src="js/navabar.js"></script>
<script src="js/js.cookie.js"></script>
<script th:src="@{/js/materialize.js}"></script>
<script th:src="@{/js/music.js}"></script>
<script th:src="@{/js/navabar.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script>
</body>
</html>

View File

@ -192,10 +192,10 @@
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="js/materialize.js"></script>
<script src="js/register.js"></script>
<script src="js/navabar.js"></script>
<script src="js/js.cookie.js"></script>
<script th:src="@{/js/materialize.js}"></script>
<script th:src="@{/js/register.js}"></script>
<script th:src="@{/js/navabar.js}"></script>
<script th:src="@{/js/js.cookie.js}"></script>
<script th:inline="javascript">