mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-02 16:59:42 +01:00
Reduced html page size by compressing result html #685
This commit is contained in:
parent
9898bf8264
commit
fd5e02e1c9
@ -139,6 +139,13 @@
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- HTML Compression -->
|
||||
<dependency>
|
||||
<groupId>com.googlecode.htmlcompressor</groupId>
|
||||
<artifactId>htmlcompressor</artifactId>
|
||||
<version>1.5.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Mockito (Test Dependency) -->
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
|
@ -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;
|
||||
|
@ -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(() -> {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
@ -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");
|
||||
|
@ -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<UUID, String[]> pluginsTab;
|
||||
|
@ -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<String, String> content;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user