diff --git a/Plan/pom.xml b/Plan/pom.xml index 9f16f2e25..ea29ad87b 100644 --- a/Plan/pom.xml +++ b/Plan/pom.xml @@ -139,6 +139,13 @@ 1.2 + + + com.googlecode.htmlcompressor + htmlcompressor + 1.5.2 + + org.mockito diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java index d8d2ecd9e..78aa8810a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/errors/ErrorResponse.java @@ -5,7 +5,7 @@ package com.djrapitops.plan.system.webserver.response.errors; import com.djrapitops.plan.system.settings.theme.Theme; -import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.pages.PageResponse; import com.djrapitops.plan.utilities.MiscUtils; import com.djrapitops.plan.utilities.file.FileUtil; import com.djrapitops.plugin.api.utility.log.Log; @@ -20,7 +20,7 @@ import java.util.Map; * * @author Rsl1122 */ -public class ErrorResponse extends Response { +public class ErrorResponse extends PageResponse { private String title; private String paragraph; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java index 644f7697f..9d3655458 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/AnalysisPageResponse.java @@ -7,7 +7,6 @@ import com.djrapitops.plan.system.info.InfoSystem; import com.djrapitops.plan.system.processing.Processing; import com.djrapitops.plan.system.webserver.cache.PageId; import com.djrapitops.plan.system.webserver.cache.ResponseCache; -import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.NotFoundResponse; import com.djrapitops.plan.utilities.html.pages.AnalysisPage; import com.djrapitops.plugin.api.utility.log.Log; @@ -18,7 +17,7 @@ import java.util.UUID; * @author Rsl1122 * @since 3.5.2 */ -public class AnalysisPageResponse extends Response { +public class AnalysisPageResponse extends PageResponse { public static AnalysisPageResponse refreshNow(UUID serverUUID) { Processing.submitNonCritical(() -> { diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java index bf41399f1..926f474ee 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/InspectPageResponse.java @@ -3,7 +3,6 @@ package com.djrapitops.plan.system.webserver.response.pages; import com.djrapitops.plan.system.settings.theme.Theme; import com.djrapitops.plan.system.webserver.cache.PageId; import com.djrapitops.plan.system.webserver.cache.ResponseCache; -import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.ErrorResponse; import com.djrapitops.plan.system.webserver.response.pages.parts.InspectPagePluginsContent; import org.apache.commons.text.StringSubstitutor; @@ -16,7 +15,7 @@ import java.util.UUID; * @author Rsl1122 * @since 3.5.2 */ -public class InspectPageResponse extends Response { +public class InspectPageResponse extends PageResponse { private final UUID uuid; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/NetworkPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/NetworkPageResponse.java index 5dda443a6..e2316491c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/NetworkPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/NetworkPageResponse.java @@ -3,7 +3,6 @@ package com.djrapitops.plan.system.webserver.response.pages; import com.djrapitops.plan.api.exceptions.ParseException; import com.djrapitops.plan.data.store.containers.NetworkContainer; import com.djrapitops.plan.system.database.databases.Database; -import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.utilities.html.pages.NetworkPage; /** @@ -11,7 +10,7 @@ import com.djrapitops.plan.utilities.html.pages.NetworkPage; * * @author Rsl1122 */ -public class NetworkPageResponse extends Response { +public class NetworkPageResponse extends PageResponse { public NetworkPageResponse() throws ParseException { super.setHeader("HTTP/1.1 200 OK"); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PageResponse.java new file mode 100644 index 000000000..6b5ceac0e --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PageResponse.java @@ -0,0 +1,27 @@ +package com.djrapitops.plan.system.webserver.response.pages; + +import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.ResponseType; +import com.googlecode.htmlcompressor.compressor.HtmlCompressor; + +/** + * Response for all HTML Page responses. + * + * @author Rsl1122 + */ +public class PageResponse extends Response { + + public PageResponse(ResponseType type) { + super(type); + } + + public PageResponse() { + } + + @Override + public void setContent(String content) { + HtmlCompressor compressor = new HtmlCompressor(); + compressor.setRemoveIntertagSpaces(true); + super.setContent(compressor.compress(content)); + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java index 2b805db9f..d076bb0dd 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/PlayersPageResponse.java @@ -1,7 +1,6 @@ package com.djrapitops.plan.system.webserver.response.pages; import com.djrapitops.plan.api.exceptions.ParseException; -import com.djrapitops.plan.system.webserver.response.Response; import com.djrapitops.plan.system.webserver.response.errors.InternalErrorResponse; import com.djrapitops.plan.utilities.html.pages.PlayersPage; import com.djrapitops.plugin.api.utility.log.Log; @@ -10,7 +9,7 @@ import com.djrapitops.plugin.api.utility.log.Log; * @author Rsl1122 * @since 3.5.2 */ -public class PlayersPageResponse extends Response { +public class PlayersPageResponse extends PageResponse { public PlayersPageResponse() { super.setHeader("HTTP/1.1 200 OK"); diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java index d58abe252..bcba4c45c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/InspectPagePluginsContent.java @@ -8,7 +8,7 @@ import com.djrapitops.plan.data.element.InspectContainer; import com.djrapitops.plan.data.plugin.HookHandler; import com.djrapitops.plan.data.plugin.PluginData; import com.djrapitops.plan.system.info.server.ServerInfo; -import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.pages.PageResponse; import com.djrapitops.plan.utilities.comparators.PluginDataNameComparator; import com.djrapitops.plan.utilities.html.Html; import com.djrapitops.plan.utilities.html.HtmlStructure; @@ -23,7 +23,7 @@ import java.util.*; * * @author Rsl1122 */ -public class InspectPagePluginsContent extends Response { +public class InspectPagePluginsContent extends PageResponse { // ServerUUID, {nav, html} private final Map pluginsTab; diff --git a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java index 3eaa8bfb3..16999e6c3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java +++ b/Plan/src/main/java/com/djrapitops/plan/system/webserver/response/pages/parts/NetworkPageContent.java @@ -4,7 +4,7 @@ */ package com.djrapitops.plan.system.webserver.response.pages.parts; -import com.djrapitops.plan.system.webserver.response.Response; +import com.djrapitops.plan.system.webserver.response.pages.PageResponse; import java.util.*; @@ -15,7 +15,7 @@ import java.util.*; * * @author Rsl1122 */ -public class NetworkPageContent extends Response { +public class NetworkPageContent extends PageResponse { private final Map content;