7 changed files with 118 additions and 3 deletions
@ -0,0 +1,56 @@
|
||||
package com.mcaps.core.models; |
||||
|
||||
import static org.apache.sling.api.resource.ResourceResolver.PROPERTY_RESOURCE_TYPE; |
||||
|
||||
import javax.annotation.PostConstruct; |
||||
|
||||
import org.apache.sling.api.resource.Resource; |
||||
import org.apache.sling.api.resource.ResourceResolver; |
||||
import org.apache.sling.models.annotations.Default; |
||||
import org.apache.sling.models.annotations.Model; |
||||
import org.apache.sling.models.annotations.injectorspecific.InjectionStrategy; |
||||
import org.apache.sling.models.annotations.injectorspecific.OSGiService; |
||||
import org.apache.sling.models.annotations.injectorspecific.SlingObject; |
||||
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; |
||||
|
||||
import com.day.cq.wcm.api.Page; |
||||
import com.day.cq.wcm.api.PageManager; |
||||
|
||||
import java.util.Optional; |
||||
|
||||
@Model(adaptables = Resource.class) |
||||
public class CourseModel { |
||||
|
||||
@ValueMapValue(name=PROPERTY_RESOURCE_TYPE, injectionStrategy=InjectionStrategy.OPTIONAL) |
||||
@Default(values="No resourceType") |
||||
protected String resourceType; |
||||
|
||||
@SlingObject |
||||
private Resource currentResource; |
||||
@SlingObject |
||||
private ResourceResolver resourceResolver; |
||||
|
||||
private String message; |
||||
private String html; |
||||
|
||||
@PostConstruct |
||||
protected void init() { |
||||
PageManager pageManager = resourceResolver.adaptTo(PageManager.class); |
||||
String currentPagePath = Optional.ofNullable(pageManager) |
||||
.map(pm -> pm.getContainingPage(currentResource)) |
||||
.map(Page::getPath).orElse(""); |
||||
|
||||
message = "Hello World!\n" |
||||
+ "Resource type is: " + resourceType + "\n" |
||||
+ "Current page is: " + currentPagePath + "\n"; |
||||
} |
||||
|
||||
public String getMessage() { |
||||
return message; |
||||
} |
||||
|
||||
public String getHtml() { |
||||
return "<body><h1>TESTING</h1></body>"; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" |
||||
jcr:primaryType="cq:Component" |
||||
jcr:title="MCAPS Site Blank Page" |
||||
sling:resourceSuperType="core/wcm/components/page/v3/page" |
||||
componentGroup=".hidden"/> |
@ -0,0 +1,3 @@
|
||||
<template data-sly-template.include="${@ statichtml}"> |
||||
${statichtml} |
||||
</template> |
@ -0,0 +1,5 @@
|
||||
<sly |
||||
data-sly-use.course="${'course-template.html'}" |
||||
data-sly-use.courseModel = "com.mcaps.core.models.CourseModel" |
||||
data-sly-call="${course.include @ statichtml = courseModel.html}" |
||||
/> |
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE HTML> |
||||
<html data-sly-use.page="com.adobe.cq.wcm.core.components.models.Page" lang="${page.language}" |
||||
data-sly-use.pwa="com.adobe.cq.wcm.core.components.models.PWA" |
||||
data-sly-use.head="head.html"> |
||||
<head data-sly-call="${head.head @ page = page, pwa = pwa}"></head> |
||||
<body class="${page.cssClassNames}" |
||||
id="${page.id}"> |
||||
<h1>SCORM Test</h1> |
||||
<sly data-sly-include="course.html"></sly> |
||||
</sly> |
||||
</body> |
||||
</html> |
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0" |
||||
jcr:primaryType="cq:Page"> |
||||
<jcr:content |
||||
cq:template="/conf/mcaps-site/settings/wcm/templates/page-content" |
||||
jcr:primaryType="cq:PageContent" |
||||
sling:resourceType="mcaps-site/components/blankpage"> |
||||
</jcr:content> |
||||
</jcr:root> |
Loading…
Reference in new issue