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/07/12 22:43:47 UTC

svn commit: r555751 - in /lenya/trunk/src/modules/resource: config/cocoon-xconf/module.xconf sitemap.xmap xslt/common/mimetype.xsl xslt/downloadLink.xsl xslt/resource2xhtml.xsl

Author: andreas
Date: Thu Jul 12 13:43:47 2007
New Revision: 555751

URL: http://svn.apache.org/viewvc?view=rev&rev=555751
Log:
Replace context-path by proxy-based URLs, introduced downloadLink format for 'resource' resource type

Added:
    lenya/trunk/src/modules/resource/xslt/downloadLink.xsl
Modified:
    lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf
    lenya/trunk/src/modules/resource/sitemap.xmap
    lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl
    lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl

Modified: lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf?view=diff&rev=555751&r1=555750&r2=555751
==============================================================================
--- lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf (original)
+++ lenya/trunk/src/modules/resource/config/cocoon-xconf/module.xconf Thu Jul 12 13:43:47 2007
@@ -26,6 +26,7 @@
     <schema src="fallback://lenya/modules/resource/resources/schemas/resource.rng" language="http://relaxng.org/ns/structure/0.9"/>
     <sample-name>fallback://lenya/modules/resource/samples/resource.xml</sample-name>
     <format name="xhtml" uri="cocoon://modules/resource/xhtml.xml"/>
+    <format name="downloadLink" uri="cocoon://modules/resource/downloadLink.xml"/>
     <format name="icon" uri="cocoon://modules/resource/icon"/>
   </component-instance>
 

Modified: lenya/trunk/src/modules/resource/sitemap.xmap
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/sitemap.xmap?view=diff&rev=555751&r1=555750&r2=555751
==============================================================================
--- lenya/trunk/src/modules/resource/sitemap.xmap (original)
+++ lenya/trunk/src/modules/resource/sitemap.xmap Thu Jul 12 13:43:47 2007
@@ -33,12 +33,12 @@
   <map:pipelines>
     <!-- Generates the lenya metadata to be aggregated for each page -->
     <map:pipeline>
-      <map:match pattern="lenyametadata.xml">
+      <map:match pattern="lenyametadata.xml/*/*/*/*">
         <map:generate type="lenyaMetaData">
-          <map:parameter name="area" value="{page-envelope:area}"/>
-          <map:parameter name="pubid" value="{page-envelope:publication-id}"/>
-          <map:parameter name="uuid" value="{page-envelope:document-uuid}"/>
-          <map:parameter name="lang" value="{page-envelope:document-language}"/>
+          <map:parameter name="pubid" value="{1}"/>
+          <map:parameter name="area" value="{2}"/>
+          <map:parameter name="uuid" value="{3}"/>
+          <map:parameter name="lang" value="{4}"/>
         </map:generate>
         <map:serialize type="xml"/>
       </map:match>
@@ -56,9 +56,8 @@
             <map:parameter name="document-type" value="{page-envelope:document-type}"/>
             <map:parameter name="nodeid" value="{page-envelope:document-name}"/>
             <map:parameter name="language" value="{page-envelope:document-language}"/>
-            <map:parameter name="context-prefix" value="{page-envelope:context-prefix}"/>
             <map:parameter name="title" value="{dublincore:title}"/>
-            <map:parameter name="root" value="/{page-envelope:publication-id}/{page-envelope:area}"/>
+            <map:parameter name="root" value="{proxy:/{page-envelope:publication-id}/{page-envelope:area}}"/>
             <map:parameter name="mimeType" value="{doc-info:mimeType}"/>
             <map:parameter name="contentLength" value="{doc-info:contentLength}"/>
             <map:parameter name="pubid" value="{page-envelope:publication-id}"/>
@@ -69,25 +68,43 @@
         </map:match>
       </map:match>
       
-      <!-- parametrized doctype matcher -->
-      <!-- pattern="{rendertype}" -->
+      <!-- pattern="{format}.xml" -->
       <map:match pattern="*.xml">
