You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by dk...@apache.org on 2018/11/11 02:54:48 UTC

[sling-org-apache-sling-app-cms] branch SLING-8074-improve-reference-list updated (4c03ef7 -> 6f591b2)

This is an automated email from the ASF dual-hosted git repository.

dklco pushed a change to branch SLING-8074-improve-reference-list
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git.


    from 4c03ef7  Working on improving the references for SLING-8074
     add 79fe5c4  [maven-release-plugin] prepare release org.apache.sling.cms-0.11.0
     add 96879b7  [maven-release-plugin] prepare for next development iteration
     add 4d8b91e  moved rava to npm repository.
     add 2a01c29  Re-adding Handlebars to fix SLING-8087
     add 38c1be2  Adding the 0.11.0 release
     add 51f0508  Adding a call to close the modal when it's opened by the editor script to fix SLING-8088
     add 1b9993f  Updating the readability configuration to be in the correct naming convention to fix SLING-8089
     add 85d765c  Fixing spelling error
     add e04acf2  Adding documentation on content insights
     new 0189181  Working on improving the references for SLING-8074
     new 6f591b2  Merge branch 'SLING-8074-improve-reference-list' of github.com:apache/sling-org-apache-sling-app-cms into SLING-8074-improve-reference-list

The 2 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:
 api/pom.xml                                        |   6 +-
 builder/pom.xml                                    |   2 +-
 core/pom.xml                                       |   6 +-
 .../readability/impl/ReadabilityServiceImpl.java   |   3 +-
 docs/content-insights.md                           |  58 +++++++
 docs/img/configure-readability-grade-range.jpg     | Bin 0 -> 30160 bytes
 docs/img/configure-readability-service.jpg         | Bin 0 -> 52586 bytes
 docs/img/insights-modal.jpg                        | Bin 0 -> 38449 bytes
 docs/mongodb.md                                    |   2 +-
 docs/releases.md                                   |  12 +-
 docs/users.md                                      |   1 +
 pom.xml                                            |   6 +-
 reference/pom.xml                                  |   8 +-
 ui/pom.xml                                         |   6 +-
 ui/src/main/frontend/gulpfile.js                   |   3 +-
 ui/src/main/frontend/package.json                  |   2 +
 ui/src/main/frontend/src/js/editor.js              |   3 +
 ui/src/main/frontend/src/js/rava.js                | 190 ---------------------
 ...dability.impl.ReadabilityServiceImpl-en.config} |   0
 19 files changed, 92 insertions(+), 216 deletions(-)
 create mode 100644 docs/content-insights.md
 create mode 100644 docs/img/configure-readability-grade-range.jpg
 create mode 100644 docs/img/configure-readability-service.jpg
 create mode 100644 docs/img/insights-modal.jpg
 delete mode 100644 ui/src/main/frontend/src/js/rava.js
 rename ui/src/main/resources/jcr_root/libs/sling-cms/{install/org.apache.sling.cms.core.readability.impl.ReadabilityServiceImpl.en.config => config/org.apache.sling.cms.core.readability.impl.ReadabilityServiceImpl-en.config} (100%)


[sling-org-apache-sling-app-cms] 02/02: Merge branch 'SLING-8074-improve-reference-list' of github.com:apache/sling-org-apache-sling-app-cms into SLING-8074-improve-reference-list

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch SLING-8074-improve-reference-list
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit 6f591b2cd026b672661f844ac9b7182838a5d662
Merge: 0189181 4c03ef7
Author: Dan Klco <dk...@apache.org>
AuthorDate: Sat Nov 10 21:54:33 2018 -0500

    Merge branch 'SLING-8074-improve-reference-list' of github.com:apache/sling-org-apache-sling-app-cms into SLING-8074-improve-reference-list



[sling-org-apache-sling-app-cms] 01/02: Working on improving the references for SLING-8074

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dklco pushed a commit to branch SLING-8074-improve-reference-list
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-app-cms.git

commit 0189181b8fea2b5d2f6da5786b5cc9679c2dd1df
Author: Dan Klco <dk...@apache.org>
AuthorDate: Mon Nov 5 22:17:12 2018 -0500

    Working on improving the references for SLING-8074
---
 .../core/internal/models/ReferenceOperation.java   | 103 +++++++++++----------
 .../libs/sling-cms/content/shared/references.json  |  17 ++++
 .../libs/sling-cms/content/site/content.json       |   7 ++
 3 files changed, 77 insertions(+), 50 deletions(-)

