From bfd1203536c64574cbcfe29544f979eac7755b1d Mon Sep 17 00:00:00 2001 From: BrokenFire Date: Fri, 16 Feb 2018 14:18:28 +0100 Subject: [PATCH 1/4] Adding versioning for js files --- src/main/java/net/Broken/MainBot.java | 3 +- .../net/Broken/webView/GeneralWebView.java | 13 ++++++++ .../net/Broken/webView/MvcApplication.java | 33 +++++++++++++++++++ .../resources/static/js/{init.js => music.js} | 0 .../{static => templates}/index.html | 27 +++++++-------- src/main/resources/templates/music.html | 9 ++--- src/main/resources/templates/register.html | 8 ++--- 7 files changed, 70 insertions(+), 23 deletions(-) create mode 100644 src/main/java/net/Broken/webView/GeneralWebView.java create mode 100644 src/main/java/net/Broken/webView/MvcApplication.java rename src/main/resources/static/js/{init.js => music.js} (100%) rename src/main/resources/{static => templates}/index.html (89%) diff --git a/src/main/java/net/Broken/MainBot.java b/src/main/java/net/Broken/MainBot.java index 41b8891..fae51f9 100644 --- a/src/main/java/net/Broken/MainBot.java +++ b/src/main/java/net/Broken/MainBot.java @@ -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; diff --git a/src/main/java/net/Broken/webView/GeneralWebView.java b/src/main/java/net/Broken/webView/GeneralWebView.java new file mode 100644 index 0000000..c16916e --- /dev/null +++ b/src/main/java/net/Broken/webView/GeneralWebView.java @@ -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"; + } +} diff --git a/src/main/java/net/Broken/webView/MvcApplication.java b/src/main/java/net/Broken/webView/MvcApplication.java new file mode 100644 index 0000000..fdd27e3 --- /dev/null +++ b/src/main/java/net/Broken/webView/MvcApplication.java @@ -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(); + } + +} + + + diff --git a/src/main/resources/static/js/init.js b/src/main/resources/static/js/music.js similarity index 100% rename from src/main/resources/static/js/init.js rename to src/main/resources/static/js/music.js diff --git a/src/main/resources/static/index.html b/src/main/resources/templates/index.html similarity index 89% rename from src/main/resources/static/index.html rename to src/main/resources/templates/index.html index d71e1cf..c496afd 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/templates/index.html @@ -3,18 +3,19 @@ - Discord Bot + Music Control - Discord Bot + href="/favicon.png"/> - - + + + @@ -25,10 +26,10 @@ menu @@ -115,19 +118,17 @@ - - -
+
- - - - + + + + diff --git a/src/main/resources/templates/music.html b/src/main/resources/templates/music.html index cd1d19c..e27a859 100644 --- a/src/main/resources/templates/music.html +++ b/src/main/resources/templates/music.html @@ -290,13 +290,14 @@ - - + - - + + + + diff --git a/src/main/resources/templates/register.html b/src/main/resources/templates/register.html index b8bf740..d350eab 100644 --- a/src/main/resources/templates/register.html +++ b/src/main/resources/templates/register.html @@ -192,10 +192,10 @@ - - - - + + + +