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 4f8a6d6  Adding version support
4f8a6d6 is described below

commit 4f8a6d6b1407e41b795289e70a75aa50758e958b
Author: Dan Klco <[email protected]>
AuthorDate: Tue Feb 6 17:22:33 2018 -0500

    Adding version support
---
 cms/docker/README.md                               |  18 ----
 cms/ui/src/main/frontend/src/js/scripts.js         |  14 +++
 .../components/cms/contenttable/contenttable.jsp   |   2 +-
 .../cms/versionmanager/versionmanager.jsp          | 112 +++++++++++++++++++++
 .../libs/sling-cms/components/pages/base/base.jsp  |   2 +-
 .../libs/sling-cms/content/shared/versions.json    |  21 ++++
 .../libs/sling-cms/content/site/content.json       |  16 +++
 7 files changed, 165 insertions(+), 20 deletions(-)

diff --git a/cms/docker/README.md b/cms/docker/README.md
deleted file mode 100644
index 471f2c5..0000000
--- a/cms/docker/README.md
+++ /dev/null
@@ -1,18 +0,0 @@
-# Apache Sling CMS Docker image
-
-The Apache Sling CMS Docker integration project is a helper aimed to make it 
simple to deploy an instance of Apache Sling CMS.
-
-## Building a Docker image
-
-$ docker build -t org.apache.sling.cms .
-
-## Running a standalone Sling instance
-
-To launch a docker instance named 'sling-cms' bound to 
-port 80 on the local machine, and with the /opt/sling/sling volume
-mounted at /srv/docker/sling in the local machine, execute:
-
-```
-$ docker run -ti -p 80:80 -v /srv/docker/sling:/opt/sling/sling \
-    --name sling-cms org.apache.sling.cms
-```
diff --git a/cms/ui/src/main/frontend/src/js/scripts.js 
b/cms/ui/src/main/frontend/src/js/scripts.js
index 0f1acd2..292bb5f 100644
--- a/cms/ui/src/main/frontend/src/js/scripts.js
+++ b/cms/ui/src/main/frontend/src/js/scripts.js
@@ -154,6 +154,20 @@ Sling.CMS = {
                }
        };
 
