[ 
https://issues.apache.org/jira/browse/SLING-985?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Lars Trieloff updated SLING-985:
--------------------------------

    Attachment: SLING-985.patch

This patch provides an atom taglib that covers the atom core vocabulary plus 
the opensearch and mediarss extensions. Bound to a 
namespace prefix like atom you can create a feed using:

<%@ page session="false" %><%
%><%@ page import="
        javax.jcr.*,
        java.util.Iterator"
%><%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"; %><%
%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"; %><%
%><%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"; %><%
%><%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"; %><%
%><%@ taglib prefix="atom" uri="http://sling.apache.org/taglibs/atom/1.0"; %>

<sling:defineObjects />
<atom:feed id="${currentNode.path}">
  <%
    NodeIterator i = currentNode.getNodes();
    while (i.hasNext()) {
      Node n = i.nextNode();
      pageContext.setAttribute("n", n);
      %>
        <sling:include path="${n.path}.entry" />
      <%
    }
  %>
</atom:feed>

This example can be used as the default jsp for the .feed extension. With 
following default JSP for the .entry extension, it becomes possible to generate 
a feed out of any JCR node. The feed would simply list the child entries.

A possible entry.jsp would look like this:

<%@ page session="false" %><%
%><%...@include file="/libs/wcm/global.jsp"%><%
%><%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"; %><%
%><%@ taglib prefix="atom" uri="http://sling.apache.org/taglibs/atom/1.0"; %>
<atom:entry id="${currentNode.path}">
  <atom:link href="${currentNode.path}"/>
  <atom:title>
  <%
  if (currentNode.hasProperty("jcr:title")) {
    %><%=currentNode.getProperty("jcr:title").getString() %><%
  } else if (currentNode.hasProperty("cq:title")) {
    %><%=currentNode.getProperty("cq:title").getString() %><%
  } else if (currentNode.hasProperty("title")) {
    %><%=currentNode.getProperty("title").getString() %><%
  } else {
    %><%=currentNode.getPath() %><%
  }
  %>
  </atom:title>
  <%
  if (currentNode.hasProperty("jcr:description")) {
    %><atom:summary><%=currentNode.getProperty("jcr:description").getString() 
%></atom:summary><%
  }
  %>
</atom:entry>


> Allow ATOM Syndication Format output
> ------------------------------------
>
>                 Key: SLING-985
>                 URL: https://issues.apache.org/jira/browse/SLING-985
>             Project: Sling
>          Issue Type: New Feature
>            Reporter: Lars Trieloff
>            Priority: Minor
>         Attachments: SLING-985.patch
>
>
> Having a JSON output for Sling is quite nice, but many web applications 
> require RSS/Atom support these days. Having an extension module that provides 
> a tag library for creating Atom feeds and atom entries out of JCR nodes would 
> be very helpful.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to