<?xml version="1.0" encoding="utf-8" ?>

<!--
# Copyright 2002-2008 Raphaël Hertzog and others
# Copyright 2007-2008 Stefano Zacchiroli
# This file is distributed under the terms of the General Public License
# version 2 or (at your option) any later version.
-->

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

<xsl:output encoding="UTF-8" method="html"/>

<xsl:param name="package"/>
<xsl:param name="dir"/>
<xsl:param name="date"/>
<xsl:param name="hasoldstable" select="''"/>
<xsl:param name="hasstable" select="''"/>
<xsl:param name="hastesting" select="''"/>
<xsl:param name="hasunstable" select="''"/>
<xsl:param name="hasexperimental" select="''"/>
<xsl:param name="hasother" select="''"/>
<xsl:param name="hass-p-u" select="''"/>
<xsl:param name="hast-p-u" select="''"/>
<xsl:param name="hasoldstable-security" select="''"/>
<xsl:param name="hasstable-security" select="''"/>
<xsl:param name="hastesting-security" select="''"/>
<xsl:param name="hassecure-testing" select="''"/>
<xsl:param name="hasvolatile" select="''"/>
<xsl:param name="hasnews" select="''"/>
<xsl:param name="hasexcuse" select="''"/>

<xsl:variable name="other"
  select="document(concat('../base/', $dir, '/other.xml'))/other"/>
<xsl:variable name="low-nmu-emails"
  select="document('../base/low_threshold_nmu.emails.xml')/emails"/>

<!-- Those variables controls the todo and problem item concerning
     standards-version not being up to date -->
<xsl:variable name="lastsv" select="'3.7.3'"/>
<xsl:variable name="lastmajorsv" select="'3.'"/>

<!-- Named templates aka functions -->
<xsl:template name="mirror">
  <xsl:text>http://ftp.debian.org/debian</xsl:text>  
</xsl:template>

<xsl:template name="outputitem">
  <xsl:choose>
    <xsl:when test="@url">
      <li><xsl:if test="@date">
        <xsl:text>[</xsl:text>
	<xsl:value-of select="@date"/>
        <xsl:text>] </xsl:text>
      </xsl:if><a href="{@url}">
      <xsl:value-of select="text()"/></a><xsl:if test="@from">
        <xsl:text> (</xsl:text>
	<xsl:value-of select="@from"/>
        <xsl:text>)</xsl:text></xsl:if></li>
    </xsl:when>
    <xsl:otherwise>
      <li><xsl:if test="@date">
        <xsl:text>[</xsl:text>
	<xsl:value-of select="@date"/>
        <xsl:text>] </xsl:text>
      </xsl:if><xsl:value-of select="text()"/></li>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

<!-- Convert + in %2b for URL escaping. Should actually first also do
other-to-%xx, especially % to %25... Fortunately, that's rare -->
<xsl:template name="escape-name">
  <xsl:param name="text"/>
  <xsl:if test="contains($text,'+')">
    <xsl:value-of select="substring-before($text,'+')"/>
    <xsl:text>%2b</xsl:text>
    <xsl:call-template name="escape-name">
    <xsl:with-param name="text"><xsl:value-of select="substring-after($text,'+')"/></xsl:with-param>
    </xsl:call-template>
  </xsl:if>
  <xsl:if test="not(contains($text,'+'))">
    <xsl:value-of select="$text"/>
  </xsl:if>
</xsl:template>

<xsl:variable name="escaped-package">
  <xsl:call-template name="escape-name">
    <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
  </xsl:call-template>
</xsl:variable>

<!-- Strip epoch -->
<xsl:template name="strip-epoch">
  <xsl:param name="version"/>
  <xsl:if test="contains($version,':')">
    <xsl:value-of select="substring-after($version,':')"/>
  </xsl:if>
  <xsl:if test="not(contains($version,':'))">
    <xsl:value-of select="$version"/>
  </xsl:if>
</xsl:template>

