incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From enor...@apache.org
Subject svn commit: r1098430 [4/4] - in /sling/trunk/samples: ./ accessmanager-ui/ accessmanager-ui/.settings/ accessmanager-ui/src/ accessmanager-ui/src/main/ accessmanager-ui/src/main/java/ accessmanager-ui/src/main/resources/ accessmanager-ui/src/main/resou...
Date Sun, 01 May 2011 22:46:49 GMT
Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/user/update_body.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/user/update_body.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/user/update_body.html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/user/update_body.html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,203 @@
+<%
+/*
+ * 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.
+ */
+
+var privilegesInfo = sling.getService(Packages.org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo);
+var authorizable = resource.adaptTo(Packages.org.apache.jackrabbit.api.security.user.Authorizable);
+var canEdit = privilegesInfo.canUpdateProperties(currentSession, authorizable.getID());
+var canRemove = privilegesInfo.canRemove(currentSession, authorizable.getID()); 
+var canUpdateMembers = privilegesInfo.canUpdateGroupMembers(currentSession, authorizable.getID());
+var valueMap = resource.adaptTo(Packages.org.apache.sling.api.resource.ValueMap);
+var isMe = authorizable.getID().equals(request.getRemoteUser());
+
+var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+
+var propNameSet = new Packages.java.util.TreeSet(valueMap.keySet());
+propNameSet.remove("declaredMemberOf");
+propNameSet.remove("memberOf");
+
+var propKeysCsv = rb.getString("csv.static.user.prop.keys");
+var items = [];
+if (propKeysCsv != null && propKeysCsv.length() > 0 && !propKeysCsv.equals("csv.static.user.prop.keys"))
{
+    items = propKeysCsv.split(",");
+}
+for (var i=0; i < items.length; i++) {
+    propNameSet.add(items[i]);
+}
+
+function propLabel(propName) {
+    var key = "prop.label." + propName;
+    var value = rb.getString(key);
+    if (value == key) {
+        return propName;
+    }
+    return value;
+};
+function format(key, args) {
+    var value = rb.getString(key);
+    return Packages.java.text.MessageFormat.format(value, args);
+}
+function displayName(path) {
+    var res = request.getResourceResolver().resolve(path);
+    var resValueMap = res.adaptTo(Packages.org.apache.sling.api.resource.ValueMap);
+    var value = resValueMap.get("displayName");
+    if (value == null) {
+        value = path.substring(path.lastIndexOf('/') + 1)        
+    }
+    return value;
+}
+%>
+<div class="ui-widget ui-widget-content ui-corner-all usermgmt-body" id="update-user-body"
>
+    <h3 class="ui-widget-header ui-corner-all usermgmt-header"><%=format(canEdit
? "header.update.user" : "header.view.user", authorizable.getID())%></h3>
+
+    <div class="info-msg-block" style="display:none;">
+        <div class="ui-state-highlight ui-corner-all"> 
+            <p>
+                <span class="ui-icon ui-icon-info"></span>
+                <span class="info-msg-text"></span>
+            </p>
+        </div>
+    </div>    
+    
+    <form id="update-user-form" accept-charset="UTF-8" 
+            action="<%=request.contextPath%><%=resource.path %>.update.html"

