SLING-5811 - Properly handle actual Resources in Sightly data-sly-resource

* Added handling for actual Resource objects in data-sly-resource
* Added tests
(applied slightly modified patch from Vlad Băilescu; closes #150)

git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1750765 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/actualresource.html b/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/actualresource.html
new file mode 100644
index 0000000..4cce9be
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/actualresource.html
@@ -0,0 +1,23 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<sly data-sly-use.actualresource="actualresource.js">
+    <div id="hash">${actualresource.hash}</div>
+    <div id="actual" data-sly-resource="${actualresource.actual @ selectors='included'}"></div>
+    <div id="path" data-sly-resource="${actualresource.path @ selectors='included'}"></div>
+</sly>
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/actualresource.js b/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/actualresource.js
new file mode 100644
index 0000000..e070b69
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/actualresource.js
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+use(function () {
+    return {
+        hash: Packages.java.lang.System.identityHashCode(resource),
+        actual: resource,
+        path: resource.getPath()
+    };
+});
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/included.html b/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/included.html
new file mode 100644
index 0000000..fb3b1a3
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/included.html
@@ -0,0 +1,19 @@
+<!--/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+  ~ 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.
+  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/-->
+<sly data-sly-use.included="${'included.js'}">${included.hash}</sly>
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/included.js b/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/included.js
new file mode 100644
index 0000000..95f611a
--- /dev/null
+++ b/src/main/resources/SLING-INF/apps/sightly/scripts/actualresource/included.js
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * 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.
+ ******************************************************************************/
+use(function () {
+    return {
+        hash: Packages.java.lang.System.identityHashCode(resource)
+    };
+});
\ No newline at end of file
diff --git a/src/main/resources/SLING-INF/sightly.json b/src/main/resources/SLING-INF/sightly.json
index 5293677..1d9a807 100644
--- a/src/main/resources/SLING-INF/sightly.json
+++ b/src/main/resources/SLING-INF/sightly.json
@@ -9,6 +9,10 @@
         "jcr:primaryType": "nt:unstructured",
         "sling:resourceType": "/apps/sightly/scripts/resource"
     },
+    "actualresource": {
+        "jcr:primaryType": "nt:unstructured",
+        "sling:resourceType": "/apps/sightly/scripts/actualresource"
+    },
     "includedresource": {
         "jcr:primaryType": "nt:unstructured",
         "sling:resourceType": "/apps/sightly/scripts/includedresource"