<xsl:template name="add-vcs-info">
  <xsl:if test="repository">
    <tr>
      <td class="labelcell">
        <xsl:text>Version Control</xsl:text>
      </td>
      <td class="contentcell">
        <xsl:if test="repository/vcs[@kind='browser']">
          <a href="{repository/vcs[@kind='browser']/@url}">
            <xsl:text>browser</xsl:text>
          </a>
          <br />
        </xsl:if>
        <xsl:if test="repository/vcs[@kind!='browser']">
          <xsl:text>raw: </xsl:text>
          <xsl:for-each select="repository/vcs[@kind!='browser']">
            <xsl:sort select="@kind" />
            <a href="{@url}">
              <xsl:value-of select="@kind" />
            </a>
            <xsl:if test="position()!=last()">
              <xsl:text>, </xsl:text>
            </xsl:if>
          </xsl:for-each>
        </xsl:if>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="add-maintenance-info">
  <xsl:param name="email" />
  <xsl:variable name="dm">
    <xsl:if test="dm-upload-allowed and string(dm-upload-allowed)='yes'">
      <xsl:text>true</xsl:text>
    </xsl:if>
  </xsl:variable>
  <xsl:variable name="lownmu">
    <xsl:if test="$low-nmu-emails/email[text()=$email]">
      <xsl:text>true</xsl:text>
    </xsl:if>
  </xsl:variable>

  <xsl:if test="string($dm)!='' or string($lownmu)!=''">
    <tr>
      <td class="labelcell">
	<xsl:text>Maintenance info</xsl:text>
      </td>
      <td class="contentcell">

	<xsl:if test="string($dm)!=''">
	  <span class="dm-tag">
	    <a href="http://www.debian.org/vote/2007/vote_003"><acronym title="Debian Maintainer Upload Allowed: can be uploaded by Debian Maintainers">DMUA</acronym></a>
	  </span>
          <xsl:text> </xsl:text>
	</xsl:if>

        <xsl:if test="string($lownmu)!=''">
	  <span class="lownmu-tag">
            <a href="http://wiki.debian.org/LowThresholdNmu"><acronym
                title="maintainer agrees with Low Threshold NMU, see wiki page for details">LowNMU</acronym></a>
	  </span>
          <xsl:text> </xsl:text>
        </xsl:if>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="output-news">
  <xsl:param name="news" />

  <xsl:if test="count($news)>0 and string($news)!=''">
    <tr class="titlerow">
    <td class="titlecell">
      Latest news <a class="feedlink" href="{$package}/news.rss20.xml">RSS</a>
    </td></tr>
    <tr class="normalrow">
    <td class="contentcell2">
    <ul id="news-list"><xsl:copy-of select="$news"/></ul>
    </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="output-static">
  <xsl:param name="static" />

  <xsl:if test="count($static)>0 and string($static)!=''">
    <tr class="titlerow">
    <td class="titlecell">
    Static Information
    </td></tr>
    <tr class="normalrow">
    <td class="contentcell2">
    <ul><xsl:copy-of select="$static"/></ul>
    </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="categorize-srcfile">
  <!-- used to recognize (and tag afterwards) well-known type of source package
    components: dsc, diff, orig -->
  <xsl:choose>
    <xsl:when test="substring(filename,string-length(filename)-2, 3)='dsc'">
      <xsl:text>dsc</xsl:text>
    </xsl:when>
    <xsl:when test="substring(filename,string-length(filename)-6, 7)='diff.gz'">
      <xsl:text>diff</xsl:text>
    </xsl:when>
    <xsl:when test="substring(filename,string-length(filename)-5, 3)='tar'">
      <xsl:text>orig</xsl:text>
    </xsl:when>
    <xsl:otherwise><xsl:text></xsl:text></xsl:otherwise>
  </xsl:choose>
</xsl:template>

<xsl:template name="maintainer-email">
  <xsl:param name="email" />
  <a class="email" href="mailto:{$email}">
    <img alt="[email]" src="../common/email.png" title="email" />
  </a>
</xsl:template>

<xsl:template name="general-information">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      General information
    </td>
  </tr>
  <tr class="normalrow">
    <td class="labelcell">Latest version</td>
    <td class="contentcell"><xsl:value-of select="version"/></td>
  </tr>
  <xsl:if test="@release!='unstable'">
    <tr class="normalrow">
      <td class="labelcell">Distribution</td>
      <td class="contentcell"><xsl:value-of select="@release"/></td>
    </tr>
  </xsl:if>
  <tr class="normalrow">
    <td class="labelcell">Maintainer</td>
    <td class="contentcell">
      <xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:text>http://qa.debian.org/developer.php?login=</xsl:text>
	  <xsl:call-template name="escape-name">
	    <xsl:with-param name="text"><xsl:value-of select="maintainer/email"/></xsl:with-param>
	  </xsl:call-template>
	</xsl:attribute>
	<xsl:value-of select="maintainer/name"/>
      </xsl:element>
      <xsl:text> </xsl:text>
      <xsl:call-template name="maintainer-email">
	<xsl:with-param name="email" select="maintainer/email" />
      </xsl:call-template>
    </td>
  </tr>
  <tr class="normalrow">
    <td class="labelcell"><a href="http://www.debian.org/doc/manuals/developers-reference/ch-pkgs.en.html#s-collaborative-maint">Uploaders</a></td>
    <td class="contentcell">
      <xsl:if test="uploaders">
	<xsl:for-each select="uploaders/item">
	  <xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://qa.debian.org/developer.php?login=</xsl:text>
	      <xsl:call-template name="escape-name">
		<xsl:with-param name="text"><xsl:value-of select="email"/></xsl:with-param>
	      </xsl:call-template>
	    </xsl:attribute>
	    <xsl:value-of select="name"/>
	  </xsl:element>
	  <xsl:text> </xsl:text>
	  <xsl:call-template name="maintainer-email">
	    <xsl:with-param name="email" select="email" />
	  </xsl:call-template>
	  <br />
	</xsl:for-each>
      </xsl:if>
      <xsl:if test="not(uploaders)">
	<a class="none" title="You should find some co-maintainers ..." name="fake">None</a>
      </xsl:if>
      <xsl:call-template name='add-maintenance-info'>
        <xsl:with-param name="email" select="maintainer/email" />
      </xsl:call-template>
  </td></tr>
  <tr class="normalrow">
    <td class="labelcell">Standards version</td>
    <td class="contentcell"><xsl:value-of select="standards-version"/></td>
  </tr>
  <tr class="normalrow">
    <td class="labelcell">Priority</td>
    <td class="contentcell"> <xsl:value-of select="priority"/> </td>
  </tr>
  <tr class="normalrow">
    <td class="labelcell">Section</td>
    <td class="contentcell"> <xsl:value-of select="section"/> </td>
  </tr>
  <xsl:call-template name='add-vcs-info' />
  <xsl:if test="architecture!='any' and architecture!='all'">
    <tr class="normalrow">
      <td class="labelcell">Architecture</td>
      <td class="contentcell"><xsl:value-of select="architecture"/></td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="bugs-count">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      Bugs count
    </td>
  </tr>
  <tr class="normalrow" id="bugs_all">
    <td class="labelcell">All bugs</td>
    <td class="contentcell">
      <xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:text>http://bugs.debian.org/src:</xsl:text>
	  <xsl:call-template name="escape-name">
	    <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
	  </xsl:call-template>
	</xsl:attribute>
	<xsl:if test="$hasother">
	  <xsl:value-of select="$other/bugs/@all"/>
	</xsl:if>
      </xsl:element>
    </td>
  </tr>
  <tr class="normalrow" id="bugs_rc">
    <td class="labelcell"><span class="indented"><acronym title="Release Critical">RC</acronym> bugs</span></td>
    <td class="contentcell">
      <xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data=</xsl:text>
	  <xsl:call-template name="escape-name">
	    <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
	  </xsl:call-template>
	  <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=critical&amp;sev-inc=grave&amp;sev-inc=serious</xsl:text>
	</xsl:attribute>
	<xsl:if test="$hasother">
	  <xsl:value-of select="$other/bugs/@rc"/>
	</xsl:if>
      </xsl:element>
    </td>
  </tr>
  <tr class="normalrow" id="bugs_in">
    <td class="labelcell"><span class="indented"><acronym title="Important and Normal">I&amp;N</acronym> bugs</span></td>
    <td class="contentcell">
      <xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data=</xsl:text>
	  <xsl:call-template name="escape-name">
	    <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
	  </xsl:call-template>
	  <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=important&amp;sev-inc=normal</xsl:text>
	</xsl:attribute>
	<xsl:if test="$hasother">
	  <xsl:value-of select="$other/bugs/@normal"/>
	</xsl:if>
      </xsl:element>
    </td>
  </tr>
  <tr class="normalrow" id="bugs_mw">
    <td class="labelcell"><span class="indented"><acronym title="Minor and Wishlist">M&amp;W</acronym> bugs</span></td>
    <td class="contentcell">
      <xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data=</xsl:text>
	  <xsl:call-template name="escape-name">
	    <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
	  </xsl:call-template>
	  <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=minor&amp;sev-inc=wishlist</xsl:text>
	</xsl:attribute>
	<xsl:if test="$hasother">
	  <xsl:value-of select="$other/bugs/@wishlist"/>
	</xsl:if>
      </xsl:element>
    </td>
  </tr>
  <tr class="normalrow" id="bugs_fp">
    <td class="labelcell"><span class="indented"><acronym title="Fixed and Pending">F&amp;P</acronym> bugs</span></td>
    <td class="contentcell">
      <xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data=</xsl:text>
	  <xsl:call-template name="escape-name">
	    <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
	  </xsl:call-template>
	  <xsl:text>&amp;archive=no&amp;pend-inc=pending-fixed&amp;pend-inc=fixed</xsl:text>
	</xsl:attribute>
	<xsl:if test="$hasother">
	  <xsl:value-of select="$other/bugs/@fixed"/>
	</xsl:if>
      </xsl:element>
    </td>
  </tr>
