| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> |
| |
| <% |
| /* |
| * 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 queryManager = currentNode.getSession().getWorkspace().getQueryManager(); |
| if(request.getParameter('qt')) { |
| var query = queryManager.createQuery("/jcr:root/content/espblog/posts/element(*, nt:unstructured)[jcr:contains(., '"+request.getParameter("qt")+"')] order by @created descending", "xpath"); |
| } else { |
| var query = queryManager.createQuery("/jcr:root/content/espblog/posts/element(*, nt:unstructured) order by @created descending", "xpath"); |
| } |
| var result = query.execute().getNodes(); |
| %> |
| |
| <html> |
| |
| <% |
| load("header.esp"); |
| %> |
| |
| <body> |
| <div class="title"> |
| <div class="logo"> |
| <a href="http://sling.apache.org"> |
| <img border="0" src="/apps/espblog/sling-logo.png"/> |
| </a> |
| </div> |
| </div> |
| |
| <div class="menu"> |
| <% |
| load("menu.esp"); |
| %> |
| </div> |
| |
| <div class="main"> |
| <h1><%= pageTitle %></h1> |
| <h2><%= request.getParameter('qt') ? "Search results" : "Recent posts" %></h2> |
| |
| <div id="postbody"> |
| <% |
| df = new Packages.java.text.SimpleDateFormat( "yyyy-MM-dd HH:mm" ); |
| |
| while(result.hasNext()) { |
| post = result.nextNode() |
| %> |
| |
| <h3><a href="<%= post.getPath() %>.html"><%=post.title%></a></h3> |
| <strong>Posted at <%=df.format(post.created.getTime())%></strong><br> |
| <p><%=post.posttext%><br/><strong class="highlight"><a href="<%=post%>.html"><%=post.hasNode("comments") ? "See comments" : "Be the first to comment"%> </a></strong> </p> |
| <%}%> |
| </div> |
| </div> |
| </body> |
| </html> |