-        <map:generate src="cocoon:/lenyametadata.xml"/>
-        <map:transform
-          src="fallback://lenya/modules/resource/xslt/resource2xhtml.xsl">
+        <map:generate src="cocoon:/{1}.xml/{page-envelope:publication-id}/{page-envelope:area}/{page-envelope:document-uuid}/{page-envelope:document-language}"/>
+        <map:serialize type="xml"/>
+      </map:match>
+      
+      <!-- {format}.xml/{pubId}/{area}/{uuid}/{language} -->
+      <map:match pattern="downloadLink.xml/*/*/*/*">
+        <map:generate src="cocoon:/lenyametadata.xml/{1}/{2}/{3}/{4}"/>
+        <map:transform src="fallback://lenya/modules/resource/xslt/downloadLink.xsl">
+          <map:parameter name="contentLength" value="{doc-info:{1}:{2}:{3}:{4}:contentLength}"/>
+          <map:parameter name="mimeType" value="{doc-info:{1}:{2}:{3}:{4}:mimeType}"/>
+          <map:parameter name="uuid" value="{3}"/>
+          <map:parameter name="language" value="{4}"/>
+          <map:parameter name="imageprefix" value="{proxy:/{1}/modules/resource}"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+      
+      <!-- {format}.xml/{pubId}/{area}/{uuid}/{language} -->
+      <!-- FIXME: page envelope calls have to be removed -->
+      <map:match pattern="xhtml.xml/*/*/*/*">
+        <map:generate src="cocoon:/lenyametadata.xml/{1}/{2}/{3}/{4}"/>
+        <map:transform src="fallback://lenya/modules/resource/xslt/resource2xhtml.xsl">
           <map:parameter name="document-type" value="{page-envelope:document-type}"/>
           <map:parameter name="nodeId" value="{page-envelope:document-name}"/>
-          <map:parameter name="path" value="{doc-info:{page-envelope:publication-id}:{page-envelope:area}:{page-envelope:document-id}:{page-envelope:document-language}:path}"/>
+          <map:parameter name="path" value="{doc-info:{1}:{2}:{3}:{4}:path}"/>
           <map:parameter name="documentParent" value="{page-envelope:document-parent}"/>
-          <map:parameter name="language" value="{page-envelope:document-language}"/>
-          <map:parameter name="context-prefix" value="{page-envelope:context-prefix}"/>
+          <map:parameter name="language" value="{4}"/>
           <map:parameter name="title" value="{dublincore:title}"/>
-          <map:parameter name="root" value="/{page-envelope:publication-id}/{page-envelope:area}"/>
-          <map:parameter name="mimeType" value="{doc-info:{page-envelope:publication-id}:{page-envelope:area}:{page-envelope:document-id}:{page-envelope:document-language}:mimeType}"/>
-          <map:parameter name="contentLength" value="{doc-info:{page-envelope:publication-id}:{page-envelope:area}:{page-envelope:document-id}:{page-envelope:document-language}:contentLength}"/>
-          <map:parameter name="documentUrl" value="{doc-info:{page-envelope:publication-id}:{page-envelope:area}:{page-envelope:document-id}:{page-envelope:document-language}:documentUrl}"/>
-          <map:parameter name="sourceExtension" value="{doc-info:{page-envelope:publication-id}:{page-envelope:area}:{page-envelope:document-id}:{page-envelope:document-language}:sourceExtension}"/>
-          <map:parameter name="pubid" value="{page-envelope:publication-id}"/>
+          <map:parameter name="root" value="{proxy:/{1}/{2}}"/>
+          <map:parameter name="mimeType" value="{doc-info:{1}:{2}:{3}:{4}:mimeType}"/>
+          <map:parameter name="contentLength" value="{doc-info:{1}:{2}:{3}:{4}:contentLength}"/>
+          <map:parameter name="documentUrl" value="{doc-info:{1}:{2}:{3}:{4}:documentUrl}"/>
+          <map:parameter name="sourceExtension" value="{doc-info:{1}:{2}:{3}:{4}:sourceExtension}"/>
+          <map:parameter name="pubid" value="{1}"/>
+          <map:parameter name="imageprefix" value="{proxy:/{1}/modules/resource}"/>
         </map:transform>
         <map:transform type="i18n"/>
         <map:serialize type="xml"/>

Modified: lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl?view=diff&rev=555751&r1=555750&r2=555751
==============================================================================
--- lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl (original)
+++ lenya/trunk/src/modules/resource/xslt/common/mimetype.xsl Thu Jul 12 13:43:47 2007
@@ -1,4 +1,20 @@
 <?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: mimetype.xsl 9187 2005-12-22 15:53:21Z josias $ -->
 

