forrest-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nicola...@apache.org
Subject cvs commit: xml-forrest/src/core/context resources.xmap
Date Thu, 08 Jan 2004 16:16:58 GMT
nicolaken    2004/01/08 08:16:58

  Modified:    src/core/context resources.xmap
  Added:       src/core/context/skins/common/images corner-imports.svg.xslt
                        dc.svg.xslt rc.svg.xslt
  Log:
  Automatic generation of borders from skin colors and naming convention.
  Rounded and straight 45 degrees corners supplied.
  
  For example, to generate a 'r'ounded corner for 't'op 'l'eft the size
  of '5' pixels of background 'header', foreground 'tab-selected' and
  border of 'tab-unselected' I can just ask for:
  
   /skin/images/rc-t-l-5-1header-2tab-selected-3-tab-unselected.png
  
  Revision  Changes    Path
  1.1                  xml-forrest/src/core/context/skins/common/images/corner-imports.svg.xslt
  
  Index: corner-imports.svg.xslt
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
      <xsl:param name="orientation-tb"/>
      <xsl:param name="orientation-lr"/>
      <xsl:param name="size"/>
      <xsl:param name="bg-color-name"/>
      <xsl:param name="stroke-color-name"/>
      <xsl:param name="fg-color-name"/>    
  
     <!-- if not all colors are present, don't even try to render the corners -->
      <xsl:variable name="size"><xsl:choose>
      	<xsl:when test="$bg-color-name and $stroke-color-name and $fg-color-name"><xsl:value-of
select="$size"/></xsl:when>
      	<xsl:otherwise>0</xsl:otherwise>
      </xsl:choose></xsl:variable>
      <xsl:variable name="smallersize" select="number($size)-1"/>
      <xsl:variable name="biggersize" select="number($size)+1"/>     
      <xsl:variable name="bg"><xsl:if test="skinconfig/colors/color[@name=$bg-color-name]">fill:<xsl:value-of
select="skinconfig/colors/color[@name=$bg-color-name]/@value"/>;</xsl:if></xsl:variable>
      <xsl:variable name="fill"><xsl:if test="skinconfig/colors/color[@name=$stroke-color-name]">fill:<xsl:value-of
select="skinconfig/colors/color[@name=$stroke-color-name]/@value"/>;</xsl:if></xsl:variable>
      <xsl:variable name="stroke"><xsl:if test="skinconfig/colors/color[@name=$fg-color-name]">stroke:<xsl:value-of