</xsl:template>

<xsl:template name="pts-subscription">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      <a class="titlelink" href="http://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system"><acronym title="Package Tracking System">PTS</acronym></a> subscription
  </td></tr>
  <tr class="normalrow">
    <td class="labelcell">Subscribers count</td>
    <td class="contentcell"><xsl:if test="$hasother">
	<xsl:value-of select="$other/pts/@count"/>
    </xsl:if></td>
  </tr>
  <tr class="normalrow">
    <td class="contentcell" colspan="2">
      <form method="post" action="/cgi-bin/pts.cgi">
	<p>
	  <input type="hidden" name="package" value="{$package}"/>
	  <select name="what">
	    <option value="subscribe">Subscribe</option>
	    <option value="unsubscribe">Unsubscribe</option>
	    <option value="advanced">Advanced mode</option>
	  </select>
	  <input type="text" name="email" size="15" value="your email" onFocus="if(email.value=='your email'){{email.value=''}}"/>
	  <input type="submit" name="submit" value="Send"/>
	</p>
      </form>
    </td>
  </tr>
</xsl:template>

<xsl:template name="binary-packages">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      Binary package(s)
  </td></tr>
  <tr class="normalrow">
    <td class="normalcell" colspan="2" style="text-align: left">
      <ul>
	<xsl:for-each select="binary/item">
	  <xsl:sort select="text()"/>
	  <xsl:variable name="pkg" select="text()"/>
	  <li class="binpkg">
	    <a class="binpkg" href="http://packages.debian.org/{text()}"><xsl:value-of select="text()"/></a>
	    <span style="font-size: 70%">
	      (<a href="http://bugs.debian.org/{text()}"><xsl:value-of select="$other/bugs/item[@name=$pkg]/@all"/> bugs</a>: 

	      <xsl:element name="a">
		<xsl:attribute name="title">critical, grave and serious</xsl:attribute>
		<xsl:attribute name="href">
		  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data=</xsl:text>
		  <xsl:call-template name="escape-name">
		    <xsl:with-param name="text"><xsl:value-of select="text()"/></xsl:with-param>
		  </xsl:call-template>
		  <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=critical&amp;sev-inc=grave&amp;sev-inc=serious</xsl:text>
		</xsl:attribute>
		<xsl:value-of select="$other/bugs/item[@name=$pkg]/@rc"/>
	      </xsl:element>, 

	      <xsl:element name="a">
		<xsl:attribute name="title">important and normal</xsl:attribute>
		<xsl:attribute name="href">
		  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data=</xsl:text>
		  <xsl:call-template name="escape-name">
		    <xsl:with-param name="text"><xsl:value-of select="text()"/></xsl:with-param>
		  </xsl:call-template>
		  <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=important&amp;sev-inc=normal</xsl:text>
		</xsl:attribute>
		<xsl:value-of select="$other/bugs/item[@name=$pkg]/@normal"/>
	      </xsl:element>, 

	      <xsl:element name="a">
		<xsl:attribute name="title">wishlist and minor</xsl:attribute>
		<xsl:attribute name="href">
		  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data=</xsl:text>
		  <xsl:call-template name="escape-name">
		    <xsl:with-param name="text"><xsl:value-of select="text()"/></xsl:with-param>
		  </xsl:call-template>
		  <xsl:text>&amp;archive=no&amp;pend-exc=pending-fixed&amp;pend-exc=fixed&amp;pend-exc=done&amp;sev-inc=minor&amp;sev-inc=wishlist</xsl:text>
		</xsl:attribute>
		<xsl:value-of select="$other/bugs/item[@name=$pkg]/@wishlist"/>
	      </xsl:element>, 

	      <xsl:element name="a">
		<xsl:attribute name="title">pending and fixed</xsl:attribute>
		<xsl:attribute name="href">
		  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data=</xsl:text>
		  <xsl:call-template name="escape-name">
		    <xsl:with-param name="text"><xsl:value-of select="text()"/></xsl:with-param>
		  </xsl:call-template>
		  <xsl:text>&amp;archive=no&amp;pend-inc=pending-fixed&amp;pend-inc=fixed</xsl:text>
		</xsl:attribute>
		<xsl:value-of select="$other/bugs/item[@name=$pkg]/@fixed"/>
	      </xsl:element>)
	    </span>
	  </li>
	</xsl:for-each>
  </ul></td></tr>
