Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/618 htl server #624

Merged
merged 57 commits into from
Apr 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
579b7eb
pagerenderer/server won't deploy to my develop-sling12. Has to do wit…
cmrockwell Oct 21, 2020
2a2c757
Add missing base template for /content/pagerenderserver/templates
cmrockwell Oct 21, 2020
2df4737
flag pagerenderserver site as internal
cmrockwell Oct 21, 2020
3a12a67
added base template to /content/pagerenderserver/templates so the exa…
cmrockwell Oct 21, 2020
df1049d
refactored by moving /apps/pagerenderserver/structure to /apps/pagere…
cmrockwell Oct 21, 2020
5e093fd
finished moving page from structure to omponents by updating these re…
cmrockwell Oct 22, 2020
2019764
To addtess issue #636, Sling JUnit Tests were added for resource adap…
cmrockwell Oct 26, 2020
51469da
#618 Moved Helper.java to core, and updated data-sly-use in page.html…
cmrockwell Oct 27, 2020
6c7f751
Although the npm build scripts are not building vue components for th…
cmrockwell Oct 27, 2020
80cb826
add pagerender/server to list of maven compile modules
cmrockwell Oct 27, 2020
0a057d2
#618 Updated PageMerge.java adding a method (getMergedResources) retu…
cmrockwell Oct 28, 2020
750a23b
#618 Updated page.html to use PageMerge.java for getting and iteratin…
cmrockwell Oct 28, 2020
1befe34
#618 updated predifned page and template content
cmrockwell Oct 28, 2020
7b3c31f
Created BaseHelper Use, which can be extended by page and component h…
cmrockwell Oct 29, 2020
49e5a7d
#618 Added getters for all HTL Java Use binding for BaseHelper, updat…
cmrockwell Oct 30, 2020
5d4b073
#618 Added convenience method to PerBase for getting per:Site/jcr:con…
cmrockwell Oct 30, 2020
5540d0d
#618 refactored PageMerge to make it possible to test: If the slingSc…
cmrockwell Nov 6, 2020
3276e59
organized slingjunit pom.xml deps
cmrockwell Nov 6, 2020
817c997
618 to make testing easier and possible, NavModel Use pojo was update…
cmrockwell Nov 6, 2020
ccc3a5d
618 added ssrPageMergeScenario1 for PageMerge::getMergedResources. Te…
cmrockwell Nov 6, 2020
16d9457
started example sub-template for PageMerge junit tests
cmrockwell Nov 6, 2020
09fecfd
removed unneeded files from slingjunit test content
cmrockwell Nov 6, 2020
c15d91c
#618 Added test content for SSR scenario 2: inheriting template conte…
cmrockwell Nov 6, 2020
b5e78c8
refactored unit tests moving common binding to setup. added test for …
cmrockwell Nov 6, 2020
237b967
#618 Updated getChildren method to resolve children resources from pa…
cmrockwell Nov 6, 2020
60f9173
Added content for JUnit SSR test scenarios
cmrockwell Nov 10, 2020
55a569f
Added JUnit SSR scenario 3 which tests combining content within conta…
cmrockwell Nov 10, 2020
76c1036
Added getCombinedResources to com.peregrine.pagerender.server.models.…
cmrockwell Nov 10, 2020
f612ab0
missed check for null
cmrockwell Nov 10, 2020
bf3a83c
moved css for drop zone to separate css file, server.css
cmrockwell Nov 11, 2020
69a5da1
fix for adding and editing components
reusr1 Nov 13, 2020
4891f36
adding missing per:Component metadata for Page. fixes error that occu…
cmrockwell Nov 13, 2020
582537f
Update pagerenderserver example site metadata. Moved siteCSS and site…
cmrockwell Nov 13, 2020
d29a323
#620 added condition for serverSide to addComponentToPath state actio…
cmrockwell Nov 17, 2020
fcd1b17
Similar change for getParentContent as done for pagerenderserver. All…
cmrockwell Nov 18, 2020
9fdbf3a
Related to Issue #620, Added ssrPageMergeScenario4 for newly created …
cmrockwell Nov 18, 2020
349ca42
optimize imports
cmrockwell Nov 18, 2020
dd66c3d
Setup for ssrPageMergeScenario5: adding content to empty containers o…
cmrockwell Nov 19, 2020
26954fa
#620 implemented html renderer for nt:unstructured as a Container tha…
cmrockwell Nov 19, 2020
708d3dd
#620 Update server.css to hide/show the container drop zone depending…
cmrockwell Nov 20, 2020
1fa6a96
refreshed branch merging develop-sling12 in
cmrockwell Apr 8, 2021
930068e
Refactored slingjunit tests such that remote tests are available when…
cmrockwell Apr 8, 2021
fe3ae26
deny everyone read on /content for author instances
cmrockwell Apr 8, 2021
fd8413d
When a site uses both server-side templates and vue templates, check …
cmrockwell Apr 13, 2021
6024826
updated Sling Junit Core to version 1.1.2, and removed unused deps sl…
cmrockwell Apr 14, 2021
884ae81
getSiteResource should return null if there is no per:Site resource i…
cmrockwell Apr 15, 2021
d95c8b3
started basic footer htl component; removed debug path output in page…
cmrockwell Apr 16, 2021
3cf2125
updated names in pom to match the vue page renderer
reusr1 Apr 19, 2021
c243a26
add server side rendering to docker build
reusr1 Apr 19, 2021
9c024f3
Merge branch 'develop-sling12' into issues/618-htl-server
reusr1 Apr 19, 2021
c540c78
updated bootstrap
cmrockwell Apr 19, 2021
3224334
added nav component for server side rendering internal site
cmrockwell Apr 19, 2021
e3908a4
updated footer component adding model
cmrockwell Apr 19, 2021
386c069
added basic footer nav template for pagerenderserver site, removed ui…
cmrockwell Apr 19, 2021
8e118a4
Merge branch 'issues/618-htl-server' of github.com:headwirecom/peregr…
cmrockwell Apr 19, 2021
6088a74
updates to resolve PR suggestions: add check for response object for …
cmrockwell Apr 24, 2021
5901bee
Merge branch 'develop-sling12' into issues/618-htl-server
cmrockwell Apr 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,10 @@ export default {
this.reWrapEditable()
},