select="skinconfig/colors/color[@name=$fg-color-name]/@value"/>;</xsl:if></xsl:variable>
          
  	<xsl:template match="skinconfig">
  
          	
  
  <svg width="{$size}" height="{$size}">
      <!-- background-->
      <rect x="-1" y="-1" width="{$biggersize}" height="{$biggersize}" style="{$bg}stroke-width:0"/>
  <!-- 0,0 0,-4 4,0 4,-4-->
  
      <xsl:variable name="flip-tb-scale">
        <xsl:choose>
      	<xsl:when test="$orientation-tb='t'">1</xsl:when>
      	<xsl:otherwise>-1</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
  
      <xsl:variable name="flip-lr-scale">
        <xsl:choose>
      	<xsl:when test="$orientation-lr='l'">1</xsl:when>
      	<xsl:otherwise>-1</xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      
      <xsl:variable name="flip-tb-translate">
        <xsl:choose>
      	<xsl:when test="$orientation-tb='t'">0</xsl:when>
      	<xsl:otherwise>-<xsl:value-of select="$size" /></xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
  
      <xsl:variable name="flip-lr-translate">
        <xsl:choose>
      	<xsl:when test="$orientation-lr='l'">0</xsl:when>
      	<xsl:otherwise>-<xsl:value-of select="$size" /></xsl:otherwise>
        </xsl:choose>
      </xsl:variable>    
      
      <!-- flip transform -->
      <g transform="scale({$flip-lr-scale},{$flip-tb-scale}) translate({$flip-lr-translate},
{$flip-tb-translate})"> 
        <xsl:call-template name = "figure" >
       	<xsl:with-param name="size"><xsl:value-of select="$size" /></xsl:with-param>
       	<xsl:with-param name="smallersize"><xsl:value-of select="$smallersize" /></xsl:with-param>
       	<xsl:with-param name="biggersize"><xsl:value-of select="$biggersize" /></xsl:with-param>
       	<xsl:with-param name="bg"><xsl:value-of select="$bg" /></xsl:with-param>
       	<xsl:with-param name="fill"><xsl:value-of select="$fill" /></xsl:with-param>
       	<xsl:with-param name="stroke"><xsl:value-of select="$stroke" /></xsl:with-param>
        </xsl:call-template>   
      </g>
  </svg>
  </xsl:template>
  
          
    <xsl:template name="figure">
         <!-- Just change shape here -->     
  		<g transform="translate(0.5 0.5)">
  			<ellipse cx="{$smallersize}" cy="{$smallersize}" rx="{$smallersize}" ry="{$smallersize}"
  				 style="{$fill}{$stroke}stroke-width:1"/>
  		</g>
  	   <!-- end -->	
    </xsl:template>
      
    
    <xsl:template match="*"></xsl:template>
    <xsl:template match="text()"></xsl:template>
    
  </xsl:stylesheet>
  
  
  
  1.1                  xml-forrest/src/core/context/skins/common/images/dc.svg.xslt
  
  Index: dc.svg.xslt
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href = "corner-imports.svg.xslt" />
    
    <!-- Diagonal 45 degrees corner -->
    <xsl:template name="figure">
          <xsl:variable name="biggersize" select="number($size)+number($size)"/>   
 
  		<g transform="translate(0 0.5)">
             <polygon points="0,{$size} {$size},0 {$biggersize},0 {$biggersize},{$biggersize}
0,{$biggersize}"
                      style="{$fill}{$stroke}stroke-width:1"/>
  		</g>
    </xsl:template>
        
  </xsl:stylesheet>
  
  
  
  
  1.1                  xml-forrest/src/core/context/skins/common/images/rc.svg.xslt
  
  Index: rc.svg.xslt
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:import href = "corner-imports.svg.xslt" />
  
    <!-- Rounded corner -->
    <xsl:template name="figure">
  		<g transform="translate(0.5 0.5)">
  			<ellipse cx="{$smallersize}" cy="{$smallersize}" rx="{$smallersize}" ry="{$smallersize}"
  				 style="{$fill}{$stroke}stroke-width:1"/>
  		</g>
    </xsl:template>
        
  </xsl:stylesheet>
  
  
  
  
  1.6       +136 -37   xml-forrest/src/core/context/resources.xmap
  
  Index: resources.xmap
  ===================================================================
  RCS file: /home/cvs/xml-forrest/src/core/context/resources.xmap,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- resources.xmap	30 Dec 2003 00:01:55 -0000	1.5
  +++ resources.xmap	8 Jan 2004 16:16:58 -0000	1.6
  @@ -32,74 +32,149 @@
      <map:resources>
         <map:resource name="skin-read">
               <map:select type="exists">
  -               <map:when test="{project:skins-dir}{forrest:skin}/{path}">
  -                  <map:read src="{project:skins-dir}{forrest:skin}/{path}" mime-type="{mime-type}"
/>
  +              <!-- First location: project skin dir -->
  +               <map:when test="{project:skins-dir}{forrest:skin}/{path}/{name}.{ext}">
  +                  <map:read src="{project:skins-dir}{forrest:skin}/{path}/{name}.{ext}"
mime-type="{mime-type}" />
                  </map:when>
  -               <map:when test="{project:skins-dir}{forrest:skin}/{path}.xslt">
  +               <map:when test="{project:skins-dir}{forrest:skin}/{path}/{name}.css.xslt">
                     <map:call resource="pipe-text-resource">
  -                    <map:parameter name="path" value="{project:skins-dir}{forrest:skin}/{path}.xslt"