</xsl:template>

<xsl:template name="available-versions">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      Available versions
  </td></tr>

  <!-- oldstable -->
  <xsl:if test="$hasoldstable">  
    <tr class="normalrow">
      <td class="labelcell"><a href="http://www.debian.org/releases/sarge/">Oldstable</a></td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/oldstable/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/oldstable.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hasoldstable-security">
    <tr class="normalrow">
      <td class="labelcell"><small>Oldstable Security Updates</small></td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/oldstable-security.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>

  <!-- stable -->
  <xsl:if test="$hasstable">  
    <tr class="normalrow">
      <td class="labelcell"><a href="http://www.debian.org/releases/stable/">Stable</a></td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/stable/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/stable.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hasstable-security">
    <tr class="normalrow">
      <td class="labelcell"><small>Stable Security Updates</small></td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/stable-security.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hass-p-u">  
    <tr class="normalrow">
      <td class="labelcell"><small>Stable Proposed Updates</small></td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/s-p-u.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>

  <!-- testing -->
  <xsl:if test="$hastesting">
    <tr class="normalrow">
      <td class="labelcell"><a href="http://www.debian.org/releases/testing/">Testing</a></td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/testing/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/testing.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hastesting-security">
    <tr class="normalrow">
      <td class="labelcell"><small>Testing Security Updates</small></td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/testing-security.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>
  <xsl:if test="$hast-p-u">
    <tr class="normalrow">
      <td class="labelcell"><small>Testing Proposed Updates</small></td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/t-p-u.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>

  <!-- unstable -->
  <xsl:if test="$hasunstable">
    <tr class="normalrow">
      <td class="labelcell">Unstable</td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/unstable/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/unstable.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>

  <!-- experimental -->
  <xsl:if test="$hasexperimental">
    <tr class="normalrow">
      <td class="labelcell">Experimental</td>
      <td class="contentcell">
        <a href="http://packages.debian.org/source/experimental/{$package}"><xsl:value-of
            select="document(concat('../base/', $dir, '/experimental.xml'))/source/version"/></a>
      </td>
    </tr>
  </xsl:if>

  <!-- secure-testing -->
  <xsl:if test="$hassecure-testing">
    <tr class="normalrow">
      <td class="labelcell">Secure testing</td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/secure-testing.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>

  <!-- volatile -->
  <xsl:if test="$hasvolatile">
    <tr class="normalrow">
      <td class="labelcell">Volatile</td>
      <td class="contentcell">
	<xsl:value-of select="document(concat('../base/', $dir, '/volatile.xml'))/source/version"/>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="patches">
  <!-- Patches list [FG] -->
  <xsl:if test="$other/@patches='yes'">
    <tr class="titlerow">
      <td class="titlecell" colspan="2">
	Patches
    </td></tr>
    <tr>
      <td class="contentcell" colspan="2" style="text-align: left">
	<ul>
	  <xsl:for-each select="$other/patches/item">
	    <li>
	      <a href="{$other/patches/item/@url}">Patch from <xsl:value-of select="$other/patches/item/@distro"/> for version <xsl:value-of select="$other/patches/item/@version"/></a>
	    </li>
	  </xsl:for-each>
	  <xsl:if test="$other/bugs/@patch!='0'">
	    <li>
	      <xsl:element name="a">
		<xsl:attribute name="href">
		  <xsl:text>http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data=</xsl:text>
		  <xsl:call-template name="escape-name">
		    <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
		  </xsl:call-template>
		  <xsl:text>&amp;include=tags:patch&amp;exclude=tags:pending&amp;pend-exc=done</xsl:text>
		</xsl:attribute>
		Patches from BTS (<xsl:value-of select="$other/bugs/@patch"/>)
	      </xsl:element>
	    </li>
	  </xsl:if>
	</ul>
      </td>
    </tr>
  </xsl:if> 
</xsl:template>

