You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gi...@apache.org on 2003/07/27 15:07:15 UTC
cvs commit: cocoon-2.1/src/blocks/webdav/samples/davmap/styles dir2propfind0.xsl dir2propfind1.xsl file2propfind0.xsl stream2write.xsl
gianugo 2003/07/27 06:07:15
Modified: src/blocks/webdav/samples samples.xml
Added: src/blocks/webdav/samples/davmap dummy.xml sitemap.xmap
src/blocks/webdav/samples/davmap/repo contentA.xml
src/blocks/webdav/samples/davmap/repo/dir1 contentB.xml
contentC.xml
src/blocks/webdav/samples/davmap/repo/dir2 contentA.xml
contentB.xml contentC.xml contentD.xml
src/blocks/webdav/samples/davmap/repo/dir2/subdir1
contentA.xml
src/blocks/webdav/samples/davmap/styles dir2propfind0.xsl
dir2propfind1.xsl file2propfind0.xsl
stream2write.xsl
Log:
Committed the new and great WebDAV server example from Guido Casper
(g.casper@s-und-n.de).
Revision Changes Path
1.2 +6 -3 cocoon-2.1/src/blocks/webdav/samples/samples.xml
Index: samples.xml
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/webdav/samples/samples.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- samples.xml 22 Jul 2003 12:17:18 -0000 1.1
+++ samples.xml 27 Jul 2003 13:07:14 -0000 1.2
@@ -56,9 +56,12 @@
</group>
<group name="Serving WebDAV">
- <sample name="WebDAV sitemap" href="./">
- Not yet available - This sample will show how to serve WebDAV clients from Cocoon
- (i.e. using Cocoon as a WebDAV server)
+ <sample name="WebDAV sitemap" href="davmap/repo/">
+ This sample shows how to serve WebDAV clients from Cocoon
+ (i.e. using Cocoon as a WebDAV server) - still some work
+ in progress, but quite usable already: point your favourite
+ WebDAV client to [Cocoon URL]/samples/webdav/davmap/repo/ and
+ have fun browsing around!
</sample>
</group>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/dummy.xml
Index: dummy.xml
===================================================================
<?xml version="1.0"?>
<page/>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/sitemap.xmap
Index: sitemap.xmap
===================================================================
<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
<map:components>
<map:generators default="file">
<map:generator name="traverse" src="org.apache.cocoon.generation.TraversableGenerator"/>
</map:generators>
<map:selectors default="browser">
<map:selector logger="sitemap.selector.method" name="request-method" src="org.apache.cocoon.selection.RequestMethodSelector"/>
<map:selector logger="sitemap.selector.header" name="depth" src="org.apache.cocoon.selection.HeaderSelector">
<header-name>Depth</header-name>
</map:selector>
</map:selectors>
</map:components>
<map:resources>
<map:resource name="GET">
<map:match pattern="**">
<map:generate src="{global:staging}{1}"/>
<map:serialize type="xml"/>
</map:match>
</map:resource>
<map:resource name="OPTIONS">
<map:match pattern="**">
<map:act type="set-header">
<map:parameter name="DAV" value="DAV:1"/>
<map:parameter name="Allow" value="OPTIONS, GET, HEAD, POST, DELETE,TRACE, PROPFIND, PROPPATCH, COPY, MOVE"/>
</map:act>
<map:generate src="dummy.xml"/>
<map:serialize type="xml"/>
</map:match>
</map:resource>
<map:resource name="PROPFIND">
<map:match pattern="**/*.*">
<map:generate type="traverse" src="{global:staging}{1}/"/>
<map:transform src="{global:staging}styles/file2propfind0.xsl">
<map:parameter name="requestURI" value="{request:requestURI}"/>
<map:parameter name="directory" value="{1}"/>
<map:parameter name="file" value="{2}.{3}"/>
</map:transform>
<map:serialize type="xml" status-code="207"/>
</map:match>
<map:match pattern="**">
<map:generate type="traverse" src="{global:staging}{1}/"/>
<map:select type="depth">
<map:when test="0">
<map:transform src="{global:staging}styles/dir2propfind0.xsl">
<map:parameter name="requestURI" value="{request:requestURI}"/>
</map:transform>
</map:when>
<map:otherwise>
<map:transform src="{global:staging}styles/dir2propfind1.xsl">
<map:parameter name="requestURI" value="{request:requestURI}"/>
</map:transform>
</map:otherwise>
</map:select>
<map:serialize type="xml" status-code="207"/>
</map:match>
</map:resource>
<map:resource name="PUT">
<map:match pattern="**/*.*">
<map:generate type="stream">
<map:parameter name="defaultContentType" value="text/xml"/>
</map:generate>
<map:transform src="styles/stream2write.xsl">
<map:parameter name="file" value="{global:staging}{1}/{2}.{3}"/>
</map:transform>
<map:transform type="write-source"/>
<map:serialize/>
</map:match>
</map:resource>
</map:resources>
<map:pipelines>
<map:component-configurations>
<global-variables>
<staging></staging>
<!--staging>webdav://localhost/webdav/davmap/</staging-->
</global-variables>
</map:component-configurations>
<map:pipeline>
<map:match pattern="repo">
<map:select type="request-method">
<map:when test="GET">
<map:call resource="GET"/>
</map:when>
<map:when test="OPTIONS">
<map:call resource="OPTIONS"/>
</map:when>
<map:when test="PROPFIND">
<map:call resource="PROPFIND"/>
</map:when>
<map:otherwise>
<map:generate src="dummy.xml"/>
<map:serialize type="xml"/>
</map:otherwise>
</map:select>
</map:match>
<map:match pattern="repo/">
<map:select type="request-method">
<map:when test="GET">
<map:call resource="GET"/>
</map:when>
<map:when test="OPTIONS">
<map:call resource="OPTIONS"/>
</map:when>
<map:when test="PROPFIND">
<map:call resource="PROPFIND"/>
</map:when>
<map:otherwise>
<map:generate src="dummy.xml"/>
<map:serialize type="xml"/>
</map:otherwise>
</map:select>
</map:match>
<map:match pattern="repo/**/*.*">
<map:select type="request-method">
<map:when test="GET">
<map:call resource="GET"/>
</map:when>
<map:when test="OPTIONS">
<map:call resource="OPTIONS"/>
</map:when>
<map:when test="PROPFIND">
<map:call resource="PROPFIND"/>
</map:when>
<map:when test="PUT">
<map:call resource="PUT"/>
</map:when>
<map:otherwise>
<map:generate src="dummy.xml"/>
<map:serialize type="xml"/>
</map:otherwise>
</map:select>
</map:match>
<map:match pattern="repo/**/">
<map:select type="request-method">
<map:when test="GET">
<map:call resource="GET"/>
</map:when>
<map:when test="OPTIONS">
<map:call resource="OPTIONS"/>
</map:when>
<map:when test="PROPFIND">
<map:call resource="PROPFIND"/>
</map:when>
</map:select>
</map:match>
<map:match pattern="repo/**">
<map:select type="request-method">
<map:when test="GET">
<map:call resource="GET"/>
</map:when>
<map:when test="OPTIONS">
<map:call resource="OPTIONS"/>
</map:when>
<map:when test="PROPFIND">
<map:call resource="PROPFIND"/>
</map:when>
</map:select>
</map:match>
</map:pipeline>
</map:pipelines>
</map:sitemap>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/repo/contentA.xml
Index: contentA.xml
===================================================================
<?xml version="1.0"?>
<page>
<title>Page 1</title>
<content>
<para>Paragraph 1</para>
<para>Paragraph 2</para>
</content>
</page>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/repo/dir1/contentB.xml
Index: contentB.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<page>
<title>contentB</title>
<content>
<para>First Paragraph</para>
<para>Second Paragraph</para>
</content>
</page>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/repo/dir1/contentC.xml
Index: contentC.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<page>
<title>contentC</title>
<content>
<para>First Paragraph</para>
<para>Second Paragraph</para>
</content>
</page>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/repo/dir2/contentA.xml
Index: contentA.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<page>
<title>contentA</title>
<content>
<para>Paragraph 1.1</para>
<para>Paragraph 2.1</para>
</content>
</page>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/repo/dir2/contentB.xml
Index: contentB.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<page>
<title>Content B</title>
<content>
<para>First Paragraph</para>
<para>Second Paragraph</para>
</content>
</page>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/repo/dir2/contentC.xml
Index: contentC.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<page>
<title>content</title>
<content>
<para>Paragraph 1</para>
<para>Paragraph 2</para>
<para>Paragraph 3</para>
<para>Paragraph 4</para>
</content>
</page>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/repo/dir2/contentD.xml
Index: contentD.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<page>
<title>content D</title>
<content>
<para>Paragraph 1</para>
<para>Paragraph 2</para>
<para>Paragraph 3</para>
</content>
</page>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/repo/dir2/subdir1/contentA.xml
Index: contentA.xml
===================================================================
<?xml version="1.0" encoding="UTF-8"?>
<page>
<title>New Content</title>
<content>
<para>Paragraph 1</para>
<para>Paragraph 2</para>
</content>
</page>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/styles/dir2propfind0.xsl
Index: dir2propfind0.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:collection="http://apache.org/cocoon/collection/1.0"
xmlns:D="DAV:">
<xsl:param name="requestURI"></xsl:param>
<xsl:variable name="adjustedRequestURI">
<xsl:choose>
<xsl:when test="substring($requestURI, string-length($requestURI),1)='/'"><xsl:value-of select="$requestURI"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$requestURI"/>/</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:template match="/collection:collection">
<D:multistatus>
<D:response>
<D:href><xsl:value-of select="$adjustedRequestURI"/></D:href>
<D:propstat>
<D:prop>
<D:displayname><xsl:value-of select="@name"/></D:displayname>
<D:getlastmodified><xsl:value-of select="@lastModified"/></D:getlastmodified>
<D:getcontenttype/>
<D:resourcetype><D:collection/></D:resourcetype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</D:multistatus>
</xsl:template>
</xsl:stylesheet>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/styles/dir2propfind1.xsl
Index: dir2propfind1.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:collection="http://apache.org/cocoon/collection/1.0"
xmlns:D="DAV:">
<xsl:param name="requestURI"></xsl:param>
<xsl:variable name="adjustedRequestURI">
<xsl:choose>
<xsl:when test="substring($requestURI, string-length($requestURI),1)='/'"><xsl:value-of select="$requestURI"/></xsl:when>
<xsl:otherwise><xsl:value-of select="$requestURI"/>/</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:template match="/collection:collection">
<D:multistatus>
<xsl:apply-templates select="collection:resource"/>
<xsl:apply-templates select="collection:collection"/>
</D:multistatus>
</xsl:template>
<xsl:template match="collection:resource">
<D:response>
<D:href><xsl:value-of select="$adjustedRequestURI"/><xsl:value-of select="@name"/></D:href>
<D:propstat>
<D:prop>
<D:displayname><xsl:value-of select="@name"/></D:displayname>
<D:getlastmodified><xsl:value-of select="@lastModified"/></D:getlastmodified>
<D:getcontentlength><xsl:value-of select="@size"/></D:getcontentlength>
<D:resourcetype/>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</xsl:template>
<xsl:template match="collection:collection">
<D:response>
<D:href><xsl:value-of select="$adjustedRequestURI"/><xsl:value-of select="@name"/>/</D:href>
<D:propstat>
<D:prop>
<D:displayname><xsl:value-of select="@name"/></D:displayname>
<D:getlastmodified><xsl:value-of select="@lastModified"/></D:getlastmodified>
<D:getcontenttype>httpd/unix-directory</D:getcontenttype>
<D:resourcetype><D:collection/></D:resourcetype>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
</D:propstat>
</D:response>
</xsl:template>
</xsl:stylesheet>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/styles/file2propfind0.xsl
Index: file2propfind0.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:collection="http://apache.org/cocoon/collection/1.0"
xmlns:D="DAV:">
<xsl:param name="requestURI"></xsl:param>
<xsl:param name="directory"></xsl:param>
<xsl:param name="file"></xsl:param>
<xsl:template match="/collection:collection">
<D:multistatus>
<xsl:apply-templates select="collection:resource[@name=$file]"/>
</D:multistatus>
</xsl:template>
<xsl:template match="collection:resource[@name=$file]">
<D:response>
<D:href><xsl:value-of select="$requestURI"/>/</D:href>
<D:propstat>
<D:prop>
<D:current-user-privilege-set/>
<D:displayname><xsl:value-of select="@name"/></D:displayname>
<D:getlastmodified><xsl:value-of select="@lastModified"/></D:getlastmodified>
<D:getcontentlength><xsl:value-of select="@size"/></D:getcontentlength>
<D:getcontenttype>text/xml</D:getcontenttype>
<D:resourcetype/>
</D:prop>
<D:status>HTTP/1.1 200 OK</D:status>
<!--D:status>HTTP/1.1 404 Not Found</D:status-->
</D:propstat>
</D:response>
</xsl:template>
</xsl:stylesheet>
1.1 cocoon-2.1/src/blocks/webdav/samples/davmap/styles/stream2write.xsl
Index: stream2write.xsl
===================================================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:req="http://apache.org/cocoon/request/2.0"
xmlns:source="http://apache.org/cocoon/source/1.0">
<xsl:param name="file"></xsl:param>
<xsl:template match="/">
<page>
<source:write create="true">
<source:source><xsl:value-of select="$file"/></source:source>
<!--source:path>page</source:path-->
<source:fragment>
<xsl:copy-of select="node()"/>
</source:fragment>
</source:write>
</page>
</xsl:template>
</xsl:stylesheet>