refreshEditor(vm) {
vm.$refs.editview.contentWindow.location.reload()
},

onInlineClick(event) {
this.pingToolbar()
},
Expand Down
29 changes: 16 additions & 13 deletions admin-base/ui.apps/src/main/js/stateActions/addComponentToPath.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
3 changes: 2 additions & 1 deletion admin-base/ui.apps/src/main/js/stateActions/savePageEdit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down
1 change: 1 addition & 0 deletions docker/scripts/install-peregrine.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ PKG_ORDER=( \
base.ui.apps-1.0-SNAPSHOT.zip \
felib.ui.apps-1.0-SNAPSHOT.zip \
pagerender-vue.ui.apps-1.0-SNAPSHOT.zip \
pagerender-server.ui.apps-1.0-SNAPSHOT.zip \
admin.ui.apps-1.0-SNAPSHOT.zip \
admin.ui.materialize-1.0-SNAPSHOT.zip \
admin.sling.ui.apps-1.0-SNAPSHOT.zip \
Expand Down
20 changes: 17 additions & 3 deletions pagerenderer/server/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<artifactId>pagerender-server.core</artifactId>
<packaging>bundle</packaging>

<name>peregrine server page renderer - Core</name>
<name>Peregrine CMS - Page Render Server - Core</name>
<description>
OSGi Bundle for the Page Render Server module.
</description>
Expand Down Expand Up @@ -128,8 +128,9 @@
</dependency>

<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<artifactId>commons-lang3</artifactId>
<groupId>org.apache.commons</groupId>
<scope>provided</scope>
</dependency>

<dependency>
Expand All @@ -146,6 +147,19 @@
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
</dependency>

<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
</dependency>

<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.scripting.sightly.compiler.java</artifactId>
<version>1.0.18</version>
<scope>provided</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
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;

import static com.peregrine.commons.util.PerConstants.JCR_CONTENT;

public class BaseHelper implements Use {

// GLOBAL OBJECTS (from Use API Binding)
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
private Object model;
private Resource siteRoot;
private PerPage currentPage;
private 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();
pagePath = pagePath.substring(0, pagePath.indexOf(JCR_CONTENT));
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);
if (Objects.isNull(model)) {
model = sling.getService(ModelFactory.class).getModelFromRequest(request);
}
} catch(Throwable t) {
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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.peregrine.pagerender.server.helpers;

import javax.script.Bindings;
import com.peregrine.pagerender.server.models.PageModel;

import java.util.Objects;

public class PageHelper extends BaseHelper {

public String getPath() {
return this.getResource().getPath();
}

public String getSiteRootPath() {
return Objects.nonNull(getSiteRoot()) ? getSiteRoot().getPath() : null;
}

public String getModelClass() {
return Objects.nonNull(getModel()) ? getModel().getClass().toString() : null;
}

public String[] getSiteCSS(){
PageModel page = getResource().adaptTo(PageModel.class);
return page.getSiteCSS();
}

public void init(Bindings bindings) {
super.init(bindings);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,28 @@
* #L%
*/

import static com.peregrine.commons.util.PerConstants.JACKSON;
import static com.peregrine.commons.util.PerConstants.JSON;
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 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.
Expand All @@ -51,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<IComponent> children;
Expand All @@ -64,4 +81,47 @@ public Container(Resource r) {
public List<IComponent> getChildren() {
return children;
}

public List<Resource> getCombinedResources(){
if (Objects.isNull(resolver)){
setup();
}
List<Resource> merged = new ArrayList<>();
// 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);
});
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);
}
}
}
Loading