view docs/xslt/changes.xslt @ 4668:ba2c7463ce18 stable-1.2

Merge of r4614, r4624-r4629, r4631: proxy recursive changes. *) Added IPv6 and UNIX-domain socket support in "debug_connection" directive. *) New function ngx_http_get_forwarded_addr() to look up real client address. On input it takes an original address, string in the X-Forwarded-For format and its length, list of trusted proxies, and a flag indicating to perform the recursive search. On output it returns NGX_OK and the "deepest" valid address in a chain, or NGX_DECLINED. It supports AF_INET and AF_INET6. Additionally, original address and/or proxy may be specified as AF_UNIX. *) Realip: chains of trusted proxies and IPv6 support. The module now supports recursive search of client address through the chain of trusted proxies, controlled by the "real_ip_recursive" directive (closes #2). It also gets full IPv6 support (closes #44) and canonical value of the $client_addr variable on address change. Example: real_ip_header X-Forwarded-For; set_real_ip_from 127.0.0.0/8; set_real_ip_from ::1; set_real_ip_from unix:; real_ip_recursive on; *) Geo: chains of trusted proxies and partial IPv6 support. The module now supports recursive search of client address through the chain of trusted proxies, controlled by the "proxy_recursive" directive in the "geo" block. It also gets partial IPv6 support: now proxies may be specified with IPv6 addresses. Example: geo $test { ... proxy 127.0.0.1; proxy ::1; proxy_recursive; } There's also a slight change in behavior. When original client address (as specified by the "geo" directive) is one of the trusted proxies, and the value of the X-Forwarded-For request header cannot not be parsed as a valid address, an original client address will be used for lookup. Previously, 255.255.255.255 was used in this case. *) Geoip: trusted proxies support and partial IPv6 support. The module now supports recursive search of client address through the chain of trusted proxies (closes #100), in the same scope as the geo module. Proxies are listed by the "geoip_proxy" directive, recursive search is enabled by the "geoip_proxy_recursive" directive. IPv6 is partially supported: proxies may be specified with IPv6 addresses. Example: geoip_country .../GeoIP.dat; geoip_proxy 127.0.0.1; geoip_proxy ::1; geoip_proxy 10.0.0.0/8; geoip_proxy_recursive on;
author Maxim Dounin <mdounin@mdounin.ru>
date Mon, 04 Jun 2012 11:58:12 +0000
parents 76bc29f06168
children db6d07dbef3c
line wrap: on
line source

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

   <xsl:output method="text"/>

   <xsl:param select="'en'" name="lang"/>

   <xsl:param select="'../xml/change_log_conf.xml'" name="configuration"/>

   <xsl:variable select="document($configuration)/configuration" name="conf"/>

   <xsl:variable select="$conf/start" name="start"/>

   <xsl:variable select="$conf/indent" name="indent"/>

   <xsl:variable select="$conf/length" name="max"/>

   <xsl:variable name="br">&lt;br&gt;</xsl:variable>

   <xsl:template match="/">
      <xsl:apply-templates select="change_log"/>
   </xsl:template>

   <xsl:template match="change_log">
      <xsl:apply-templates select="changes"/>
   </xsl:template>

   <xsl:template match="changes">

      <xsl:text>
</xsl:text>

      <xsl:value-of select="substring(concat($conf/changes[@lang=$lang]/title,                        //change_log/@title,                        ' ', @ver,                        '                                                    '),                 1, $conf/changes[@lang=$lang]/length)"/>

      <xsl:if test="$lang='ru'">
         <xsl:value-of select="@date"/>
      </xsl:if>

      <xsl:if test="$lang='en'">

         <xsl:value-of select="substring(@date, 1, 2)"/>

         <xsl:value-of select="$conf/changes[@lang=$lang]/month[number(substring(current()/@date,                                                             4, 2))]"/>

         <xsl:value-of select="substring(@date, 7, 4)"/>
      </xsl:if>

      <xsl:text>
</xsl:text>

      <xsl:apply-templates select="change"/>

      <xsl:text>
</xsl:text>
   </xsl:template>

   <xsl:template match="change">

      <xsl:variable select="$conf/changes[@lang=$lang]/*[local-name(.)=current()/@type]" name="prefix"/>

      <xsl:variable name="postfix">
         <xsl:if test="$prefix">
            <xsl:text>: </xsl:text>
         </xsl:if>
      </xsl:variable>

      <xsl:apply-templates select="para[@lang=$lang]">
         <xsl:with-param select="concat($start, $prefix, $postfix)" name="prefix"/>
      </xsl:apply-templates>
   </xsl:template>

   <xsl:template match="para" name="para">
      <xsl:param name="prefix"/>

      <xsl:variable name="text">
         <xsl:apply-templates/>
      </xsl:variable>

      <xsl:text>
</xsl:text>

      <xsl:call-template name="wrap">
         <xsl:with-param select="normalize-space($text)" name="text"/>
         <xsl:with-param name="prefix">
            <xsl:choose>

               <xsl:when test="position() = 1">
                  <xsl:value-of select="$prefix"/>
               </xsl:when>
               <xsl:otherwise>
                  <xsl:value-of select="$indent"/>
               </xsl:otherwise>
            </xsl:choose>
         </xsl:with-param>
      </xsl:call-template>
   </xsl:template>

   <xsl:template name="wrap">
      <xsl:param name="text"/>
      <xsl:param name="prefix"/>

      <xsl:if test="$text">

         <xsl:variable name="offset">

            <xsl:choose>
               <xsl:when test="starts-with($text, concat($br, ' '))">
                  <xsl:value-of select="string-length($br) + 2"/>
               </xsl:when>
               <xsl:when test="starts-with($text, $br)">
                  <xsl:value-of select="string-length($br) + 1"/>
               </xsl:when>
               <xsl:otherwise>
                    1</xsl:otherwise>
            </xsl:choose>
         </xsl:variable>

         <xsl:variable name="length">

            <xsl:call-template name="length">
               <xsl:with-param select="substring($text, $offset)" name="text"/>
               <xsl:with-param select="string-length($prefix)" name="prefix"/>
               <xsl:with-param select="$max" name="length"/>
            </xsl:call-template>
         </xsl:variable>

         <xsl:value-of select="$prefix"/>

         <xsl:value-of select="normalize-space(translate(substring($text, $offset, $length),                                     ' ', ' '))"/>

         <xsl:text>
</xsl:text>

         <xsl:call-template name="wrap">
            <xsl:with-param select="substring($text, $length + $offset)" name="text"/>
            <xsl:with-param select="$indent" name="prefix"/>
         </xsl:call-template>
      </xsl:if>
   </xsl:template>

   <xsl:template name="length">
      <xsl:param name="text"/>
      <xsl:param name="prefix"/>
      <xsl:param name="length"/>

      <xsl:variable select="substring-before(substring($text, 1,                                     $length - $prefix + string-length($br)),                                     $br)" name="break"/>

      <xsl:choose>
         <xsl:when test="$break">
            <xsl:value-of select="string-length($break)"/>
         </xsl:when>
         <xsl:when test="$length = 0">
            <xsl:value-of select="$max - $prefix"/>
         </xsl:when>
         <xsl:when test="string-length($text) + $prefix &lt;= $length">
            <xsl:value-of select="$length - $prefix"/>
         </xsl:when>
         <xsl:when test="substring($text, $length - $prefix + 1, 1) = ' '">
            <xsl:value-of select="$length - $prefix + 1"/>
         </xsl:when>
         <xsl:otherwise>

            <xsl:call-template name="length">
               <xsl:with-param select="$text" name="text"/>
               <xsl:with-param select="$prefix" name="prefix"/>
               <xsl:with-param select="$length - 1" name="length"/>
            </xsl:call-template>
         </xsl:otherwise>
      </xsl:choose>
   </xsl:template>

   <xsl:template match="at">@</xsl:template>

   <xsl:template match="br">
      <xsl:value-of select="$br"/>
   </xsl:template>

   <xsl:template match="nobr">
      <xsl:value-of select="translate(., ' ', ' ')"/>
   </xsl:template>

</xsl:stylesheet>