forked from Qortal/qortal
Added support for subdirectories in the HTML parser.
This commit is contained in:
parent
182dcc7e5f
commit
53f44a4029
@ -13,8 +13,9 @@ public class HTMLParser {
|
|||||||
|
|
||||||
private String linkPrefix;
|
private String linkPrefix;
|
||||||
|
|
||||||
public HTMLParser(String resourceId, boolean usePrefix) {
|
public HTMLParser(String resourceId, String inPath, boolean usePrefix) {
|
||||||
this.linkPrefix = usePrefix ? "/site/" + resourceId : "";
|
String inPathWithoutFilename = inPath.substring(0, inPath.lastIndexOf('/'));
|
||||||
|
this.linkPrefix = usePrefix ? String.format("/site/%s%s", resourceId, inPathWithoutFilename) : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -335,7 +335,7 @@ public class WebsiteResource {
|
|||||||
if (HTMLParser.isHtmlFile(filename)) {
|
if (HTMLParser.isHtmlFile(filename)) {
|
||||||
// HTML file - needs to be parsed
|
// HTML file - needs to be parsed
|
||||||
byte[] data = Files.readAllBytes(Paths.get(filePath)); // TODO: limit file size that can be read into memory
|
byte[] data = Files.readAllBytes(Paths.get(filePath)); // TODO: limit file size that can be read into memory
|
||||||
HTMLParser htmlParser = new HTMLParser(resourceId, usePrefix);
|
HTMLParser htmlParser = new HTMLParser(resourceId, inPath, usePrefix);
|
||||||
data = htmlParser.replaceRelativeLinks(filename, data);
|
data = htmlParser.replaceRelativeLinks(filename, data);
|
||||||
response.setContentType(context.getMimeType(filename));
|
response.setContentType(context.getMimeType(filename));
|
||||||
response.setContentLength(data.length);
|
response.setContentLength(data.length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user