<xsl:template name="other-links">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      Other links
  </td></tr>
  <tr>
    <td class="contentcell" colspan="2" style="text-align: left">
      <ul>
        <xsl:if test="homepage">
          <li> <a href="{homepage}">Upstream homepage</a> </li>
        </xsl:if>
	<li>
	  <xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://packages.debian.org/changelogs/</xsl:text>
	      <xsl:value-of select="directory"/>
	      <xsl:text>/current/changelog</xsl:text>
	    </xsl:attribute>
	    <xsl:text>Changelog</xsl:text>
	  </xsl:element>
	  /
	  <xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://packages.debian.org/changelogs/</xsl:text>
	      <xsl:value-of select="directory"/>
	      <xsl:text>/current/copyright</xsl:text>
	    </xsl:attribute>
	    <xsl:text>Copyright</xsl:text>
	  </xsl:element>
	</li>
	<xsl:if test="architecture!='all'">
	  <li>
            <xsl:text>Buildd: </xsl:text>
            <a href="http://buildd.debian.org/pkg.cgi?pkg={$escaped-package}"
              title="buildd.debian.org build logs">logs</a>
            <xsl:text>, </xsl:text>
            <a href="http://people.debian.org/~igloo/status.php?packages={$escaped-package}"
              title="igloo build logs on people.debian.org">more</a>
            <xsl:text>, </xsl:text>
            <a href="http://experimental.debian.net/build.php?pkg={$escaped-package}"
              title="experimental.debian.net build logs">exp</a>
            <xsl:text>, </xsl:text>
            <a href="http://buildd.debian-ports.org/status/package.php?p={$escaped-package}"
              title="debian ports build logs">ports</a>
	  </li>
	</xsl:if>
	<!-- DISABLED until ddtp.debian.org is back up
	<li>
	  <xsl:element name="a">
	    <xsl:attribute name="href">
	      <xsl:text>http://ddtp.debian.org/stats/pdesc/report.cgi?package=</xsl:text>
	      <xsl:call-template name="escape-name">
		<xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
	      </xsl:call-template>
	      <xsl:text>&amp;lang=all&amp;type=src-drvbin&amp;subword=0</xsl:text>
	    </xsl:attribute>
	    Description's translations (DDTP)
	  </xsl:element>
	</li>
	<xsl:if test="$other/@debconf='yes'">
	  <li>
	    <xsl:element name="a">
	      <xsl:attribute name="href">
		<xsl:text>http://ddtp.debian.org/cgi-bin/ddtp.cgi?part=debconf&amp;package=</xsl:text>
		<xsl:call-template name="escape-name">
		  <xsl:with-param name="text"><xsl:value-of select="$package"/></xsl:with-param>
		</xsl:call-template>
	      </xsl:attribute>
	      Debconf templates's translations (DDTP)
	    </xsl:element>
	  </li>
	</xsl:if>
	-->
	<xsl:if test="($hasunstable and $other/debcheck/@unstable='yes')
	  or ($hastesting and $other/debcheck/@testing='yes')
	  or ($hasstable and $other/debcheck/@stable='yes')">
	  <li>
	    Debcheck on:
	    <xsl:if test="$hasunstable">
	      <xsl:text> </xsl:text>
              <a href="http://qa.debian.org/debcheck.php?dist=unstable&amp;package={$escaped-package}">unstable</a>
	    </xsl:if>
	    <xsl:if test="$hastesting">
	      <xsl:text> </xsl:text>
              <a href="http://qa.debian.org/debcheck.php?dist=testing&amp;package={$escaped-package}">testing</a>
	    </xsl:if>
	    <xsl:if test="$hasstable">
	      <xsl:text> </xsl:text>
              <a href="http://qa.debian.org/debcheck.php?dist=stable&amp;package={$escaped-package}">stable</a>
	    </xsl:if>
	  </li>
	</xsl:if>
	<!-- convert maintainer/name to follow lintian.debian.org convention -->
	<xsl:variable name="pattern" select="concat('àáèéëêòöøîìùñ~/()&#34; ', &quot;'&quot;)"/>
	<xsl:variable name="_email" select="translate(maintainer/email, $pattern, '_____________________')"/>
	<li><a href="http://lintian.debian.org/reports/maintainer/{$_email}.html#{$package}">Lintian report</a></li>
	<li>
          <a href="http://qa.debian.org/developer.php?popcon={$escaped-package}">Popcon stats</a>
	</li>
        <xsl:if test="$other/@svnbuildstat='yes'">
          <li>
            <a href="http://svnbuildstat.debian.net/packages/info/{$escaped-package}">Svnbuildstat</a>
          </li>
        </xsl:if>
      </ul>
    </td>
  </tr>
</xsl:template>