diff --git a/core/src/main/java/org/apache/sling/cms/core/internal/models/ReferenceOperation.java b/core/src/main/java/org/apache/sling/cms/core/internal/models/ReferenceOperation.java
index baa05c5..311a8d1 100644
--- a/core/src/main/java/org/apache/sling/cms/core/internal/models/ReferenceOperation.java
+++ b/core/src/main/java/org/apache/sling/cms/core/internal/models/ReferenceOperation.java
@@ -33,61 +33,64 @@ import org.slf4j.LoggerFactory;
  */
 public abstract class ReferenceOperation {
 
-	private static final Logger log = LoggerFactory.getLogger(ReferenceOperation.class);
+    private static final Logger log = LoggerFactory.getLogger(ReferenceOperation.class);
 
-	private Pattern regex = null;
+    private Pattern regex = null;
 
-	private Resource resource = null;
+    private Resource resource = null;
 
-	public ReferenceOperation(Resource resource) {
-		String path = resource.getPath().replace("/", "\\/");
-		if (CMSConstants.NT_PAGE.equals(resource.getResourceType())) {
-			regex = Pattern.compile(
-					"(^" + path + "($|\\/)|(\\'|\\\")" + path + "(\\.html|\\'|\\\"|\\/))");
-		} else {
-			regex = Pattern.compile("(^" + path + "($|\\/)|(\\'|\\\")" + path + "(\\'|\\\"|\\/))");
-		}
-		this.resource = resource;
-	}
+    public ReferenceOperation(Resource resource) {
+        String path = resource.getPath().replace("/", "\\/");
+        if (CMSConstants.NT_PAGE.equals(resource.getResourceType())) {
+            regex = Pattern.compile("(^" + path + "($|\\/)|(\\'|\\\")" + path + "(\\.html|\\'|\\\"|\\/))");
+        } else {
+            regex = Pattern.compile("(^" + path + "($|\\/)|(\\'|\\\")" + path + "(\\'|\\\"|\\/))");
+        }
+        this.resource = resource;
+    }
 
-	public void init() {
-		log.debug("Finding references to {}", resource.getPath());
+    private void checkReferences(Resource resource) {
+        log.debug("Checking for references in resource {}", resource);
+        ValueMap properties = resource.getValueMap();
+        properties.keySet().forEach(k -> {
+            if (properties.get(k) instanceof String) {
+                if (matches(properties.get(k, String.class))) {
+                    log.trace("Found reference in property {}@{}", resource.getPath(), k);
+                    doProcess(resource, k);
+                }
+            } else if (properties.get(k) instanceof String[]) {
+                for (String v : properties.get(k, String[].class)) {
+                    if (matches(v)) {
+                        log.trace("Found reference in property {}@{}", resource.getPath(), k);
+                        doProcess(resource, k);
+                        break;
+                    }
+                }
+            }
 
-		String query = "SELECT * FROM [nt:base] AS s WHERE CONTAINS(s.*, '" + resource.getPath() + "')";
-		Iterator<Resource> resources = resource.getResourceResolver().findResources(query, Query.JCR_SQL2);
-		log.debug("Checking for references with: {}", query);
-		while (resources.hasNext()) {
-			Resource r = resources.next();
-			log.debug("Checking for references in resource {}", r);
-			ValueMap properties = r.getValueMap();
-			for (String k : properties.keySet()) {
-				if (properties.get(k) instanceof String) {
-					Matcher matcher = regex.matcher(properties.get(k, String.class));
-					if (matcher.find()) {
-						log.trace("Found reference in property {}@{}", r.getPath(), k);
-						doProcess(r, k);
-					}
-				} else if (properties.get(k) instanceof String[]) {
-					boolean matches = false;
-					for (String v : properties.get(k, String[].class)) {
-						Matcher matcher = regex.matcher(v);
-						if (matcher.find()) {
-							matches = true;
-							break;
-						}
-					}
-					if (matches) {
-						log.trace("Found reference in property {}@{}", r.getPath(), k);
-						doProcess(r, k);
-					}
-				}
-			}
-		}
-	}
+        });
+    }
 
-	public abstract void doProcess(Resource resource, String matchingKey);
+    public abstract void doProcess(Resource resource, String matchingKey);
 
-	public Pattern getRegex() {
-		return regex;
-	}
+    public Pattern getRegex() {
+        return regex;
+    }
+
+    public void init() {
+        log.debug("Finding references to {}", resource.getPath());
+        String query = "SELECT * FROM [nt:base] AS s WHERE NOT ISDESCENDANTNODE([/jcr:system/jcr:versionStorage]) AND CONTAINS(s.*, '"
+                + resource.getPath() + "')";
+        Iterator<Resource> resources = resource.getResourceResolver().findResources(query, Query.JCR_SQL2);
+        log.debug("Checking for references with: {}", query);
+        while (resources.hasNext()) {
+            Resource r = resources.next();
+            checkReferences(r);
+        }
+    }
+
+    private boolean matches(String value) {
+        Matcher matcher = regex.matcher(value);
+        return matcher.find();
+    }
 }
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/references.json b/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/references.json
new file mode 100644
index 0000000..100d492
--- /dev/null
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/references.json
@@ -0,0 +1,17 @@
+{
+    "jcr:primaryType": "sling:Page",
+    "jcr:content": {
+        "sling:resourceType": "sling-cms/components/pages/modal",
+        "jcr:title": "View References",
+        "jcr:primaryType": "nt:unstructured",
+        "container": {
+            "jcr:primaryType": "nt:unstructured",
+            "sling:resourceType": "sling-cms/components/general/container",
+            "references": {
+                "jcr:primaryType": "nt:unstructured",
+                "sling:resourceType": "sling-cms/components/editor/fields/references",
+                "label": "References"
+            }
+        }
+    }
+}
diff --git a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/content.json b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/content.json
index f48b94c..eae063e 100644
--- a/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/content.json
+++ b/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/content.json
@@ -261,6 +261,13 @@
                                     "icon": "move-alt",
                                     "prefix": "/cms/shared/movecopy.html"
                                 },
+                                "references": {
+                                    "jcr:primaryType": "nt:unstructured",
+                                    "modal": true,
+                                    "title": "References",
+                                    "icon": "directions",
+                                    "prefix": "/cms/shared/references.html"
+                                },
                                 "version": {
                                     "jcr:primaryType": "nt:unstructured",
                                     "ajaxPath": ".versionmanager",