/>
  +                    <map:parameter name="path" value="{project:skins-dir}{forrest:skin}/{path}/{name}.css.xslt"
/>
                       <map:parameter name="mime-type" value="text/css" />
                     </map:call>
                  </map:when>
  -               <map:when test="{forrest:home}context/skins/{forrest:skin}/{path}">
  -                  <map:read src="{forrest:home}context/skins/{forrest:skin}/{path}"
mime-type="{mime-type}" />
  +               <map:when test="{project:skins-dir}{forrest:skin}/{path}/{name}.svg.xslt">
  +                  <map:call resource="pipe-svg2png-resource">
  +                    <map:parameter name="path" value="{project:skins-dir}{forrest:skin}/{path}/{name}.svg.xslt"
/>
  +                  </map:call>
  +               </map:when>
  +               
  +              <!-- Second location: forrest skin dir -->
  +               <map:when test="{forrest:home}context/skins/{forrest:skin}/{path}/{name}.{ext}">
  +                  <map:read src="{forrest:home}context/skins/{forrest:skin}/{path}/{name}.{ext}"
mime-type="{mime-type}" />
                  </map:when>
  -               <map:when test="{forrest:home}context/skins/{forrest:skin}/{path}.xslt">
  +               <map:when test="{forrest:home}context/skins/{forrest:skin}/{path}/{name}.css.xslt">
                     <map:call resource="pipe-text-resource">
  -                    <map:parameter name="path" value="{forrest:home}context/skins/{forrest:skin}/{path}.xslt"
/>
  +                    <map:parameter name="path" value="{forrest:home}context/skins/{forrest:skin}/{path}/{name}.css.xslt"
/>
                       <map:parameter name="mime-type" value="text/css" />
                     </map:call>
                  </map:when>
  -               <map:when test="{forrest:home}context/skins/common/{path}">
  -                  <map:read src="{forrest:home}context/skins/common/{path}" mime-type="{mime-type}"
/>
  +               <map:when test="{forrest:home}context/skins/{forrest:skin}/{path}/{name}.svg.xslt">
  +                  <map:call resource="pipe-svg2png-resource">
  +                    <map:parameter name="path" value="{forrest:home}context/skins/{forrest:skin}/{path}/{name}.svg.xslt"
/>
  +                  </map:call>
                  </map:when>
  -               <map:otherwise>
  +               
  +              <!-- Third location: forrest common skin dir -->
  +               <map:when test="{forrest:home}context/skins/common/{path}/{name}.{ext}">
  +                  <map:read src="{forrest:home}context/skins/common/{path}/{name}.{ext}"
mime-type="{mime-type}" />
  +               </map:when>
  +               <map:when test="{forrest:home}context/skins/common/{path}/{name}.css.xslt">
                     <map:call resource="pipe-text-resource">
  -                    <map:parameter name="path" value="{forrest:home}context/skins/common/{path}.xslt"
/>
  +                    <map:parameter name="path" value="{forrest:home}context/skins/common/{path}/{name}.css.xslt"
/>
                       <map:parameter name="mime-type" value="text/css" />
                     </map:call>
  +               </map:when>
  +               <map:otherwise>
  +                  <map:call resource="pipe-svg2png-resource">
  +                    <map:parameter name="path" value="{forrest:home}context/skins/common/{path}/{name}.svg.xslt"
/>
  +                  </map:call>
  +               </map:otherwise>
  +            </map:select>
  +      </map:resource>
  +
  +       <map:resource name="read-svg2png-corner-resource">
  +            <map:select type="exists">
  +               <map:when test="{project:skins-dir}{forrest:skin}/{path}/{name}.svg.xslt">
  +                  <map:call resource="pipe-svg2png-corner-resource">
  +                    <map:parameter name="path" value="{project:skins-dir}{forrest:skin}/{path}/{name}.svg.xslt"
