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/02/27 04:17:48 UTC

[sling-whiteboard] branch master updated: Adding a filter to the content table and adding some helper methods to the models for common site structures

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

dklco pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-whiteboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 909bb50  Adding a filter to the content table and adding some helper methods to the models for common site structures
     new 79781b0  Merge branch 'master' of github.com:apache/sling-whiteboard
909bb50 is described below

commit 909bb503f38830ff890f787cdcb66bc2f4dc6472
Author: Dan Klco <da...@gmail.com>
AuthorDate: Mon Feb 26 20:17:35 2018 -0800

    Adding a filter to the content table and adding some helper methods to the models for common site structures
---
 .../org/apache/sling/cms/core/models/Page.java     | 22 ++++++++++++++++++++--
 .../org/apache/sling/cms/core/models/Site.java     | 22 +++++++++++++++++-----
 cms/ui/src/main/frontend/src/js/scripts.js         | 20 ++++++++++++++++++++
 .../resources/SLING-INF/nodetypes/nodetypes.cnd    |  1 +
 .../cms/contentbreadcrumb/contentbreadcrumb.jsp    |  8 +++++++-
 .../components/cms/contenttable/contenttable.jsp   |  2 +-
 .../components/editor/scripts/localeOptions.jsp    |  2 +-
 .../jcr_root/libs/sling-cms/content/site/edit.json |  7 +++++++
 .../libs/sling-cms/content/template/create.json    |  2 +-
 9 files changed, 75 insertions(+), 11 deletions(-)

diff --git a/cms/core/src/main/java/org/apache/sling/cms/core/models/Page.java b/cms/core/src/main/java/org/apache/sling/cms/core/models/Page.java
index 5ff42dd..e7bb46b 100644
--- a/cms/core/src/main/java/org/apache/sling/cms/core/models/Page.java
+++ b/cms/core/src/main/java/org/apache/sling/cms/core/models/Page.java
@@ -57,11 +57,29 @@ public class Page extends AbstractContentModel {
 		return published;
 	}
 
-	public String getTemplatePath() {
-		return this.template;
+	public String getPublishedPath() {
+		Site site = resource.adaptTo(SiteManager.class).getSite();
+		if (site != null) {
+			return resource.getPath().replace(site.getPath(), "") + ".html";
+		} else {
+			return resource.getPath() + ".html";
+		}
+	}
+
+	public String getPublishedURL() {
+		Site site = resource.adaptTo(SiteManager.class).getSite();
+		if (site != null) {
+			return site.getUrl() + getPublishedPath();
+		} else {
+			return resource.getPath();
+		}
 	}
 
 	public PageTemplate getTemplate() {
 		return this.resource.getResourceResolver().getResource(template).adaptTo(PageTemplate.class);
 	}
+
+	public String getTemplatePath() {
+		return this.template;
+	}
 }