+            method="post" >
+        <fieldset>
+            <input type="hidden" value="UTF-8" name="_charset_" />
+            <input id="redirect" type="hidden" name=":redirect" value="<%=request.contextPath%><%=resource.path
%>.html" />
+
+            <%-- Member Of --%>
+            <% var key = "memberOf"; 
+               var value = valueMap.get(key);
+            %>
+            <div class="prop-line ui-helper-clearfix">
+                <label for="<%=key%>"><%=propLabel(key)%>:</label>
+
+                <ol id="<%=key%>">
+                    <li id="<%=key%>__empty" <%= value.length == 0 ? "" : "style='display:none'"
%>><%=rb.getString("memberOf.empty")%></li>
+                    <%                      
+                       for (i = 0; i < value.length; i++) {
+                          var group = value[i];
+                    %>                            
+                        <li>
+                            <a href="<%=request.contextPath%><%=group%>.html"><%=displayName(group)%></a>
+                        </li>
+                    <%
+                       }/* endfor */
+                    %>
+                </ol>
+            </div>
+
+            <%
+                var it = propNameSet.iterator();
+                while (it.hasNext()) {
+                    key = it.next();
+                    value = valueMap.get(key);
+                    if (value == null) {
+                        value = "";
+                    }
+            %>
+            <div class="prop-line ui-helper-clearfix">
+                <label for="<%=key%>"><%=propLabel(key)%>:</label>
+                <input id="<%=key%>" type="text" name="<%=key%>" value='<%=value%>'
<%= canEdit ? "" : "disabled=\"disabled\" readonly=\"readonly\" class=\"disabled\""%>/>
+                <% if (canEdit) { %>
+                <a href='#' class="noscript-hide remove-property" title='<%=rb.getString("tooltip.removeProperty")%>'><span
class="ui-icon ui-icon-circle-close"></span></a>
+                <% } /* endif(canEdit) */ %>
+            </div>
+            <%
+                } /* endwhile */
+            %>
+
+            <p id="updateSubmitBtns" class="ui-helper-clearfix">
+                <label>&#160;</label>
+                <% if (canEdit) { %><button accesskey="u" id="updateUserBtn" type="submit"><%=rb.getString("button.save")%></button><%
} %>
+                <span class="noscript-hide">
+                <% if (canRemove) { %><a href="#" id="removeUserLink"><%=rb.getString("link.remove")%></a>
| <% } %>
+                <% if (canEdit) { %><a href="#" id="add_property"><%=rb.getString("link.add.property")%></a><%
} %>
+                </span>
+            </p>
+        </fieldset>
+    </form>
+</div>
+
+<% if (canEdit) { %>
+<div id="add-property-dialog" title="<%=rb.getString("dialog.title.add.property")%>"
style="display:none">
+    <form id='add-property-form' action="#">
+    <fieldset>
+        <label for="newPropName"><%=rb.getString("label.property.name")%></label>
+        <input type="text" name="name" id="newPropName" />
+    </fieldset>
+    </form>
+</div>
+<% } /*endif(canEdit) */ %>
+
+<% if (canRemove) { %>
+<div id="remove-user-dialog" title='<%=rb.getString("dialog.title.confirm.remove")%>'
style="display:none">
+    <form id='remove-user-form' action="<%=resource.path%>.delete.html" method="post">
+    <fieldset>
+        <input type="hidden" name=":redirect" value="<%=request.contextPath%>/system/userManager/user.html"
/>
+        <p>
+            <%=rb.getString("msg.user.confirm.remove") %>
+        </p>
+    </fieldset>
+    </form>
+</div>
+<% } /*endif(canRemove) */ %>
+
+<% if (isMe) { %>
+<div class="ui-widget ui-widget-content ui-corner-all usermgmt-body" id="update-password-body"
>
+    <h3 class="ui-widget-header ui-corner-all usermgmt-header"><%=rb.getString("header.change.password")%></h3>
+    
+    <div class="info-msg-block" style="display:none;">
+        <div class="ui-state-highlight ui-corner-all"> 
+            <p>
+                <span class="ui-icon ui-icon-info"></span>
+                <span class="info-msg-text"></span>
+            </p>
+        </div>
+    </div>    
+    
+    <form id="update-password-form" accept-charset="UTF-8"
+            action="<%=request.contextPath%><%=resource.path %>.changePassword.html"

+            method="post">
+        <fieldset>
+            <input type="hidden" value="UTF-8" name="_charset_" />
+            <input id="pwdRedirect" type="hidden" name=":redirect" value="<%=request.contextPath%><%=resource.path
%>.html" />
+
+            <div class="prop-line ui-helper-clearfix">
+                <label for="oldPwd" accesskey="o"><%=propLabel("oldPwd")%>:</label>
+                <input id="oldPwd" type="password" name="oldPwd" value=''/>
+            </div>
+
+            <div class="prop-line ui-helper-clearfix">
+                <label for="newPwd" accesskey="p"><%=propLabel("newPwd")%>:</label>
               
+                <input id="newPwd"  type="password" name="newPwd" value=''/>
+            </div>
+
+            <div class="prop-line ui-helper-clearfix">
+                <label for="newPwdConfirm" accesskey="c"><%=propLabel("newPwdConfirm")%>:</label>
+                <input id="newPwdConfirm" type="password" name="newPwdConfirm" value=''/>
+            </div>
+
+            <div class="ui-helper-clearfix">
+                <label>&#160;</label>
+                <button accesskey="d" id="updatePasswordBtn" type="submit"><%=rb.getString("button.updatePwd")%></button>
+            </div>
+        </fieldset>
+    </form>
+</div>
+<% } /*endif (isme)*/ %>

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/autocomplete.json.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/autocomplete.json.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/autocomplete.json.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/autocomplete.json.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,46 @@
+<%
+/*
+ * 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.
+ */
+
+var jsonArray = new Packages.org.apache.sling.commons.json.JSONArray();
+var offset = 0;
+var maxResults = 15;
+
+var term = request.getParameter("term");
+var searchResults;
+if (term != null && term.length() > 0) {
+   var jcrSession = request.getResourceResolver().adaptTo(Packages.javax.jcr.Session);
+   var userManager = Packages.org.apache.sling.jcr.base.util.AccessControlUtil.getUserManager(jcrSession);
+
+   var query = new Packages.org.apache.sling.usermgr.FindPeopleQuery(3, term, true, offset,
maxResults);
+   searchResults = userManager.findAuthorizables(query);
+}
+if (searchResults) {
+    while (searchResults.hasNext()) {
+           var a = searchResults.next();
+           var jsonObj = new Packages.org.apache.sling.commons.json.JSONObject();
+           jsonObj.put("value", a.getID());
+           var labelProp = a.getProperty("displayName");
+           if (labelProp != null && labelProp.length > 0) {
+             jsonObj.put("label", labelProp[0].getString());
+           }
+           
+           jsonArray.put(jsonObj);
+    }
+}
+response.getWriter().write(jsonArray.toString(2));
+%>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/body.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/body.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/body.html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/body.html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,74 @@
+<%
+/*
+ * 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.
+ */
+
+var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+
+var title = request.getAttribute("page.title");
+if (title == null) {
+    title = rb.getString("page.title.find.authorizables");
+}
+
+var spParam = request.getParameter("sp");
+if (spParam == null) {
+    spParam = "";
+}
+var qParam = request.getParameter("q");
+if (qParam == null) {
+    qParam = "";
+}
+var oParam = request.getParameter("o");
+if (oParam == null) {
+    oParam = "0";
+}
+%>
+<div class="ui-widget ui-widget-content ui-corner-all usermgmt-body" id="authorizables-body"
>
+    <form id="find-authorizables-form" accept-charset="UTF-8"
+            action="<%=request.contextPath%><%=resource.path%>.html" 
+            method="get">
+        <fieldset class="ui-helper-clearfix">
+            <input type="hidden" value="UTF-8" name="_charset_" />
+            <input type="hidden" id="searchOffset" name="o" value="<%=oParam%>"
/>
+
+            <div id='find-authorizables-header' class="ui-widget-header ui-corner-all
ui-helper-clearfix">
+                <h3 class="usermgmt-header"><%=title%></h3>
+                <span id="find-authorizables-block">
+                    <input id="findAuthorizablesQuery" type="text" name="q" value="<%=qParam%>"
/>
+                    <button accesskey="s" id="findAuthorizablesBtn" type="submit"><%=rb.getString("button.search")%></button>
+                </span>
+            </div>
+
+            <div id="find-authorizables-quick-nav" style="display:none">
+                <%
+                   var csv = rb.getString("csv.quicksearch.items");
+                   var items = [];
+                   if (csv != null && csv.length() > 0 && !csv.equals("csv.quicksearch.items"))
{
+                       items = csv.split(",");
+                   }
+                   for (var i = 0; i < items.length; i++) { 
+                      var c = items[i];
+                %>
+                <input type="radio" id="radio<%=c%>" name="sp" value="<%=c%>"
<%=c.equals(spParam) ? "checked='checked'" : "" %>/><label for="radio<%=c%>"><%=c%></label>
+                <% } /*endfor*/%>
+                <input type="radio" id="radioAll" name="sp" value="*" <%="*" == spParam
? "checked='checked'" : "" %>/><label id="radioAllLabel" for="radioAll"><%=rb.getString("quicksearch.label.all")%></label>
+                <input type="radio" id="radioNone" name="sp" value="" <%="" == spParam
? "checked='checked'" : "" %> style="display:none;"/>
+            </div>
+        </fieldset>
+    </form>
+    
+    <% sling.include(resource.path + ".searchresult.html"); %>    
+</div>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,34 @@
+<%
+/*
+ * 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.
+ */
+
+var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+
+//header options
+request.setAttribute("page.title", rb.getString("page.title.find.authorizables"));
+
+//page sidebar template
+request.setAttribute("sidebar.template", resource.path + ".sidebar.html");
+request.setAttribute("sidebar.template.options", "sling/usermgmt");
+
+//page body template
+request.setAttribute("body.template", resource.path + ".body.html");
+//request.setAttribute("body.template.options", "sling/userManager");
+
+//render the page using the default page template
+sling.include(resource.path + ".page.html", "sling/usermgmt");
+%>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/searchresult.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/searchresult.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/searchresult.html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/userManager/searchresult.html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,118 @@
+<%
+/*
+ * 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.
+ */
+
+var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+var searchType = request.getAttribute("search.type");
+if (searchType == null) {
+    searchType = 3; //all Authorizables should be searched
+}
+
+function format(key, args) {
+    var value = rb.getString(key);
+    return Packages.java.text.MessageFormat.format(value, args);
+}
+
+var qParam = request.getParameter("q");
+if (qParam != null && qParam.length() == 0) {
+    qParam = "*"; //empty search == 'All'
+}
+
+var isPrefixQuery = false;
+var spParam = request.getParameter("sp");
+if (spParam != null && spParam.length() > 0) {
+    isPrefixQuery = true;
+    if (!spParam.equals("*")) {
+        qParam = spParam + "*";
+    }
+}
+
+var maxResults = 25; //rows per page
+var offset = 0;
+var oParam = request.getParameter("o"); //paging start row
+if (oParam != null && oParam.length() > 0) {
+    offset = parseInt(oParam); 
+}
+
+var searchResults = null;
+if (qParam != null) {
+   var jcrSession = request.getResourceResolver().adaptTo(Packages.javax.jcr.Session);
+   var userManager = Packages.org.apache.sling.jcr.base.util.AccessControlUtil.getUserManager(jcrSession);
+   
+   var query = new Packages.org.apache.sling.usermgr.FindPeopleQuery(searchType, qParam,
isPrefixQuery, offset, maxResults);
+   searchResults = userManager.findAuthorizables(query);
+}
+var readyToSearch = qParam == null;
+var noMatches = searchResults != null && !searchResults.hasNext();
+%>
+<div id="authorizables-results-body" >
+<% if (readyToSearch) { %>
+    <div id="search-result-ready-to-search" class="search-empty-msg ui-corner-all ui-state-highlight"><%=rb.getString("msg.readyToSearch")%></div>
+<% } else if (noMatches) { %>
+    <div id="search-result-no-matches" class="search-empty-msg ui-corner-all ui-state-highlight"><%=rb.getString("msg.noMatchesFound")%></div>
+<% } else { %>
+    <table id="search-result" width="100%" class="ui-widget ui-widget-content ui-corner-all">
+        <thead id="search-result-head" class="ui-widget-header">
+            <tr>
+                <th align="left" width="50%"><%=rb.getString("label.column.name")%></th>
+                <th align="left" width="50%"><%=rb.getString("label.column.displayName")%></th>
+            </tr>
+        </thead>
+        <tbody id="search-result-body">
+        <%   var count = 0;
+             var resourceResolver = resource.getResourceResolver();
+             while (count < maxResults && searchResults.hasNext()) {
+                var a = searchResults.next();
+                count++;
+                
+                var principalResource = resourceResolver.getResource("/system/userManager/"
+ (a.isGroup() ? "group/" : "user/") + a.getID());
+                var valueMap = principalResource.adaptTo(Packages.org.apache.sling.api.resource.ValueMap);
+        %>
+            <tr <%= (count % 2 == 1) ? "" : "class='odd'" %>>
+                <td><a href="<%=request.contextPath%><%=principalResource.path%>.html"><%=a.getID()%></a></td>
+                <td><%=valueMap.get("displayName", "")%></td>
+            </tr>
+        <%   } /*endwhile*/ %>
+        </tbody>
+        <%-- paging --%>
+        <tfoot id="search-result-foot" class="ui-widget-header">
+            <tr>
+                <td id="search-result-paging" align="center" colspan="2">
+                    <form id="find-authorizables-paging-form" accept-charset="UTF-8"
+                            action="<%=request.contextPath%><%=resource.path%>.html"

+                            method="get">
+                        <input type="hidden" value="UTF-8" name="_charset_" />
+                        <input type="hidden" name="q" value="<%=qParam%>" />
+                        <% if (offset > maxResults) { %>
+                            <button id='first_page' title='<%=rb.getString("tooltip.paging.first.page")
%>' type="submit" name="o" value="0"><%=rb.getString("label.paging.first.page")%></button>
+                        <% }
+                           if (offset > 1) { %>
+                            <button id='prev_page' title='<%=rb.getString("tooltip.paging.prev.page")
%>' type="submit" name="o" value="<%=Math.max(0, offset - maxResults)%>"><%=rb.getString("label.paging.prev.page")%></button>
+                        <% }
+                           var currentPageMsg = format("paging.current.page", [offset + 1,
offset + count]);
+                        %>
+                        <span id='current_page'><%=currentPageMsg%></span>
+                        <% if (searchResults.hasNext()) { %>
+                            <button id='next_page' title='<%=rb.getString("tooltip.paging.next.page")
%>' type="submit" name="o" value="<%=offset + maxResults%>"><%=rb.getString("label.paging.next.page")%></button>
+                        <% } %>                
+                    </form>
+                </td>
+            </tr>
+        </tfoot>
+    </table>
+<% } /*endelse*/ %>
+</div>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/usermgmt/page.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/usermgmt/page.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/usermgmt/page.html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/usermgmt/page.html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,117 @@
+<%
+/*
+ * 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.
+ */
+%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xml:lang="en" lang="en"
+      xmlns="http://www.w3.org/1999/xhtml"
+>
+<head>
+    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+    <%
+      //allow the caller to override the title by
+      //  specifying request attributes.
+      var title = request.getAttribute("page.title");
+      if (title == null) {
+         title = resource.path;
+      }
+      
+      var userDisplayName = null;
+      if (request.getUserPrincipal() != null && !"anonymous".equals(request.getRemoteUser()))
{
+          var userResource = request.getResourceResolver().getResource("/system/userManager/user/"
+ request.getRemoteUser());
+          var valueMap = userResource.adaptTo(Packages.org.apache.sling.api.resource.ValueMap);
+          userDisplayName = valueMap.get("displayName", request.getRemoteUser());
+      }
+      
+      var currentPage = request.contextPath + resource.path + ".html";
+      var logoutTarget = request.getAttribute("logout.target");
+      if (logoutTarget == null) {
+          logoutTarget = currentPage;
+      }
+      var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+    %>
+    <title><%= Packages.java.text.MessageFormat.format(rb.getString("page.template.title"),
title) %></title>
+    
+    <link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/themes/cupertino/jquery-ui.css"
type="text/css"/>
+    <link rel="stylesheet" href="<%= request.getContextPath() %>/css/usermanager/usermanager.min.css"
type="text/css"/>
+</head>
+<%
+//flush the buffer early so the browser can start start fetching the stylesheets and scripts
in parallel
+// while the rest of the page is being rendered below.
+response.flushBuffer();
+%>
+<body>
+    <div id="menu_login" class="ui-widget ui-widget-content ui-corner-all">
+      <% if (userDisplayName != null) { %>        
+      <strong id="menu_username"><%=userDisplayName%></strong> | <a
href="<%=request.contextPath%>/system/sling/logout?resource=<%=logoutTarget%>"
id="do_logout"><%=rb.getString("link.logout")%></a>
+      <% } else { %>
+      <a href="<%=request.contextPath%>/system/sling/selector/login?resource=<%=currentPage%>"
id="do_login"><%=rb.getString("link.login")%></a>
+      <% } %>
+    </div>
+    
+    <div class="title">
+        <div class="logo">
+            <a href="http://sling.apache.org">
+                <img alt='<%=rb.getString("logo.alt")%>' src="<%=request.getContextPath()%>/images/sling-logo.png"/>
+            </a>
+        </div>
+    </div>
+    
+    <div class="menu">
+    <% 
+        var template = request.getAttribute("sidebar.template");
+        if (template != null) {
+           var options = request.getAttribute("sidebar.template.options");
+           if (options == null) {
+              sling.include(template);
+           } else {
+              sling.include(template, options);
+           }
+        } 
+    %>
+    </div>          
+
+    <div id="content" class="main">
+        <noscript>
+            <div class="ui-widget" style="margin-bottom: 10px;">
+                <div style="padding: 0pt 0.7em;" class="ui-state-error ui-corner-all">

