fix: challenge introduction page loads (#2095)

This commit is contained in:
Nanne Baars 2025-03-31 22:49:26 +02:00 committed by GitHub
parent c3f9158eab
commit b3dec8bdc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 20 additions and 14 deletions

View File

@ -47,17 +47,26 @@ public class LessonTemplateResolver extends FileTemplateResolver {
var templateName = resourceName.substring(PREFIX.length());
byte[] resource = resources.get(templateName);
if (resource == null) {
try {
resource =
resourceLoader
.getResource("classpath:/" + templateName)
.getInputStream()
.readAllBytes();
} catch (IOException e) {
log.error("Unable to find lesson HTML: {}", template);
}
resources.put(templateName, resource);
resource = loadAndCache(templateName);
}
if (resource == null) {
return new StringTemplateResource("Unable to find lesson HTML: %s".formatted(templateName));
}
return new StringTemplateResource(new String(resource, StandardCharsets.UTF_8));
}
private byte[] loadAndCache(String templateName) {
try {
var resource =
resourceLoader.getResource("classpath:/" + templateName).getInputStream().readAllBytes();
resources.put(templateName, resource);
return resource;
} catch (IOException e) {
log.error(
"Unable to find lesson HTML: '{}', does the name of HTML file name match the lesson class name?",
templateName);
return null;
}
}
}

View File

@ -2,9 +2,6 @@
<html xmlns:th="http://www.thymeleaf.org">
<div class="lesson-page-wrapper">
<div class="adoc-content" th:replace="~{doc:lessons/challenges/documentation/Challenge_introduction.adoc}"></div>
</div>
<div class="lesson-page-wrapper">
<div class="attack-container">
<div class="assignment-success"><i class="fa fa-2 fa-check hidden" aria-hidden="true"></i></div>

View File

@ -1,4 +1,4 @@
<!DOCTYPE html>
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">