<xsl:template name="package-files">
  <tr class="titlerow">
    <td class="titlecell" colspan="2">
      Source package
  </td></tr>
  <tr class="titlerow">
    <td class="labelcell">
      <xsl:element name="a">
	<xsl:attribute name="href">
	  <xsl:call-template name="mirror"/>
	  <xsl:text>/</xsl:text>
	  <xsl:value-of select="directory"/>
	  <xsl:text>/</xsl:text>
	</xsl:attribute>
	<xsl:text>Files</xsl:text>
      </xsl:element>
    </td>
    <td class="contentcell" id="src_files">
      <ul>
	<xsl:for-each select="files/item">
	  <xsl:variable name="filetype">
	    <xsl:call-template name="categorize-srcfile" />
	  </xsl:variable>
	  <xsl:element name="li">
	    <xsl:attribute name="class">srcfile</xsl:attribute>
	    <xsl:if test="string($filetype)!=''">
	      <xsl:attribute name="id">
		<xsl:text>srcfile_</xsl:text>
		<xsl:value-of select="$filetype" />
	      </xsl:attribute>
	    </xsl:if>
	    <xsl:element name="a">
	      <xsl:attribute name="class">srcfile</xsl:attribute>
	      <xsl:attribute name="href">
		<xsl:call-template name="mirror"/>	  
		<xsl:text>/</xsl:text>
		<xsl:value-of select="../../directory"/>
		<xsl:text>/</xsl:text>
		<xsl:value-of select="filename"/>
	      </xsl:attribute>
	      <xsl:attribute name="title">
		<xsl:value-of select="filename" />
		<xsl:text>: </xsl:text>
		<xsl:value-of select="size"/>
		<xsl:text> bytes</xsl:text>
	      </xsl:attribute>
	      <xsl:text>.</xsl:text>
	      <xsl:value-of select="$filetype"/>
	    </xsl:element>
	  </xsl:element>
	</xsl:for-each>
      </ul>
    </td>
  </tr>
</xsl:template>

