<?xml version="1.0"?>
<!-- ===============================================
Pipelines for resources (css, images, javascript etc).


Generates  :  CSS, images (possibly from SVG), javascript.
Example URL:  http://localhost:8888/images/project-logo.gif
Used by    :  sitemap.xmap
Uses       :  resources/*, skins/*/{css,images}

$Revision: 1.4 $
==================================================== -->

<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
  <map:components>
    <map:generators default="file"/>
    <map:serializers default="html">
      <map:serializer name="svg2jpeg" mime-type="image/jpeg" src="org.apache.cocoon.serialization.SVGSerializer">
        <parameter name="quality" type="float" value="1.0"/>
      </map:serializer>
      <map:serializer mime-type="image/png" name="svg2png" src="org.apache.cocoon.serialization.SVGSerializer"/>
    </map:serializers>
 
    <map:transformers default="xslt"/>
    <map:readers default="resource"/>
    <map:matchers default="wildcard"/>
    <map:selectors default="browser"/>
  </map:components>

  <map:resources>
    <map:resource name="skin-read">
      <map:read src="skins/{forrest:skin}/{path}" mime-type="{mime-type}" />
    </map:resource>
  </map:resources>

  <map:pipelines>

    <map:pipeline>
      <map:match pattern="skin/**.js">
        <map:call resource="skin-read">
          <map:parameter name="path" value="scripts/{1}.js" />
          <map:parameter name="mime-type" value="application/x-javascript" />
        </map:call>
      </map:match>

      <map:match pattern="**/skin/**.js">
        <map:call resource="skin-read">
          <map:parameter name="path" value="scripts/{2}.js" />
          <map:parameter name="mime-type" value="application/x-javascript" />
        </map:call>
      </map:match>

      <map:match pattern="**.js">
        <map:read src="resources/scripts/{1}.js" mime-type="application/x-javascript" />
      </map:match>

      <map:match pattern="skin/**.css">
        <map:call resource="skin-read">
          <map:parameter name="path" value="css/{1}.css" />
          <map:parameter name="mime-type" value="text/css" />
        </map:call>
      </map:match>

      <map:match pattern="**/skin/**.css">
        <map:call resource="skin-read">
          <map:parameter name="path" value="css/{2}.css" />
          <map:parameter name="mime-type" value="text/css" />
        </map:call>
      </map:match>

      <map:match pattern="**.css">
        <map:read src="resources/css/{1}.css" mime-type="text/css" />
      </map:match>

      <map:match pattern="skin/images/**.*">
        <map:call resource="skin-read">
          <map:parameter name="path" value="images/{1}.{2}" />
          <map:parameter name="mime-type" value="image/{2}" />
        </map:call>
      </map:match>

      <!-- DS: handles images local to a contributor directory -->
      <map:match pattern="**my-images/**.*">
        <map:read src="content/xdocs/{1}my-images/{2}.{3}" mime-type="image/{3}" />
      </map:match>

      <map:match pattern="images/**.png">
        <map:select type="exists">
          <map:when test="resources/images/{1}.svg">
            <map:generate src="resources/images/{1}.svg" />
	    <map:transform src="resources/stylesheets/project2text.xsl" />
            <map:serialize type="svg2png" />
          </map:when>
          <map:otherwise>
            <map:read src="resources/images/{1}.png" mime-type="image/png" />
          </map:otherwise>
        </map:select>
      </map:match>

      <map:match pattern="images/**.*">
        <map:read src="resources/images/{1}.{2}" mime-type="image/{2}" />
      </map:match>

      <map:match pattern="**/images/**.*">
        <map:read src="resources/images/{2}.{3}" mime-type="image/{3}" />
      </map:match>

      <map:match pattern="**favicon.ico">
        <map:call resource="skin-read">
          <map:parameter name="path" value="images/favicon.ico" />
          <map:parameter name="mime-type" value="image/x-icon" />
        </map:call>
      </map:match>

    </map:pipeline>
  </map:pipelines>
</map:sitemap>
