You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by an...@apache.org on 2007/03/30 18:33:49 UTC

svn commit: r524163 - in /lenya/trunk/src: java/org/apache/lenya/util/ modules/news/ modules/news/config/cocoon-xconf/ modules/news/xslt/ pubs/default/ pubs/default/resources/shared/css/

Author: andreas
Date: Fri Mar 30 09:33:48 2007
New Revision: 524163

URL: http://svn.apache.org/viewvc?view=rev&rev=524163
Log:
Added support for news RSS

Added:
    lenya/trunk/src/modules/news/xslt/collection2rss.xsl
Modified:
    lenya/trunk/src/java/org/apache/lenya/util/Query.java
    lenya/trunk/src/modules/news/config/cocoon-xconf/resourcetype-news.xconf
    lenya/trunk/src/modules/news/sitemap.xmap
    lenya/trunk/src/modules/news/xslt/collection2include.xsl
    lenya/trunk/src/pubs/default/resources/shared/css/news.css
    lenya/trunk/src/pubs/default/sitemap.xmap

Modified: lenya/trunk/src/java/org/apache/lenya/util/Query.java
URL: http://svn.apache.org/viewvc/lenya/trunk/src/java/org/apache/lenya/util/Query.java?view=diff&rev=524163&r1=524162&r2=524163
==============================================================================
--- lenya/trunk/src/java/org/apache/lenya/util/Query.java (original)
+++ lenya/trunk/src/java/org/apache/lenya/util/Query.java Fri Mar 30 09:33:48 2007
@@ -18,12 +18,14 @@
 package org.apache.lenya.util;
 
 import java.util.HashMap;