/>
  +                    <map:parameter name="orientation-tb" value="{orientation-tb}"/>
  +                    <map:parameter name="orientation-lr" value="{orientation-lr}"/>
  +                    <map:parameter name="size" value="{size}"/>   
  +                    <map:parameter name="bg-color-name" value="{bg-color-name}"/>
  +                    <map:parameter name="stroke-color-name" value="{stroke-color-name}"/>
  +                    <map:parameter name="fg-color-name" value="{fg-color-name}"/>
  
  +                  </map:call>
  +               </map:when>
  +               <map:when test="{forrest:home}context/skins/{forrest:skin}/{path}/{name}.svg.xslt">
  +                  <map:call resource="pipe-svg2png-corner-resource">
  +                    <map:parameter name="path" value="{forrest:home}context/skins/{forrest:skin}/{path}/{name}.svg.xslt"
/>
  +                    <map:parameter name="orientation-tb" value="{orientation-tb}"/>
  +                    <map:parameter name="orientation-lr" value="{orientation-lr}"/>
  +                    <map:parameter name="size" value="{size}"/>   
  +                    <map:parameter name="bg-color-name" value="{bg-color-name}"/>
  +                    <map:parameter name="stroke-color-name" value="{stroke-color-name}"/>
  +                    <map:parameter name="fg-color-name" value="{fg-color-name}"/>
  
  +                  </map:call>
  +               </map:when>
  +               <map:otherwise>
  +                  <map:call resource="pipe-svg2png-corner-resource">
  +                    <map:parameter name="path" value="{forrest:home}context/skins/common/{path}/{name}.svg.xslt"
/>
  +                    <map:parameter name="orientation-tb" value="{orientation-tb}"/>
  +                    <map:parameter name="orientation-lr" value="{orientation-lr}"/>
  +                    <map:parameter name="size" value="{size}"/>   
  +                    <map:parameter name="bg-color-name" value="{bg-color-name}"/>
  +                    <map:parameter name="stroke-color-name" value="{stroke-color-name}"/>
  +                    <map:parameter name="fg-color-name" value="{fg-color-name}"/>
  
  +                  </map:call>
                  </map:otherwise>
               </map:select>
         </map:resource>
         
         <map:resource name="pipe-text-resource">
  -        <map:call resource="generate-xslt-resource">
  +        <map:call resource="generate-resource">
              <map:parameter name="path" value="{path}" />
            </map:call>
            <map:serialize type="text" mime-type="{mime-type}"/>
         </map:resource>
  -      
  -      <map:resource name="generate-xslt-resource">
  +
  +      <map:resource name="pipe-svg2png-resource">
  +         <map:call resource="generate-resource">
  +           <map:parameter name="path" value="{path}" />
  +         </map:call>
  +         <map:call resource="transform-project2text"/>
  +         <map:serialize type="svg2png" />
  +      </map:resource>
  +
  +      <map:resource name="pipe-svg2png-corner-resource">
           <map:generate src="{project:skinconf}" />
  -        <map:transform src="{path}"/>
  +        <map:transform src="{path}">
  +            <map:parameter name="orientation-tb" 
  +                         value="{orientation-tb}"/>
  +            <map:parameter name="orientation-lr" 
  +                         value="{orientation-lr}"/>
  +            <map:parameter name="size" 
  +                         value="{size}"/>
  +            <map:parameter name="bg-color-name" 
  +                         value="{bg-color-name}"/>
  +            <map:parameter name="stroke-color-name" 
  +                         value="{stroke-color-name}"/>
  +            <map:parameter name="fg-color-name" 
  +                         value="{fg-color-name}"/>            
  +        </map:transform>
  +        <map:call resource="transform-project2text"/>
  +        <map:serialize type="svg2png" />
         </map:resource>
         
  -      <map:resource name="generate-xml-resource">
  +      <map:resource name="generate-resource">
           <map:generate src="{project:skinconf}" />
           <map:transform src="{path}"/>
         </map:resource>
  -
  +      
         <map:resource name="transform-project2text">
            <map:transform src="{forrest:stylesheets}/project2text.xsl">
               <map:parameter name="config-file" value="{project:skinconf}"/>
            </map:transform>      
         </map:resource>
  -      
  -      <map:resource name="pipe-svg2png-resource">
  -         <map:call resource="generate-xml-resource">
  -           <map:parameter name="path" value="{path}" />
  -         </map:call>
  -         <map:call resource="transform-project2text"/>
  -         <map:serialize type="svg2png" />
  -      </map:resource>
  -      
  +
      </map:resources>
      
      <map:pipelines>
          <map:pipeline>
            <map:match pattern="**skin/**.js">
               <map:call resource="skin-read">
  -               <map:parameter name="path" value="scripts/{2}.js" />
  +               <map:parameter name="path" value="scripts" />
  +               <map:parameter name="name" value="{2}" />
  +               <map:parameter name="ext" value="js" />
                  <map:parameter name="mime-type" value="application/x-javascript" />
               </map:call>
            </map:match>
  @@ -111,7 +186,9 @@
   
            <map:match pattern="**skin/**.css">
               <map:call resource="skin-read">
  -               <map:parameter name="path" value="css/{2}.css" />
  +               <map:parameter name="path" value="css" />
  +               <map:parameter name="name" value="{2}" />
  +               <map:parameter name="ext" value="css" />
                  <map:parameter name="mime-type" value="text/css" />
               </map:call>
            </map:match>
  @@ -121,10 +198,26 @@
               <map:read src="resources/css/{1}.css" mime-type="text/css" />
            </map:match>
   
  -         <map:match pattern="skin/images/**.*">
  +         <!-- special case cormer generator pipeline -->
  +         <map:match pattern="skin/images**/*c-*-*-*-1*-2*-3*.png">
  +            <map:call resource="read-svg2png-corner-resource">
  +               <map:parameter name="path" value="images/{1}" />
  +               <map:parameter name="name" value="{2}c" />
  +               <map:parameter name="orientation-tb" value="{3}"/>
  +               <map:parameter name="orientation-lr" value="{4}"/>
  +               <map:parameter name="size" value="{5}"/>    
  +               <map:parameter name="bg-color-name" value="{6}"/>
  +               <map:parameter name="stroke-color-name" value="{7}"/>
  +               <map:parameter name="fg-color-name" value="{8}"/>    
  +            </map:call>
  +         </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:parameter name="path" value="images/{1}" />
  +               <map:parameter name="name" value="{2}" />
  +               <map:parameter name="ext" value="{3}" />
  +               <map:parameter name="mime-type" value="image/{3}" />
               </map:call>
            </map:match>
   
  @@ -163,7 +256,9 @@
                    <!-- needed for compatibility for the standard resources/images that
