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 2008/03/30 22:22:11 UTC

svn commit: r642811 - in /lenya/sandbox/modules/feed: sitemap.xmap xslt/atom2xhtml.xsl xslt/includeFeed.xsl

Author: andreas
Date: Sun Mar 30 13:22:09 2008
New Revision: 642811

URL: http://svn.apache.org/viewvc?rev=642811&view=rev
Log:
Adding fallback for unavailable feeds.

Added:
    lenya/sandbox/modules/feed/xslt/includeFeed.xsl
Modified:
    lenya/sandbox/modules/feed/sitemap.xmap
    lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl

Modified: lenya/sandbox/modules/feed/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/feed/sitemap.xmap?rev=642811&r1=642810&r2=642811&view=diff
==============================================================================
--- lenya/sandbox/modules/feed/sitemap.xmap (original)
+++ lenya/sandbox/modules/feed/sitemap.xmap Sun Mar 30 13:22:09 2008
@@ -30,9 +30,13 @@
 
     <map:pipeline>
       
-      <!-- {1:sourceFormat}/{3:feedUrl} -->
+      <!-- {1:sourceFormat}/{2:feedUrl} -->
       <map:match pattern="*/**">
-        <map:generate src="{2}"/>
+        <map:generate src="fallback://lenya/modules/collection/samples/collection.xml"/>
+        <map:transform src="xslt/includeFeed.xsl">
+          <map:parameter name="uri" value="{2}"/>
+        </map:transform>
+        <map:transform type="include"/>
         <map:transform src="xslt/{1}2{request-param:format}.xsl"/>
         <map:transform type="unescape"/>
         <map:transform src="xslt/addXhtmlNamespace.xsl"/>

Modified: lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl?rev=642811&r1=642810&r2=642811&view=diff
==============================================================================
--- lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl (original)
+++ lenya/sandbox/modules/feed/xslt/atom2xhtml.xsl Sun Mar 30 13:22:09 2008
@@ -31,10 +31,21 @@
   <xsl:param name="defaultLanguage" select="'en'"/>
   
   
+  <xsl:template match="col:collection">
+    <xsl:copy>
+      <xsl:copy-of select="@*"/>
+      <xsl:apply-templates/>
+    </xsl:copy>
+  </xsl:template>
+  
+  
+  <xsl:template match="col:document">
+    <xsl:copy-of select="."/>
+  </xsl:template>
+  
+  
   <xsl:template match="atom:feed">
-    <col:collection>
-      <xsl:apply-templates select="atom:entry"/>
-    </col:collection>
+    <xsl:apply-templates select="atom:entry"/>
   </xsl:template>
   
   
@@ -67,5 +78,5 @@
     </col:document>
   </xsl:template>
   
-
+  
 </xsl:stylesheet>

Added: lenya/sandbox/modules/feed/xslt/includeFeed.xsl
URL: http://svn.apache.org/viewvc/lenya/sandbox/modules/feed/xslt/includeFeed.xsl?rev=642811&view=auto
==============================================================================
--- lenya/sandbox/modules/feed/xslt/includeFeed.xsl (added)
+++ lenya/sandbox/modules/feed/xslt/includeFeed.xsl Sun Mar 30 13:22:09 2008
@@ -0,0 +1,41 @@
+<?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.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+  xmlns:i="http://apache.org/cocoon/include/1.0"
+  xmlns:col="http://apache.org/cocoon/lenya/collection/1.0"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"
+  >
+  
+  <xsl:param name="uri"/>
+  
+  <xsl:template match="col:collection">
+    <xsl:copy>
+      <i:include src="{$uri}">
+        <i:fallback>
+          <col:document>
+            <dc:title>The feed at "<xsl:value-of select="$uri"/>" is unavailable.</dc:title>
+            <dc:date><i18n:date-time pattern="yyyy-MM-dd HH:mm:ss"/></dc:date>
+          </col:document>
+        </i:fallback>
+      </i:include>
+    </xsl:copy>
+  </xsl:template>
+  
+  
+</xsl:stylesheet>
\ No newline at end of file



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