mirror of
https://github.com/Qortal/qortal.git
synced 2025-03-27 07:45:53 +00:00
Renamed the "usePrefix" parameter to "includeResourceIdInPrefix", and slightly modified its functionality.
This commit is contained in:
parent
5928b54a33
commit
d628b3ab2a
@ -24,11 +24,11 @@ public class HTMLParser {
|
|||||||
private String theme;
|
private String theme;
|
||||||
private boolean usingCustomRouting;
|
private boolean usingCustomRouting;
|
||||||
|
|
||||||
public HTMLParser(String resourceId, String inPath, String prefix, boolean usePrefix, byte[] data,
|
public HTMLParser(String resourceId, String inPath, String prefix, boolean includeResourceIdInPrefix, byte[] data,
|
||||||
String qdnContext, Service service, String identifier, String theme, boolean usingCustomRouting) {
|
String qdnContext, Service service, String identifier, String theme, boolean usingCustomRouting) {
|
||||||
String inPathWithoutFilename = inPath.contains("/") ? inPath.substring(0, inPath.lastIndexOf('/')) : "";
|
String inPathWithoutFilename = inPath.contains("/") ? inPath.substring(0, inPath.lastIndexOf('/')) : String.format("/%s",inPath);
|
||||||
this.qdnBase = usePrefix ? String.format("%s/%s", prefix, resourceId) : "";
|
this.qdnBase = includeResourceIdInPrefix ? String.format("%s/%s", prefix, resourceId) : prefix;
|
||||||
this.qdnBaseWithPath = usePrefix ? String.format("%s/%s%s", prefix, resourceId, inPathWithoutFilename) : "";
|
this.qdnBaseWithPath = includeResourceIdInPrefix ? String.format("%s/%s%s", prefix, resourceId, inPathWithoutFilename) : String.format("%s%s", prefix, inPathWithoutFilename);
|
||||||
this.data = data;
|
this.data = data;
|
||||||
this.qdnContext = qdnContext;
|
this.qdnContext = qdnContext;
|
||||||
this.resourceId = resourceId;
|
this.resourceId = resourceId;
|
||||||
@ -82,7 +82,7 @@ public class HTMLParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isHtmlFile(String path) {
|
public static boolean isHtmlFile(String path) {
|
||||||
if (path.endsWith(".html") || path.endsWith(".htm")) {
|
if (path.endsWith(".html") || path.endsWith(".htm") || path.equals("")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -48,10 +48,10 @@ public class DomainMapResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private HttpServletResponse get(String resourceId, ResourceIdType resourceIdType, Service service, String identifier,
|
private HttpServletResponse get(String resourceId, ResourceIdType resourceIdType, Service service, String identifier,
|
||||||
String inPath, String secret58, String prefix, boolean usePrefix, boolean async) {
|
String inPath, String secret58, String prefix, boolean includeResourceIdInPrefix, boolean async) {
|
||||||
|
|
||||||
ArbitraryDataRenderer renderer = new ArbitraryDataRenderer(resourceId, resourceIdType, service, identifier, inPath,
|
ArbitraryDataRenderer renderer = new ArbitraryDataRenderer(resourceId, resourceIdType, service, identifier, inPath,
|
||||||
secret58, prefix, usePrefix, async, "domainMap", request, response, context);
|
secret58, prefix, includeResourceIdInPrefix, async, "domainMap", request, response, context);
|
||||||
return renderer.render();
|
return renderer.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class GatewayResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private HttpServletResponse parsePath(String inPath, String qdnContext, String secret58, boolean usePrefix, boolean async) {
|
private HttpServletResponse parsePath(String inPath, String qdnContext, String secret58, boolean includeResourceIdInPrefix, boolean async) {
|
||||||
|
|
||||||
if (inPath == null || inPath.equals("")) {
|
if (inPath == null || inPath.equals("")) {
|
||||||
// Assume not a real file
|
// Assume not a real file
|
||||||
@ -157,7 +157,7 @@ public class GatewayResource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ArbitraryDataRenderer renderer = new ArbitraryDataRenderer(name, ResourceIdType.NAME, service, identifier, outPath,
|
ArbitraryDataRenderer renderer = new ArbitraryDataRenderer(name, ResourceIdType.NAME, service, identifier, outPath,
|
||||||
secret58, prefix, usePrefix, async, qdnContext, request, response, context);
|
secret58, prefix, includeResourceIdInPrefix, async, qdnContext, request, response, context);
|
||||||
return renderer.render();
|
return renderer.render();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,10 +157,10 @@ public class RenderResource {
|
|||||||
|
|
||||||
|
|
||||||
private HttpServletResponse get(String resourceId, ResourceIdType resourceIdType, Service service, String identifier,
|
private HttpServletResponse get(String resourceId, ResourceIdType resourceIdType, Service service, String identifier,
|
||||||
String inPath, String secret58, String prefix, boolean usePrefix, boolean async, String theme) {
|
String inPath, String secret58, String prefix, boolean includeResourceIdInPrefix, boolean async, String theme) {
|
||||||
|
|
||||||
ArbitraryDataRenderer renderer = new ArbitraryDataRenderer(resourceId, resourceIdType, service, identifier, inPath,
|
ArbitraryDataRenderer renderer = new ArbitraryDataRenderer(resourceId, resourceIdType, service, identifier, inPath,
|
||||||
secret58, prefix, usePrefix, async, "render", request, response, context);
|
secret58, prefix, includeResourceIdInPrefix, async, "render", request, response, context);
|
||||||
|
|
||||||
if (theme != null) {
|
if (theme != null) {
|
||||||
renderer.setTheme(theme);
|
renderer.setTheme(theme);
|
||||||
|
@ -40,7 +40,7 @@ public class ArbitraryDataRenderer {
|
|||||||
private String inPath;
|
private String inPath;
|
||||||
private final String secret58;
|
private final String secret58;
|
||||||
private final String prefix;
|
private final String prefix;
|
||||||
private final boolean usePrefix;
|
private final boolean includeResourceIdInPrefix;
|
||||||
private final boolean async;
|
private final boolean async;
|
||||||
private final String qdnContext;
|
private final String qdnContext;
|
||||||
private final HttpServletRequest request;
|
private final HttpServletRequest request;
|
||||||
@ -48,7 +48,7 @@ public class ArbitraryDataRenderer {
|
|||||||
private final ServletContext context;
|
private final ServletContext context;
|
||||||
|
|
||||||
public ArbitraryDataRenderer(String resourceId, ResourceIdType resourceIdType, Service service, String identifier,
|
public ArbitraryDataRenderer(String resourceId, ResourceIdType resourceIdType, Service service, String identifier,
|
||||||
String inPath, String secret58, String prefix, boolean usePrefix, boolean async, String qdnContext,
|
String inPath, String secret58, String prefix, boolean includeResourceIdInPrefix, boolean async, String qdnContext,
|
||||||
HttpServletRequest request, HttpServletResponse response, ServletContext context) {
|
HttpServletRequest request, HttpServletResponse response, ServletContext context) {
|
||||||
|
|
||||||
this.resourceId = resourceId;
|
this.resourceId = resourceId;
|
||||||
@ -58,7 +58,7 @@ public class ArbitraryDataRenderer {
|
|||||||
this.inPath = inPath;
|
this.inPath = inPath;
|
||||||
this.secret58 = secret58;
|
this.secret58 = secret58;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
this.usePrefix = usePrefix;
|
this.includeResourceIdInPrefix = includeResourceIdInPrefix;
|
||||||
this.async = async;
|
this.async = async;
|
||||||
this.qdnContext = qdnContext;
|
this.qdnContext = qdnContext;
|
||||||
this.request = request;
|
this.request = request;
|
||||||
@ -159,7 +159,7 @@ public class ArbitraryDataRenderer {
|
|||||||
if (HTMLParser.isHtmlFile(filename)) {
|
if (HTMLParser.isHtmlFile(filename)) {
|
||||||
// HTML file - needs to be parsed
|
// HTML file - needs to be parsed
|
||||||
byte[] data = Files.readAllBytes(filePath); // TODO: limit file size that can be read into memory
|
byte[] data = Files.readAllBytes(filePath); // TODO: limit file size that can be read into memory
|
||||||
HTMLParser htmlParser = new HTMLParser(resourceId, inPath, prefix, usePrefix, data, qdnContext, service, identifier, theme, usingCustomRouting);
|
HTMLParser htmlParser = new HTMLParser(resourceId, inPath, prefix, includeResourceIdInPrefix, data, qdnContext, service, identifier, theme, usingCustomRouting);
|
||||||
htmlParser.addAdditionalHeaderTags();
|
htmlParser.addAdditionalHeaderTags();
|
||||||
response.addHeader("Content-Security-Policy", "default-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src 'self' data: blob:; img-src 'self' data: blob:;");
|
response.addHeader("Content-Security-Policy", "default-src 'self' 'unsafe-inline' 'unsafe-eval'; media-src 'self' data: blob:; img-src 'self' data: blob:;");
|
||||||
response.setContentType(context.getMimeType(filename));
|
response.setContentType(context.getMimeType(filename));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user