are now
                         in the common skin -->
                    <map:call resource="skin-read">
  -                   <map:parameter name="path" value="images/{1}.png" />
  +                   <map:parameter name="path" value="images" />
  +                   <map:parameter name="name" value="{1}" />
  +                   <map:parameter name="ext" value="png" />
                      <map:parameter name="mime-type" value="image/png" />
                    </map:call>
                  </map:otherwise>
  @@ -185,7 +280,9 @@
                    <!-- needed for compatibility for the standard resources/images that
are now
                         in the common skin -->
                    <map:call resource="skin-read">
  -                   <map:parameter name="path" value="images/{1}.{2}" />
  +                   <map:parameter name="path" value="images" />
  +                   <map:parameter name="name" value="{1}" />
  +                   <map:parameter name="ext" value="{2}" />
                      <map:parameter name="mime-type" value="image/{2}" />
                    </map:call>
                  </map:otherwise>
  @@ -224,9 +321,11 @@
               </map:select>
            </map:match>
   
  -         <map:match pattern="**favicon.ico">
  +         <map:match pattern="**/*.ico">
               <map:call resource="skin-read">
  -               <map:parameter name="path" value="images/favicon.ico" />
  +               <map:parameter name="path" value="images/{1}" />
  +               <map:parameter name="name" value="{2}" />
  +               <map:parameter name="ext" value="ico" />
                  <map:parameter name="mime-type" value="image/x-icon" />
               </map:call>
            </map:match>
  
  
  

Mime
View raw message