diff --git a/cms/core/src/main/java/org/apache/sling/cms/core/models/Site.java b/cms/core/src/main/java/org/apache/sling/cms/core/models/Site.java
index 84e377d..ffe9c9f 100644
--- a/cms/core/src/main/java/org/apache/sling/cms/core/models/Site.java
+++ b/cms/core/src/main/java/org/apache/sling/cms/core/models/Site.java
@@ -34,6 +34,7 @@ import org.apache.sling.models.annotations.Optional;
 public class Site {
 
 	public static final String PN_CONFIG = CMSConstants.NAMESPACE + ":config";
+	public static final String PN_URL = CMSConstants.NAMESPACE + ":url";
 
 	private static Resource findSiteResource(Resource resource) {
 		if (CMSConstants.NT_SITE.equals(resource.getValueMap().get(JcrConstants.JCR_PRIMARYTYPE, String.class))) {
@@ -72,6 +73,10 @@ public class Site {
 	@Named(CMSConstants.PN_TITLE)
 	private String title;
 
+	@Inject
+	@Named(PN_URL)
+	private String url;
+
 	public Site(Resource resource) {
 		this.resource = resource;
 	}
@@ -102,10 +107,6 @@ public class Site {
 		return description;
 	}
 
-	public String getLocaleString() {
-		return locale;
-	}
-
 	public Locale getLocale() {
 		String[] segments = locale.split("_");
 		if (segments.length == 3) {
@@ -116,6 +117,10 @@ public class Site {
 		return new Locale(segments[0]);
 	}
 
+	public String getLocaleString() {
+		return locale;
+	}
+
 	public String getPath() {
 		return resource.getPath();
 	}
@@ -140,6 +145,13 @@ public class Site {
 		return title;
 	}
 
+	/**
+	 * @return the url
+	 */
+	public String getUrl() {
+		return url;
+	}
+
 	/*
 	 * (non-Javadoc)
 	 * 
@@ -161,7 +173,7 @@ public class Site {
 	@Override
 	public String toString() {
 		return "Site [config=" + config + ", description=" + description + ", locale=" + locale + ", resource="
-				+ resource + ", title=" + title + "]";
+				+ resource + ", title=" + title + ", url=" + url + "]";
 	}
 
 }
diff --git a/cms/ui/src/main/frontend/src/js/scripts.js b/cms/ui/src/main/frontend/src/js/scripts.js
index ee041ed..8bb38d5 100644
--- a/cms/ui/src/main/frontend/src/js/scripts.js
+++ b/cms/ui/src/main/frontend/src/js/scripts.js
@@ -154,6 +154,26 @@ Sling.CMS = {
 		}
 	};
 
+	Sling.CMS.ext['content-filter'] = {
+		decorate: function($ctx) {
+			var filterContent = function(){
+				var term = $('.content-filter input[type=text]').val().toLowerCase();
+				$('.sortable tbody tr').each(function(idx,el){
+					if($(el).text().toLowerCase().indexOf(term) !== -1){
+						$(el).show();
+					} else {
+						$(el).hide();
+					}
+				});
+			}
+			$('.content-filter').submit(function(){
+				filterContent();
+				return false;
+			});
+			$('.content-filter input[type=text]').keyup(filterContent).change(filterContent);
+		}
+	}
+
 	Sling.CMS.ext['fetch-json'] = {
 		decorate: function($ctx) {
 			$ctx.find('.fetch-json').each(function(){
diff --git a/cms/ui/src/main/resources/SLING-INF/nodetypes/nodetypes.cnd b/cms/ui/src/main/resources/SLING-INF/nodetypes/nodetypes.cnd
index 308cba8..b4bce16 100644
--- a/cms/ui/src/main/resources/SLING-INF/nodetypes/nodetypes.cnd
+++ b/cms/ui/src/main/resources/SLING-INF/nodetypes/nodetypes.cnd
@@ -57,6 +57,7 @@
 	- sling:config (string)
 	- sling:created (date)
 	- sling:createdBy (string)
+	- sling:url (string)
 	- jcr:language (string)
 	- jcr:lastModified (date)
 	- jcr:lastModifiedBy (string)
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/contentbreadcrumb/contentbreadcrumb.jsp b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/contentbreadcrumb/contentbreadcrumb.jsp
index 5a6c606..5bc7d95 100644
--- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/contentbreadcrumb/contentbreadcrumb.jsp
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/contentbreadcrumb/contentbreadcrumb.jsp
@@ -38,4 +38,10 @@
 			<sling:encode value="${slingRequest.requestPathInfo.suffixResource.valueMap['jcr:title'] != null ? slingRequest.requestPathInfo.suffixResource.valueMap['jcr:title'] : slingRequest.requestPathInfo.suffixResource.valueMap['jcr:content/jcr:title']}" default="${slingRequest.requestPathInfo.suffix}" mode="HTML" />
 		</li>
 	</c:if>
-</ul>
\ No newline at end of file
+	<li class="Pull-Right">
+		<form method="get" class="content-filter">
+			<label for="filter" class="hide">Filter</label>
+			<input type="text" placeholder="Filter..." />
+		</form>
+	</li>
+</ul>
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/contenttable/contenttable.jsp b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/contenttable/contenttable.jsp
index 5e8554c..312ea53 100644
--- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/contenttable/contenttable.jsp
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/contenttable/contenttable.jsp
@@ -17,7 +17,7 @@
  * under the License.
  */ --%>
  <%@include file="/libs/sling-cms/global.jsp"%>
-<table>
+<table class="sortable">
 	<thead>
 		<tr>
 			<c:forEach var="column" items="${sling:listChildren(sling:getRelativeResource(resource,'columns'))}">
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/scripts/localeOptions.jsp b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/scripts/localeOptions.jsp
index 21c925f..6ade9a5 100644
--- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/scripts/localeOptions.jsp
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/editor/scripts/localeOptions.jsp
@@ -20,7 +20,7 @@
 <option value="">Select Locale</option>
 <c:forEach var="locale" items="${sling:adaptTo(slingRequest,'org.apache.sling.cms.core.models.LocaleList').locales}">
 	<c:if test="${not empty locale.language}">
-		<option value="${locale}" ${rt == editProperties['sling:locale'] ? 'selected' : ''}>
+		<option value="${locale}" ${locale == editProperties['jcr:language'] ? 'selected' : ''}>
 			${locale.displayLanguage} ${locale.displayCountry} (${locale})
 		</option>
 	</c:if>
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/edit.json b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/edit.json
index b7da6cb..0fdc13e 100644
--- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/edit.json
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/edit.json
@@ -33,6 +33,13 @@
 						"name": "jcr:description",
 						"required": false
 					},
+					"url": {
+						"jcr:primaryType": "nt:unstructured",
+						"sling:resourceType": "sling-cms/components/editor/fields/text",
+						"label": "Primary URL",
+						"name": "sling:url",
+						"required": true
+					},
 					"locale": {
 						"jcr:primaryType": "nt:unstructured",
 						"sling:resourceType": "sling-cms/components/editor/fields/select",
diff --git a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/template/create.json b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/template/create.json
index e03f223..851eed0 100644
--- a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/template/create.json
+++ b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/template/create.json
@@ -15,7 +15,7 @@
 			"slingform": {
 				"jcr:primaryType": "nt:unstructured",
 				"sling:resourceType": "sling-cms/components/editor/slingform",
-				"actionSuffix": "/*",
+				"actionSuffix": "/templates/",
 				"button": "Create Template",
 				"successPrepend":"/libs/sling-cms/content/site/content.html",
 				"fields": {

-- 
To stop receiving notification emails like this one, please contact
dklco@apache.org.