From 579b7eb7b2ef91e2638d9d3cee15cc81e17ddc8a Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 21 Oct 2020 12:14:22 -0400 Subject: [PATCH 01/53] pagerenderer/server won't deploy to my develop-sling12. Has to do with common-lang dependency. Also frontend-maven-plugin (node) was failing, but not sure what it does for server/ui.apps. Commenting out for now, also the module to build, install and deploy to Sling --- pagerenderer/server/core/pom.xml | 5 +- pagerenderer/server/ui.apps/pom.xml | 108 ++++++++++++++-------------- 2 files changed, 57 insertions(+), 56 deletions(-) diff --git a/pagerenderer/server/core/pom.xml b/pagerenderer/server/core/pom.xml index e47f1e3871..1f37cbda53 100644 --- a/pagerenderer/server/core/pom.xml +++ b/pagerenderer/server/core/pom.xml @@ -132,8 +132,9 @@ - commons-lang - commons-lang + commons-lang3 + org.apache.commons + provided diff --git a/pagerenderer/server/ui.apps/pom.xml b/pagerenderer/server/ui.apps/pom.xml index 3d2f5c47c4..95811380e7 100644 --- a/pagerenderer/server/ui.apps/pom.xml +++ b/pagerenderer/server/ui.apps/pom.xml @@ -87,61 +87,61 @@ - - com.github.eirslett - frontend-maven-plugin - - ${nodepath} - - - - install node and npm - - install-node-and-npm - - - v12.18.3 - - + + + + + + + + + + + + + + + + - - npm install - - npm - - - - install - - - - npm run build - - npm - - compile - - - ./node_modules - - run build - - - - npm run site - - npm - - site - - - ./node_modules - - run site - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 2a2c7572a8b7adb2044e79f2f169cbde6e141626 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 21 Oct 2020 14:51:09 -0400 Subject: [PATCH 02/53] Add missing base template for /content/pagerenderserver/templates Fix NPE due to incorrect the init method local variable 'resource' overriding instance property --- .../structure/page/Helper.java | 2 +- .../templates/base/.content.xml | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/Helper.java b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/Helper.java index bc315ce60c..e913d3bbe7 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/Helper.java +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/Helper.java @@ -61,7 +61,7 @@ public String getModelClass() { } public void init(Bindings bindings) { - Resource resource = (Resource) bindings.get("resource"); + resource = (Resource) bindings.get("resource"); SlingHttpServletRequest request = (SlingHttpServletRequest) bindings.get("request"); SlingScriptHelper sling = (SlingScriptHelper) bindings.get("sling"); diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml new file mode 100644 index 0000000000..8048697523 --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + From 2df47373089f8368a0841b0e203bf04d30b924cd Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 21 Oct 2020 15:21:08 -0400 Subject: [PATCH 03/53] flag pagerenderserver site as internal --- .../main/content/jcr_root/content/pagerenderserver/.content.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml index 2835bfff8f..d560fe4550 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml @@ -27,5 +27,5 @@ xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="per:Site" jcr:title="Pagerender-Server Site" - internal="false" + internal="true" template="false"/> \ No newline at end of file From 3a12a67a50e44319dc2c8aed89cfec6589b95162 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 21 Oct 2020 15:22:53 -0400 Subject: [PATCH 04/53] added base template to /content/pagerenderserver/templates so the example vue site can have new page without errors. Added TODO comments about nav and footer for these sites --- .../templates/base/.content.xml | 7 +-- .../pagerendervue/templates/base/.content.xml | 47 +++++++++++++++++++ 2 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 pagerenderer/vue/ui.apps/src/main/content/jcr_root/content/pagerendervue/templates/base/.content.xml diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml index 8048697523..83f49b8077 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml @@ -34,12 +34,13 @@ sling:resourceType="pagerenderserver/structure/page" jcr:title="example htl site template"> - + sling:resourceType="pagerenderserver/components/footer"/> --> diff --git a/pagerenderer/vue/ui.apps/src/main/content/jcr_root/content/pagerendervue/templates/base/.content.xml b/pagerenderer/vue/ui.apps/src/main/content/jcr_root/content/pagerendervue/templates/base/.content.xml new file mode 100644 index 0000000000..8f46279033 --- /dev/null +++ b/pagerenderer/vue/ui.apps/src/main/content/jcr_root/content/pagerendervue/templates/base/.content.xml @@ -0,0 +1,47 @@ + + + + + + + + + + + From df1049d63126248013c818384c0749fa0fe05c6c Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 21 Oct 2020 18:30:48 -0400 Subject: [PATCH 05/53] refactored by moving /apps/pagerenderserver/structure to /apps/pagerenderserver/components. Adjusted PageRenderServerConstants.java and /content/pagerenderserver/ paths accordingly --- .../models/PageRenderServerConstants.java | 4 +-- .../components/container/.content.xml | 36 +++++++++++++++++++ .../container/container.html | 0 .../components/page/.content.xml | 36 +++++++++++++++++++ .../page/Helper.java | 2 +- .../page/dialog.json | 0 .../page/explorer_dialog.json | 0 .../{structure => components}/page/page.html | 2 +- .../page/renderer.html | 0 .../page/serviceworker.html | 0 .../page/tracker-bodyend.html | 0 .../page/tracker-bodystart.html | 0 .../page/tracker-head.html | 0 .../pagerenderserver/pages/about/.content.xml | 4 +-- .../pagerenderserver/pages/index/.content.xml | 4 +-- .../templates/base/.content.xml | 2 +- 16 files changed, 81 insertions(+), 9 deletions(-) create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/.content.xml rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/container/container.html (100%) create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/.content.xml rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/Helper.java (98%) rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/dialog.json (100%) rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/explorer_dialog.json (100%) rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/page.html (92%) rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/renderer.html (100%) rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/serviceworker.html (100%) rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/tracker-bodyend.html (100%) rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/tracker-bodystart.html (100%) rename pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/{structure => components}/page/tracker-head.html (100%) diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/PageRenderServerConstants.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/PageRenderServerConstants.java index 62c9bfcc08..e6dc8f36b5 100644 --- a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/PageRenderServerConstants.java +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/PageRenderServerConstants.java @@ -2,6 +2,6 @@ public class PageRenderServerConstants { public static final String PR_SERVER_COMPONENT_BASE_TYPE = "pagerenderserver/components/base"; - public static final String PR_SERVER_COMPONENT_CONTAINER_TYPE = "pagerenderserver/structure/container"; - public static final String PR_SERVER_COMPONENT_PAGE_TYPE = "pagerenderserver/structure/page"; + public static final String PR_SERVER_COMPONENT_CONTAINER_TYPE = "pagerenderserver/components/container"; + public static final String PR_SERVER_COMPONENT_PAGE_TYPE = "pagerenderserver/components/page"; } diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/.content.xml new file mode 100644 index 0000000000..265b492298 --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/.content.xml @@ -0,0 +1,36 @@ + + + + diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/container/container.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html similarity index 100% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/container/container.html rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/.content.xml new file mode 100644 index 0000000000..037db5ecdd --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/.content.xml @@ -0,0 +1,36 @@ + + + + diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/Helper.java b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/Helper.java similarity index 98% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/Helper.java rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/Helper.java index e913d3bbe7..42fc89338d 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/Helper.java +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/Helper.java @@ -1,4 +1,4 @@ -package apps.pagerenderserver.structure.page; +package apps.pagerenderserver.components.page; /*- * #%L diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/dialog.json b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/dialog.json similarity index 100% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/dialog.json rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/dialog.json diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/explorer_dialog.json b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/explorer_dialog.json similarity index 100% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/explorer_dialog.json rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/explorer_dialog.json diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/page.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html similarity index 92% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/page.html rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html index 43e70cd476..9a90735fa1 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/page.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html @@ -1,4 +1,4 @@ - + diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/renderer.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/renderer.html similarity index 100% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/renderer.html rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/renderer.html diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/serviceworker.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/serviceworker.html similarity index 100% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/serviceworker.html rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/serviceworker.html diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/tracker-bodyend.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/tracker-bodyend.html similarity index 100% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/tracker-bodyend.html rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/tracker-bodyend.html diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/tracker-bodystart.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/tracker-bodystart.html similarity index 100% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/tracker-bodystart.html rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/tracker-bodystart.html diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/tracker-head.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/tracker-head.html similarity index 100% rename from pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/structure/page/tracker-head.html rename to pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/tracker-head.html diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/about/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/about/.content.xml index b4a1046773..924df52f5b 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/about/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/about/.content.xml @@ -31,11 +31,11 @@ + sling:resourceType="pagerenderserver/components/container"> + sling:resourceType="pagerenderserver/components/container"> - - - - - - - - - - - - - - - + + com.github.eirslett + frontend-maven-plugin + + ${nodepath} + + + + install node and npm + + install-node-and-npm + + + v12.18.3 + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + npm install + + npm + + + + install + + + + npm run build + + npm + + compile + + + ./node_modules + + run build + + + + npm run site + + npm + + site + + + ./node_modules + + run site + + + + From 80cb826b2029ea460bef315527e63ce5991437e7 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Tue, 27 Oct 2020 14:33:27 -0400 Subject: [PATCH 10/53] add pagerender/server to list of maven compile modules --- pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/pom.xml b/pom.xml index eae72b2eeb..f8a3f8d331 100644 --- a/pom.xml +++ b/pom.xml @@ -1004,6 +1004,7 @@ buildscripts platform pagerenderer/vue + pagerenderer/server admin-base samples/example-vue-site themes/themeclean From 0a057d29bc61a1c69e719de946857c1f9e566f10 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 28 Oct 2020 12:59:17 -0400 Subject: [PATCH 11/53] #618 Updated PageMerge.java adding a method (getMergedResources) returning a list of resources coming either from the template or the page content. --- .../peregrine/nodetypes/merge/PageMerge.java | 52 ++++++++++++++++--- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java index 92556538c6..55e42ad1d1 100644 --- a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java +++ b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java @@ -36,11 +36,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; import java.io.StringWriter; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.Map; -import java.util.TreeMap; +import java.util.*; import javax.script.Bindings; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; @@ -63,6 +59,7 @@ public class PageMerge implements Use { private static ThreadLocal renderContext = new ThreadLocal<>(); public static final String FROM_TEMPLATE = "fromTemplate"; + public static final String CHILDREN = "children"; public static final String REQUEST = "request"; public static final String SLING = "sling"; public static final String TEMPLATE = "template"; @@ -71,7 +68,7 @@ public class PageMerge implements Use { private ModelFactory modelFactory; private SlingHttpServletRequest request; - + private Resource resource; public static RenderContext getRenderContext() { return renderContext.get(); } @@ -85,6 +82,44 @@ public String getMerged() { return toJSON(getMerged(res)); } + public List getMergedResources(){ + List pageResources = new ArrayList<>(); + resource = request.getResource(); + if(resource.getName().equals(JCR_CONTENT)) { + resource = resource.getParent(); + } + Map resourceMap = getMerged(resource); + // MAP to List + List maps = (ArrayList) resourceMap.get(CHILDREN); + for (Map map : maps) { + getChildren(map, pageResources); + } + return pageResources; + } + + private void getChildren(Map map, List resources){ + List maps = (ArrayList) map.get(CHILDREN); + String templatePath = getTemplatePath(); + // when maps is null; + // the map represents a resource that is not a container; it should be added to the resource list. + if( Objects.isNull(maps)){ + String relativePath = (String) map.get("path"); + String basePath = ""; + if (Objects.nonNull(map.get(FROM_TEMPLATE)) && (boolean) map.get(FROM_TEMPLATE)){ + basePath = templatePath; + } else { + basePath = resource.getPath(); + } + Resource resource = this.resource.getResourceResolver().getResource(basePath+relativePath); + resources.add(resource); + } else { + // when maps is defined; the resource is a container, and we need to get it's resources. + for (Map nestedMap : maps) { + getChildren(nestedMap, resources); + } + } + } + public String getMergedForScript() { log.debug("merge on {}", request.getResource().getPath()); Resource res = request.getResource(); @@ -140,6 +175,11 @@ private void flagFromTemplate(Map template) { } } + private String getTemplatePath(){ + Resource jcrContent = this.resource.getChild(JCR_CONTENT); + return jcrContent.getValueMap().get(TEMPLATE, String.class); + } + private Map merge(Map template, Map page) { TreeMap res = new TreeMap(); res.putAll(template); From 750a23b87a7112faf7b291fbe77f0b6475d441a7 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 28 Oct 2020 13:05:21 -0400 Subject: [PATCH 12/53] #618 Updated page.html to use PageMerge.java for getting and iterating merged resources as htl --- .../pagerenderserver/components/page/page.html | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html index 7e477c405a..043b2dd3b0 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html @@ -1,4 +1,6 @@ - + + + @@ -24,17 +26,20 @@
- ${helper.path} -
+ ${helper.path} +
-
- +
+ + + + From 1befe349ccbd48961b4ed02efed83b6b758e658e Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 28 Oct 2020 13:07:17 -0400 Subject: [PATCH 13/53] #618 updated predifned page and template content --- .../pagerenderserver/pages/about/.content.xml | 4 +++- .../pagerenderserver/pages/index/.content.xml | 4 +++- .../pagerenderserver/templates/base/.content.xml | 16 ++++++++++------ 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/about/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/about/.content.xml index 924df52f5b..b89cbfa00e 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/about/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/about/.content.xml @@ -32,7 +32,9 @@ + jcr:title="peregrine-server About" + template="/content/pagerenderserver/templates/base" + templatePath="/content/pagerenderserver/templates/base" > diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/index/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/index/.content.xml index e1eec7a325..21bbef500e 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/index/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/index/.content.xml @@ -32,7 +32,9 @@ + jcr:title="peregrine-server Index" + template="/content/pagerenderserver/templates/base" + templatePath="/content/pagerenderserver/templates/base" > diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml index f76b5519a0..c5823660df 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml @@ -31,13 +31,17 @@ - + jcr:title="example htl site template" + sling:resourceType="pagerenderserver/components/page"> + + + + + From 7b3c31f202105d2a73a3f3a410b3b9397041a144 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Thu, 29 Oct 2020 13:34:41 -0400 Subject: [PATCH 14/53] Created BaseHelper Use, which can be extended by page and component helpers alike. Refactored PageHelper Use class to extend BaseHelper --- .../pagerender/server/helpers/BaseHelper.java | 86 +++++++++++++++++++ .../pagerender/server/helpers/PageHelper.java | 35 ++------ 2 files changed, 91 insertions(+), 30 deletions(-) create mode 100644 pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/BaseHelper.java diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/BaseHelper.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/BaseHelper.java new file mode 100644 index 0000000000..45a542cf23 --- /dev/null +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/BaseHelper.java @@ -0,0 +1,86 @@ +package com.peregrine.pagerender.server.helpers; + +import com.peregrine.adaption.PerPage; +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.SlingHttpServletResponse; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ResourceResolver; +import org.apache.sling.api.resource.ValueMap; +import org.apache.sling.api.scripting.SlingScriptHelper; +import org.apache.sling.models.factory.ModelFactory; +import org.apache.sling.scripting.sightly.pojo.Use; +import org.slf4j.Logger; + +import javax.jcr.Node; +import javax.jcr.Session; +import javax.script.Bindings; +import java.io.BufferedReader; +import java.io.PrintWriter; +import java.util.Objects; + +public class BaseHelper implements Use { + + // GLOBAL OBJECTS (from Use API Binding) + protected Node currentNode; + protected Session currentSession; + protected Logger log; + protected PrintWriter out; + protected ValueMap properties; + protected BufferedReader reader; + protected SlingHttpServletRequest request; + protected ResourceResolver resolver; + protected Resource resource; + protected SlingHttpServletResponse response; + protected SlingScriptHelper sling; + + // Peregrine API + protected Object model; + protected Resource siteRoot; + protected PerPage currentPage; + protected String pagePath; + + // Constants + public static String CURRENT_NODE = "currentNode"; + public static String CURRENT_SESSION = "currentSession"; + public static String LOG = "log"; + public static String OUT = "out"; + public static String PROPERTIES = "properties"; + public static String READER = "reader"; + public static String REQUEST = "request"; + public static String RESOLVER = "resolver"; + public static String RESOURCE = "resource"; + public static String RESPONSE = "response"; + public static String SLING = "sling"; + + public void init(Bindings bindings) { + // initialize all global bindings (minus caconfig) + currentNode = (Node) bindings.get(CURRENT_NODE); + currentSession = (Session) bindings.get(CURRENT_SESSION); + log = (Logger) bindings.get(LOG); + out = (PrintWriter) bindings.get(OUT); + properties = (ValueMap) bindings.get(PROPERTIES); + reader = (BufferedReader) bindings.get(READER); + request = (SlingHttpServletRequest) bindings.get(REQUEST); + resolver = (ResourceResolver) bindings.get(RESOLVER); + resource = (Resource) bindings.get(RESOURCE); + response = (SlingHttpServletResponse) bindings.get(RESPONSE); + sling = (SlingScriptHelper) bindings.get(SLING); + + // initialize peregrine api + pagePath = request.getRequestPathInfo().getResourcePath(); + Resource pageRes = resolver.getResource(pagePath); + if (Objects.nonNull(pageRes)){ + currentPage = pageRes.adaptTo(PerPage.class); + } + if (Objects.nonNull(currentPage)){ + siteRoot = currentPage.getSiteResource(); + } + try { + model = sling.getService(ModelFactory.class).getModelFromResource(resource); + } catch(Throwable t) { + model = sling.getService(ModelFactory.class).getModelFromRequest(request); + } + } + + +} diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java index 7f3cc8bcf5..f4f99282de 100644 --- a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java @@ -1,19 +1,11 @@ package com.peregrine.pagerender.server.helpers; import javax.script.Bindings; - import com.peregrine.pagerender.server.models.PageModel; -import org.apache.sling.scripting.sightly.pojo.Use; -import org.apache.sling.api.resource.Resource; -import org.apache.sling.models.factory.ModelFactory; -import org.apache.sling.api.SlingHttpServletRequest; -import org.apache.sling.api.scripting.SlingScriptHelper; -public class PageHelper implements Use { +import java.util.Objects; - private Object model; - private String siteRootPath; - private Resource resource; +public class PageHelper extends BaseHelper { public String getHello() { return "hello"; @@ -28,11 +20,11 @@ public Object getModel() { } public String getSiteRootPath() { - return siteRootPath; + return Objects.nonNull(siteRoot) ? siteRoot.getPath() : null; } public String getModelClass() { - return model.getClass().toString(); + return Objects.nonNull(model) ? model.getClass().toString() : null; } public String[] getSiteCSS(){ @@ -40,25 +32,8 @@ public String[] getSiteCSS(){ return page.getSiteCSS(); } - public void init(Bindings bindings) { - resource = (Resource) bindings.get("resource"); - SlingHttpServletRequest request = (SlingHttpServletRequest) bindings.get("request"); - SlingScriptHelper sling = (SlingScriptHelper) bindings.get("sling"); - - String path = resource.getPath(); - path = path.substring("/content/".length()); - - int slash = path.indexOf("/"); - String siteName = slash > 0 ? path.substring(0, path.indexOf("/")) : path; - siteRootPath = "/content/" + siteName + "/pages"; - - try { - model = sling.getService(ModelFactory.class).getModelFromResource(resource); - } catch(Throwable t) { - model = sling.getService(ModelFactory.class).getModelFromRequest(request); - } - model.toString(); + super.init(bindings); } } \ No newline at end of file From 49e5a7d268834eac19602d7e543f46ca2af5dd8e Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 30 Oct 2020 14:02:19 -0400 Subject: [PATCH 15/53] #618 Added getters for all HTL Java Use binding for BaseHelper, updated PageHelper to use getters instead of direct access --- .../pagerender/server/helpers/BaseHelper.java | 96 +++++++++++++++---- .../pagerender/server/helpers/PageHelper.java | 11 +-- 2 files changed, 84 insertions(+), 23 deletions(-) diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/BaseHelper.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/BaseHelper.java index 45a542cf23..c81ccb6449 100644 --- a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/BaseHelper.java +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/BaseHelper.java @@ -18,26 +18,28 @@ import java.io.PrintWriter; import java.util.Objects; +import static com.peregrine.commons.util.PerConstants.JCR_CONTENT; + public class BaseHelper implements Use { // GLOBAL OBJECTS (from Use API Binding) - protected Node currentNode; - protected Session currentSession; - protected Logger log; - protected PrintWriter out; - protected ValueMap properties; - protected BufferedReader reader; - protected SlingHttpServletRequest request; - protected ResourceResolver resolver; - protected Resource resource; - protected SlingHttpServletResponse response; - protected SlingScriptHelper sling; + private Node currentNode; + private Session currentSession; + private Logger log; + private PrintWriter out; + private ValueMap properties; + private BufferedReader reader; + private SlingHttpServletRequest request; + private ResourceResolver resolver; + private Resource resource; + private SlingHttpServletResponse response; + private SlingScriptHelper sling; // Peregrine API - protected Object model; - protected Resource siteRoot; - protected PerPage currentPage; - protected String pagePath; + private Object model; + private Resource siteRoot; + private PerPage currentPage; + private String pagePath; // Constants public static String CURRENT_NODE = "currentNode"; @@ -68,6 +70,7 @@ public void init(Bindings bindings) { // initialize peregrine api pagePath = request.getRequestPathInfo().getResourcePath(); + pagePath = pagePath.substring(0, pagePath.indexOf(JCR_CONTENT)); Resource pageRes = resolver.getResource(pagePath); if (Objects.nonNull(pageRes)){ currentPage = pageRes.adaptTo(PerPage.class); @@ -77,10 +80,71 @@ public void init(Bindings bindings) { } try { model = sling.getService(ModelFactory.class).getModelFromResource(resource); + if (Objects.isNull(model)) { + model = sling.getService(ModelFactory.class).getModelFromRequest(request); + } } catch(Throwable t) { - model = sling.getService(ModelFactory.class).getModelFromRequest(request); + log.warn("could not get model for "+resource.getPath()); } } + public PrintWriter getOut() { + return out; + } + + public ValueMap getProperties() { + return properties; + } + + public BufferedReader getReader() { + return reader; + } + + public SlingHttpServletRequest getRequest() { + return request; + } + public ResourceResolver getResolver() { + return resolver; + } + + public Resource getResource() { + return resource; + } + + public SlingHttpServletResponse getResponse() { + return response; + } + + public SlingScriptHelper getSling() { + return sling; + } + + public Object getModel() { + return model; + } + + public Resource getSiteRoot() { + return siteRoot; + } + + public PerPage getCurrentPage() { + return currentPage; + } + + public String getPagePath() { + return pagePath; + } + + public Node getCurrentNode() { + return currentNode; + } + + public Session getCurrentSession() { + return currentSession; + } + + public Logger getLog() { + return log; + } } diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java index f4f99282de..206481d9a5 100644 --- a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java @@ -12,23 +12,20 @@ public String getHello() { } public String getPath() { - return resource.getPath(); + return this.getResource().getPath(); } - public Object getModel() { - return model; - } public String getSiteRootPath() { - return Objects.nonNull(siteRoot) ? siteRoot.getPath() : null; + return Objects.nonNull(getSiteRoot()) ? getSiteRoot().getPath() : null; } public String getModelClass() { - return Objects.nonNull(model) ? model.getClass().toString() : null; + return Objects.nonNull(getModel()) ? getModel().getClass().toString() : null; } public String[] getSiteCSS(){ - PageModel page = resource.adaptTo(PageModel.class); + PageModel page = getResource().adaptTo(PageModel.class); return page.getSiteCSS(); } From 5d4b0734e1d04c9ce793f62c37a0ded49d32aba3 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 30 Oct 2020 14:03:26 -0400 Subject: [PATCH 16/53] #618 Added convenience method to PerBase for getting per:Site/jcr:content ValueMap --- .../src/main/java/com/peregrine/adaption/PerBase.java | 7 ++++++- .../java/com/peregrine/adaption/impl/PerBaseImpl.java | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/platform/base/core/src/main/java/com/peregrine/adaption/PerBase.java b/platform/base/core/src/main/java/com/peregrine/adaption/PerBase.java index 961d64a126..01e39be1e8 100644 --- a/platform/base/core/src/main/java/com/peregrine/adaption/PerBase.java +++ b/platform/base/core/src/main/java/com/peregrine/adaption/PerBase.java @@ -61,10 +61,15 @@ public interface PerBase /** @return Modifiable Value Map of the Content Resource if the page has a content **/ public ModifiableValueMap getModifiableProperties(); /** - * + * * @return the parent site/tenant per:Site resource */ public Resource getSiteResource(); + /** + * + * @return the parent site/tenant per:Site/jcr:content properties + */ + public ValueMap getSiteProperties(); /** * Provide Content Property diff --git a/platform/base/core/src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java b/platform/base/core/src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java index 5b493ca8ad..075c3e1999 100644 --- a/platform/base/core/src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java +++ b/platform/base/core/src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java @@ -145,6 +145,14 @@ public T getContentProperty(String propertyName, T defaultValue) { answer; } + @Override + public ValueMap getSiteProperties(){ + if(Objects.nonNull(getSiteResource()) && Objects.nonNull(getSiteResource().getChild(JCR_CONTENT))){ + return getSiteResource().getChild(JCR_CONTENT).getValueMap(); + } + return null; + } + @Override public Resource getSiteResource(){ return this.getSiteResource(this.resource); From 5540d0d492bcd620d89fe3b600d9da95ff3457af Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 09:49:11 -0500 Subject: [PATCH 17/53] #618 refactored PageMerge to make it possible to test: If the slingScriptHelper is null, then it will try to get the modelFactory from the bindings, which is added by the Adaption Jtest adds it. Use classes have bindings such as resource. Getting the resource from the request was problematic for testing, it is easier to test if PageMaerg.java uses the resource reference from the bindings, and not the reference attached to the request --- .../peregrine/nodetypes/merge/PageMerge.java | 48 +++++++++++-------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java index 55e42ad1d1..2417963dc9 100644 --- a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java +++ b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java @@ -32,6 +32,7 @@ import static com.peregrine.commons.util.PerConstants.PAGE_PRIMARY_TYPE; import static com.peregrine.commons.util.PerConstants.PATH; import static java.util.regex.Pattern.compile; +import static org.apache.sling.api.scripting.SlingBindings.RESOURCE; import com.fasterxml.jackson.databind.ObjectMapper; import java.io.IOException; @@ -63,6 +64,7 @@ public class PageMerge implements Use { public static final String REQUEST = "request"; public static final String SLING = "sling"; public static final String TEMPLATE = "template"; + public static final String MODEL_FACTORY = "modelFactory"; public static final String REGEX_TEMPLATES = "(?<=\\/content\\/)([a-zA-Z0-9\\\\s\\\\_-])*(?=\\/templates)"; private ModelFactory modelFactory; @@ -84,7 +86,9 @@ public String getMerged() { public List getMergedResources(){ List pageResources = new ArrayList<>(); - resource = request.getResource(); + if (Objects.isNull(resource)){ + resource = request.getResource(); + } if(resource.getName().equals(JCR_CONTENT)) { resource = resource.getParent(); } @@ -98,26 +102,23 @@ public List getMergedResources(){ } private void getChildren(Map map, List resources){ - List maps = (ArrayList) map.get(CHILDREN); String templatePath = getTemplatePath(); - // when maps is null; - // the map represents a resource that is not a container; it should be added to the resource list. - if( Objects.isNull(maps)){ - String relativePath = (String) map.get("path"); - String basePath = ""; - if (Objects.nonNull(map.get(FROM_TEMPLATE)) && (boolean) map.get(FROM_TEMPLATE)){ - basePath = templatePath; - } else { + String relativePath = (String) map.get("path"); + String basePath = resource.getPath(); + if (Objects.nonNull(map.get(FROM_TEMPLATE)) && (boolean) map.get(FROM_TEMPLATE)){ + // if fromTemplate is set true determine whether the resource is an container empty container + List childMaps = (ArrayList) map.get(CHILDREN); + if (Objects.nonNull(childMaps)){ + // this represents a page editing content container + // so basePath needs to be readjusted to the page path basePath = resource.getPath(); - } - Resource resource = this.resource.getResourceResolver().getResource(basePath+relativePath); - resources.add(resource); - } else { - // when maps is defined; the resource is a container, and we need to get it's resources. - for (Map nestedMap : maps) { - getChildren(nestedMap, resources); + } else { + basePath = templatePath; } } + // get the component resource from the page's content or the template + Resource componentResource = this.resource.getResourceResolver().getResource(basePath+relativePath); + resources.add(componentResource); } public String getMergedForScript() { @@ -146,7 +147,7 @@ public Map getMerged(Resource resource) { } } if(templatePath != null) { - Map template = getMerged(request.getResourceResolver().getResource(templatePath)); + Map template = getMerged(this.resource.getResourceResolver().getResource(templatePath)); flagFromTemplate(template); return merge(template, page); } @@ -243,8 +244,15 @@ private String toJSON(Map template) { @Override public void init(final Bindings bindings) { request = (SlingHttpServletRequest) bindings.get(REQUEST); - SlingScriptHelper sling = (SlingScriptHelper) bindings.get(SLING); - modelFactory = sling.getService(ModelFactory.class); + resource = (Resource) bindings.get(RESOURCE); renderContext.set(new RenderContext(request)); + SlingScriptHelper sling = (SlingScriptHelper) bindings.get(SLING); + if (Objects.nonNull(sling)) { + // the typical path + modelFactory = sling.getService(ModelFactory.class); + } else if ( Objects.nonNull(bindings.get(MODEL_FACTORY))) { + // for unit testing + modelFactory = (ModelFactory) bindings.get(MODEL_FACTORY); + } } } From 3276e59a8680ce887ebbd3e560a8959fec2cdb54 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 09:49:48 -0500 Subject: [PATCH 18/53] organized slingjunit pom.xml deps --- slingjunit.parent/core/pom.xml | 72 +++++++++++++++++++++++----------- 1 file changed, 50 insertions(+), 22 deletions(-) diff --git a/slingjunit.parent/core/pom.xml b/slingjunit.parent/core/pom.xml index b861fd5b12..c83e11b525 100644 --- a/slingjunit.parent/core/pom.xml +++ b/slingjunit.parent/core/pom.xml @@ -36,6 +36,7 @@ + org.apache.sling org.apache.sling.junit.core @@ -46,6 +47,7 @@ junit provided + ${project.groupId} admin.core @@ -64,39 +66,42 @@ ${project.version} provided + + - org.slf4j - slf4j-api - provided - - - guava - com.google.guava - provided + org.apache.sling + org.apache.sling.api - org.apache.jackrabbit - jackrabbit-jcr-commons + org.apache.sling + org.apache.sling.scripting.sightly.compiler.java org.apache.sling - org.apache.sling.api + org.apache.sling.servlet-helpers - javax.jcr - jcr + org.apache.sling + org.apache.sling.models.api org.apache.sling org.apache.sling.settings + + - org.osgi - osgi.annotation + javax.jcr + jcr - org.osgi - org.osgi.service.component.annotations + org.apache.jackrabbit + jackrabbit-jcr-commons + + + org.apache.jackrabbit + oak-core-spi + 1.32.0 org.apache.jackrabbit @@ -114,20 +119,43 @@ 3.0.4 provided + + org.osgi org.osgi.compendium + + org.osgi + org.osgi.core + provided + + + org.osgi + osgi.annotation + + + org.osgi + org.osgi.service.component.annotations + + + + + org.slf4j + slf4j-api + provided + + + guava + com.google.guava + provided + org.apache.httpcomponents httpclient 4.5.12 - - org.apache.jackrabbit - oak-core-spi - 1.32.0 - + From 817c997442b394abb64abbb9c89955e40461b5e2 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 09:51:08 -0500 Subject: [PATCH 19/53] 618 to make testing easier and possible, NavModel Use pojo was updated to use resource from the bindings and not a reference through the request --- .../src/main/java/com/example/site/models/NavModel.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/samples/example-vue-site/core/src/main/java/com/example/site/models/NavModel.java b/samples/example-vue-site/core/src/main/java/com/example/site/models/NavModel.java index 11b933de10..8d524acde0 100644 --- a/samples/example-vue-site/core/src/main/java/com/example/site/models/NavModel.java +++ b/samples/example-vue-site/core/src/main/java/com/example/site/models/NavModel.java @@ -54,7 +54,7 @@ public NavModel(Resource resource) { public String getBrand() { RenderContext rx = PageMerge.getRenderContext(); SlingHttpServletRequest request = rx.getRequest(); - Resource homePage = getResourceAt(request.getResource(), 3); + Resource homePage = getResourceAt(this.getResource(), 3); Resource content = homePage.getChild("jcr:content"); return content.adaptTo(ValueMap.class).get("brand", String.class); } @@ -63,8 +63,8 @@ public List getNavigation() { List ret = new ArrayList<>(); RenderContext rx = PageMerge.getRenderContext(); - SlingHttpServletRequest request = rx.getRequest(); - Resource homePage = getResourceAt(request.getResource(), 3); +// SlingHttpServletRequest request = rx.getRequest(); + Resource homePage = getResourceAt( this.getResource(), 3); Iterator children = homePage.listChildren(); From ccc3a5db3c6e7847c70f744d8c2e8aff94c7b79e Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 09:55:39 -0500 Subject: [PATCH 20/53] 618 added ssrPageMergeScenario1 for PageMerge::getMergedResources. Test whether getMergedResources properly merges template content with page content for HTL rendering --- .../peregrine/slingjunit/AdaptionJTest.java | 75 +++++++++++++++++-- 1 file changed, 67 insertions(+), 8 deletions(-) diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java index b03e73e214..ba2b96d73b 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java +++ b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java @@ -2,12 +2,15 @@ import com.peregrine.adaption.PerAsset; import com.peregrine.adaption.PerPage; +import com.peregrine.nodetypes.merge.PageMerge; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.api.resource.ResourceUtil; +import org.apache.sling.models.factory.ModelFactory; import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner; import org.apache.sling.junit.annotations.TestReference; +import org.apache.sling.servlethelpers.MockSlingHttpServletRequest; import org.junit.After; import org.junit.Before; import org.junit.Test; @@ -15,28 +18,38 @@ import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.nodetype.NodeType; +import javax.script.SimpleBindings; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; import static junit.framework.TestCase.assertNotNull; import static org.junit.Assert.*; - +/** + * Run test using this URL + * http://localhost:8080/system/sling/junit/com.peregrine.slingjunit.AdaptionJTest.html + * + */ @RunWith(SlingAnnotationsTestRunner.class) public class AdaptionJTest { - private static String PAGE_EXAMPLE = "/content/example/pages/contact"; + private static String CONTACT_PAGE_PATH = "/content/example/pages/contact"; private static String ASSET_EXAMPLE = "/content/example/assets/images/logo.png"; private static String OBJECT_EXAMPLE = "/content/example/objects/sample"; private static String TEMPLATE_EXAMPLE = "/content/example/templates/base"; - + private MockSlingHttpServletRequest request; private Resource resource; @TestReference private ResourceResolverFactory resolverFactory; private ResourceResolver resourceResolver; + @TestReference + private ModelFactory modelFactory; @Test public void getSiteFromPage(){ assertNotNull(resourceResolver); - resource = resourceResolver.getResource(PAGE_EXAMPLE); + resource = resourceResolver.getResource(CONTACT_PAGE_PATH); assertFalse( ResourceUtil.isNonExistingResource(resource)); PerPage page = resource.adaptTo(PerPage.class); assertNotNull(page); @@ -73,14 +86,60 @@ public void getSiteFromTemplate(){ assertSiteResource(template.getSiteResource()); } -// TODO: Object needs Adaption implemented -// @Test -// public void getSiteFromObject(){ -// } + /** + * Server Side Rendering SSR Page Merge Scenario 1 + * + * Template has structural components (nav and footer) no containers + * Page has content container with children + * + * Template: /content/example/templates/base/ + * _jcr_content/nav + * _jcr_content/footer + * + * Page: /content/example/pages/contact/ + * _jcr_content/nfceefd40-b802-4203-8147-9cb2b2c78c6b + * _jcr_content/n3736dc36-9cc3-49d7-a7d4-bf4d94e0ea2f + * n8680c077-cc22-40d3-8989-d86d832a85d1 + * + * Resulting Page Merge + * /content/example/templates/base/_jcr_content/nav + * /content/example/templates/base/_jcr_content/footer + * /content/example/pages/contact/_jcr_content/nfceefd40-b802-4203-8147-9cb2b2c78c6b + * /content/example/pages/contact/_jcr_content/n3736dc36-9cc3-49d7-a7d4-bf4d94e0ea2f + * /content/example/pages/contact/_jcr_content/n3736dc36-9cc3-49d7-a7d4-bf4d94e0ea2f/n8680c077-cc22-40d3-8989-d86d832a85d1 + * + */ + @Test + public void ssrPageMergeScenario1(){ + resource = resourceResolver.getResource(CONTACT_PAGE_PATH); + List resourcePaths = new ArrayList<>(); + resourcePaths.add("/content/example/templates/base/jcr:content/nav"); + resourcePaths.add("/content/example/templates/base/jcr:content/footer"); + resourcePaths.add("/content/example/pages/contact/jcr:content/nfceefd40-b802-4203-8147-9cb2b2c78c6b"); + resourcePaths.add("/content/example/pages/contact/jcr:content/n3736dc36-9cc3-49d7-a7d4-bf4d94e0ea2f"); +// Note: children of containers are not included in the resource list. +// /content/example/pages/contact/jcr:content/n3736dc36-9cc3-49d7-a7d4-bf4d94e0ea2f/n8680c077-cc22-40d3-8989-d86d832a85d1 +// resources inside containers are rendered when the container is rendered, when it lists all children + SimpleBindings bindings = new SimpleBindings(); + bindings.put("resource", resource); + bindings.put("request", request); + bindings.put("modelFactory", modelFactory); + + PageMerge pageMerge = new PageMerge(); + pageMerge.init(bindings); + List actualResources = pageMerge.getMergedResources(); + assertEquals(resourcePaths.size(), actualResources.size()); + List actualResourcePaths = actualResources.stream() + .map(Resource::getPath) + .collect(Collectors.toList()); + assertTrue(actualResourcePaths.containsAll(resourcePaths)); + assertTrue(resourcePaths.containsAll(actualResourcePaths)); + } @Before public void setUp() throws Exception { resourceResolver = resolverFactory.getAdministrativeResourceResolver(null); + request = new MockSlingHttpServletRequest(resourceResolver); } @After From 16d945751c11d1942375750be4abceabc1029667 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 11:29:41 -0500 Subject: [PATCH 21/53] started example sub-template for PageMerge junit tests --- .../templates/base/sub-template/.content.xml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml new file mode 100644 index 0000000000..a2bbdce07b --- /dev/null +++ b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file From 09fecfd8a14724f7c96cb85007fddab915baab27 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 16:18:50 -0500 Subject: [PATCH 22/53] removed unneeded files from slingjunit test content --- .../content/example/pages/manifest.json | 30 ------- .../content/example/pages/serviceworker.js | 84 ------------------- 2 files changed, 114 deletions(-) delete mode 100644 slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/manifest.json delete mode 100644 slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/serviceworker.js diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/manifest.json b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/manifest.json deleted file mode 100644 index b4fce57b21..0000000000 --- a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/manifest.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "short_name": "pcms example", - "name": "peregrine cms example site", - "display": "fullscreen", - "theme_color": "#c0c0c0", - "background_color": "#ffffff", - "icons": [ - { - "src": "/etc/felibs/examplesite/images/launcher-icon-1x.png", - "type": "image/png", - "sizes": "48x48" - }, - { - "src": "/etc/felibs/examplesite/images/launcher-icon-2x.png", - "type": "image/png", - "sizes": "96x96" - }, - { - "src": "/etc/felibs/examplesite/images/launcher-icon-4x.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "/etc/felibs/examplesite/images/launcher-icon-4x.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": "/content/example/pages/index.html" -} \ No newline at end of file diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/serviceworker.js b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/serviceworker.js deleted file mode 100644 index 45a9a5a400..0000000000 --- a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/serviceworker.js +++ /dev/null @@ -1,84 +0,0 @@ -/*- - * #%L - * example site - UI Apps - * %% - * Copyright (C) 2017 headwire inc. - * %% - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - * #L% - */ -var CACHE_NAME = 'my-site-cache-v1'; -var urlsToCache = [ - '/content/example/pages/index.html', - '/content/example/pages/index.html?launcher=true' -]; - -self.addEventListener('install', function(event) { - // Perform install steps - event.waitUntil( - caches.open(CACHE_NAME) - .then(function(cache) { - console.log('Opened cache'); - console.log('cache for', urlsToCache) - return cache.addAll(urlsToCache); - }) - ); -}); - -self.addEventListener('fetch', function(event) { - event.respondWith( - caches.match(event.request) - .then(function(response) { - console.log('request for',event.request) - - // Cache hit - return response - if (response) { - return response; - } - - // IMPORTANT: Clone the request. A request is a stream and - // can only be consumed once. Since we are consuming this - // once by cache and once by the browser for fetch, we need - // to clone the response. - var fetchRequest = event.request.clone(); - - return fetch(fetchRequest).then( - function(response) { - // Check if we received a valid response - if(!response || response.status !== 200 || response.type !== 'basic') { - return response; - } - - // IMPORTANT: Clone the response. A response is a stream - // and because we want the browser to consume the response - // as well as the cache consuming the response, we need - // to clone it so we have two streams. - var responseToCache = response.clone(); - - caches.open(CACHE_NAME) - .then(function(cache) { - cache.put(event.request, responseToCache); - }); - - return response; - } - ); - }) - - ); -}); From c15d91ce9e76e26d6c222f8b12f5ab03e8cb69f6 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 16:20:15 -0500 Subject: [PATCH 23/53] #618 Added test content for SSR scenario 2: inheriting template content from a parent template --- .../main/content/META-INF/vault/filter.xml | 6 ++--- .../pages/sub-template-page/.content.xml | 26 +++++++++++++++++++ .../templates/base/sub-template/.content.xml | 3 +-- 3 files changed, 30 insertions(+), 5 deletions(-) create mode 100644 slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml b/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml index fb9c67d675..1353a54105 100644 --- a/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml +++ b/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml @@ -26,8 +26,8 @@ - - - + + + diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml new file mode 100644 index 0000000000..52b26d5688 --- /dev/null +++ b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml @@ -0,0 +1,26 @@ + + + + + + + + + + diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml index a2bbdce07b..c037322ccf 100644 --- a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml +++ b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml @@ -10,7 +10,6 @@ + jcr:title="example sub-template" />
\ No newline at end of file From b5e78c82e30c7513288da0d725c3f2bf1b95fa7d Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 16:22:09 -0500 Subject: [PATCH 24/53] refactored unit tests moving common binding to setup. added test for SSR scenario 2: sub-template inheritance --- .../peregrine/slingjunit/AdaptionJTest.java | 36 ++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java index ba2b96d73b..4a83c08e29 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java +++ b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java @@ -39,6 +39,7 @@ public class AdaptionJTest { private MockSlingHttpServletRequest request; private Resource resource; + private SimpleBindings bindings; @TestReference private ResourceResolverFactory resolverFactory; private ResourceResolver resourceResolver; @@ -120,11 +121,7 @@ public void ssrPageMergeScenario1(){ // Note: children of containers are not included in the resource list. // /content/example/pages/contact/jcr:content/n3736dc36-9cc3-49d7-a7d4-bf4d94e0ea2f/n8680c077-cc22-40d3-8989-d86d832a85d1 // resources inside containers are rendered when the container is rendered, when it lists all children - SimpleBindings bindings = new SimpleBindings(); bindings.put("resource", resource); - bindings.put("request", request); - bindings.put("modelFactory", modelFactory); - PageMerge pageMerge = new PageMerge(); pageMerge.init(bindings); List actualResources = pageMerge.getMergedResources(); @@ -136,10 +133,41 @@ public void ssrPageMergeScenario1(){ assertTrue(resourcePaths.containsAll(actualResourcePaths)); } + /** + ssrPageMergeScenario2 test pages based on a sub-template + sub-template: /content/example/templates/base/sub-template + page: + */ + @Test + public void ssrPageMergeScenario2(){ + resource = resourceResolver.getResource("/content/example/pages/sub-template-page"); + // set up expected resource list + List resourcePaths = new ArrayList<>(); + resourcePaths.add("/content/example/templates/base/jcr:content/nav"); + resourcePaths.add("/content/example/templates/base/jcr:content/footer"); + resourcePaths.add("/content/example/pages/sub-template-page/jcr:content/container"); + bindings.put("resource", resource); + PageMerge pageMerge = new PageMerge(); + pageMerge.init(bindings); + // run test + List actualResources = pageMerge.getMergedResources(); + assertEquals(resourcePaths.size(), actualResources.size()); + List actualResourcePaths = actualResources.stream() + .map(Resource::getPath) + .collect(Collectors.toList()); + assertTrue(actualResourcePaths.containsAll(resourcePaths)); + assertTrue(resourcePaths.containsAll(actualResourcePaths)); + } + + @Before public void setUp() throws Exception { resourceResolver = resolverFactory.getAdministrativeResourceResolver(null); request = new MockSlingHttpServletRequest(resourceResolver); + bindings = new SimpleBindings(); + bindings.put("request", request); + bindings.put("modelFactory", modelFactory); + bindings.put("resolver", resourceResolver); } @After From 237b96728019a8bf42422a1f225314dbc0f46b8f Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 6 Nov 2020 16:29:14 -0500 Subject: [PATCH 25/53] #618 Updated getChildren method to resolve children resources from parent templates --- .../peregrine/nodetypes/merge/PageMerge.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java index 2417963dc9..85bd900767 100644 --- a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java +++ b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java @@ -32,6 +32,7 @@ import static com.peregrine.commons.util.PerConstants.PAGE_PRIMARY_TYPE; import static com.peregrine.commons.util.PerConstants.PATH; import static java.util.regex.Pattern.compile; +import static org.apache.sling.api.scripting.SlingBindings.RESOLVER; import static org.apache.sling.api.scripting.SlingBindings.RESOURCE; import com.fasterxml.jackson.databind.ObjectMapper; @@ -41,6 +42,7 @@ import javax.script.Bindings; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.scripting.SlingScriptHelper; import org.apache.sling.models.factory.ExportException; import org.apache.sling.models.factory.MissingExporterException; @@ -68,7 +70,7 @@ public class PageMerge implements Use { public static final String REGEX_TEMPLATES = "(?<=\\/content\\/)([a-zA-Z0-9\\\\s\\\\_-])*(?=\\/templates)"; private ModelFactory modelFactory; - + private ResourceResolver resolver; private SlingHttpServletRequest request; private Resource resource; public static RenderContext getRenderContext() { @@ -115,10 +117,27 @@ private void getChildren(Map map, List resources){ } else { basePath = templatePath; } + + Resource templateContent = this.resolver.getResource(basePath+relativePath); + Resource templateResource = this.resolver.getResource(templatePath); + while (Objects.isNull(templateContent) && Objects.nonNull(templateResource)){ + // while loop logic. Enter if templateContent is null, but templateResource is non null. + // then try to resolve the templateContent from template parents content + // exit while loop when templateContent is resolved or templateResource becomes null + templateResource = templateResource.getParent(); + if (Objects.nonNull(templateResource)) { + templateContent = resolver.getResource(templateResource.getPath()+relativePath); + } + } + if(Objects.nonNull(templateContent)){ + resources.add(templateContent); + } + } else { + // page content + Resource pageResource = this.resource.getResourceResolver() + .getResource(resource.getPath()+relativePath); + resources.add(pageResource); } - // get the component resource from the page's content or the template - Resource componentResource = this.resource.getResourceResolver().getResource(basePath+relativePath); - resources.add(componentResource); } public String getMergedForScript() { @@ -147,7 +166,7 @@ public Map getMerged(Resource resource) { } } if(templatePath != null) { - Map template = getMerged(this.resource.getResourceResolver().getResource(templatePath)); + Map template = getMerged(this.resolver.getResource(templatePath)); flagFromTemplate(template); return merge(template, page); } @@ -246,6 +265,7 @@ public void init(final Bindings bindings) { request = (SlingHttpServletRequest) bindings.get(REQUEST); resource = (Resource) bindings.get(RESOURCE); renderContext.set(new RenderContext(request)); + resolver = (ResourceResolver) bindings.get(RESOLVER); SlingScriptHelper sling = (SlingScriptHelper) bindings.get(SLING); if (Objects.nonNull(sling)) { // the typical path From 60f9173c0e37e6b6f40958b997c778cf96f257e1 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Tue, 10 Nov 2020 13:36:22 -0500 Subject: [PATCH 26/53] Added content for JUnit SSR test scenarios --- .../templates/base/.content.xml | 18 ++++++++----- slingjunit.parent/core/pom.xml | 6 +++++ .../main/content/META-INF/vault/filter.xml | 2 ++ .../sub-template-container-page/.content.xml | 25 ++++++++++++++++++ .../base/sub-template-container/.content.xml | 26 +++++++++++++++++++ 5 files changed, 71 insertions(+), 6 deletions(-) create mode 100644 slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml create mode 100644 slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml index c5823660df..75ab1a900c 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/base/.content.xml @@ -38,14 +38,20 @@ sling:resourceType="pagerenderserver/components/base" text="example template content"/> - - - + sling:resourceType="pagerenderserver/components/footer"/> +--> -
diff --git a/slingjunit.parent/core/pom.xml b/slingjunit.parent/core/pom.xml index c83e11b525..40e2a3d934 100644 --- a/slingjunit.parent/core/pom.xml +++ b/slingjunit.parent/core/pom.xml @@ -66,6 +66,12 @@ ${project.version} provided
+ + ${project.groupId} + pagerender-server.core + ${project.version} + provided + diff --git a/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml b/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml index 1353a54105..35d60bae00 100644 --- a/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml +++ b/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml @@ -27,7 +27,9 @@ + + diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml new file mode 100644 index 0000000000..a323228d89 --- /dev/null +++ b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml @@ -0,0 +1,25 @@ + + + + + + + + + + diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml new file mode 100644 index 0000000000..9d6b63161e --- /dev/null +++ b/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml @@ -0,0 +1,26 @@ + + + + + + + + + \ No newline at end of file From 55a569f5a76061663e9d78548ccaa50827583f79 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Tue, 10 Nov 2020 13:39:49 -0500 Subject: [PATCH 27/53] Added JUnit SSR scenario 3 which tests combining content within containers in template with page content containers --- .../peregrine/slingjunit/AdaptionJTest.java | 55 ++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java index 4a83c08e29..57605c36d3 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java +++ b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java @@ -3,6 +3,7 @@ import com.peregrine.adaption.PerAsset; import com.peregrine.adaption.PerPage; import com.peregrine.nodetypes.merge.PageMerge; +import com.peregrine.pagerender.server.models.Container; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; @@ -134,9 +135,13 @@ public void ssrPageMergeScenario1(){ } /** + * ssrPageMergeScenario2 test pages based on a sub-template + + parent-template: /content/example/templates/base sub-template: /content/example/templates/base/sub-template - page: + page: /content/example/pages/sub-template-page + Passes if the $page has content resources inherited from the $parent-template */ @Test public void ssrPageMergeScenario2(){ @@ -159,6 +164,54 @@ public void ssrPageMergeScenario2(){ assertTrue(resourcePaths.containsAll(actualResourcePaths)); } + /** + * + ssrPageMergeScenario3 templates with content containers + + template: /content/pagerenderserver/templates/base + page: /content/pagerenderserver/pages/index + Passes if List actualResources has + content resources inherited from the $template + content resources from the $page + overrides template content with page content if their relative paths are the same + */ + @Test + public void ssrPageMergeScenario3(){ + // set up expected resource list + resource = resourceResolver.getResource("/content/pagerenderserver/pages/index"); + List resourcePaths = new ArrayList<>(); + resourcePaths.add("/content/pagerenderserver/templates/base/jcr:content/base"); + resourcePaths.add("/content/pagerenderserver/pages/index/jcr:content/content"); + bindings.put("resource", resource); + PageMerge pageMerge = new PageMerge(); + pageMerge.init(bindings); + + // run page merge test + List actualResources = pageMerge.getMergedResources(); + assertEquals(resourcePaths.size(), actualResources.size()); + List actualResourcePaths = actualResources.stream() + .map(Resource::getPath) + .collect(Collectors.toList()); + assertTrue(actualResourcePaths.containsAll(resourcePaths)); + assertTrue(resourcePaths.containsAll(actualResourcePaths)); + + // run container merge test + Resource containerRes = resourceResolver.getResource("/content/pagerenderserver/pages/index/jcr:content/content"); + List containerPaths = new ArrayList<>(); + containerPaths.add("/content/pagerenderserver/templates/base/jcr:content/content/text"); + containerPaths.add("/content/pagerenderserver/templates/base/jcr:content/content/text1"); + containerPaths.add("/content/pagerenderserver/pages/index/jcr:content/content/text1"); + containerPaths.add("/content/pagerenderserver/pages/index/jcr:content/content/text2"); + Container containerModel = containerRes.adaptTo(Container.class); + assertNotNull(containerModel); + List combinedResources = containerModel.getCombinedResources(); + List actualCombinedPaths = combinedResources.stream() + .map(Resource::getPath) + .collect(Collectors.toList()); + assertEquals(containerPaths.size(), actualCombinedPaths.size()); + assertTrue(containerPaths.containsAll(actualCombinedPaths)); + } + @Before public void setUp() throws Exception { From 76c10366eb7aac3f8776ea26b1f5e79048056bac Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Tue, 10 Nov 2020 13:42:57 -0500 Subject: [PATCH 28/53] Added getCombinedResources to com.peregrine.pagerender.server.models.Container for SSR test 3 --- .../pagerender/server/models/Container.java | 32 +++++++++++++-- .../components/container/container.html | 40 ++++++++++++++++++- 2 files changed, 67 insertions(+), 5 deletions(-) diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java index 40c8978e8a..309cb4f0d2 100644 --- a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java @@ -25,17 +25,19 @@ * #L% */ -import static com.peregrine.commons.util.PerConstants.JACKSON; -import static com.peregrine.commons.util.PerConstants.JSON; +import static com.peregrine.commons.util.PerConstants.*; import static com.peregrine.pagerender.server.models.PageRenderServerConstants.PR_SERVER_COMPONENT_CONTAINER_TYPE; import com.fasterxml.jackson.annotation.JsonIgnore; +import com.peregrine.adaption.PerPage; import com.peregrine.nodetypes.models.AbstractComponent; import com.peregrine.nodetypes.models.IComponent; -import java.util.List; + +import java.util.*; import javax.inject.Inject; import javax.inject.Named; import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.models.annotations.Exporter; import org.apache.sling.models.annotations.Model; @@ -64,4 +66,28 @@ public Container(Resource r) { public List getChildren() { return children; } + + public List getCombinedResources(){ + ResourceResolver resolver = this.getResource().getResourceResolver(); + List merged = new ArrayList<>(); + // find the page + String pagePath = this.getResource().getPath().substring(0, this.getResource().getPath().indexOf(JCR_CONTENT)); + Resource page = resolver.getResource(pagePath); + PerPage perPage = page.adaptTo(PerPage.class); + String relativePath = this.getPath(); + // find the template + PerPage templatePage = perPage.getTemplate(); + // find the container under the template + if( Objects.nonNull(templatePage)) { + Resource templateContainer = resolver.getResource(templatePage.getPath() + relativePath); + // get template container children, add them to the list + templateContainer.getChildren().forEach(resource -> merged.add(resource)); + } + // get page container children + this.getResource().getChildren().forEach(resource -> { + merged.add(resource); + }); + return merged; + } + } diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html index d1c9ea4d01..20fdafbcd3 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html @@ -1,3 +1,39 @@ - - + + + + + + + +
+ Drop Components +
+ + + \ No newline at end of file From f612ab04a6920bdb35fcb5da4c79dc4ff2cbb59e Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Tue, 10 Nov 2020 14:15:34 -0500 Subject: [PATCH 29/53] missed check for null --- .../com/peregrine/pagerender/server/models/Container.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java index 309cb4f0d2..3dfa3cb09a 100644 --- a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java @@ -78,10 +78,12 @@ public List getCombinedResources(){ // find the template PerPage templatePage = perPage.getTemplate(); // find the container under the template - if( Objects.nonNull(templatePage)) { + if(Objects.nonNull(templatePage)){ Resource templateContainer = resolver.getResource(templatePage.getPath() + relativePath); // get template container children, add them to the list - templateContainer.getChildren().forEach(resource -> merged.add(resource)); + if(Objects.nonNull(templateContainer)){ + templateContainer.getChildren().forEach(resource -> merged.add(resource)); + } } // get page container children this.getResource().getChildren().forEach(resource -> { From bf3a83ce2135f147d0904b57b8fe32e78b0b1638 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 11 Nov 2020 10:20:55 -0500 Subject: [PATCH 30/53] moved css for drop zone to separate css file, server.css --- .../components/container/container.html | 49 ++++++------------- .../components/page/page.html | 4 +- .../content/pagerenderserver/.content.xml | 6 ++- .../felibs/pagerenderserver/css/server.css | 19 +++++++ 4 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/etc/felibs/pagerenderserver/css/server.css diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html index 20fdafbcd3..4b5e36a7c3 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html @@ -1,39 +1,18 @@ - - - +
+ + + + - - + -
- Drop Components +
+ Drop Components +
- - - \ No newline at end of file diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html index 043b2dd3b0..f1009d2010 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html @@ -42,8 +42,8 @@ - - + + diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml index d560fe4550..e920d1d46e 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml @@ -28,4 +28,8 @@ jcr:primaryType="per:Site" jcr:title="Pagerender-Server Site" internal="true" - template="false"/> \ No newline at end of file + template="false"> + + \ No newline at end of file diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/etc/felibs/pagerenderserver/css/server.css b/pagerenderer/server/ui.apps/src/main/content/jcr_root/etc/felibs/pagerenderserver/css/server.css new file mode 100644 index 0000000000..3a295247d0 --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/etc/felibs/pagerenderserver/css/server.css @@ -0,0 +1,19 @@ +.per-drop-target { + border: 1px dashed #c0c0c0; + clear: both; + padding: 4px; + margin: 4px; + text-align: center; + width: calc(100% - 8px); + white-space: nowrap; + text-overflow: ellipsis; + color: black !important; + overflow: hidden; + font-size: 0.75em; + background: #f8f8f8e0; +} +.per-drop-target-empty { + font-size: 1.5em; + height: 3em; + padding-top: 0.75em; +} \ No newline at end of file From 69a5da186674354e64bba0e7fc60a9a4741dd933 Mon Sep 17 00:00:00 2001 From: Ruben Reusser Date: Fri, 13 Nov 2020 08:24:39 -0800 Subject: [PATCH 31/53] fix for adding and editing components --- .../admin/components/contentview/template.vue | 4 +++ .../src/main/js/stateActions/savePageEdit.js | 3 +- .../components/base/base.html | 2 +- .../components/container/container.html | 29 ++++++++++++------- .../components/page/page.html | 8 +++++ 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/admin-base/ui.apps/src/main/content/jcr_root/apps/admin/components/contentview/template.vue b/admin-base/ui.apps/src/main/content/jcr_root/apps/admin/components/contentview/template.vue index 8137443734..babaf85697 100644 --- a/admin-base/ui.apps/src/main/content/jcr_root/apps/admin/components/contentview/template.vue +++ b/admin-base/ui.apps/src/main/content/jcr_root/apps/admin/components/contentview/template.vue @@ -513,6 +513,10 @@ export default { this.reWrapEditable() }, + refreshEditor(vm) { + vm.$refs.editview.contentWindow.location.reload() + }, + onInlineClick(event) { this.pingToolbar() }, diff --git a/admin-base/ui.apps/src/main/js/stateActions/savePageEdit.js b/admin-base/ui.apps/src/main/js/stateActions/savePageEdit.js index 9167d1038a..fa02c9443a 100644 --- a/admin-base/ui.apps/src/main/js/stateActions/savePageEdit.js +++ b/admin-base/ui.apps/src/main/js/stateActions/savePageEdit.js @@ -38,7 +38,8 @@ export default function(me, target) { delete view.state.editor; set(view, '/state/editorVisible', false) if(view.pageView.page.serverSide) { - me.action(me.getApp().$children[0], 'refreshEditor', view.pageView.page).then( () => { resolve() }) + me.action(me.getApp().$children[0], 'refreshEditor', view.pageView.page) + resolve() } else { resolve() } diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/base/base.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/base/base.html index af91ac3191..2fb932f2ca 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/base/base.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/base/base.html @@ -1,4 +1,4 @@ -
${helper.model} +
${helper.model.path} ${properties.text @ context='html'}
\ No newline at end of file diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html index 4b5e36a7c3..dbaa54a962 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html @@ -1,18 +1,27 @@ -
- - - - + +
+ +
+ container start +
+ + + -
- Drop Components +
+ container end
+
+ \ No newline at end of file diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html index f1009d2010..46c3dd07a2 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html @@ -22,6 +22,14 @@ + + From 4891f363740b6ff9c12056879c8d24349189fd65 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 13 Nov 2020 16:10:45 -0500 Subject: [PATCH 32/53] adding missing per:Component metadata for Page. fixes error that occured when creating new templates for pagerendervue tenant --- .../apps/pagerendervue/structure/container/.content.xml | 7 +++++++ .../apps/pagerendervue/structure/page/.content.xml | 9 +++++++++ 2 files changed, 16 insertions(+) create mode 100644 pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/container/.content.xml create mode 100644 pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/page/.content.xml diff --git a/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/container/.content.xml b/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/container/.content.xml new file mode 100644 index 0000000000..22fe87646a --- /dev/null +++ b/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/container/.content.xml @@ -0,0 +1,7 @@ + + + diff --git a/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/page/.content.xml b/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/page/.content.xml new file mode 100644 index 0000000000..13b2b0bd1d --- /dev/null +++ b/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/page/.content.xml @@ -0,0 +1,9 @@ + + + + From 582537f17cda60cdef778991e53f85067aea7117 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 13 Nov 2020 17:09:15 -0500 Subject: [PATCH 33/53] Update pagerenderserver example site metadata. Moved siteCSS and siteJS to /content/pagerenderserver/.content.xml. in anticipation of issue #636. cleaned up base component --- .../jcr_root/apps/pagerenderserver/components/base/base.html | 4 +++- .../content/jcr_root/content/pagerenderserver/.content.xml | 4 +++- .../jcr_root/content/pagerenderserver/templates/.content.xml | 4 +--- .../jcr_root/apps/pagerendervue/structure/page/.content.xml | 1 + 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/base/base.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/base/base.html index 2fb932f2ca..73c0694983 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/base/base.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/base/base.html @@ -1,4 +1,6 @@ -
${helper.model.path} + +
${properties.text @ context='html'} + ${properties.text ? '': 'placeholder text'}
\ No newline at end of file diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml index e920d1d46e..052636d83d 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/.content.xml @@ -31,5 +31,7 @@ template="false"> + siteCSS="[https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css,/etc/felibs/pagerenderserver/css/server.css]" + siteJS="[https://code.jquery.com/jquery-3.1.1.slim.min.js,https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js,https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js]" + /> \ No newline at end of file diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/.content.xml index 3566b4353c..70f706e055 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/.content.xml @@ -33,8 +33,6 @@ + jcr:title="pagerender-server root template"/> diff --git a/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/page/.content.xml b/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/page/.content.xml index 13b2b0bd1d..87f8279968 100644 --- a/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/page/.content.xml +++ b/pagerenderer/vue/ui.apps/src/main/content/jcr_root/apps/pagerendervue/structure/page/.content.xml @@ -6,4 +6,5 @@ xmlns:nt="http://www.jcp.org/jcr/nt/1.0" jcr:primaryType="per:Component" jcr:title="page component pagerendervue" + group=".hidden" templateComponent="true"/> From d29a323c44d47c0f7a222995c497a9c365faad05 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Tue, 17 Nov 2020 18:11:27 -0500 Subject: [PATCH 34/53] #620 added condition for serverSide to addComponentToPath state action such that refreshEditor is called and rendering is refreshed showing added components --- .../js/stateActions/addComponentToPath.js | 29 ++++++++++--------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/admin-base/ui.apps/src/main/js/stateActions/addComponentToPath.js b/admin-base/ui.apps/src/main/js/stateActions/addComponentToPath.js index c8f186a784..c171f00b23 100644 --- a/admin-base/ui.apps/src/main/js/stateActions/addComponentToPath.js +++ b/admin-base/ui.apps/src/main/js/stateActions/addComponentToPath.js @@ -61,19 +61,22 @@ export default function(me, target) { processed = true; return me.getApi().insertNodeAt(target.pagePath+targetNode.path, componentPath, target.drop, variation) .then( (data) => { - if(targetNodeUpdate.fromTemplate === true) { - return me.getApi().populatePageView(me.getNodeFromView('/pageView/path')) - } else { - if(target.drop.startsWith('into')) { - Vue.set(targetNodeUpdate, 'children', data.children) - } - else if(target.drop === 'before' || target.drop === 'after') - { - Vue.set(targetNodeUpdate, 'children', data.children) - } - log.fine(data) - } - }) + if(view.pageView.page.serverSide) { + me.action(me.getApp().$children[0], 'refreshEditor', view.pageView.page) + return me.getApi().populatePageView(me.getNodeFromView('/pageView/path')) + } else if(targetNodeUpdate.fromTemplate === true) { + return me.getApi().populatePageView(me.getNodeFromView('/pageView/path')) + } else { + if(target.drop.startsWith('into')) { + Vue.set(targetNodeUpdate, 'children', data.children) + } + else if(target.drop === 'before' || target.drop === 'after') + { + Vue.set(targetNodeUpdate, 'children', data.children) + } + log.fine(data) + } + }) } // copy/paste? From fcd1b17d7804f09ebb88acc577cca5d95db2a3c5 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 18 Nov 2020 10:39:06 -0500 Subject: [PATCH 35/53] Similar change for getParentContent as done for pagerenderserver. Allows getting parent content from tenant root per:Site/jcr:content --- .../com/peregrine/pagerender/vue/models/PageModel.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pagerenderer/vue/core/src/main/java/com/peregrine/pagerender/vue/models/PageModel.java b/pagerenderer/vue/core/src/main/java/com/peregrine/pagerender/vue/models/PageModel.java index 8a9b311841..0f1d382b8d 100644 --- a/pagerenderer/vue/core/src/main/java/com/peregrine/pagerender/vue/models/PageModel.java +++ b/pagerenderer/vue/core/src/main/java/com/peregrine/pagerender/vue/models/PageModel.java @@ -38,6 +38,7 @@ import com.peregrine.nodetypes.models.IComponent; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import javax.inject.Inject; import javax.inject.Named; @@ -78,11 +79,9 @@ public Resource getParentContent(Resource res) { Resource page = res.getParent(); if(page != null) { Resource parentPage = page.getParent(); - if(parentPage != null) { - if(PAGE_PRIMARY_TYPE.equals(parentPage.getResourceType())) { - Resource child = parentPage.getChild(JCR_CONTENT); - return child; - } + if(Objects.nonNull(parentPage) && Objects.nonNull(parentPage.getChild(JCR_CONTENT))) { + Resource child = parentPage.getChild(JCR_CONTENT); + return child; } } return null; From 9fdbf3a72a504c911671210d58ceaa66b8efab89 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 18 Nov 2020 18:33:56 -0500 Subject: [PATCH 36/53] Related to Issue #620, Added ssrPageMergeScenario4 for newly created pages. Tests that new pages they have containers for authoring and resources inherited from the template --- .../pages/new-empty/.content.xml | 17 ++++++++++++ .../peregrine/nodetypes/merge/PageMerge.java | 27 ++++++++----------- .../peregrine/slingjunit/AdaptionJTest.java | 23 ++++++++++++++++ 3 files changed, 51 insertions(+), 16 deletions(-) create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/new-empty/.content.xml diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/new-empty/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/new-empty/.content.xml new file mode 100644 index 0000000000..89fa112b8f --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/new-empty/.content.xml @@ -0,0 +1,17 @@ + + + + + + + + diff --git a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java index 85bd900767..c911609db9 100644 --- a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java +++ b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java @@ -103,21 +103,21 @@ public List getMergedResources(){ return pageResources; } - private void getChildren(Map map, List resources){ + private void getChildren(Map map, List resources) { String templatePath = getTemplatePath(); String relativePath = (String) map.get("path"); String basePath = resource.getPath(); - if (Objects.nonNull(map.get(FROM_TEMPLATE)) && (boolean) map.get(FROM_TEMPLATE)){ - // if fromTemplate is set true determine whether the resource is an container empty container - List childMaps = (ArrayList) map.get(CHILDREN); - if (Objects.nonNull(childMaps)){ - // this represents a page editing content container - // so basePath needs to be readjusted to the page path - basePath = resource.getPath(); - } else { - basePath = templatePath; - } + if (Objects.nonNull(resolver.getResource(basePath+relativePath))){ + // if resource is from the template and the resource is not a type of container + // then the base path should point to the template + resources.add(resolver.getResource(basePath+relativePath)); + } else if (Objects.nonNull(resolver.getResource(templatePath+relativePath))){ + // if resource is from the template and the resource is type of container + // then the base path should point to the page + resources.add(resolver.getResource(templatePath+relativePath)); + } else { + // otherwise try to add content resource inherited from parent templates Resource templateContent = this.resolver.getResource(basePath+relativePath); Resource templateResource = this.resolver.getResource(templatePath); while (Objects.isNull(templateContent) && Objects.nonNull(templateResource)){ @@ -132,11 +132,6 @@ private void getChildren(Map map, List resources){ if(Objects.nonNull(templateContent)){ resources.add(templateContent); } - } else { - // page content - Resource pageResource = this.resource.getResourceResolver() - .getResource(resource.getPath()+relativePath); - resources.add(pageResource); } } diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java index 57605c36d3..ee0fd6321d 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java +++ b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java @@ -212,6 +212,29 @@ public void ssrPageMergeScenario3(){ assertTrue(containerPaths.containsAll(actualCombinedPaths)); } + /** + * + ssrPageMergeScenario4 new page should have template content, and content containers for authoring + template: /content/pagerenderserver/templates/base + page: /content/pagerenderserver/pages/new-empty + * + */ + @Test + public void ssrPageMergeScenario4(){ + // set up expected resource list + resource = resourceResolver.getResource("/content/pagerenderserver/pages/new-empty"); + List resourcePaths = new ArrayList<>(); + resourcePaths.add("/content/pagerenderserver/templates/base/jcr:content/base"); + resourcePaths.add("/content/pagerenderserver/templates/base/jcr:content/content"); + // set PageMerge object to test + bindings.put("resource", resource); + PageMerge pageMerge = new PageMerge(); + pageMerge.init(bindings); + // run page merge test + List actualResources = pageMerge.getMergedResources(); + assertEquals(resourcePaths.size(), actualResources.size()); + + } @Before public void setUp() throws Exception { From 349ca42631f26ac782b9bc46d041ce6a1ee5c90c Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 18 Nov 2020 18:38:23 -0500 Subject: [PATCH 37/53] optimize imports --- .../peregrine/nodetypes/merge/PageMerge.java | 35 +++++++++++-------- .../peregrine/slingjunit/AdaptionJTest.java | 9 +++-- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java index c911609db9..737c2f3e74 100644 --- a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java +++ b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java @@ -25,21 +25,7 @@ * #L% */ -import static com.peregrine.commons.util.PerConstants.COMPONENT; -import static com.peregrine.commons.util.PerConstants.JACKSON; -import static com.peregrine.commons.util.PerConstants.JCR_CONTENT; -import static com.peregrine.commons.util.PerConstants.NT_UNSTRUCTURED; -import static com.peregrine.commons.util.PerConstants.PAGE_PRIMARY_TYPE; -import static com.peregrine.commons.util.PerConstants.PATH; -import static java.util.regex.Pattern.compile; -import static org.apache.sling.api.scripting.SlingBindings.RESOLVER; -import static org.apache.sling.api.scripting.SlingBindings.RESOURCE; - import com.fasterxml.jackson.databind.ObjectMapper; -import java.io.IOException; -import java.io.StringWriter; -import java.util.*; -import javax.script.Bindings; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; @@ -51,6 +37,27 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import javax.script.Bindings; +import java.io.IOException; +import java.io.StringWriter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.TreeMap; + +import static com.peregrine.commons.util.PerConstants.COMPONENT; +import static com.peregrine.commons.util.PerConstants.JACKSON; +import static com.peregrine.commons.util.PerConstants.JCR_CONTENT; +import static com.peregrine.commons.util.PerConstants.NT_UNSTRUCTURED; +import static com.peregrine.commons.util.PerConstants.PAGE_PRIMARY_TYPE; +import static com.peregrine.commons.util.PerConstants.PATH; +import static java.util.regex.Pattern.compile; +import static org.apache.sling.api.scripting.SlingBindings.RESOLVER; +import static org.apache.sling.api.scripting.SlingBindings.RESOURCE; + /** * Created by rr on 5/8/2017. */ diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java index ee0fd6321d..3484b16c80 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java +++ b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java @@ -8,14 +8,15 @@ import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.api.resource.ResourceUtil; -import org.apache.sling.models.factory.ModelFactory; import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner; import org.apache.sling.junit.annotations.TestReference; +import org.apache.sling.models.factory.ModelFactory; import org.apache.sling.servlethelpers.MockSlingHttpServletRequest; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; + import javax.jcr.Node; import javax.jcr.RepositoryException; import javax.jcr.nodetype.NodeType; @@ -23,8 +24,12 @@ import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; + import static junit.framework.TestCase.assertNotNull; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * Run test using this URL From dd66c3dba6d82954ac49607b5550fddf4a7ee7d2 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Thu, 19 Nov 2020 12:34:06 -0500 Subject: [PATCH 38/53] Setup for ssrPageMergeScenario5: adding content to empty containers on page --- .../pages/non-empty-container/.content.xml | 21 ++++++++++ .../templates/empty-container/.content.xml | 18 ++++++++ .../peregrine/slingjunit/AdaptionJTest.java | 41 +++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/non-empty-container/.content.xml create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/empty-container/.content.xml diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/non-empty-container/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/non-empty-container/.content.xml new file mode 100644 index 0000000000..4479287ae5 --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/pages/non-empty-container/.content.xml @@ -0,0 +1,21 @@ + + + + + + + + + + diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/empty-container/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/empty-container/.content.xml new file mode 100644 index 0000000000..94437347c1 --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/empty-container/.content.xml @@ -0,0 +1,18 @@ + + + + + + + + + + diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java index 3484b16c80..6a1d0fa9c7 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java +++ b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java @@ -25,7 +25,9 @@ import java.util.List; import java.util.stream.Collectors; +import static com.peregrine.commons.util.PerConstants.NT_UNSTRUCTURED; import static junit.framework.TestCase.assertNotNull; +import static org.apache.sling.api.resource.Resource.RESOURCE_TYPE_NON_EXISTING; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -238,7 +240,46 @@ public void ssrPageMergeScenario4(){ // run page merge test List actualResources = pageMerge.getMergedResources(); assertEquals(resourcePaths.size(), actualResources.size()); + assertAllResourcesHaveTypes(actualResources); + } + + /** + * + ssrPageMergeScenario5 + Test intermediate resources such that a template is configured with an empty container for authoring page + An author drops a component into the container from a page. The container resource type defined by the template should define the + rendering even though the container's intermediate path within the page's content has no resource type + template/jcr:content/container (sling:resourceType) + page/jcr:content/container (only nt:unstructured) + + template: /content/pagerenderserver/templates/empty-container + page: /content/pagerenderserver/pages/non-empty-container + * + */ + @Test + public void ssrPageMergeScenario5(){ + // set up expected resource list + resource = resourceResolver.getResource("/content/pagerenderserver/pages/non-empty-container"); + List resourcePaths = new ArrayList<>(); + resourcePaths.add("/content/pagerenderserver/pages/non-empty-container/jcr:content/content"); + // set PageMerge object to test + bindings.put("resource", resource); + PageMerge pageMerge = new PageMerge(); + pageMerge.init(bindings); + // run page merge test + List actualResources = pageMerge.getMergedResources(); + assertEquals(resourcePaths.size(), actualResources.size()); + assertAllResourcesHaveTypes(actualResources); + } + private void assertAllResourcesHaveTypes(List resourceList){ + resourceList.stream().forEach( resourceInList -> { + assertNotNull(resourceInList.getResourceType()); + assertFalse(resourceInList.getResourceType().isEmpty()); + assertFalse(resourceInList.getResourceType().isBlank()); + assertFalse(resourceInList.getResourceType().equals(RESOURCE_TYPE_NON_EXISTING)); + assertFalse(resourceInList.getResourceType().equals(NT_UNSTRUCTURED)); + }); } @Before From 26954fad4ab8f99a662e88c19b6ada2ff620222f Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Thu, 19 Nov 2020 15:45:29 -0500 Subject: [PATCH 39/53] #620 implemented html renderer for nt:unstructured as a Container that merges children and properties for template and page resources --- pagerenderer/server/core/pom.xml | 6 ++ .../pagerender/server/helpers/PageHelper.java | 6 -- .../pagerender/server/models/Container.java | 72 +++++++++++++------ .../main/content/META-INF/vault/filter.xml | 1 + .../apps/nt/unstructured/unstructured.html | 22 ++++++ .../components/container/container.html | 4 -- .../templates/empty-container/.content.xml | 1 + .../peregrine/nodetypes/merge/PageMerge.java | 3 +- .../peregrine/slingjunit/AdaptionJTest.java | 21 +++--- 9 files changed, 94 insertions(+), 42 deletions(-) create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/nt/unstructured/unstructured.html diff --git a/pagerenderer/server/core/pom.xml b/pagerenderer/server/core/pom.xml index 4e6d2cdbd7..a020d8b218 100644 --- a/pagerenderer/server/core/pom.xml +++ b/pagerenderer/server/core/pom.xml @@ -152,6 +152,12 @@ javax.inject + + javax.annotation + javax.annotation-api + 1.3.2 + + org.apache.sling org.apache.sling.scripting.sightly.compiler.java diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java index 206481d9a5..ddff8c18c4 100644 --- a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/helpers/PageHelper.java @@ -7,15 +7,10 @@ public class PageHelper extends BaseHelper { - public String getHello() { - return "hello"; - } - public String getPath() { return this.getResource().getPath(); } - public String getSiteRootPath() { return Objects.nonNull(getSiteRoot()) ? getSiteRoot().getPath() : null; } @@ -32,5 +27,4 @@ public String[] getSiteCSS(){ public void init(Bindings bindings) { super.init(bindings); } - } \ No newline at end of file diff --git a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java index 3dfa3cb09a..a3fedd6463 100644 --- a/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java +++ b/pagerenderer/server/core/src/main/java/com/peregrine/pagerender/server/models/Container.java @@ -25,21 +25,28 @@ * #L% */ -import static com.peregrine.commons.util.PerConstants.*; -import static com.peregrine.pagerender.server.models.PageRenderServerConstants.PR_SERVER_COMPONENT_CONTAINER_TYPE; - import com.fasterxml.jackson.annotation.JsonIgnore; import com.peregrine.adaption.PerPage; import com.peregrine.nodetypes.models.AbstractComponent; import com.peregrine.nodetypes.models.IComponent; - -import java.util.*; -import javax.inject.Inject; -import javax.inject.Named; import org.apache.sling.api.resource.Resource; import org.apache.sling.api.resource.ResourceResolver; +import org.apache.sling.api.resource.ValueMap; +import org.apache.sling.api.wrappers.CompositeValueMap; import org.apache.sling.models.annotations.Exporter; import org.apache.sling.models.annotations.Model; +import javax.annotation.PostConstruct; + +import javax.inject.Inject; +import javax.inject.Named; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; + +import static com.peregrine.commons.util.PerConstants.JACKSON; +import static com.peregrine.commons.util.PerConstants.JCR_CONTENT; +import static com.peregrine.commons.util.PerConstants.JSON; +import static com.peregrine.pagerender.server.models.PageRenderServerConstants.PR_SERVER_COMPONENT_CONTAINER_TYPE; /** * Created by rr on 12/2/2016. @@ -53,6 +60,14 @@ extensions = JSON) public class Container extends AbstractComponent { + private ResourceResolver resolver; + private String pagePath; + private Resource page; + private PerPage templatePage; + private PerPage perPage; + private String relativePath; + private Resource templateContainer; + @Inject @Named(".") private List children; @@ -68,23 +83,14 @@ public List getChildren() { } public List getCombinedResources(){ - ResourceResolver resolver = this.getResource().getResourceResolver(); + if (Objects.isNull(resolver)){ + setup(); + } List merged = new ArrayList<>(); - // find the page - String pagePath = this.getResource().getPath().substring(0, this.getResource().getPath().indexOf(JCR_CONTENT)); - Resource page = resolver.getResource(pagePath); - PerPage perPage = page.adaptTo(PerPage.class); - String relativePath = this.getPath(); - // find the template - PerPage templatePage = perPage.getTemplate(); - // find the container under the template - if(Objects.nonNull(templatePage)){ - Resource templateContainer = resolver.getResource(templatePage.getPath() + relativePath); - // get template container children, add them to the list + // get template container children, add them to the list if(Objects.nonNull(templateContainer)){ templateContainer.getChildren().forEach(resource -> merged.add(resource)); } - } // get page container children this.getResource().getChildren().forEach(resource -> { merged.add(resource); @@ -92,4 +98,30 @@ public List getCombinedResources(){ return merged; } + public ValueMap getCombinedProperties(){ + if (Objects.isNull(resolver)){ + setup(); + } + ValueMap contentVM = this.getResource().getValueMap(); + if (Objects.nonNull(templateContainer)){ + ValueMap templateVM = templateContainer.getValueMap(); + return new CompositeValueMap(contentVM, templateVM, true); + } else { + return contentVM; + } + } + + + void setup() { + resolver = this.getResource().getResourceResolver(); + pagePath = this.getResource().getPath().substring(0, this.getResource().getPath().indexOf(JCR_CONTENT)); + page = resolver.getResource(pagePath); + perPage = page.adaptTo(PerPage.class); + templatePage = perPage.getTemplate(); + relativePath = this.getPath(); + // find the container under the template + if (Objects.nonNull(templatePage)) { + templateContainer = resolver.getResource(templatePage.getPath() + relativePath); + } + } } diff --git a/pagerenderer/server/ui.apps/src/main/content/META-INF/vault/filter.xml b/pagerenderer/server/ui.apps/src/main/content/META-INF/vault/filter.xml index 9225182859..e19dd730cc 100644 --- a/pagerenderer/server/ui.apps/src/main/content/META-INF/vault/filter.xml +++ b/pagerenderer/server/ui.apps/src/main/content/META-INF/vault/filter.xml @@ -31,4 +31,5 @@ + diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/nt/unstructured/unstructured.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/nt/unstructured/unstructured.html new file mode 100644 index 0000000000..19311a1cfe --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/nt/unstructured/unstructured.html @@ -0,0 +1,22 @@ + +
+
+ container start +
+ + + + + +
+ container end +
+ +
+
\ No newline at end of file diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html index dbaa54a962..4996c93705 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html @@ -12,10 +12,6 @@ - -
diff --git a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java index 737c2f3e74..67fcc6993e 100644 --- a/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java +++ b/platform/base/core/src/main/java/com/peregrine/nodetypes/merge/PageMerge.java @@ -119,6 +119,7 @@ private void getChildren(Map map, List resources) { // if resource is from the template and the resource is not a type of container // then the base path should point to the template resources.add(resolver.getResource(basePath+relativePath)); + } else if (Objects.nonNull(resolver.getResource(templatePath+relativePath))){ // if resource is from the template and the resource is type of container // then the base path should point to the page @@ -136,7 +137,7 @@ private void getChildren(Map map, List resources) { templateContent = resolver.getResource(templateResource.getPath()+relativePath); } } - if(Objects.nonNull(templateContent)){ + if (Objects.nonNull(templateContent)){ resources.add(templateContent); } } diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java index 6a1d0fa9c7..e074502241 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java +++ b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/AdaptionJTest.java @@ -240,7 +240,6 @@ public void ssrPageMergeScenario4(){ // run page merge test List actualResources = pageMerge.getMergedResources(); assertEquals(resourcePaths.size(), actualResources.size()); - assertAllResourcesHaveTypes(actualResources); } /** @@ -269,19 +268,19 @@ public void ssrPageMergeScenario5(){ // run page merge test List actualResources = pageMerge.getMergedResources(); assertEquals(resourcePaths.size(), actualResources.size()); - assertAllResourcesHaveTypes(actualResources); - } - private void assertAllResourcesHaveTypes(List resourceList){ - resourceList.stream().forEach( resourceInList -> { - assertNotNull(resourceInList.getResourceType()); - assertFalse(resourceInList.getResourceType().isEmpty()); - assertFalse(resourceInList.getResourceType().isBlank()); - assertFalse(resourceInList.getResourceType().equals(RESOURCE_TYPE_NON_EXISTING)); - assertFalse(resourceInList.getResourceType().equals(NT_UNSTRUCTURED)); - }); + // test intermediate container (nt:unstructured) + resource = resourceResolver.getResource("/content/pagerenderserver/pages/non-empty-container/jcr:content/content"); + assertTrue(resource.getResourceType().equals(NT_UNSTRUCTURED)); + Container containerRes = resource.adaptTo(Container.class); + assertNotNull(containerRes); + assertEquals(1, containerRes.getCombinedResources().size()); + assertEquals("/content/pagerenderserver/pages/non-empty-container/jcr:content/content/text1", + containerRes.getCombinedResources().get(0).getPath()); + assertEquals("12", containerRes.getCombinedProperties().get("mobilecolspan", String.class)); } + @Before public void setUp() throws Exception { resourceResolver = resolverFactory.getAdministrativeResourceResolver(null); From 708d3dde8f9d8db8328dee5529363aa3213dee62 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 20 Nov 2020 10:57:17 -0500 Subject: [PATCH 40/53] #620 Update server.css to hide/show the container drop zone depending on author mode --- .../etc/felibs/pagerenderserver/css/server.css | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/etc/felibs/pagerenderserver/css/server.css b/pagerenderer/server/ui.apps/src/main/content/jcr_root/etc/felibs/pagerenderserver/css/server.css index 3a295247d0..a30dda6620 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/etc/felibs/pagerenderserver/css/server.css +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/etc/felibs/pagerenderserver/css/server.css @@ -1,4 +1,11 @@ .per-drop-target { + display: none; +} +.per-drop-target-empty { + display: none; +} +.edit-mode .per-drop-target { + display: inherit; border: 1px dashed #c0c0c0; clear: both; padding: 4px; @@ -12,7 +19,8 @@ font-size: 0.75em; background: #f8f8f8e0; } -.per-drop-target-empty { +.edit-mode .per-drop-target-empty { + display: inherit; font-size: 1.5em; height: 3em; padding-top: 0.75em; From 930068e98a7af10259832bf035435d23bc1717fd Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Thu, 8 Apr 2021 16:17:08 -0400 Subject: [PATCH 41/53] Refactored slingjunit tests such that remote tests are available when 'remote' runmode exists, local replication tests are available when 'local' runmode exists, and there is a common set of test as well --- slingjunit.parent/core.local/pom.xml | 229 ++++++++++++++++++ .../slingjunit/localFS/LocalFSJTest.java | 1 - ...inWhitelist.fragment-slingjunit-local.json | 5 + slingjunit.parent/core.remote/pom.xml | 223 +++++++++++++++++ .../slingjunit/author/PermissionJTest.java | 3 +- .../author/RemoteReplAuthorJTest.java | 1 - ...nWhitelist.fragment-slingjunit-remote.json | 5 + slingjunit.parent/core/pom.xml | 2 +- .../slingjunit/ReplicationTestBase.java | 2 +- .../{ui.apps => package.common}/pom.xml | 9 +- .../main/content/META-INF/vault/filter.xml | 0 .../main/content/META-INF/vault/settings.xml | 0 .../content/example/assets/.content.xml | 0 .../example/assets/images/.content.xml | 0 .../assets/images/Stella.png/.content.xml | 0 .../Stella.png/_jcr_content/_jcr_data.binary | Bin .../_jcr_content/metadata/.content.xml | 0 .../metadata/icc-profile/.content.xml | 0 .../metadata/per-data/.content.xml | 0 .../metadata/png-iccp/.content.xml | 0 .../metadata/png-ihdr/.content.xml | 0 .../metadata/png-phys/.content.xml | 0 .../_jcr_content/metadata/xmp/.content.xml | 0 .../assets/images/logo.png/.content.xml | 0 .../logo.png/_jcr_content/_jcr_data.binary | Bin .../images/peregrine-logo.png/.content.xml | 0 .../_jcr_content/_jcr_data.binary | Bin .../content/example/pages/.content.xml | 0 .../example/pages/contact/.content.xml | 0 .../sub-template-container-page/.content.xml | 0 .../pages/sub-template-page/.content.xml | 0 .../base/sub-template-container/.content.xml | 0 .../templates/base/sub-template/.content.xml | 0 slingjunit.parent/package.local/pom.xml | 119 +++++++++ .../main/content/META-INF/vault/filter.xml | 28 +++ .../main/content/META-INF/vault/settings.xml | 29 +++ slingjunit.parent/package.remote/pom.xml | 119 +++++++++ .../main/content/META-INF/vault/filter.xml | 28 +++ .../main/content/META-INF/vault/settings.xml | 29 +++ slingjunit.parent/pom.xml | 6 +- 40 files changed, 829 insertions(+), 9 deletions(-) create mode 100644 slingjunit.parent/core.local/pom.xml rename slingjunit.parent/{core => core.local}/src/main/java/com/peregrine/slingjunit/localFS/LocalFSJTest.java (98%) create mode 100644 slingjunit.parent/core.local/src/main/resources/SLING-INF/contents/apps/per/slingjunit/config/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-slingjunit-local.json create mode 100644 slingjunit.parent/core.remote/pom.xml rename slingjunit.parent/{core => core.remote}/src/main/java/com/peregrine/slingjunit/author/PermissionJTest.java (97%) rename slingjunit.parent/{core => core.remote}/src/main/java/com/peregrine/slingjunit/author/RemoteReplAuthorJTest.java (98%) create mode 100644 slingjunit.parent/core.remote/src/main/resources/SLING-INF/contents/apps/per/slingjunit/config/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-slingjunit-remote.json rename slingjunit.parent/{ui.apps => package.common}/pom.xml (94%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/META-INF/vault/filter.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/META-INF/vault/settings.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/_jcr_data.binary (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/icc-profile/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/per-data/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-iccp/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-ihdr/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-phys/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/xmp/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/logo.png/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/logo.png/_jcr_content/_jcr_data.binary (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/_jcr_content/_jcr_data.binary (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/pages/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/pages/contact/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml (100%) rename slingjunit.parent/{ui.apps => package.common}/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml (100%) create mode 100644 slingjunit.parent/package.local/pom.xml create mode 100644 slingjunit.parent/package.local/src/main/content/META-INF/vault/filter.xml create mode 100644 slingjunit.parent/package.local/src/main/content/META-INF/vault/settings.xml create mode 100644 slingjunit.parent/package.remote/pom.xml create mode 100644 slingjunit.parent/package.remote/src/main/content/META-INF/vault/filter.xml create mode 100644 slingjunit.parent/package.remote/src/main/content/META-INF/vault/settings.xml diff --git a/slingjunit.parent/core.local/pom.xml b/slingjunit.parent/core.local/pom.xml new file mode 100644 index 0000000000..87bb2bd0a5 --- /dev/null +++ b/slingjunit.parent/core.local/pom.xml @@ -0,0 +1,229 @@ + + + + + 4.0.0 + + + com.peregrine-cms + slingjunit.parent + 1.0-SNAPSHOT + ../pom.xml + + + slingjunit.core.local + bundle + Peregrine Sling-JUnit 'local' Runmode Tests + JUnit tests for Peregrine CMS designed to the run within Sling-JUnit test-runner, /system/sling/junit/.html + + + + + org.apache.sling + org.apache.sling.junit.core + provided + + + junit + junit + provided + + + ${project.groupId} + admin.core + ${project.version} + provided + + + ${project.groupId} + base.core + ${project.version} + provided + + + ${project.groupId} + pagerender-server.core + ${project.version} + provided + + + ${project.groupId} + admin.core + ${project.version} + provided + + + ${project.groupId} + slingjunit.core + ${project.version} + provided + + + org.slf4j + slf4j-api + provided + + + guava + com.google.guava + provided + + + org.apache.jackrabbit + jackrabbit-jcr-commons + + + org.apache.sling + org.apache.sling.api + + + javax.jcr + jcr + + + org.apache.sling + org.apache.sling.settings + + + org.osgi + osgi.annotation + + + org.osgi + org.osgi.service.component.annotations + + + org.apache.jackrabbit + oak-api + 1.26.0 + provided + + + org.apache.jackrabbit + jackrabbit-api + + + org.apache.sling + org.apache.sling.jcr.jackrabbit.accessmanager + 3.0.8 + provided + + + org.osgi + org.osgi.service.cm + 1.6.0 + provided + + + org.apache.sling + org.apache.sling.models.api + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + org.apache.jackrabbit + oak-core-spi + 1.38.0 + + + org.apache.sling + org.apache.sling.scripting.sightly.compiler.java + 1.0.18 + provided + + + org.apache.sling + org.apache.sling.servlet-helpers + + + + + + + + src/main/resources + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + org.apache.felix + maven-bundle-plugin + true + + + *;scope=compile;inline=true + .*JTest + + SLING-INF/contents;overwrite=true + + + <_noee>true + + + + + + org.apache.sling + maven-sling-plugin + + http://${sling.host}:${sling.port}/system/console + ${sling.user} + ${sling.password} + + + + + + + + autoInstallBundle + + + + org.apache.sling + maven-sling-plugin + + + install-bundle + + install + + + + + + + + + + + \ No newline at end of file diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/localFS/LocalFSJTest.java b/slingjunit.parent/core.local/src/main/java/com/peregrine/slingjunit/localFS/LocalFSJTest.java similarity index 98% rename from slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/localFS/LocalFSJTest.java rename to slingjunit.parent/core.local/src/main/java/com/peregrine/slingjunit/localFS/LocalFSJTest.java index 2bd988aaed..582b85f0b1 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/localFS/LocalFSJTest.java +++ b/slingjunit.parent/core.local/src/main/java/com/peregrine/slingjunit/localFS/LocalFSJTest.java @@ -16,7 +16,6 @@ import org.junit.runner.RunWith; import java.io.File; import java.util.Calendar; -import static com.peregrine.slingjunit.author.RemoteReplAuthorJTest.STELLA_PNG; import static org.apache.jackrabbit.JcrConstants.JCR_LASTMODIFIED; import static org.junit.Assert.*; import static org.junit.Assert.assertFalse; diff --git a/slingjunit.parent/core.local/src/main/resources/SLING-INF/contents/apps/per/slingjunit/config/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-slingjunit-local.json b/slingjunit.parent/core.local/src/main/resources/SLING-INF/contents/apps/per/slingjunit/config/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-slingjunit-local.json new file mode 100644 index 0000000000..6073498465 --- /dev/null +++ b/slingjunit.parent/core.local/src/main/resources/SLING-INF/contents/apps/per/slingjunit/config/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-slingjunit-local.json @@ -0,0 +1,5 @@ +{ + "jcr:primaryType": "sling:OsgiConfig", + "whitelist.name": "slingjunit", + "whitelist.bundles": ["org.apache.sling.junit.core.local"] +} diff --git a/slingjunit.parent/core.remote/pom.xml b/slingjunit.parent/core.remote/pom.xml new file mode 100644 index 0000000000..4071553550 --- /dev/null +++ b/slingjunit.parent/core.remote/pom.xml @@ -0,0 +1,223 @@ + + + + + 4.0.0 + + + com.peregrine-cms + slingjunit.parent + 1.0-SNAPSHOT + ../pom.xml + + + slingjunit.core.remote + bundle + Peregrine Sling-JUnit 'remote' Runmode Tests + JUnit tests for Peregrine CMS designed to the run within Sling-JUnit test-runner, /system/sling/junit/.html + + + + + org.apache.sling + org.apache.sling.junit.core + provided + + + junit + junit + provided + + + ${project.groupId} + admin.core + ${project.version} + provided + + + ${project.groupId} + base.core + ${project.version} + provided + + + ${project.groupId} + slingjunit.core + ${project.version} + provided + + + ${project.groupId} + pagerender-server.core + ${project.version} + provided + + + org.slf4j + slf4j-api + provided + + + guava + com.google.guava + provided + + + org.apache.jackrabbit + jackrabbit-jcr-commons + + + org.apache.sling + org.apache.sling.api + + + javax.jcr + jcr + + + org.apache.sling + org.apache.sling.settings + + + org.osgi + osgi.annotation + + + org.osgi + org.osgi.service.component.annotations + + + org.apache.jackrabbit + oak-api + 1.26.0 + provided + + + org.apache.jackrabbit + jackrabbit-api + + + org.apache.sling + org.apache.sling.jcr.jackrabbit.accessmanager + 3.0.8 + provided + + + org.osgi + org.osgi.service.cm + 1.6.0 + provided + + + org.apache.sling + org.apache.sling.models.api + + + org.apache.httpcomponents + httpclient + 4.5.13 + + + org.apache.jackrabbit + oak-core-spi + 1.38.0 + + + org.apache.sling + org.apache.sling.scripting.sightly.compiler.java + 1.0.18 + provided + + + org.apache.sling + org.apache.sling.servlet-helpers + + + + + + + + src/main/resources + + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${maven.compiler.source} + ${maven.compiler.target} + + + + org.apache.felix + maven-bundle-plugin + true + + + *;scope=compile;inline=true + .*JTest + + SLING-INF/contents;overwrite=true + + + <_noee>true + + + + + + org.apache.sling + maven-sling-plugin + + http://${sling.host}:${sling.port}/system/console + ${sling.user} + ${sling.password} + + + + + + + + autoInstallBundle + + + + org.apache.sling + maven-sling-plugin + + + install-bundle + + install + + + + + + + + + + + \ No newline at end of file diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/author/PermissionJTest.java b/slingjunit.parent/core.remote/src/main/java/com/peregrine/slingjunit/author/PermissionJTest.java similarity index 97% rename from slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/author/PermissionJTest.java rename to slingjunit.parent/core.remote/src/main/java/com/peregrine/slingjunit/author/PermissionJTest.java index 69d3200ce1..ef1c0e374a 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/author/PermissionJTest.java +++ b/slingjunit.parent/core.remote/src/main/java/com/peregrine/slingjunit/author/PermissionJTest.java @@ -34,13 +34,12 @@ import org.junit.runner.RunWith; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - -import static com.peregrine.slingjunit.VersionsJTest.EXAMPLE_SITE_ROOT; import static org.junit.Assert.*; @RunWith(SlingAnnotationsTestRunner.class) public class PermissionJTest { + static final public String EXAMPLE_SITE_ROOT = "/content/example"; private final Logger logger = LoggerFactory.getLogger(getClass()); @TestReference AdminResourceHandler resourceManagement; diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/author/RemoteReplAuthorJTest.java b/slingjunit.parent/core.remote/src/main/java/com/peregrine/slingjunit/author/RemoteReplAuthorJTest.java similarity index 98% rename from slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/author/RemoteReplAuthorJTest.java rename to slingjunit.parent/core.remote/src/main/java/com/peregrine/slingjunit/author/RemoteReplAuthorJTest.java index 3aece4a8fd..6df0c5a0a6 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/author/RemoteReplAuthorJTest.java +++ b/slingjunit.parent/core.remote/src/main/java/com/peregrine/slingjunit/author/RemoteReplAuthorJTest.java @@ -64,7 +64,6 @@ public class RemoteReplAuthorJTest extends ReplicationTestBase { "com.peregrine-cms.distribution:test-distribution=distribution-agent-user" }; private static String USER_MAPPING = "user.mapping"; - public static String STELLA_PNG = "/content/example/assets/images/Stella.png"; private static String CONTACT_PATH = "/content/example/pages/contact"; private static String COMPONENT_PATH= "/content/example/pages/contact/jcr:content/n3736dc36-9cc3-49d7-a7d4-bf4d94e0ea2f"; private static String REMOTE = "remote"; diff --git a/slingjunit.parent/core.remote/src/main/resources/SLING-INF/contents/apps/per/slingjunit/config/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-slingjunit-remote.json b/slingjunit.parent/core.remote/src/main/resources/SLING-INF/contents/apps/per/slingjunit/config/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-slingjunit-remote.json new file mode 100644 index 0000000000..672cdbe17e --- /dev/null +++ b/slingjunit.parent/core.remote/src/main/resources/SLING-INF/contents/apps/per/slingjunit/config/org.apache.sling.jcr.base.internal.LoginAdminWhitelist.fragment-slingjunit-remote.json @@ -0,0 +1,5 @@ +{ + "jcr:primaryType": "sling:OsgiConfig", + "whitelist.name": "slingjunit", + "whitelist.bundles": ["org.apache.sling.junit.core.remote"] +} diff --git a/slingjunit.parent/core/pom.xml b/slingjunit.parent/core/pom.xml index 07acc68542..422de7d363 100644 --- a/slingjunit.parent/core/pom.xml +++ b/slingjunit.parent/core/pom.xml @@ -31,7 +31,7 @@ slingjunit.core bundle - Peregrine Sling-JUnit Testing Bundle + Peregrine Sling-JUnit Common Tests Bundle JUnit tests for Peregrine CMS designed to the run within Sling-JUnit test-runner, /system/sling/junit/.html diff --git a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/ReplicationTestBase.java b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/ReplicationTestBase.java index 68e2f20289..b863ef90c4 100644 --- a/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/ReplicationTestBase.java +++ b/slingjunit.parent/core/src/main/java/com/peregrine/slingjunit/ReplicationTestBase.java @@ -17,7 +17,7 @@ public abstract class ReplicationTestBase { private static String PUBLISH_DOMAIN = "http://localhost:8180"; - + public static String STELLA_PNG = "/content/example/assets/images/Stella.png"; protected Calendar beforeTime; protected void setPublishDomain(String publishDomain) { diff --git a/slingjunit.parent/ui.apps/pom.xml b/slingjunit.parent/package.common/pom.xml similarity index 94% rename from slingjunit.parent/ui.apps/pom.xml rename to slingjunit.parent/package.common/pom.xml index 30c91b1e1d..d585aa0c59 100644 --- a/slingjunit.parent/ui.apps/pom.xml +++ b/slingjunit.parent/package.common/pom.xml @@ -29,7 +29,7 @@ ../pom.xml - slingjunit.ui.apps + slingjunit.package.common content-package Peregrine Sling-JUnit Testing Package @@ -49,6 +49,11 @@ slingjunit.core ${project.version} + + ${project.groupId} + slingjunit.core.remote + ${project.version} + @@ -93,6 +98,7 @@ + core-junit-test-package package @@ -117,7 +123,6 @@ ${project.version} - diff --git a/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml b/slingjunit.parent/package.common/src/main/content/META-INF/vault/filter.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/META-INF/vault/filter.xml rename to slingjunit.parent/package.common/src/main/content/META-INF/vault/filter.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/META-INF/vault/settings.xml b/slingjunit.parent/package.common/src/main/content/META-INF/vault/settings.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/META-INF/vault/settings.xml rename to slingjunit.parent/package.common/src/main/content/META-INF/vault/settings.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/_jcr_data.binary b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/_jcr_data.binary similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/_jcr_data.binary rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/_jcr_data.binary diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/icc-profile/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/icc-profile/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/icc-profile/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/icc-profile/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/per-data/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/per-data/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/per-data/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/per-data/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-iccp/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-iccp/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-iccp/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-iccp/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-ihdr/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-ihdr/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-ihdr/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-ihdr/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-phys/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-phys/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-phys/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/png-phys/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/xmp/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/xmp/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/xmp/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/Stella.png/_jcr_content/metadata/xmp/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/logo.png/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/logo.png/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/logo.png/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/logo.png/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/logo.png/_jcr_content/_jcr_data.binary b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/logo.png/_jcr_content/_jcr_data.binary similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/logo.png/_jcr_content/_jcr_data.binary rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/logo.png/_jcr_content/_jcr_data.binary diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/_jcr_content/_jcr_data.binary b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/_jcr_content/_jcr_data.binary similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/_jcr_content/_jcr_data.binary rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/assets/images/peregrine-logo.png/_jcr_content/_jcr_data.binary diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/pages/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/pages/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/contact/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/pages/contact/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/contact/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/pages/contact/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/pages/sub-template-container-page/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/pages/sub-template-page/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/templates/base/sub-template-container/.content.xml diff --git a/slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml b/slingjunit.parent/package.common/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml similarity index 100% rename from slingjunit.parent/ui.apps/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml rename to slingjunit.parent/package.common/src/main/content/jcr_root/content/example/templates/base/sub-template/.content.xml diff --git a/slingjunit.parent/package.local/pom.xml b/slingjunit.parent/package.local/pom.xml new file mode 100644 index 0000000000..6f37dac142 --- /dev/null +++ b/slingjunit.parent/package.local/pom.xml @@ -0,0 +1,119 @@ + + + + + 4.0.0 + + + com.peregrine-cms + slingjunit.parent + 1.0-SNAPSHOT + ../pom.xml + + + slingjunit.package.local + content-package + + Peregrine Sling-JUnit Testing Package (Local Runmode) + JUnit tests for Peregrine CMS designed to the run within Sling-JUnit test-runner, /system/sling/junit/.html + + + false + + + + + ${project.groupId} + slingjunit.core.local + ${project.version} + + + + + + + + + ${basedir}/src/main/content/META-INF + ../vault-work/META-INF + + + ${basedir}/src/main/content/jcr_root + + + **/.vlt + **/.vltignore + **/.gitignore + **/*.iml + **/.classpath + **/.project + **/.settings + **/.DS_Store + **/target/** + **/pom.xml + + + + + + + io.wcm.maven.plugins + wcmio-content-package-maven-plugin + true + + ${sling.user} + ${sling.password} + true + com.peregrine-cms.slingjunit + + + + local-junit-test-package + + package + + + /apps/slingjunit/install.local + + + ${project.groupId} + slingjunit.core.local + true + + + + + + + + org.codehaus.mojo + license-maven-plugin + + peregrine-cms-license + ${project.baseUri}../../src/license + + + + + diff --git a/slingjunit.parent/package.local/src/main/content/META-INF/vault/filter.xml b/slingjunit.parent/package.local/src/main/content/META-INF/vault/filter.xml new file mode 100644 index 0000000000..171716e164 --- /dev/null +++ b/slingjunit.parent/package.local/src/main/content/META-INF/vault/filter.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/slingjunit.parent/package.local/src/main/content/META-INF/vault/settings.xml b/slingjunit.parent/package.local/src/main/content/META-INF/vault/settings.xml new file mode 100644 index 0000000000..4872b8611b --- /dev/null +++ b/slingjunit.parent/package.local/src/main/content/META-INF/vault/settings.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/slingjunit.parent/package.remote/pom.xml b/slingjunit.parent/package.remote/pom.xml new file mode 100644 index 0000000000..2aedf9a0ed --- /dev/null +++ b/slingjunit.parent/package.remote/pom.xml @@ -0,0 +1,119 @@ + + + + + 4.0.0 + + + com.peregrine-cms + slingjunit.parent + 1.0-SNAPSHOT + ../pom.xml + + + slingjunit.package.remote + content-package + + Peregrine Sling-JUnit Testing Package (Remote Runmode) + JUnit tests for Peregrine CMS designed to the run within Sling-JUnit test-runner, /system/sling/junit/.html + + + false + + + + + ${project.groupId} + slingjunit.core.remote + ${project.version} + + + + + + + + + ${basedir}/src/main/content/META-INF + ../vault-work/META-INF + + + ${basedir}/src/main/content/jcr_root + + + **/.vlt + **/.vltignore + **/.gitignore + **/*.iml + **/.classpath + **/.project + **/.settings + **/.DS_Store + **/target/** + **/pom.xml + + + + + + + io.wcm.maven.plugins + wcmio-content-package-maven-plugin + true + + ${sling.user} + ${sling.password} + true + com.peregrine-cms.slingjunit + + + + remote-junit-test-package + + package + + + /apps/slingjunit/install.author + + + ${project.groupId} + slingjunit.core.remote + true + + + + + + + + org.codehaus.mojo + license-maven-plugin + + peregrine-cms-license + ${project.baseUri}../../src/license + + + + + diff --git a/slingjunit.parent/package.remote/src/main/content/META-INF/vault/filter.xml b/slingjunit.parent/package.remote/src/main/content/META-INF/vault/filter.xml new file mode 100644 index 0000000000..171716e164 --- /dev/null +++ b/slingjunit.parent/package.remote/src/main/content/META-INF/vault/filter.xml @@ -0,0 +1,28 @@ + + + + + diff --git a/slingjunit.parent/package.remote/src/main/content/META-INF/vault/settings.xml b/slingjunit.parent/package.remote/src/main/content/META-INF/vault/settings.xml new file mode 100644 index 0000000000..4872b8611b --- /dev/null +++ b/slingjunit.parent/package.remote/src/main/content/META-INF/vault/settings.xml @@ -0,0 +1,29 @@ + + + + + + diff --git a/slingjunit.parent/pom.xml b/slingjunit.parent/pom.xml index f819d36369..6fe1b6e1d1 100644 --- a/slingjunit.parent/pom.xml +++ b/slingjunit.parent/pom.xml @@ -73,7 +73,11 @@ core - ui.apps + core.remote + core.local + package.common + package.remote + package.local From fe3ae262a5f8e2caff81da18b04860df04c6b7c8 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Thu, 8 Apr 2021 16:52:35 -0400 Subject: [PATCH 42/53] deny everyone read on /content for author instances --- ...positoryInitializer-peregrineRemote.config | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 platform/base/ui.apps/src/main/content/jcr_root/apps/runmodes/config.author/org.apache.sling.jcr.repoinit.RepositoryInitializer-peregrineRemote.config diff --git a/platform/base/ui.apps/src/main/content/jcr_root/apps/runmodes/config.author/org.apache.sling.jcr.repoinit.RepositoryInitializer-peregrineRemote.config b/platform/base/ui.apps/src/main/content/jcr_root/apps/runmodes/config.author/org.apache.sling.jcr.repoinit.RepositoryInitializer-peregrineRemote.config new file mode 100644 index 0000000000..0feea69457 --- /dev/null +++ b/platform/base/ui.apps/src/main/content/jcr_root/apps/runmodes/config.author/org.apache.sling.jcr.repoinit.RepositoryInitializer-peregrineRemote.config @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with this +# work for additional information regarding copyright ownership. The ASF +# licenses this file to You under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations under +# the License. + +scripts=[\ +" + set ACL for everyone + deny jcr:read on /content + end +"\ +] \ No newline at end of file From fd8413dcdd43aa65a27863e581b90442d48e6e7c Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Tue, 13 Apr 2021 18:07:05 -0400 Subject: [PATCH 43/53] When a site uses both server-side templates and vue templates, check the serverSide property. if it exists and is true, then load the page. Otherwise proceed with clientside rendering. --- .../vue/ui.apps/src/main/js/peregrineApp.js | 21 +++++-------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/pagerenderer/vue/ui.apps/src/main/js/peregrineApp.js b/pagerenderer/vue/ui.apps/src/main/js/peregrineApp.js index 3d899f50ab..52fef474db 100644 --- a/pagerenderer/vue/ui.apps/src/main/js/peregrineApp.js +++ b/pagerenderer/vue/ui.apps/src/main/js/peregrineApp.js @@ -309,22 +309,11 @@ function loadContentImpl(path, firstTime, fromPopState, onPage = false) { axios.get(dataUrl).then(function (response) { log.fine('got data for', path) - // if(response.data.template) { - // - // var pageData = response.data - // - // axios.get(response.data.template+'.data.json').then(function(response) { - // - // var templateData = response.data - // var mergedData = merge(templateData, pageData) - // //merging nav, footer and content together with pageData - // processLoadedContent(mergedData, path, firstTime, fromPopState) - // }).catch(function(error) { - // log.error("error getting %s %j", dataUrl, error); - // }) - // } else { - processLoadedContent(response.data, path, firstTime, fromPopState) - // } + if (response.data.serverSide === true){ + document.location = `${response.data.pagePath}.html` + } else { + processLoadedContent(response.data, path, firstTime, fromPopState) + } }).catch(function(error) { log.error("error getting %s %j", dataUrl, error); From 6024826a25c65149204336192ca9f9b8ed7d6bec Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Wed, 14 Apr 2021 17:36:47 -0400 Subject: [PATCH 44/53] updated Sling Junit Core to version 1.1.2, and removed unused deps slingjunit.core pom.xml files --- pom.xml | 2 +- slingjunit.parent/core.local/pom.xml | 29 --------------------------- slingjunit.parent/core.remote/pom.xml | 17 ---------------- slingjunit.parent/core/pom.xml | 26 +----------------------- 4 files changed, 2 insertions(+), 72 deletions(-) diff --git a/pom.xml b/pom.xml index 96e986435d..8dbf9bbf42 100644 --- a/pom.xml +++ b/pom.xml @@ -72,7 +72,7 @@ 1.9.5 2.12.0 2.1.0 - 1.1.0 + 1.1.2 2.0.8 2.0.0 1.0.22 diff --git a/slingjunit.parent/core.local/pom.xml b/slingjunit.parent/core.local/pom.xml index 87bb2bd0a5..86685634c4 100644 --- a/slingjunit.parent/core.local/pom.xml +++ b/slingjunit.parent/core.local/pom.xml @@ -110,46 +110,17 @@ org.osgi org.osgi.service.component.annotations - - org.apache.jackrabbit - oak-api - 1.26.0 - provided - org.apache.jackrabbit jackrabbit-api - - org.apache.sling - org.apache.sling.jcr.jackrabbit.accessmanager - 3.0.8 - provided - - - org.osgi - org.osgi.service.cm - 1.6.0 - provided - org.apache.sling org.apache.sling.models.api - - org.apache.httpcomponents - httpclient - 4.5.13 - - - org.apache.jackrabbit - oak-core-spi - 1.38.0 - org.apache.sling org.apache.sling.scripting.sightly.compiler.java - 1.0.18 provided diff --git a/slingjunit.parent/core.remote/pom.xml b/slingjunit.parent/core.remote/pom.xml index 4071553550..be063bb51d 100644 --- a/slingjunit.parent/core.remote/pom.xml +++ b/slingjunit.parent/core.remote/pom.xml @@ -104,12 +104,6 @@ org.osgi org.osgi.service.component.annotations - - org.apache.jackrabbit - oak-api - 1.26.0 - provided - org.apache.jackrabbit jackrabbit-api @@ -130,20 +124,9 @@ org.apache.sling org.apache.sling.models.api - - org.apache.httpcomponents - httpclient - 4.5.13 - - - org.apache.jackrabbit - oak-core-spi - 1.38.0 - org.apache.sling org.apache.sling.scripting.sightly.compiler.java - 1.0.18 provided diff --git a/slingjunit.parent/core/pom.xml b/slingjunit.parent/core/pom.xml index 422de7d363..2716502a60 100644 --- a/slingjunit.parent/core/pom.xml +++ b/slingjunit.parent/core/pom.xml @@ -98,28 +98,10 @@ org.osgi org.osgi.service.component.annotations - - org.apache.jackrabbit - oak-api - 1.26.0 - provided - org.apache.jackrabbit jackrabbit-api - - org.apache.sling - org.apache.sling.jcr.jackrabbit.accessmanager - 3.0.8 - provided - - - org.osgi - org.osgi.service.cm - 1.6.0 - provided - org.apache.sling org.apache.sling.models.api @@ -127,17 +109,11 @@ org.apache.httpcomponents httpclient - 4.5.13 - - - org.apache.jackrabbit - oak-core-spi - 1.38.0 + provided org.apache.sling org.apache.sling.scripting.sightly.compiler.java - 1.0.18 provided From 884ae81ad4d352856e3c282add8f95bee9381b48 Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Thu, 15 Apr 2021 15:57:10 -0400 Subject: [PATCH 45/53] getSiteResource should return null if there is no per:Site resource in the parents --- .../src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platform/base/core/src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java b/platform/base/core/src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java index 63e3850641..be3c33ff71 100644 --- a/platform/base/core/src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java +++ b/platform/base/core/src/main/java/com/peregrine/adaption/impl/PerBaseImpl.java @@ -166,7 +166,7 @@ private Resource getSiteResource(Resource resource){ if( nt.getName().equals(SITE_PRIMARY_TYPE)){ return resource; } else { - return getSiteResource(resource.getParent()); + return Objects.nonNull(resource.getParent()) ? getSiteResource(resource.getParent()) : null; } } catch (RepositoryException e) { logger.error("Error getting root per:Site resource ", e); From d95c8b3818fd4de3421149ad774a184074b6c4dd Mon Sep 17 00:00:00 2001 From: Cris Rockwell Date: Fri, 16 Apr 2021 17:44:44 -0400 Subject: [PATCH 46/53] started basic footer htl component; removed debug path output in page.html --- .../components/container/container.html | 2 +- .../components/footer/.content.xml | 36 +++++++++++++++++++ .../components/footer/footer.html | 9 +++++ .../components/page/page.html | 2 +- .../templates/empty-container/.content.xml | 2 +- .../templates/footer/.content.xml | 22 ++++++++++++ 6 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/footer/.content.xml create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/footer/footer.html create mode 100644 pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/footer/.content.xml diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html index 4996c93705..923b0e2911 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/container/container.html @@ -1,5 +1,5 @@ -
+
+ + + diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/footer/footer.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/footer/footer.html new file mode 100644 index 0000000000..e349e385fa --- /dev/null +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/footer/footer.html @@ -0,0 +1,9 @@ +
+ + ${properties.text @ context='html'} + ${properties.text ? '': '© 2021 by peregrine-cms, an open source project'} + +
\ No newline at end of file diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html index 46c3dd07a2..b4090d6abe 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/apps/pagerenderserver/components/page/page.html @@ -34,7 +34,7 @@
- ${helper.path} +
diff --git a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/empty-container/.content.xml b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/empty-container/.content.xml index 1ba277a85a..5d177ed424 100644 --- a/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/empty-container/.content.xml +++ b/pagerenderer/server/ui.apps/src/main/content/jcr_root/content/pagerenderserver/templates/empty-container/.content.xml @@ -8,7 +8,7 @@ + + + + + + +