unico       2003/10/30 06:36:13

  Added:       src/blocks/webdav/samples/davmap/styles collection2html.xsl
  Log:
  add directory browsing
  
  Revision  Changes    Path
  1.1                  
cocoon-2.1/src/blocks/webdav/samples/davmap/styles/collection2html.xsl
  
  Index: collection2html.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0" 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
    xmlns:xlink="http://www.w3.org/1999/xlink";
    xmlns:collection="http://apache.org/cocoon/collection/1.0";>
    
    <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">
      <html>
        <head>
          <title>
            <xsl:value-of select="@name"/>
          </title>
        </head>
        <body bgcolor="#ffffff">
          <table width="90%" cellspacing="0" cellpadding="5" align="center">
            <tr>
              <td colspan="4">
                <font size="+2">
                  <strong>
                    Directory Listing For <xsl:value-of select="@name"/>
                  </strong>
                </font>
              </td>
            </tr>
            <tr>
              <td colspan="4">&#160;</td>
            </tr>
            <xsl:call-template name="collection-header" />
            <xsl:apply-templates>
              <xsl:with-param name="href" select="$adjustedRequestURI" />
            </xsl:apply-templates>
            <tr>
              <td colspan="4" bgcolor="#cccccc">
                <font size="-1">Powered by Cocoon</font>
              </td>
            </tr>
          </table>
        </body>
      </html>
    </xsl:template>
    
    <xsl:template name="collection-header">
      <tr bgcolor="#cccccc">
        <td align="left">
          <font size="+1">
            <strong>Filename</strong>
          </font>
        </td>
        <td align="right">
          <font size="+1">
            <strong>Size</strong>
          </font>
        </td>
        <td align="right">
          <font size="+1">
            <strong>Created</strong>
          </font>
        </td>
        <td align="right">
          <font size="+1">
            <strong>Last Modified</strong>
          </font>
        </td>
      </tr>
    </xsl:template>
        
    <xsl:template match="collection:collection">
      <xsl:param name="href" />
      <tr>
        <xsl:if test="position() mod 2 = 0">
          <xsl:attribute name="bgcolor">#eeeeee</xsl:attribute>
        </xsl:if>
        <td align="left">&#160;&#160;<a href="[EMAIL PROTECTED]">
          <tt><xsl:value-of select="@name"/></tt></a>
        </td>
        <td align="right">
          <tt>&#160;</tt>
        </td>
        <td align="right">
          <tt>
            <xsl:value-of select="@created"/>
          </tt>
        </td>
        <td align="right">
          <tt>
            <xsl:value-of select="@modified"/>
          </tt>
        </td>
      </tr>
    </xsl:template>
    
    <xsl:template match="collection:resource">
      <xsl:param name="href" />
      <tr>
        <xsl:if test="position() mod 2 = 0">
          <xsl:attribute name="bgcolor">#eeeeee</xsl:attribute>
        </xsl:if>
        <td align="left">&#160;&#160;<a href="[EMAIL PROTECTED]">
          <tt><xsl:value-of select="@name"/></tt></a>
        </td>
        <td align="right">
          <tt>&#160;</tt>
        </td>
        <td align="right">
          <tt><xsl:value-of select="@created"/></tt>
        </td>
        <td align="right">
          <tt><xsl:value-of select="@modified"/></tt>
        </td>
      </tr>
    </xsl:template>
    
  </xsl:stylesheet>
  
  
  

Reply via email to