Added: lenya/trunk/src/modules/resource/xslt/downloadLink.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/xslt/downloadLink.xsl?view=auto&rev=555751
==============================================================================
--- lenya/trunk/src/modules/resource/xslt/downloadLink.xsl (added)
+++ lenya/trunk/src/modules/resource/xslt/downloadLink.xsl Thu Jul 12 13:43:47 2007
@@ -0,0 +1,83 @@
+<?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: xhtml-standard.xsl,v 1.44 2004/12/14 11:00:41 josias Exp $ -->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+  xmlns="http://www.w3.org/1999/xhtml"
+  xmlns:meta="http://apache.org/cocoon/lenya/metadata/1.0"
+  xmlns:xhtml="http://www.w3.org/1999/xhtml"
+  xmlns:dc="http://purl.org/dc/elements/1.1/"
+  xmlns:media="http://apache.org/lenya/pubs/default/media/1.0"
+  xmlns:mediameta="http://apache.org/lenya/metadata/media/1.0"
+  xmlns:docmeta="http://apache.org/lenya/metadata/document/1.0"
+  xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
+  xmlns:dcterms="http://purl.org/dc/terms/"
+  exclude-result-prefixes="xhtml meta dc">
+  
+  <xsl:import href="fallback://lenya/modules/resource/xslt/common/mimetype.xsl"/>
+  
+  
+  <xsl:param name="documentUrl"/>
+  <xsl:param name="sourceExtension"/>
+  <xsl:param name="contentLength"/>
+  <xsl:param name="uuid"/>
+  <xsl:param name="language"/>
+  <xsl:param name="imageprefix"/>
+  <xsl:param name="mimeType"/>
+  
+  <xsl:variable name="mediaUrl" select="concat(substring-before($documentUrl, '.html'), '.', $sourceExtension)"/>
+  
+  <xsl:template match="/">
+    <xsl:apply-templates select="//meta:metadata" mode="media"/>
+  </xsl:template>
+    
+  <xsl:template match="meta:metadata" mode="media">
+  
+    <xsl:variable name="title">
+      <xsl:choose>
+        <xsl:when test="normalize-space(dc:elements/dc:title) != ''">
+          <xsl:value-of select="dc:elements/dc:title"/>
+        </xsl:when>
+        <xsl:otherwise>
+          <i18n:text>No title</i18n:text>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:variable>
+    
+    <xsl:variable name="size">
+      <xsl:value-of select="format-number($contentLength div 1024, '#,###.##')"/>
+    </xsl:variable>
+    
+    <p class="asset">
+      <a href="lenya-document:{$uuid},lang={$language}" title="{text()}">
+        <xsl:call-template name="icon">
+          <xsl:with-param name="mimetype" select="$mimeType"/>
+          <xsl:with-param name="imageprefix" select="$imageprefix"/>
+        </xsl:call-template>
+      </a>
+      &#160;
+      <a href="lenya-document:{$uuid},lang={$language}" title="{text()}">
+        <xsl:value-of select="dc:elements/dc:title"/>
+      </a>
+      (<xsl:value-of select="number($size)"/> KB)
+    </p>
+
+  </xsl:template>
+  
+</xsl:stylesheet>

Modified: lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl
URL: http://svn.apache.org/viewvc/lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl?view=diff&rev=555751&r1=555750&r2=555751
==============================================================================
--- lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl (original)
+++ lenya/trunk/src/modules/resource/xslt/resource2xhtml.xsl Thu Jul 12 13:43:47 2007
@@ -1,4 +1,20 @@
 <?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: xhtml-standard.xsl,v 1.44 2004/12/14 11:00:41 josias Exp $ -->
 
@@ -19,7 +35,6 @@
   <xsl:param name="root"/> <!-- the URL up to (including) the area -->
   <xsl:param name="path"/>
   <xsl:param name="pubid"/>
-  <xsl:param name="context-prefix" select="''"/>
   <xsl:param name="language"/>
   <xsl:param name="document-type"/>
   <xsl:param name="documentParent"/>
@@ -28,13 +43,10 @@
   <xsl:param name="mimeType"/>
   <xsl:param name="documentUrl"/>
   <xsl:param name="sourceExtension"/>
+  <xsl:param name="imageprefix"/>
   
   <xsl:variable name="mediaUrl" select="concat(substring-before($documentUrl, '.html'), '.', $sourceExtension)"/>
-  
-  <xsl:variable name="imageprefix"
-    select="concat($context-prefix,'/',$pubid,'/modules/resource')"/>
-  <xsl:variable name="nodeid"
-    select="concat($context-prefix,$root,$documentParent)"/>
+  <xsl:variable name="nodeid" select="concat($root, $documentParent)"/>
   
   <xsl:template match="/">
     <xhtml:div id="body">



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