+       Sling.CMS.ext['fetch-json'] = {
+               decorate: function($ctx) {
+                       $ctx.find('.fetch-json').each(function(){
+                               $ctr = $(this);
+                               $.getJSON($ctr.data('url'),function(res){
+                                       var source   = 
$('#'+$ctr.data('template')).html();
+                                       var template = 
Handlebars.compile(source);
+                                       $ctr.append(template(res));
+                                       Sling.CMS.decorate($ctr);
+                               });
+                       });
+               }
+       }
+
        Sling.CMS.ext['includeconfig'] = {
                decorate: function($ctx){
                        $ctx.find('.Sling-CMS__include-config').each(function(){
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 89c5764..d10a660 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
@@ -41,7 +41,7 @@
                                                                                
<c:forEach var="actionConfig" items="${sling:listChildren(colConfig)}">
                                                                                
        <c:choose>
                                                                                
                <c:when test="${actionConfig.valueMap.modal}">
-                                                                               
                        <a class="Button Fetch-Modal" 
data-title="${sling:encode(actionConfig.valueMap.title,'HTML_ATTR')}" 
data-path=".Main-Content form" 
href="${actionConfig.valueMap.prefix}${child.path}" 
title="${sling:encode(actionConfig.valueMap.title,'HTML_ATTR')}">
+                                                                               
                        <a class="Button Fetch-Modal" 
data-title="${sling:encode(actionConfig.valueMap.title,'HTML_ATTR')}" 
data-path="${actionConfig.valueMap.ajaxPath != null ? 
actionConfig.valueMap.ajaxPath : '.Main-Content form'}" 
href="${actionConfig.valueMap.prefix}${child.path}" 
title="${sling:encode(actionConfig.valueMap.title,'HTML_ATTR')}">
                                                                                
                                ${actionConfig.valueMap.text}
                                                                                
                        </a>
                                                                                
                </c:when>
diff --git 
a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/versionmanager/versionmanager.jsp
 
b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/versionmanager/versionmanager.jsp
new file mode 100644
index 0000000..f5f603e
--- /dev/null
+++ 
b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/cms/versionmanager/versionmanager.jsp
@@ -0,0 +1,112 @@
+<%-- /*
+ * 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.
+ */ --%>
+ <%@include file="/libs/sling-cms/global.jsp"%>
+ <div class="versionmanager">
+       <c:set var="versionable" value="false" />
+       <c:if 
test="${slingRequest.requestPathInfo.suffixResource.valueMap['jcr:mixinTypes'] 
!= null && 
fn:contains(fn:join(slingRequest.requestPathInfo.suffixResource.valueMap['jcr:mixinTypes'],','),'mix:versionable')}">
+               <c:set var="versionable" value="true" />
+       </c:if>
+       <c:choose>
+               <c:when test="${versionable == 'true'}">
+                       <c:choose>
+                               <c:when 
test="${sling:adaptTo(slingRequest.requestPathInfo.suffixResource,'javax.jcr.Node').checkedOut}">
+                                       <form method="post" 
action="${slingRequest.requestPathInfo.suffix}" enctype="multipart/form-data" 
class="Form-Ajax" data-add-date="false">
+                                               <input type="hidden" 
name=":operation" value="checkin" />
+                                               <div class="Field-Group">
+                                                       <button type="submit" 
class="btn btn-success" title="Check the content back out so it can not be 
edited (opposite of JCR Checkout)">
+                                                               Checkout
+                                                       </button>
+                                               </div>
+                                       </form>
+                               </c:when>
+                               <c:otherwise>
+                                       <form method="post" 
action="${slingRequest.requestPathInfo.suffix}" enctype="multipart/form-data" 
class="Form-Ajax" data-add-date="false">
+                                               <input type="hidden" 
name=":operation" value="checkout" />
+                                               <div class="Field-Group">
+                                                       <button type="submit" 
class="btn btn-success" title="Check the content back in so it can be edited 
(opposite of JCR Checkin)">
+                                                               Checkin
+                                                       </button>
+                                               </div>
+                                       </form>
+                               </c:otherwise>
+                       </c:choose>
+               </c:when>
+               <c:otherwise>
+                       <form method="post" 
action="${slingRequest.requestPathInfo.suffix}" enctype="multipart/form-data" 
class="Form-Ajax" data-add-date="false">
+                               <input type="hidden" name=":autoCheckout" 
value="true">
+                               <input type="hidden" name=":autoCheckin" 
value="true">
+                               <input type="hidden" 
name="jcr:mixinTypes@TypeHint" value="Type[]">
+                           <input type="hidden" name="jcr:mixinTypes" 
value="mix:versionable">
+                               <div class="Field-Group">
+                                       <button type="submit" class="btn 
btn-success" title="Make the content versionable">
+                                               Make Versionable
+                                       </button>
+                               </div>
+                       </form>
+               </c:otherwise>
+       </c:choose>
+       <table>
+               <thead>
+                       <tr>
+                               <th>Version</th>
+                               <th>Created</th>
+                               <th>Successors</th>
+                               <th>Predecessors</th>
+                               <th>Restore</th>
+                       </tr>
+               </thead>
+               <tbody class="fetch-json" 
data-url="${slingRequest.requestPathInfo.suffix}.V.json" 
data-template="version-template">
+                       
+               </tbody>
+       </table>
+       <script id="version-template" type="text/x-handlebars-template">
+               {{#each versions }}
+                       <tr>
+                               <td>
+                                       {{@key}}
+                               </td>
+                               <td>
+                                       {{created}}
+                               </td>
+                               <td>
+                                       {{#each successors }}
+                                               {{this}}<br/>
+                                       {{/each}}
+                               </td>
+                               <td>
+                                       {{#each predecessors }}
+                                               {{this}}<br/>
+                                       {{/each}}
+                               </td>
+                               <td>
+                                       <form method="post" 
action="${slingRequest.requestPathInfo.suffix}" enctype="multipart/form-data" 
class="Form-Ajax" data-add-date="false">
+                                               <input type="hidden" 
name=":operation" value="restore" />
+                                               <input type="hidden" 
name=":version" value="{{@key}}" />
+                                               <div class="Field-Group">
+                                                       <button type="submit" 
class="btn btn-success" title="Restore the content to {{@key}}">
+                                                               Restore Version
+                                                       </button>
+                                               </div>
+                                       </form>
+                               </td>
+                       </tr>
+               {{/each}}
+       </script>
+ </div>
+ 
\ No newline at end of file
diff --git 
a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/base.jsp
 
b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/base.jsp
index 4eba32c..ba73388 100644
--- 
a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/base.jsp
+++ 
b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/components/pages/base/base.jsp
@@ -17,7 +17,7 @@
  * under the License.
  */ --%>
  <%@include file="/libs/sling-cms/global.jsp"%>
-<html>
+<html lang="en">
        <sling:call script="head.jsp" />
        <sling:call script="body.jsp" />
 </html>
diff --git 
a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/versions.json
 
b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/versions.json
new file mode 100644
index 0000000..ca321bf
--- /dev/null
+++ 
b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/shared/versions.json
@@ -0,0 +1,21 @@
+{
+       "jcr:primaryType": "sling:Page",
+       "jcr:content": {
+               "sling:resourceType": "sling-cms/components/pages/base",
+               "jcr:title": "Manage Versions",
+               "jcr:primaryType": "nt:unstructured",
+               "container": {
+                       "jcr:primaryType": "nt:unstructured",
+                       "sling:resourceType": 
"sling-cms/components/general/container",
+                       "richtext": {
+                               "jcr:primaryType": "nt:unstructured",
+                               "sling:resourceType": 
"sling-cms/components/general/richtext",
+                               "text": "<h3>Manage Versions</h3>"
+                       },
+                       "versionmanager": {
+                               "jcr:primaryType": "nt:unstructured",
+                               "sling:resourceType": 
"sling-cms/components/cms/versionmanager"
+                       }
+               }
+       }
+}
\ No newline at end of file
diff --git 
a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/content.json 
b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/content.json
index e473556..840d658 100644
--- 
a/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/content.json
+++ 
b/cms/ui/src/main/resources/jcr_root/libs/sling-cms/content/site/content.json
@@ -126,6 +126,14 @@
                                                                        "text": 
"&#x21c6;",
                                                                        
"prefix": "/cms/shared/movecopy.html"
                                                                },
+                                                               "version": {
+                                                                       
"jcr:primaryType": "nt:unstructured",
+                                                                       
"ajaxPath": ".versionmanager",
+                                                                       
"modal": true,
+                                                                       
"title": "Manage Versions",
+                                                                       "text": 
"&#10710;",
+                                                                       
"prefix": "/cms/shared/versions.html"
+                                                               },
                                                                "delete": {
                                                                        
"jcr:primaryType": "nt:unstructured",
                                                                        
"modal": true,
@@ -192,6 +200,14 @@
                                                                        "text": 
"&#x21c6;",
                                                                        
"prefix": "/cms/shared/movecopy.html"
                                                                },
+                                                               "version": {
+                                                                       
"jcr:primaryType": "nt:unstructured",
+                                                                       
"ajaxPath": ".versionmanager",
+                                                                       
"modal": true,
+                                                                       
"title": "Manage Versions",
+                                                                       "text": 
"&#10710;",
+                                                                       
"prefix": "/cms/shared/versions.html"
+                                                               },
                                                                "delete": {
                                                                        
"jcr:primaryType": "nt:unstructured",
                                                                        
"modal": true,

-- 
To stop receiving notification emails like this one, please contact
[email protected].

Reply via email to