You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ol...@apache.org on 2015/01/12 19:24:27 UTC
svn commit: r1651157 - in /sling/trunk/contrib/scripting/thymeleaf: ./
src/main/java/org/apache/sling/scripting/thymeleaf/internal/dialect/
src/main/java/org/apache/sling/scripting/thymeleaf/internal/dom/
src/main/java/org/apache/sling/scripting/thymel...
Author: olli
Date: Mon Jan 12 18:24:27 2015
New Revision: 1651157
URL: http://svn.apache.org/r1651157
Log:
SLING-4297 add a dialect and processors to provide out-of-the-box support for a Sling Include
* new Sling dialect
* include with support for resource and path
(resourceType, replaceSelectors, addSelectors and replaceSuffix request dispatcher options
and unwrap to remove host tag)
Added:
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dialect/
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dialect/SlingDialect.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dom/
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dom/NodeUtil.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingAddSelectorsAttrProcessor.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingIncludeAttrProcessor.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingNodePropertyAttrProcessor.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingPathAttrProcessor.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSelectorsAttrProcessor.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSuffixAttrProcessor.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceAttrProcessor.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceTypeAttrProcessor.java
sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingUnwrapAttrProcessor.java
Modified:
sling/trunk/contrib/scripting/thymeleaf/pom.xml
Modified: sling/trunk/contrib/scripting/thymeleaf/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/pom.xml?rev=1651157&r1=1651156&r2=1651157&view=diff
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/pom.xml (original)
+++ sling/trunk/contrib/scripting/thymeleaf/pom.xml Mon Jan 12 18:24:27 2015
@@ -87,6 +87,12 @@
</dependency>
<dependency>
<groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.scripting.core</artifactId>
+ <version>2.0.29-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.commons.osgi</artifactId>
<version>2.2.0</version>
<scope>provided</scope>
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dialect/SlingDialect.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dialect/SlingDialect.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dialect/SlingDialect.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dialect/SlingDialect.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,74 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.dialect;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+import org.apache.sling.scripting.thymeleaf.internal.processor.attr.SlingAddSelectorsAttrProcessor;
+import org.apache.sling.scripting.thymeleaf.internal.processor.attr.SlingIncludeAttrProcessor;
+import org.apache.sling.scripting.thymeleaf.internal.processor.attr.SlingPathAttrProcessor;
+import org.apache.sling.scripting.thymeleaf.internal.processor.attr.SlingReplaceSelectorsAttrProcessor;
+import org.apache.sling.scripting.thymeleaf.internal.processor.attr.SlingReplaceSuffixAttrProcessor;
+import org.apache.sling.scripting.thymeleaf.internal.processor.attr.SlingResourceAttrProcessor;
+import org.apache.sling.scripting.thymeleaf.internal.processor.attr.SlingResourceTypeAttrProcessor;
+import org.apache.sling.scripting.thymeleaf.internal.processor.attr.SlingUnwrapAttrProcessor;
+import org.osgi.framework.Constants;
+import org.thymeleaf.dialect.AbstractDialect;
+import org.thymeleaf.processor.IProcessor;
+
+@Component(
+ label = "Apache Sling Scripting Thymeleaf âSling Dialectâ",
+ description = "Sling dialect for Sling Scripting Thymeleaf",
+ immediate = true,
+ metatype = true
+)
+@Service
+@Properties({
+ @Property(name = Constants.SERVICE_VENDOR, value = "The Apache Software Foundation"),
+ @Property(name = Constants.SERVICE_DESCRIPTION, value = "Sling dialect for Sling Scripting Thymeleaf")
+})
+public class SlingDialect extends AbstractDialect {
+
+ public static final String PREFIX = "sling";
+
+ @Override
+ public String getPrefix() {
+ return PREFIX;
+ }
+
+ @Override
+ public Set<IProcessor> getProcessors() {
+ final Set<IProcessor> processors = new HashSet<IProcessor>();
+ processors.add(new SlingAddSelectorsAttrProcessor());
+ processors.add(new SlingIncludeAttrProcessor());
+ processors.add(new SlingPathAttrProcessor());
+ processors.add(new SlingReplaceSelectorsAttrProcessor());
+ processors.add(new SlingReplaceSuffixAttrProcessor());
+ processors.add(new SlingResourceAttrProcessor());
+ processors.add(new SlingResourceTypeAttrProcessor());
+ processors.add(new SlingUnwrapAttrProcessor());
+ return processors;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dom/NodeUtil.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dom/NodeUtil.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dom/NodeUtil.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/dom/NodeUtil.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,34 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.dom;
+
+import org.thymeleaf.dom.Node;
+
+public class NodeUtil {
+
+ public static <T> T getNodeProperty(final Node node, final String name, final Class<T> clazz) {
+ final Object nodeProperty = node.getNodeProperty(name);
+ try {
+ return clazz.cast(nodeProperty);
+ } catch (ClassCastException e) {
+ return null;
+ }
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingAddSelectorsAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingAddSelectorsAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingAddSelectorsAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingAddSelectorsAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+public class SlingAddSelectorsAttrProcessor extends SlingNodePropertyAttrProcessor {
+
+ public static final int ATTR_PRECEDENCE = 99;
+
+ public static final String ATTR_NAME = "addSelectors";
+
+ public static final String NODE_PROPERTY_NAME = String.format("%s.%s", PREFIX, ATTR_NAME);
+
+ public SlingAddSelectorsAttrProcessor() {
+ super(ATTR_NAME);
+ }
+
+ @Override
+ public int getPrecedence() {
+ return ATTR_PRECEDENCE;
+ }
+
+ @Override
+ protected String getNodePropertyName() {
+ return NODE_PROPERTY_NAME;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingIncludeAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingIncludeAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingIncludeAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingIncludeAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,163 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
+
+import org.apache.commons.io.IOUtils;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.SlingHttpServletResponse;
+import org.apache.sling.api.request.RequestDispatcherOptions;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.api.resource.SyntheticResource;
+import org.apache.sling.scripting.core.servlet.BufferedServletOutputStream;
+import org.apache.sling.scripting.core.servlet.CaptureResponseWrapper;
+import org.apache.sling.scripting.thymeleaf.internal.SlingWebContext;
+import org.apache.sling.scripting.thymeleaf.internal.dom.NodeUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.thymeleaf.Arguments;
+import org.thymeleaf.context.IContext;
+import org.thymeleaf.dom.Element;
+import org.thymeleaf.dom.Macro;
+import org.thymeleaf.processor.ProcessorResult;
+import org.thymeleaf.processor.attr.AbstractAttrProcessor;
+
+public class SlingIncludeAttrProcessor extends AbstractAttrProcessor {
+
+ public static final int ATTR_PRECEDENCE = 100;
+
+ public static final String ATTR_NAME = "include";
+
+ private final Logger logger = LoggerFactory.getLogger(SlingIncludeAttrProcessor.class);
+
+ public SlingIncludeAttrProcessor() {
+ super(ATTR_NAME);
+ }
+
+ @Override
+ public int getPrecedence() {
+ return ATTR_PRECEDENCE;
+ }
+
+ @Override
+ protected ProcessorResult processAttribute(final Arguments arguments, final Element element, final String attributeName) {
+ final IContext context = arguments.getTemplateProcessingParameters().getContext();
+ if (context instanceof SlingWebContext) {
+ final SlingWebContext slingWebContext = (SlingWebContext) context;
+ final SlingHttpServletRequest slingHttpServletRequest = slingWebContext.getHttpServletRequest();
+ final SlingHttpServletResponse slingHttpServletResponse = slingWebContext.getHttpServletResponse();
+ // resource and path
+ Resource resource = NodeUtil.getNodeProperty(element, SlingResourceAttrProcessor.NODE_PROPERTY_NAME, Resource.class);
+ String path = NodeUtil.getNodeProperty(element, SlingPathAttrProcessor.NODE_PROPERTY_NAME, String.class);
+ // request dispatcher options
+ final String resourceType = NodeUtil.getNodeProperty(element, SlingResourceTypeAttrProcessor.NODE_PROPERTY_NAME, String.class);
+ final String replaceSelectors = NodeUtil.getNodeProperty(element, SlingReplaceSelectorsAttrProcessor.NODE_PROPERTY_NAME, String.class);
+ final String addSelectors = NodeUtil.getNodeProperty(element, SlingAddSelectorsAttrProcessor.NODE_PROPERTY_NAME, String.class);
+ final String replaceSuffix = NodeUtil.getNodeProperty(element, SlingReplaceSuffixAttrProcessor.NODE_PROPERTY_NAME, String.class);
+ // dispatch
+ final String content = dispatch(resource, path, slingHttpServletRequest, slingHttpServletResponse, resourceType, replaceSelectors, addSelectors, replaceSuffix);
+ // cleanup
+ element.removeAttribute(attributeName);
+ element.clearChildren();
+ // add output
+ final Macro macro = new Macro(content);
+ element.addChild(macro);
+ final Boolean unwrap = NodeUtil.getNodeProperty(element, SlingUnwrapAttrProcessor.NODE_PROPERTY_NAME, Boolean.class);
+ if (unwrap != null && unwrap) {
+ element.getParent().extractChild(element);
+ }
+ } else {
+ throw new RuntimeException("Context is not an instance of SlingWebContext, unable to process include attribute");
+ }
+ return ProcessorResult.OK;
+ }
+
+ /**
+ * @see org.apache.sling.scripting.jsp.taglib.IncludeTagHandler
+ */
+ protected String dispatch(Resource resource, String path, final SlingHttpServletRequest slingHttpServletRequest, final SlingHttpServletResponse slingHttpServletResponse, final String resourceType, final String replaceSelectors, final String addSelectors, final String replaceSuffix) {
+ final RequestDispatcherOptions options = new RequestDispatcherOptions();
+ options.setForceResourceType(resourceType);
+ options.setReplaceSelectors(replaceSelectors);
+ options.setAddSelectors(addSelectors);
+ options.setReplaceSuffix(replaceSuffix);
+
+ // ensure the path (if set) is absolute and normalized
+ if (path != null) {
+ if (!path.startsWith("/")) {
+ path = slingHttpServletRequest.getResource().getPath() + "/" + path;
+ }
+ path = ResourceUtil.normalize(path);
+ }
+
+ // check the resource
+ if (resource == null) {
+ if (path == null) {
+ // neither resource nor path is defined, use current resource
+ resource = slingHttpServletRequest.getResource();
+ } else {
+ // check whether the path (would) resolve, else SyntheticRes.
+ final Resource tmp = slingHttpServletRequest.getResourceResolver().resolve(path);
+ if (tmp == null && resourceType != null) {
+ resource = new SyntheticResource(slingHttpServletRequest.getResourceResolver(), path, resourceType); // TODO DispatcherSyntheticResource?
+ // remove resource type overwrite as synthetic resource is correctly typed as requested
+ options.remove(RequestDispatcherOptions.OPT_FORCE_RESOURCE_TYPE);
+ }
+ }
+ }
+
+ try {
+ // create a dispatcher for the resource or path
+ RequestDispatcher dispatcher;
+ if (resource != null) {
+ dispatcher = slingHttpServletRequest.getRequestDispatcher(resource, options);
+ } else {
+ dispatcher = slingHttpServletRequest.getRequestDispatcher(path, options);
+ }
+
+ if (dispatcher != null) {
+ final String encoding = slingHttpServletResponse.getCharacterEncoding();
+ final BufferedServletOutputStream bsos = new BufferedServletOutputStream(encoding);
+ try {
+ final CaptureResponseWrapper wrapper = new CaptureResponseWrapper(slingHttpServletResponse, bsos);
+ dispatcher.include(slingHttpServletRequest, wrapper);
+ if (!wrapper.isBinaryResponse()) {
+ wrapper.flushBuffer();
+ return bsos.getBuffer();
+ }
+ } catch (ServletException e) {
+ logger.error(e.getMessage(), e);
+ } finally {
+ IOUtils.closeQuietly(bsos);
+ }
+ } else {
+ logger.error("no request dispatcher: unable to include {}/'{}'", resource, path);
+ }
+ } catch (IOException e) {
+ logger.error(e.getMessage(), e);
+ }
+ return null;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingNodePropertyAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingNodePropertyAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingNodePropertyAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingNodePropertyAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+import org.thymeleaf.Arguments;
+import org.thymeleaf.Configuration;
+import org.thymeleaf.dom.Element;
+import org.thymeleaf.processor.ProcessorResult;
+import org.thymeleaf.processor.attr.AbstractAttrProcessor;
+import org.thymeleaf.standard.expression.IStandardExpression;
+import org.thymeleaf.standard.expression.IStandardExpressionParser;
+import org.thymeleaf.standard.expression.StandardExpressions;
+
+public abstract class SlingNodePropertyAttrProcessor extends AbstractAttrProcessor {
+
+ public static final String PREFIX = "sling";
+
+ public SlingNodePropertyAttrProcessor(final String attributeName) {
+ super(attributeName);
+ }
+
+ protected abstract String getNodePropertyName();
+
+ @Override
+ protected ProcessorResult processAttribute(final Arguments arguments, final Element element, final String attributeName) {
+ final Configuration configuration = arguments.getConfiguration();
+ final String attributeValue = element.getAttributeValue(attributeName);
+ final IStandardExpressionParser parser = StandardExpressions.getExpressionParser(configuration);
+ final IStandardExpression expression = parser.parseExpression(configuration, arguments, attributeValue);
+ final Object result = expression.execute(configuration, arguments);
+ element.setNodeProperty(getNodePropertyName(), result);
+ element.removeAttribute(attributeName);
+ return ProcessorResult.OK;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingPathAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingPathAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingPathAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingPathAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+public class SlingPathAttrProcessor extends SlingNodePropertyAttrProcessor {
+
+ public static final int ATTR_PRECEDENCE = 99;
+
+ public static final String ATTR_NAME = "path";
+
+ public static final String NODE_PROPERTY_NAME = String.format("%s.%s", PREFIX, ATTR_NAME);
+
+ public SlingPathAttrProcessor() {
+ super(ATTR_NAME);
+ }
+
+ @Override
+ public int getPrecedence() {
+ return ATTR_PRECEDENCE;
+ }
+
+ @Override
+ protected String getNodePropertyName() {
+ return NODE_PROPERTY_NAME;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSelectorsAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSelectorsAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSelectorsAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSelectorsAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+public class SlingReplaceSelectorsAttrProcessor extends SlingNodePropertyAttrProcessor {
+
+ public static final int ATTR_PRECEDENCE = 99;
+
+ public static final String ATTR_NAME = "replaceSelectors";
+
+ public static final String NODE_PROPERTY_NAME = String.format("%s.%s", PREFIX, ATTR_NAME);
+
+ public SlingReplaceSelectorsAttrProcessor() {
+ super(ATTR_NAME);
+ }
+
+ @Override
+ public int getPrecedence() {
+ return ATTR_PRECEDENCE;
+ }
+
+ @Override
+ protected String getNodePropertyName() {
+ return NODE_PROPERTY_NAME;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSuffixAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSuffixAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSuffixAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingReplaceSuffixAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+public class SlingReplaceSuffixAttrProcessor extends SlingNodePropertyAttrProcessor {
+
+ public static final int ATTR_PRECEDENCE = 99;
+
+ public static final String ATTR_NAME = "replaceSuffix";
+
+ public static final String NODE_PROPERTY_NAME = String.format("%s.%s", PREFIX, ATTR_NAME);
+
+ public SlingReplaceSuffixAttrProcessor() {
+ super(ATTR_NAME);
+ }
+
+ @Override
+ public int getPrecedence() {
+ return ATTR_PRECEDENCE;
+ }
+
+ @Override
+ protected String getNodePropertyName() {
+ return NODE_PROPERTY_NAME;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+public class SlingResourceAttrProcessor extends SlingNodePropertyAttrProcessor {
+
+ public static final int ATTR_PRECEDENCE = 99;
+
+ public static final String ATTR_NAME = "resource";
+
+ public static final String NODE_PROPERTY_NAME = String.format("%s.%s", PREFIX, ATTR_NAME);
+
+ public SlingResourceAttrProcessor() {
+ super(ATTR_NAME);
+ }
+
+ @Override
+ public int getPrecedence() {
+ return ATTR_PRECEDENCE;
+ }
+
+ @Override
+ protected String getNodePropertyName() {
+ return NODE_PROPERTY_NAME;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceTypeAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceTypeAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceTypeAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingResourceTypeAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+public class SlingResourceTypeAttrProcessor extends SlingNodePropertyAttrProcessor {
+
+ public static final int ATTR_PRECEDENCE = 99;
+
+ public static final String ATTR_NAME = "resourceType";
+
+ public static final String NODE_PROPERTY_NAME = String.format("%s.%s", PREFIX, ATTR_NAME);
+
+ public SlingResourceTypeAttrProcessor() {
+ super(ATTR_NAME);
+ }
+
+ @Override
+ public int getPrecedence() {
+ return ATTR_PRECEDENCE;
+ }
+
+ @Override
+ protected String getNodePropertyName() {
+ return NODE_PROPERTY_NAME;
+ }
+
+}
Added: sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingUnwrapAttrProcessor.java
URL: http://svn.apache.org/viewvc/sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingUnwrapAttrProcessor.java?rev=1651157&view=auto
==============================================================================
--- sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingUnwrapAttrProcessor.java (added)
+++ sling/trunk/contrib/scripting/thymeleaf/src/main/java/org/apache/sling/scripting/thymeleaf/internal/processor/attr/SlingUnwrapAttrProcessor.java Mon Jan 12 18:24:27 2015
@@ -0,0 +1,43 @@
+/*
+ * 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.
+ */
+package org.apache.sling.scripting.thymeleaf.internal.processor.attr;
+
+public class SlingUnwrapAttrProcessor extends SlingNodePropertyAttrProcessor {
+
+ public static final int ATTR_PRECEDENCE = 99;
+
+ public static final String ATTR_NAME = "unwrap";
+
+ public static final String NODE_PROPERTY_NAME = String.format("%s.%s", PREFIX, ATTR_NAME);
+
+ public SlingUnwrapAttrProcessor() {
+ super(ATTR_NAME);
+ }
+
+ @Override
+ public int getPrecedence() {
+ return ATTR_PRECEDENCE;
+ }
+
+ @Override
+ protected String getNodePropertyName() {
+ return NODE_PROPERTY_NAME;
+ }
+
+}