diff --git a/core/src/main/java/com/mcaps/core/models/CourseModel.java b/core/src/main/java/com/mcaps/core/models/CourseModel.java index 03fcfb7..312c178 100644 --- a/core/src/main/java/com/mcaps/core/models/CourseModel.java +++ b/core/src/main/java/com/mcaps/core/models/CourseModel.java @@ -40,9 +40,8 @@ public class CourseModel { .map(pm -> pm.getContainingPage(currentResource)) .map(Page::getPath).orElse(""); - message = "Hello World!\n" - + "Resource type is: " + resourceType + "\n" - + "Current page is: " + currentPagePath + "\n"; + message = "

Resource type is: " + resourceType + + "

Current page is: " + currentPagePath + "

"; } public String getMessage() { @@ -50,7 +49,7 @@ public class CourseModel { } public String getHtml() { - return "

TESTING

"+message+"

"; + return "
"+message+"
"; } } diff --git a/core/src/main/java/com/mcaps/core/servlets/HtmlServlet.java b/core/src/main/java/com/mcaps/core/servlets/HtmlServlet.java new file mode 100644 index 0000000..bfa0d10 --- /dev/null +++ b/core/src/main/java/com/mcaps/core/servlets/HtmlServlet.java @@ -0,0 +1,49 @@ + +package com.mcaps.core.servlets; + +import com.day.cq.commons.jcr.JcrConstants; + +import org.apache.commons.io.IOUtils; +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.SlingHttpServletResponse; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.servlets.HttpConstants; +import org.apache.sling.api.servlets.SlingAllMethodsServlet; +import org.apache.sling.api.servlets.SlingSafeMethodsServlet; +import org.apache.sling.servlets.annotations.SlingServletResourceTypes; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.propertytypes.ServiceDescription; + +import javax.servlet.Servlet; +import javax.servlet.ServletException; +import java.io.IOException; +import java.io.InputStream; + +/** + * Servlet that writes some sample content into the response. It is mounted for + * all resources of a specific Sling resource type. The + * {@link SlingSafeMethodsServlet} shall be used for HTTP methods that are + * idempotent. For write operations use the {@link SlingAllMethodsServlet}. + */ +@Component(service = { Servlet.class },property = { + "sling.servlet.paths=/content/dam/ms-mcaps" , + "sling.servlet.methods=GET", + "sling.servlet.extensions=html" +}) + +public class HtmlServlet extends SlingSafeMethodsServlet { + @Override + protected void doGet(SlingHttpServletRequest request, SlingHttpServletResponse response) throws ServletException, IOException { + // Get the path of the requested HTML file + String path = request.getRequestPathInfo().getResourcePath(); + + // Read the content of the HTML file from DAM + InputStream htmlStream = request.getResource().adaptTo(InputStream.class); + + // Set the content type + response.setContentType("text/html"); + + // Copy the content to the response + IOUtils.copy(htmlStream, response.getOutputStream()); + } +} diff --git a/ui.apps/src/main/content/jcr_root/apps/mcaps-site/components/blankpage/blankpage.html b/ui.apps/src/main/content/jcr_root/apps/mcaps-site/components/blankpage/blankpage.html index 201d65e..376e5e3 100644 --- a/ui.apps/src/main/content/jcr_root/apps/mcaps-site/components/blankpage/blankpage.html +++ b/ui.apps/src/main/content/jcr_root/apps/mcaps-site/components/blankpage/blankpage.html @@ -5,7 +5,7 @@ -

SCORM Test

+

SCORM Package Unwrapped