<xsl:template name="todo-list">
  <xsl:variable name="todo">
    <xsl:if test="@nmu">
      <li>Incorporate and acknowledge the changes from the non maintainer upload.</li>
    </xsl:if>
    <xsl:if test="not(uploaders)and(priority='standard' or priority='required' or priority='important')">
      <li>The package is of priority standard or higher, you should really find some co-maintainers.</li>
    </xsl:if>
    <xsl:if test="not(starts-with(standards-version, $lastsv))">
      <li>The package should be updated to follow the last version of
	<a href="http://www.debian.org/doc/debian-policy/">Debian Policy</a> (Standards-Version 
	<xsl:value-of select="$lastsv"/> instead of 
	<xsl:value-of select="standards-version"/>).</li>
    </xsl:if>
    <xsl:if test="$hasother">
      <xsl:for-each select="$other/todo/item">
	<xsl:call-template name="outputitem"/>
      </xsl:for-each>
      <xsl:if test="$other[dehs/@newer]">
	<li>A new upstream version is available:
          <a href="http://dehs.alioth.debian.org/maintainer.php?name={$escaped-package}"><xsl:value-of select="$other/dehs/@newer"/></a>,
          you should consider packaging it.</li>
      </xsl:if>
      <xsl:if test="$other/bugs/@patch!='0'">
	<li>The Bug Tracking System contains
          <a href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data={$escaped-package}&amp;include=tags:patch&amp;exclude=tags:pending&amp;pend-exc=done">patches fixing
	    <xsl:value-of select="$other/bugs/@patch"/> bug<xsl:if test="$other/bugs/@patch!='1'">s</xsl:if>
          </a>, you should include
	  <xsl:if test="$other/bugs/@patch!='1'">them</xsl:if>.
	</li>
      </xsl:if>
    </xsl:if>
  </xsl:variable>
  <xsl:if test="count($todo)>0 and string($todo)!=''">  
    <tr class="titlerow">
      <td class="titlecell" id="todo">
	Todo
    </td></tr>
    <tr class="normalrow">
      <td class="contentcell2">
	<ul>
	  <xsl:copy-of select="$todo"/>
	</ul>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="problems">
  <xsl:variable name="problems">
    <xsl:if test="$hasexcuse and document(concat('../base/', $dir, '/excuse.xml'))/excuse/@problematic">
      <li>The package has not yet entered <a
	  href="http://ftp-master.debian.org/testing/update_excuses.html.gz#{$package}">testing</a>
	even though the <xsl:value-of select="document(concat('../base/', $dir, '/excuse.xml'))/excuse/@limit"/>-day
	delay is over.
        <a href="http://release.debian.org/migration/testing.pl?package={$escaped-package}">Check why</a>.</li>
    </xsl:if>
    <xsl:if test="not(starts-with(standards-version, $lastmajorsv))">
      <li>The package is severly out of date with respect to the Debian
	Policy. Latest version is <xsl:value-of select="$lastsv"/>
	and your package only follows
	<xsl:value-of select="standards-version"/>...</li>
    </xsl:if>
    <xsl:if test="@release!='unstable' and @release!='experimental'">
      <li>This package is neither part of unstable nor experimental. This
	probably means that the package <a
	  href="http://ftp-master.debian.org/removals.txt">has been removed</a> (or
	has been renamed). Thus the information here is of little interest ...
	the package is going to disappear unless someone takes it over and
	reintroduces it into unstable.</li>
    </xsl:if>
    <xsl:if test="$hasother">

      <!-- Override disparity handling. [JvW] -->
      <xsl:if test="$other/@override='yes'">
	<xsl:for-each select="$other/override/group">
	  <li>There were override disparities found in suite <xsl:value-of
	      select="@suite"/>:
	    <ul>
	      <xsl:for-each select="disparity">
		<li><xsl:value-of select="text()"/></li>
	      </xsl:for-each>
	    </ul>
	  </li>
	</xsl:for-each>
      </xsl:if>

      <!-- Wnpp handling. [PvR] -->
      <xsl:if test="$other/@wnpp='yes'">
	<li>
	  <xsl:choose>
	    <xsl:when test="$other/wnpp/@type='O'">
	      <xsl:choose>
		<xsl:when test="@release!='unstable' and @release!='experimental'">
		  The WNPP database contains an O (Orphaned) entry for
		  this package. This is probably an error, as it is neither part of
		  unstable nor experimental.
		</xsl:when>
		<xsl:otherwise>
		  <span style="font-weight: bold">This package has been orphaned</span>. 
		  This means that it does not have a real maintainer at the
		  moment. Please consider adopting this package if you are interested in it.
		</xsl:otherwise>
	      </xsl:choose>
	    </xsl:when>
	    <xsl:when test="$other/wnpp/@type='ITA'">
	      <xsl:choose>
		<xsl:when test="@release!='unstable' and @release!='experimental'">
		  The WNPP database contains an ITA (Intent To Adopt) entry for
		  this package. This is probably an error, as it is neither part of
		  unstable nor experimental.
		</xsl:when>
		<xsl:otherwise>
		  This package has been orphaned, but someone intends to maintain it.
		</xsl:otherwise>
	      </xsl:choose>
	    </xsl:when>
	    <xsl:when test="$other/wnpp/@type='RFA'">
	      <xsl:choose>
		<xsl:when test="@release!='unstable' and @release!='experimental'">
		  The WNPP database contains an RFA (Request For Adoption) entry for
		  this package. This is probably an error, as it is neither part of
		  unstable nor experimental.
		</xsl:when>
		<xsl:otherwise>
		  The current maintainer is looking for someone who can take over
		  maintenance of this package. If you are interested in this package,
		  please consider taking it over. Alternatively you may
		  want to be co-maintainer in order to help the actual maintainer.
		</xsl:otherwise>
	      </xsl:choose>
	    </xsl:when>
	    <xsl:when test="$other/wnpp/@type='RFH'">
	      <xsl:choose>
		<xsl:when test="@release!='unstable' and @release!='experimental'">
		  The WNPP database contains an RFH (Request For Help) entry for
		  this package. This is probably an error, as it is neither part of
		  unstable nor experimental.
		</xsl:when>
		<xsl:otherwise>
		  The current maintainer is looking for someone who can help with the
		  maintenance of this package. If you are interested in this package,
		  please consider helping out. One way you can help is offer to be a
		  co-maintainer or triage bugs in the bts.
		</xsl:otherwise>
	      </xsl:choose>
	    </xsl:when>
	    <xsl:when test="$other/wnpp/@type='ITP'">
	      <xsl:choose>
		<xsl:when test="@release!='unstable' and @release!='experimental'">
		  The WNPP database contains an ITP (Intent To Package). This probably
		  means that somebody is going to reintroduce this package into unstable.
		</xsl:when>
		<xsl:otherwise>
		  The WNPP database contains an ITP (Intent To Package) entry for
		  this package. This is probably an error, as it has already been
		  packaged.
		</xsl:otherwise>
	      </xsl:choose>
	    </xsl:when>
	    <xsl:when test="$other/wnpp/@type='RFP'">
	      <xsl:choose>
		<xsl:when test="@release!='unstable' and @release!='experimental'">
		  The WNPP database contains an RFP (Request For Package). This probably
		  means that somebody would like to see this package reintroduced into
		  unstable by a volunteer.
		</xsl:when>
		<xsl:otherwise>
		  The WNPP database contains an RFP (Request For Package) entry
		  for this package.  This is probably an error, as it has already
		  been packaged.
		</xsl:otherwise>
	      </xsl:choose>
	    </xsl:when>
	    <xsl:when test="$other/wnpp/@type='RM'">
	      <span style="font-weight: bold">This package has been requested to be
		removed</span>. 
	      This means that, when this request gets processed by an ftp-master, this
	      package will no longer be in unstable, and will automatically be removed
	      from testing too afterwards. If for some reason you want keep this
	      package in unstable, please discuss so in the bug.
	    </xsl:when>
	    <xsl:otherwise>
	      The WNPP database contains an entry for this package, 
	      but it is unclear what kind of entry it is. This is probably an error.
	    </xsl:otherwise>
	  </xsl:choose>
	  <xsl:variable name="bn" select="$other/wnpp/@bugnumber"/>
	  Please see bug number <a href="http://bugs.debian.org/{$bn}">
	    #<xsl:value-of select="$bn"/></a> for more information.
	</li>
      </xsl:if>

      <!-- disable watch rendering, see above -->
      <!--
      <xsl:if test="$other/@watch='yes'">
	<li>
	  <xsl:if test="$other/watch/@warning!=''">
	    uscan had problems while searching for a new upstream version: <xsl:value-of select="$other/watch/@warning"/>
	  </xsl:if>
	</li>
      </xsl:if>
      -->
      <xsl:if test="$other[dehs/@error]">
        <li>The package has a <kbd>debian/watch</kbd> file, but the last
          attempt to use it for checking for newer upstream versions failed
          with
          <a href="http://dehs.alioth.debian.org/maintainer.php?name={$escaped-package}">an
            error</a>.</li>
      </xsl:if>

      <!-- Misc problems reported -->
      <xsl:for-each select="$other/problems/item">
	<xsl:call-template name="outputitem"/>
      </xsl:for-each>
    </xsl:if>
  </xsl:variable>
  <xsl:if test="count($problems)>0 and string($problems)!=''">
    <tr class="titlerow">
      <td class="titlecell" id="problems">
	Problems
    </td></tr>
    <tr class="normalrow">
      <td class="contentcell2">
	<ul><xsl:copy-of select="$problems"/></ul>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="testing-status">
  <xsl:if test="$hasexcuse">
    <tr class="titlerow">
      <td class="titlecell">
	Testing status
    </td></tr>
    <tr class="normalrow">
      <td class="contentcell2" style="text-align: left">
	<ul>
	  <xsl:for-each select="document(concat('../base/', $dir, '/excuse.xml'))/excuse/item">
	    <xsl:call-template name="outputitem"/>
	  </xsl:for-each>
	</ul>
      </td>
    </tr>
  </xsl:if>