+import java.util.Iterator;
 import java.util.Map;
 
 /**
  * <p>
  * Utility class to analyze a query string of the form
  * <code>key1=value1&key2=value2&...</code>.
+ * Access is not thread-safe.
  * </p>
  * <p>
  * Invalid parts (not a valid key-value-pair) are omitted.
@@ -96,6 +98,25 @@
 
     public String getPairDelimiter() {
         return pairDelimiter;
+    }
+    
+    public void removeValue(String key) {
+        this.key2value.remove(key);
+    }
+    
+    public String toString() {
+        StringBuffer buf = new StringBuffer();
+        for (Iterator i = this.key2value.keySet().iterator(); i.hasNext(); ) {
+            String key = (String) i.next();
+            String value = (String) this.key2value.get(key);
+            buf.append(key);
+            buf.append(this.keyValueDelimiter);
+            buf.append(value);
+            if (i.hasNext()) {
+                buf.append(this.pairDelimiter);
+            }
+        }
+        return buf.toString();
     }
 
 }

Modified: lenya/trunk/src/modules/news/config/cocoon-xconf/resourcetype-news.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/config/cocoon-xconf/resourcetype-news.xconf?view=diff&rev=524163&r1=524162&r2=524163
==============================================================================
--- lenya/trunk/src/modules/news/config/cocoon-xconf/resourcetype-news.xconf (original)
+++ lenya/trunk/src/modules/news/config/cocoon-xconf/resourcetype-news.xconf Fri Mar 30 09:33:48 2007
@@ -30,6 +30,7 @@
     <sample-name>fallback://lenya/modules/collection/samples/children.xml</sample-name>
     <format name="xhtml" uri="cocoon://modules/news/xhtml.xml"/>
     <format name="include" uri="cocoon://modules/news/include.xml"/>
+    <format name="rss" uri="cocoon://modules/news/rss.xml"/>
     
   </component-instance>
 

Modified: lenya/trunk/src/modules/news/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/sitemap.xmap?view=diff&rev=524163&r1=524162&r2=524163
==============================================================================
--- lenya/trunk/src/modules/news/sitemap.xmap (original)
+++ lenya/trunk/src/modules/news/sitemap.xmap Fri Mar 30 09:33:48 2007
@@ -56,7 +56,13 @@
           <map:parameter name="language" value="{5}"/>
           <map:parameter name="title" value=""/>
           <map:parameter name="area" value="{3}"/>
+          <map:parameter name="uuid" value="{4}"/>
+          <map:parameter name="baseUrl" value="{base-url:{2}:{3}:false}"/>
         </map:transform>
+        <map:match pattern="rss.xml/**">
+          <map:transform type="uuid2url"/>
+          <map:transform src="xslt/rss/xhtmllink2rsslink.xsl"/>
+        </map:match>
         <map:serialize type="xml"/>
       </map:match>
 

Modified: lenya/trunk/src/modules/news/xslt/collection2include.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/xslt/collection2include.xsl?view=diff&rev=524163&r1=524162&r2=524163
==============================================================================
--- lenya/trunk/src/modules/news/xslt/collection2include.xsl (original)
+++ lenya/trunk/src/modules/news/xslt/collection2include.xsl Fri Mar 30 09:33:48 2007
@@ -35,11 +35,15 @@
   <xsl:param name="rendertype" select="''"/>
   <xsl:param name="nodeid"/>
   <xsl:param name="language"/>
+  <xsl:param name="uuid"/>
   
   
   <xsl:template match="/col:collection">
     <xsl:variable name="title" select="meta:metadata/dc:elements/dc:title"/>
     <div id="news">
+      <div class="rsslink">
+        <a href="lenya-document:{$uuid}?uuid2url.extension=rss">RSS 2.0</a>
+      </div>
       <h1><xsl:value-of select="$title"/></h1>
       <xsl:apply-templates select="col:document">
         <xsl:sort order="descending" select="meta:metadata/dc:elements/dc:date"/>

Added: lenya/trunk/src/modules/news/xslt/collection2rss.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/news/xslt/collection2rss.xsl?view=auto&rev=524163
==============================================================================
--- lenya/trunk/src/modules/news/xslt/collection2rss.xsl (added)
+++ lenya/trunk/src/modules/news/xslt/collection2rss.xsl Fri Mar 30 09:33:48 2007
@@ -0,0 +1,101 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  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.
+-->
+
+<!-- $Id: xhtml2xhtml.xsl 201776 2005-06-25 18:25:26Z gregor $ -->
+
+<xsl:stylesheet version="1.0"
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+    xmlns:xhtml="http://www.w3.org/1999/xhtml"
+    xmlns:lenya="http://apache.org/cocoon/lenya/page-envelope/1.0" 
+    xmlns:dc="http://purl.org/dc/elements/1.1/"
+    xmlns:col="http://apache.org/cocoon/lenya/collection/1.0"
+    xmlns:meta="http://apache.org/cocoon/lenya/metadata/1.0"
+    xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+    exclude-result-prefixes="xhtml lenya col meta dc i18n"
+    >
+    
+  <xsl:include href="fallback://lenya/modules/xhtml/xslt/helper-object.xsl"/>
+  
+  <xsl:param name="rendertype" select="''"/>
+  <xsl:param name="nodeid"/>
+  <xsl:param name="language"/>
+  <xsl:param name="area"/>
+  <xsl:param name="baseUrl"/>
+  
+  
+  <xsl:template match="/col:collection">
+    <xsl:variable name="title" select="meta:metadata/dc:elements/dc:title"/>
+    
+    <rss version="2.0">
+      
+      <channel>
+        <title><xsl:value-of select="$title"/></title>
+        <link><xsl:value-of select="$baseUrl"/></link>
+        <description></description>
+        <language><xsl:value-of select="$language"/></language>
+        <copyright></copyright>
+        <pubDate><xsl:call-template name="date"/></pubDate>
+        
+        <!--
+        <image>
+          <url></url>
+          <title></title>
+          <link></link>
+        </image>
+        -->
+        
+        <xsl:apply-templates select="col:document">
+          <xsl:sort order="descending" select="meta:metadata/dc:elements/dc:date"/>
+        </xsl:apply-templates>
+        
+      </channel>
+      
+    </rss>
+  </xsl:template>
+  
+  
+  <xsl:template name="date">
+    <xsl:for-each select="col:document">
+      <xsl:sort select="meta:metadata/dc:elements/dc:date"/>
+      <xsl:if test="position() = 1">
+        <xsl:variable name="date" select="meta:metadata/dc:elements/dc:date"/>
+        <i18n:date-time src-pattern="yyyy-MM-dd hh:mm:ss" pattern="EEE, d MMM yyyy HH:mm:ss Z" value="{$date}" />
+        <xsl:value-of select="meta:metadata/dc:elements/dc:date"/>
+      </xsl:if>
+    </xsl:for-each>
+  </xsl:template>
+
+
+  <xsl:template match="col:document">
+    <item>
+      <title><xsl:value-of select="meta:metadata/dc:elements/dc:title"/></title>
+      <description><xsl:value-of select="meta:metadata/dc:elements/dc:description"/></description>
+      <link><xhtml:a href="lenya-document:{@uuid}"/></link>
+      <author><xsl:value-of select="meta:metadata/dc:elements/dc:creator"/></author>
+    </item>
+  </xsl:template>
+
+
+  <xsl:template match="@*|node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+  
+
+</xsl:stylesheet> 

Modified: lenya/trunk/src/pubs/default/resources/shared/css/news.css
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/resources/shared/css/news.css?view=diff&rev=524163&r1=524162&r2=524163
==============================================================================
--- lenya/trunk/src/pubs/default/resources/shared/css/news.css (original)
+++ lenya/trunk/src/pubs/default/resources/shared/css/news.css Fri Mar 30 09:33:48 2007
@@ -28,6 +28,7 @@
   width: 30%;
   border: solid 1px #BB9999;
   margin: 0px 10px 10px 10px;
+  padding: 10px;
   background-color: #FFEEEE;
 }
 
@@ -43,4 +44,20 @@
 }
 
 div#news h2 div {
+}
+
+div.rsslink {
+  float: right;
+  font-size: x-small;
+  border-top: solid 1px #FFFFFF;
+  border-left: solid 1px #FFFFFF;
+  border-bottom: solid 1px #666666;
+  border-right: solid 1px #666666;
+  background-color: #FFEEEE;
+  color: #000000;
+  padding: 1px 3px 1px 3px;
+}
+
+div.rsslink a {
+  text-decoration: none;
 }

Modified: lenya/trunk/src/pubs/default/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/pubs/default/sitemap.xmap?view=diff&rev=524163&r1=524162&r2=524163
==============================================================================
--- lenya/trunk/src/pubs/default/sitemap.xmap (original)
+++ lenya/trunk/src/pubs/default/sitemap.xmap Fri Mar 30 09:33:48 2007
@@ -104,6 +104,12 @@
     </map:pipeline>
     
     <map:pipeline type="caching">
+      
+      <map:match pattern="**.rss">
+        <map:generate src="{resource-type:format-rss}"/>
+        <map:serialize type="xml"/>
+      </map:match>
+      
       <!-- pattern="meta?docid={docid}&lang={lang}" -->
       <map:match pattern="*/**.html.meta">
         <map:generate type="lenyaMetaData">



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@lenya.apache.org
For additional commands, e-mail: commits-help@lenya.apache.org