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

Update/sling12 #681

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 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
d9a1230
Moved failing repoinit directives for files to admin-base/ui.apps, so…
cmrockwell Dec 8, 2020
13e7a07
merged 618 server side work
cmrockwell Dec 9, 2020
867839a
Merge branch 'issues/677-Fix-Repoinit-Errors' into update/sling12
cmrockwell Dec 9, 2020
27a2ddb
updated sling 12 starter
cmrockwell Dec 9, 2020
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
2 changes: 1 addition & 1 deletion admin-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
</build>

<modules>
<module>sling.ui.apps</module>
<module>core</module>
<module>materialize</module>
<module>ui.apps</module>
<module>sling.ui.apps</module>
</modules>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ export default {
this.reWrapEditable()
},

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

onInlineClick(event) {
this.pingToolbar()
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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=[\
"
# This Repoinit Script is here to make sure that during an upgrade the necessary users
# and permissions are available
#
# ATTENTION: because of creating users and groups with path this script depends on org.apache.sling.jcr.repoinit-1.1.10
#

# set ACL's for all_tenants group on paths lower than root
# Note: this replaces jcr:read for everyone on root
set ACL for all_tenants
allow jcr:read on /index.html
allow jcr:read on /favicon.ico
allow jcr:read on /robots.txt
allow jcr:read on /perapi/admin
allow jcr:read on /apps
allow jcr:read on /i18n
allow jcr:read on /content
end

"\
]
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
18 changes: 16 additions & 2 deletions pagerenderer/server/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,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 @@ -150,6 +151,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);
}
}
Loading