</xsl:template>

<xsl:template name="static-info">
  <xsl:call-template name="output-static">
    <xsl:with-param name="static" select="$static" />
  </xsl:call-template>
</xsl:template>

<xsl:template name="latest-news">
  <xsl:call-template name="output-news">
    <xsl:with-param name="news" select="$news" />
  </xsl:call-template>
</xsl:template>

<xsl:variable name="static">
  <xsl:if test="$hasnews">
    <xsl:for-each select="document(concat('../base/', $dir, '/news.xml'))/news/static/item">
      <xsl:call-template name="outputitem"/>
    </xsl:for-each>
  </xsl:if>
</xsl:variable>

<xsl:variable name="news">
  <xsl:if test="$hasnews">
    <xsl:for-each select="document(concat('../base/', $dir, '/news.xml'))/news/news/item">
      <xsl:call-template name="outputitem"/>
    </xsl:for-each>
  </xsl:if>
</xsl:variable>

<!-- All the work is done in a single template -->
<xsl:template match="source">

  <!-- Start of html -->
  <xsl:text disable-output-escaping="yes">
  &lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"&gt;
  </xsl:text>
  <html>
  <head>
  <meta name="ROBOTS" content="NOFOLLOW"/>
  <link type="text/css" title="User selected" rel="stylesheet" href="../common/default.css"/>
  <link type="text/css" title="Official" rel="alternate stylesheet" href="../common/revamp.css"/>
  <link type="text/css" title="Legacy PTS" rel="alternate stylesheet" href="../common/pts.css"/>
  <link type="text/css" title="Compact rendering" rel="alternate stylesheet" href="../common/compact.css"/>
  <script type="text/javascript" src="../common/pts.js"></script>
  <xsl:if test="count($news)>0 and string($news)!=''">
    <link rel="alternate" type="application/rss+xml" title="RSS"
      href="{$package}/news.rss20.xml" />
  </xsl:if>
  <title>Overview of <xsl:value-of select="$package"/> source package</title>
  </head>
  <body onload="javascript:onLoad();">
  
  <div id="quickforms" style="float: right;">
  <form method="get" action="/common/index.html">
  <p><span title="Jump to package">Go:</span> 
  <input type="text" name="src" value=""/></p>
  </form>
  <form id="csspref-form" method="get" action="/common/set-csspref.php">
  <p>Switch style: <select name="csspref" onchange="javascript:onChangeStyle();">
  <option value="revamp.css">Default</option>
  <option value="compact.css">Compact</option>
  <option value="pts.css">Legacy</option>
  </select></p>
  </form>
  
  </div>
  <h1>Overview of
  <xsl:element name="a">
    <xsl:attribute name="href">
      <xsl:text>http://packages.debian.org/src:</xsl:text>
       <xsl:value-of select="$package"/>
    </xsl:attribute>
   <xsl:value-of select="$package"/>
  </xsl:element>
  source package</h1>

  <div id="body">
  <xsl:choose>
  <xsl:when test="$removed='yes'">
  <!-- REMOVED PACKAGE -->
  <p>This package is not part of any Debian distribution. Thus you won't
  find much information here. The package is either very new and hasn't
  appeared on mirrors yet, or it's an old package that eventually got removed.
  The old news are kept for historic purpose only.</p>

  <table class="righttable">
    <xsl:call-template name="static-info" />
    <xsl:call-template name="latest-news" />
  </table>

  <!-- END REMOVED PACKAGE -->
  </xsl:when>
  <xsl:otherwise>
  <!-- NON REMOVED PACKAGE -->
    
  <table class="containertable">
  <tr class="containerrow" valign="top">
  <td class="containercell">
  <!-- LEFT SIDE -->
  <table class="lefttable">
    <xsl:call-template name="general-information" />
    <xsl:call-template name="available-versions" />
  </table>
  <table class="lefttable">
    <xsl:call-template name="package-files" />
    <xsl:call-template name="binary-packages" />
  </table>
  <!-- END LEFT SIDE -->
  </td><td class="containercell">
  <!-- RIGHT SIDE -->
  <table class="righttable">
    <xsl:call-template name="todo-list" />
    <xsl:call-template name="problems" />
  </table>
  <table class="righttable">
    <xsl:call-template name="testing-status" />
    <xsl:call-template name="static-info" />
    <xsl:call-template name="latest-news" />
  </table>
  <!-- END RIGHT SIDE -->
  </td><td class="containercell">
  <table class="lefttable">
    <xsl:call-template name="bugs-count" />
    <xsl:call-template name="pts-subscription" />
  </table>
  <table class="lefttable">
    <xsl:call-template name="patches" />
  </table>
  <table class="lefttable">
    <xsl:call-template name="other-links" />
  </table>
  </td></tr>
  </table>

  <!-- END NON REMOVED PACKAGE -->
  </xsl:otherwise>
  </xsl:choose>

  <hr/>
  <div class="footer">
    <p>
      <a href="http://www.debian.org">Debian</a> Package Tracking System -
      Copyright 2002-2008 Raphaël Hertzog and others.<br/>
      Report problems to the <a href="http://bugs.debian.org/qa.debian.org"
	><tt>qa.debian.org</tt> pseudopackage</a> in the <a
	href="http://bugs.debian.org">Debian <acronym title="Bug Tracking
	  System">BTS</acronym></a>.<br/>
      Last modified : <xsl:value-of select="$date"/>.
    </p>
  </div>
  </div>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