+                    <p><span style="float: left; margin-right: 0.3em;" class="ui-icon
ui-icon-alert"></span> 
+                    <%=rb.getString("msg.noscript")%></p>
+                </div>
+            </div>
+        </noscript>
+    
+    <% 
+        var template = request.getAttribute("body.template");
+        if (template != null) {
+           var options = request.getAttribute("body.template.options");
+           if (options == null) {
+              sling.include(template);
+           } else {
+              sling.include(template, options);
+           }
+        } 
+    %>
+    </div>
+
+    <%-- scripts moved to the bottom to help the page load faster --%>    
+    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
+    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js"></script>
+    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8/jquery.validate.min.js"></script>
+    <script type="text/javascript" src="<%= request.getContextPath() %>/js/usermanager/usermanager.min.js"></script>
+    <script type="text/javascript">UserManager.contextPath = "<%=request.contextPath%>";</script>
+</body>
+</html>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/usermgmt/sidebar.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/usermgmt/sidebar.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/usermgmt/sidebar.html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/usermgmt/sidebar.html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,60 @@
+<%
+/*
+ * 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.
+ */
+
+var privilegesInfo = sling.getService(Packages.org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo);
+var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+%>
+<ul id="sidebar-nav" class="ui-corner-br">
+    <li>
+        <a href="<%=request.contextPath%>/system/userManager.html"><%=rb.getString("menu.link.authorizables")%></a>
+    </li>
+    <li>
+        <a style="margin-left: 15px;" href="<%=request.contextPath%>/system/userManager/user.html"><%=rb.getString("menu.link.users")%></a>
+    </li>
+    <li>
+        <a style="margin-left: 15px;" href="<%=request.contextPath%>/system/userManager/group.html"><%=rb.getString("menu.link.groups")%></a>
+    </li>
+    <li>&#160;</li>
+    <% if (privilegesInfo.canAddUser(currentSession)) { %>
+    <li>
+        <a href="<%=request.contextPath%>/system/userManager/user.create.html"><%=rb.getString("menu.link.createUser")%></a>
+    </li>
+    <% } %>
+    <% if (privilegesInfo.canAddGroup(currentSession)) { %>
+    <li>
+        <a href="<%=request.contextPath%>/system/userManager/group.create.html"><%=rb.getString("menu.link.createGroup")%></a>
+    </li>
+    <% } %>
+    <% 
+       var res = request.getResourceResolver().resolve(resource.path);
+       var authorizable = resource.adaptTo(Packages.org.apache.jackrabbit.api.security.user.Authorizable);
+       var canEdit = false;
+       if (authorizable) {
+           canEdit = privilegesInfo.canUpdateProperties(currentSession, authorizable.getID());
+       }
+       if (res.resourceType == "sling/user") { %>
+    <li>
+        <a href="<%=request.contextPath%><%=resource.path%>.html"><%=rb.getString(canEdit
? "menu.link.updateUser" : "menu.link.viewUser")%></a>
+    </li>
+    <% } %>
+    <% if (res.resourceType == "sling/group") { %>
+    <li>
+        <a href="<%=request.contextPath%><%=resource.path%>.html"><%=rb.getString(canEdit
? "menu.link.updateGroup" : "menu.link.viewGroup")%></a>
+    </li>
+    <% } %>
+</ul>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/body.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/body.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/body.html.esp (added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/body.html.esp Sun
May  1 22:46:46 2011
@@ -0,0 +1,29 @@
+<%
+/*
+ * 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.
+ */
+
+var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+
+var searchType = 1; //search only users
+request.setAttribute("search.type", searchType);
+
+var title = rb.getString("page.title.find.users");
+request.setAttribute("page.title", title);
+
+//delegate the 'authorizables' script to render the page
+sling.include(resource.path + ".body.html", "sling/userManager");
+%>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/create.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/create.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/create.html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/create.html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,40 @@
+<%
+/*
+ * 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.
+ */
+
+var privilegesInfo = sling.getService(Packages.org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo);
+if (!privilegesInfo.canAddUser(currentSession)) {
+    //user can't create users.
+    response.sendError(403);
+} else {
+    var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+
+    //header options
+    request.setAttribute("page.title", rb.getString("page.title.create.user"));
+
+    //page sidebar template
+    request.setAttribute("sidebar.template", resource.path + ".sidebar.html");
+    request.setAttribute("sidebar.template.options", "sling/usermgmt");
+
+    //page body template
+    request.setAttribute("body.template", resource.path + ".create_body.html");
+    request.setAttribute("body.template.options", null);
+
+    //render the page using the default page template
+    sling.include(resource.path + ".page.html", "sling/usermgmt");
+}
+%>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/create_body.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/create_body.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/create_body.html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/create_body.html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,77 @@
+<%
+/*
+ * 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.
+ */
+
+var privilegesInfo = sling.getService(Packages.org.apache.sling.jackrabbit.usermanager.AuthorizablePrivilegesInfo);
+if (!privilegesInfo.canAddUser(currentSession)) {
+    //user can't create users.
+    response.sendError(403);
+} else {
+    var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+%>
+<div class="ui-widget ui-widget-content ui-corner-all usermgmt-body" id="create-user-body"
>
+    <h3 class="ui-widget-header ui-corner-all usermgmt-header"><%=rb.getString("page.title.create.user")%></h3>
+    
+    <div class="info-msg-block" style="display:none;">
+        <div class="ui-state-highlight ui-corner-all"> 
+            <p>
+                <span class="ui-icon ui-icon-info"></span>
+                <span class="info-msg-text"></span>
+            </p>
+        </div>
+    </div>    
+    
+    <form id="create-user-form" accept-charset="UTF-8" 
+            action="<%=request.contextPath%>/system/userManager/user.create.html" 
+            method="post">
+        <fieldset>
+            <input type="hidden" value="UTF-8" name="_charset_" />
+            <input id="redirect" type="hidden" name=":redirect" value="<%=request.contextPath%>"
/>
+
+            <div class="prop-line ui-helper-clearfix">
+                <label for="userId" accesskey="u"><%=rb.getString("prop.label.userid")%>:</label>
+                <input id="userId" type="text" name=":name" />
+            </div>
+
+            <div class="prop-line ui-helper-clearfix">
+                <label for="displayName" accesskey="e"><%=rb.getString("prop.label.displayName")%>:</label>
+                <input id="displayName" type="text" name="displayName" />
+            </div>
+
+            <div class="prop-line ui-helper-clearfix">
+                <label for="email" accesskey="e"><%=rb.getString("prop.label.email")%>:</label>
+                <input id="email" type="text" name="email" />
+            </div>
+
+            <div class="prop-line ui-helper-clearfix">
+                <label for="pwd" accesskey="p"><%=rb.getString("prop.label.pwd")%>:</label>
               
+                <input id="pwd"  type="password" name="pwd" />
+            </div>
+
+            <div class="prop-line ui-helper-clearfix">
+                <label for="pwdConfirm" accesskey="c"><%=rb.getString("prop.label.pwdConfirm")%>:</label>
+                <input id="pwdConfirm" type="password" name="pwdConfirm" />
+            </div>
+
+            <div class="ui-helper-clearfix">
+                <label>&#160;</label>
+                <button accesskey="r" id="createUserBtn" type="submit"><%=rb.getString("button.create")%></button>
+            </div>
+        </fieldset>
+    </form>
+</div>
+<% } /*endif (canAddUser) */ %>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/html.esp (added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/html.esp Sun May
 1 22:46:46 2011
@@ -0,0 +1,34 @@
+<%
+/*
+ * 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.
+ */
+
+var rb = request.getResourceBundle("org.apache.sling.usermgr.Resources", null);
+
+//header options
+request.setAttribute("page.title", rb.getString("page.title.find.users"));
+
+//page sidebar template
+request.setAttribute("sidebar.template", resource.path + ".sidebar.html");
+request.setAttribute("sidebar.template.options", "sling/usermgmt");
+
+//page body template
+request.setAttribute("body.template", resource.path + ".body.html");
+//request.setAttribute("body.template.options", "sling/users");
+
+//render the page using the default page template
+sling.include(resource.path + ".page.html", "sling/usermgmt");
+%>
\ No newline at end of file

Added: sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/searchresult.html.esp
URL: http://svn.apache.org/viewvc/sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/searchresult.html.esp?rev=1098430&view=auto
==============================================================================
--- sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/searchresult.html.esp
(added)
+++ sling/trunk/samples/usermanager-ui/src/main/resources/libs/sling/users/searchresult.html.esp
Sun May  1 22:46:46 2011
@@ -0,0 +1,24 @@
+<%
+/*
+ * 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.
+ */
+
+var searchType = 1; //search only users
+request.setAttribute("search.type", searchType);
+
+//delegate the 'authorizables' script to render the page
+sling.include(resource.path + ".searchresult.html", "sling/userManager");
+%>
\ No newline at end of file



Mime
View raw message