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 2019/09/15 11:39:01 UTC
[sling-org-apache-sling-scripting-thymeleaf] branch master updated
(66d9f6e -> 19537f7)
This is an automated email from the ASF dual-hosted git repository.
olli pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-thymeleaf.git.
from 66d9f6e SLING-8503 Update Felix Framework to 6.0.3
new 5d61867 style
new 8778df5 polish HTML
new 19537f7 SLING-8709 Make value map of current resource available in bindings as properties
The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
...n.java => ThymeleafBindingsValuesProvider.java} | 37 ++++++++++++----------
.../thymeleaf/it/tests/ThymeleafTestSupport.java | 5 +--
...java => ThymeleafBindingsValuesProviderIT.java} | 6 ++--
.../apps/thymeleaf/page/adaptto/html.html | 6 ++--
.../{fragments/head.html => bindings/html.html} | 6 ++--
.../apps/thymeleaf/page/decoupled/html.html | 2 +-
.../apps/thymeleaf/page/fragments/head.html | 2 +-
.../apps/thymeleaf/page/include/html.html | 8 ++---
.../resources/apps/thymeleaf/page/link/html.html | 4 +--
.../resources/apps/thymeleaf/page/main/html.html | 4 +--
.../apps/thymeleaf/page/replace/html.html | 4 +--
.../resources/apps/thymeleaf/page/text/html.html | 6 ++--
src/test/resources/content/thymeleaf.json | 6 ++++
13 files changed, 54 insertions(+), 42 deletions(-)
copy src/main/java/org/apache/sling/scripting/thymeleaf/internal/{SlingResourceTemplateResolverConfiguration.java => ThymeleafBindingsValuesProvider.java} (52%)
copy src/test/java/org/apache/sling/scripting/thymeleaf/it/tests/html/{ThymeleafReplaceIT.java => ThymeleafBindingsValuesProviderIT.java} (90%)
copy src/test/resources/apps/thymeleaf/page/{fragments/head.html => bindings/html.html} (91%)
[sling-org-apache-sling-scripting-thymeleaf] 02/03: polish HTML
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-thymeleaf.git
commit 8778df5c3d55ff9456d9495283286e385eadd53a
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Sep 15 13:30:02 2019 +0200
polish HTML
---
src/test/resources/apps/thymeleaf/page/adaptto/html.html | 6 +++---
src/test/resources/apps/thymeleaf/page/decoupled/html.html | 2 +-
src/test/resources/apps/thymeleaf/page/fragments/head.html | 2 +-
src/test/resources/apps/thymeleaf/page/include/html.html | 8 ++++----
src/test/resources/apps/thymeleaf/page/link/html.html | 4 ++--
src/test/resources/apps/thymeleaf/page/main/html.html | 4 ++--
src/test/resources/apps/thymeleaf/page/replace/html.html | 4 ++--
src/test/resources/apps/thymeleaf/page/text/html.html | 6 +++---
8 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/src/test/resources/apps/thymeleaf/page/adaptto/html.html b/src/test/resources/apps/thymeleaf/page/adaptto/html.html
index 40ae135..4b1e986 100644
--- a/src/test/resources/apps/thymeleaf/page/adaptto/html.html
+++ b/src/test/resources/apps/thymeleaf/page/adaptto/html.html
@@ -17,12 +17,12 @@
specific language governing permissions and limitations
under the License.
-->
-<html data-th-with="page=${request.adaptTo(@org.apache.sling.scripting.thymeleaf.it.app.Page@class)}">
+<html lang="en" data-th-with="page=${request.adaptTo(@org.apache.sling.scripting.thymeleaf.it.app.Page@class)}">
<head>
<meta charset="UTF-8"/>
- <title data-th-text="${page.title}">Thymeleaf With with Sling Model</title>
+ <title data-th-text="${page.title}">Thymeleaf</title>
</head>
<body>
-<span id="name" data-th-text="${page.name}"></span>
+<span id="name" data-th-text="${page.name}">Page Name</span>
</body>
</html>
diff --git a/src/test/resources/apps/thymeleaf/page/decoupled/html.html b/src/test/resources/apps/thymeleaf/page/decoupled/html.html
index 90779c9..22b5bbd 100644
--- a/src/test/resources/apps/thymeleaf/page/decoupled/html.html
+++ b/src/test/resources/apps/thymeleaf/page/decoupled/html.html
@@ -17,7 +17,7 @@
specific language governing permissions and limitations
under the License.
-->
-<html>
+<html lang="en">
<head>
<title id="title">Thymeleaf</title>
</head>
diff --git a/src/test/resources/apps/thymeleaf/page/fragments/head.html b/src/test/resources/apps/thymeleaf/page/fragments/head.html
index e256136..f5a4cfd 100644
--- a/src/test/resources/apps/thymeleaf/page/fragments/head.html
+++ b/src/test/resources/apps/thymeleaf/page/fragments/head.html
@@ -17,7 +17,7 @@
specific language governing permissions and limitations
under the License.
-->
-<html>
+<html lang="de">
<head data-th-fragment="default">
<meta charset="UTF-8"/>
<title>Head Title</title>
diff --git a/src/test/resources/apps/thymeleaf/page/include/html.html b/src/test/resources/apps/thymeleaf/page/include/html.html
index 96c2ace..4e639d9 100644
--- a/src/test/resources/apps/thymeleaf/page/include/html.html
+++ b/src/test/resources/apps/thymeleaf/page/include/html.html
@@ -17,21 +17,21 @@
specific language governing permissions and limitations
under the License.
-->
-<html>
+<html lang="de">
<head>
<meta charset="UTF-8"/>
<title>Sling Include (with JSP)</title>
</head>
<body>
<!-- simple include with resource type -->
-<span id="simple" data-sling-include="${resource}" data-sling-resourceType="'jsp/page/resource'"></span>
+<span id="simple" data-sling-include="${resource}" data-sling-resourceType="'jsp/page/resource'">simple</span>
<!-- include (keeping container element) -->
<div id="wrap">
- <span data-sling-include="${resource}" data-sling-resourceType="'jsp/page/resource'" data-sling-unwrap="false"></span>
+ <span data-sling-include="${resource}" data-sling-resourceType="'jsp/page/resource'" data-sling-unwrap="false">wrap</span>
</div>
<!-- include (unwrapping) -->
<div id="unwrap">
- <span data-sling-include="${resource}" data-sling-resourceType="'jsp/page/resource'" data-sling-unwrap="true"></span>
+ <span data-sling-include="${resource}" data-sling-resourceType="'jsp/page/resource'" data-sling-unwrap="true">unwrap</span>
</div>
</body>
</html>
diff --git a/src/test/resources/apps/thymeleaf/page/link/html.html b/src/test/resources/apps/thymeleaf/page/link/html.html
index e9171f3..c4470d9 100644
--- a/src/test/resources/apps/thymeleaf/page/link/html.html
+++ b/src/test/resources/apps/thymeleaf/page/link/html.html
@@ -17,10 +17,10 @@
specific language governing permissions and limitations
under the License.
-->
-<html>
+<html lang="en">
<head>
<meta charset="UTF-8"/>
- <title></title>
+ <title>Thymeleaf</title>
</head>
<body>
<a id="foo" href="#" data-th-href="@{foo}">foo</a>
diff --git a/src/test/resources/apps/thymeleaf/page/main/html.html b/src/test/resources/apps/thymeleaf/page/main/html.html
index 35937bc..4142d52 100644
--- a/src/test/resources/apps/thymeleaf/page/main/html.html
+++ b/src/test/resources/apps/thymeleaf/page/main/html.html
@@ -17,10 +17,10 @@
specific language governing permissions and limitations
under the License.
-->
-<html data-th-with="page=${request.adaptTo(@org.apache.sling.scripting.thymeleaf.it.app.Page@class)}">
+<html lang="de" data-th-with="page=${request.adaptTo(@org.apache.sling.scripting.thymeleaf.it.app.Page@class)}">
<head>
<meta charset="UTF-8"/>
- <title data-th-text="${page.title}">Page Title</title>
+ <title data-th-text="${page.title}">Thymeleaf</title>
</head>
<body>
<p data-th-text="${page.name}">Page Name</p>
diff --git a/src/test/resources/apps/thymeleaf/page/replace/html.html b/src/test/resources/apps/thymeleaf/page/replace/html.html
index 1c9ea89..38f1f0a 100644
--- a/src/test/resources/apps/thymeleaf/page/replace/html.html
+++ b/src/test/resources/apps/thymeleaf/page/replace/html.html
@@ -17,9 +17,9 @@
specific language governing permissions and limitations
under the License.
-->
-<html>
+<html lang="de">
<head data-th-replace="/apps/thymeleaf/page/fragments/head.html::default">
- <title>Thymeleaf Replace</title>
+ <title>Thymeleaf</title>
</head>
<body>
</body>
diff --git a/src/test/resources/apps/thymeleaf/page/text/html.html b/src/test/resources/apps/thymeleaf/page/text/html.html
index b177352..3226c80 100644
--- a/src/test/resources/apps/thymeleaf/page/text/html.html
+++ b/src/test/resources/apps/thymeleaf/page/text/html.html
@@ -17,12 +17,12 @@
specific language governing permissions and limitations
under the License.
-->
-<html>
+<html lang="de">
<head>
<meta charset="UTF-8"/>
- <title data-th-text="${resource.getValueMap().get('title')}"></title>
+ <title data-th-text="${resource.getValueMap().get('title')}">Thymeleaf</title>
</head>
<body>
-<span id="name" data-th-text="${resource.name}"></span>
+<span id="name" data-th-text="${resource.name}">Resource Name</span>
</body>
</html>
[sling-org-apache-sling-scripting-thymeleaf] 03/03: SLING-8709 Make
value map of current resource available in bindings as properties
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-thymeleaf.git
commit 19537f7ec370758e20d778c5dbb37f49df9198ea
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Sep 15 13:38:24 2019 +0200
SLING-8709 Make value map of current resource available in bindings as properties
---
.../internal/ThymeleafBindingsValuesProvider.java | 47 +++++++++++++++++++
.../html/ThymeleafBindingsValuesProviderIT.java | 53 ++++++++++++++++++++++
.../apps/thymeleaf/page/bindings/html.html | 27 +++++++++++
src/test/resources/content/thymeleaf.json | 6 +++
4 files changed, 133 insertions(+)
diff --git a/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafBindingsValuesProvider.java b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafBindingsValuesProvider.java
new file mode 100644
index 0000000..7d88204
--- /dev/null
+++ b/src/main/java/org/apache/sling/scripting/thymeleaf/internal/ThymeleafBindingsValuesProvider.java
@@ -0,0 +1,47 @@
+/*
+ * 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;
+
+import javax.script.Bindings;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.scripting.SlingBindings;
+import org.apache.sling.scripting.api.BindingsValuesProvider;
+import org.osgi.service.component.annotations.Component;
+
+@Component(
+ property = {
+ "javax.script.name=thymeleaf"
+ }
+)
+public class ThymeleafBindingsValuesProvider implements BindingsValuesProvider {
+
+ private static final String PROPERTIES = "properties";
+
+ @Override
+ public void addBindings(final Bindings bindings) {
+ if (!bindings.containsKey(PROPERTIES)) {
+ final Resource resource = (Resource) bindings.get(SlingBindings.RESOURCE);
+ if (resource != null) {
+ bindings.put(PROPERTIES, resource.getValueMap());
+ }
+ }
+ }
+
+}
diff --git a/src/test/java/org/apache/sling/scripting/thymeleaf/it/tests/html/ThymeleafBindingsValuesProviderIT.java b/src/test/java/org/apache/sling/scripting/thymeleaf/it/tests/html/ThymeleafBindingsValuesProviderIT.java
new file mode 100644
index 0000000..a800db9
--- /dev/null
+++ b/src/test/java/org/apache/sling/scripting/thymeleaf/it/tests/html/ThymeleafBindingsValuesProviderIT.java
@@ -0,0 +1,53 @@
+/*
+ * 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.it.tests.html;
+
+import java.io.IOException;
+
+import org.apache.sling.scripting.thymeleaf.it.tests.ThymeleafTestSupport;
+import org.jsoup.Jsoup;
+import org.jsoup.nodes.Document;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.PaxExam;
+import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
+import org.ops4j.pax.exam.spi.reactors.PerClass;
+
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertThat;
+
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class ThymeleafBindingsValuesProviderIT extends ThymeleafTestSupport {
+
+ private Document document;
+
+ @Before
+ public void setup() throws IOException {
+ final String url = String.format("http://localhost:%s/thymeleaf/bindings.html", httpPort());
+ document = Jsoup.connect(url).get();
+ }
+
+ @Test
+ public void testTitle() {
+ assertThat(document.title(), is("Thymeleaf Bindings"));
+ }
+
+}
diff --git a/src/test/resources/apps/thymeleaf/page/bindings/html.html b/src/test/resources/apps/thymeleaf/page/bindings/html.html
new file mode 100644
index 0000000..1bf4a7f
--- /dev/null
+++ b/src/test/resources/apps/thymeleaf/page/bindings/html.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<!--
+ 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.
+-->
+<html lang="de">
+<head>
+ <meta charset="UTF-8"/>
+ <title data-th-text="${properties.title}">Thymeleaf</title>
+</head>
+<body>
+</body>
+</html>
diff --git a/src/test/resources/content/thymeleaf.json b/src/test/resources/content/thymeleaf.json
index b79a222..61247ca 100644
--- a/src/test/resources/content/thymeleaf.json
+++ b/src/test/resources/content/thymeleaf.json
@@ -9,6 +9,12 @@
"sling:resourceSuperType": "thymeleaf/page",
"title": "Sling Models adaptTo()"
},
+ "bindings": {
+ "jcr:primaryType": "nt:unstructured",
+ "sling:resourceType": "thymeleaf/page/bindings",
+ "sling:resourceSuperType": "thymeleaf/page",
+ "title": "Thymeleaf Bindings"
+ },
"decoupled": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "thymeleaf/page/decoupled",
[sling-org-apache-sling-scripting-thymeleaf] 01/03: style
Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
olli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-thymeleaf.git
commit 5d6186724d08bc3da760473f182283acb8582a26
Author: Oliver Lietz <ol...@apache.org>
AuthorDate: Sun Sep 15 13:20:59 2019 +0200
style
---
.../sling/scripting/thymeleaf/it/tests/ThymeleafTestSupport.java | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/test/java/org/apache/sling/scripting/thymeleaf/it/tests/ThymeleafTestSupport.java b/src/test/java/org/apache/sling/scripting/thymeleaf/it/tests/ThymeleafTestSupport.java
index 66cebe9..7bd4f66 100644
--- a/src/test/java/org/apache/sling/scripting/thymeleaf/it/tests/ThymeleafTestSupport.java
+++ b/src/test/java/org/apache/sling/scripting/thymeleaf/it/tests/ThymeleafTestSupport.java
@@ -46,6 +46,7 @@ import static org.apache.sling.testing.paxexam.SlingOptions.slingScriptingJsp;
import static org.ops4j.pax.exam.CoreOptions.composite;
import static org.ops4j.pax.exam.CoreOptions.junitBundles;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
+import static org.ops4j.pax.exam.CoreOptions.options;
public abstract class ThymeleafTestSupport extends TestSupport {
@@ -73,7 +74,7 @@ public abstract class ThymeleafTestSupport extends TestSupport {
@Configuration
public Option[] configuration() {
- return new Option[]{
+ return options(
baseConfiguration(),
quickstart(),
// Sling Scripting Thymeleaf
@@ -87,7 +88,7 @@ public abstract class ThymeleafTestSupport extends TestSupport {
mavenBundle().groupId("org.jsoup").artifactId("jsoup").versionAsInProject(),
mavenBundle().groupId("org.apache.servicemix.bundles").artifactId("org.apache.servicemix.bundles.hamcrest").versionAsInProject(),
junitBundles()
- };
+ );
}
@ProbeBuilder