<?xml version="1.0" encoding="ISO-8859-1" ?>

<!--
# Copyright 2002 Raphaël Hertzog
# 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="ISO-8859-1" method="html"/>

<xsl:param name="package"/>
<xsl:param name="dir"/>
<xsl:param name="date"/>
<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="hasstable-security" select="''"/>
<xsl:param name="hastesting-security" select="''"/>
<xsl:param name="hasnews" select="''"/>
<xsl:param name="hasexcuse" select="''"/>

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

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

<!-- Named templates aka functions -->
<xsl:template name="mirror">
  <xsl:choose>
    <xsl:when test="contains(source/section, 'non-US')">
      <xsl:text>http://non-us.debian.org/debian-non-US</xsl:text>  
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>http://http.us.debian.org/debian</xsl:text>  
    </xsl:otherwise>
  </xsl:choose>
</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></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>

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

  <!-- Start of html -->
  <html>
  <head>
  <meta name="ROBOTS" content="NOFOLLOW"/>
  <link rel="stylesheet" href="../common/pts.css"/>
  <title>Overview of <xsl:value-of select="$package"/> source package</title>
  </head>
  <body>
  
  <form method="get" action="/common/index.html" style="float: right;">
  Jump to package : <br/>
  <input type="text" name="src" value=""/>
  </form>
  <h1>Overview of <xsl:value-of select="$package"/> source package</h1>

  <table class="containertable">
  <tr class="containerrow" valign="top">
  <td class="containercell">
  <!-- LEFT SIDE -->
  <table class="lefttable">
  <tr class="titlerow">
  <td class="titlecell" colspan="2">
  General Information
  </td></tr>
  <tr class="normalrow">
  <td class="labelcell">Last 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"><a class="email" href="http://qa.debian.org/developer.php?login={maintainer/email}">
  <xsl:value-of select="maintainer/name"/></a> [<a class="email" href="mailto:{maintainer/email}">mail</a>]</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">Co-Maintainers</a></td>
  <td class="contentcell">
  <xsl:if test="uploaders">
    <xsl:for-each select="uploaders/item">
      <a class="email" href="http://qa.debian.org/developer.php?login={email}"><xsl:value-of select="name"/></a> [<a class="email" href="mailto:{email}">mail</a>]<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>
  </td></tr>
  <tr class="normalrow">
  <td class="labelcell">Standards-Version</td>
  <td class="contentcell"><xsl:value-of select="standards-version"/></td>
  </tr>
  
  <tr class="titlerow">
  <td class="titlecell" colspan="2">
  Bugs Count
  </td></tr>
  <tr class="normalrow">
  <td class="labelcell">All bugs</td>
  <td class="contentcell">
  <a href="http://bugs.debian.org/src:{$package}"><xsl:if test="$hasother">
    <xsl:value-of select="$other/bugs/@all"/>
  </xsl:if></a>
  </td>
  </tr>
  <tr class="normalrow">
  <td class="labelcell">Release Critical</td>
  <td class="contentcell">
  <a href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data={$package}&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:if test="$hasother">
    <xsl:value-of select="$other/bugs/@rc"/>
  </xsl:if></a>
  </td>
  </tr>
  <tr class="normalrow">
  <td class="labelcell">Important and Normal</td>
  <td class="contentcell">
  <a href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data={$package}&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:if test="$hasother">
    <xsl:value-of select="$other/bugs/@normal"/>
  </xsl:if></a>
  </td>
  </tr>
  <tr class="normalrow">
  <td class="labelcell">Minor and Wishlist</td>
  <td class="contentcell">
  <a href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data={$package}&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:if test="$hasother">
    <xsl:value-of select="$other/bugs/@wishlist"/>
  </xsl:if></a>
  </td>
  </tr>
  <tr class="normalrow">
  <td class="labelcell">Fixed and Pending</td>
  <td class="contentcell">
  <a href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=src&amp;data={$package}&amp;archive=no&amp;pend-inc=pending-fixed&amp;pend-inc=fixed"><xsl:if test="$hasother">
    <xsl:value-of select="$other/bugs/@fixed"/>
  </xsl:if></a>
  </td>
  </tr>

  <tr class="titlerow">
  <td class="titlecell" colspan="2">
  Subscription - <a class="titlelink" href="http://www.debian.org/doc/manuals/developers-reference/ch-resources.en.html#s-pkg-tracking-system">Package Tracking System</a>
  </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">
    <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"/>
  </form>
  </td>
  </tr>

  <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">
  <xsl:for-each select="binary/item">
    <xsl:sort select="text()"/>
    <xsl:variable name="pkg" select="text()"/>
    <li>
    <a 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>: 
  <a title="critical, grave and serious" href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data={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:value-of select="$other/bugs/item[@name=$pkg]/@rc"/></a>,
  <a title="important and normal" href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data={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:value-of select="$other/bugs/item[@name=$pkg]/@normal"/></a>,
  <a title="wishlist and minor" href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data={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:value-of select="$other/bugs/item[@name=$pkg]/@wishlist"/></a>,
  <a title="pending and fixed" href="http://bugs.debian.org/cgi-bin/pkgreport.cgi?which=pkg&amp;data={text()}&amp;archive=no&amp;pend-inc=pending-fixed&amp;pend-inc=fixed"><xsl:value-of select="$other/bugs/item[@name=$pkg]/@fixed"/></a>)
    </span>
    </li>
  </xsl:for-each>
  </td></tr>

  <tr class="titlerow">
  <td class="titlecell" colspan="2">
  Other available versions
  </td></tr>
  <xsl:if test="$hasexperimental">
  <tr class="normalrow">
  <td class="labelcell">Experimental</td>
  <td class="contentcell">
  <xsl:value-of select="document(concat('../base/', $dir, '/experimental.xml'))/source/version"/>
  </td>
  </tr>
  </xsl:if>
  <xsl:if test="$hasstable-security">
  <tr class="normalrow">
  <td class="labelcell">Security Updates (stable)</td>
  <td class="contentcell">
  <xsl:value-of select="document(concat('../base/', $dir, '/stable-security.xml'))/source/version"/>
  </td>
  </tr>
  </xsl:if>
  <xsl:if test="$hastesting-security">
  <tr class="normalrow">
  <td class="labelcell">Security Updates (testing)</td>
  <td class="contentcell">
  <xsl:value-of select="document(concat('../base/', $dir, '/testing-security.xml'))/source/version"/>
  </td>
  </tr>
  </xsl:if>
  <xsl:if test="$hastesting">
  <tr class="normalrow">
  <td class="labelcell">Testing</td>
  <td class="contentcell">
  <xsl:value-of select="document(concat('../base/', $dir, '/testing.xml'))/source/version"/>
  </td>
  </tr>
  </xsl:if>
  <xsl:if test="$hast-p-u">
  <tr class="normalrow">
  <td class="labelcell">Testing Proposed Updates</td>
  <td class="contentcell">
  <xsl:value-of select="document(concat('../base/', $dir, '/t-p-u.xml'))/source/version"/>
  </td>
  </tr>
  </xsl:if>
  <xsl:if test="$hasstable">  
  <tr class="normalrow">
  <td class="labelcell">Stable</td>
  <td class="contentcell">
  <xsl:value-of select="document(concat('../base/', $dir, '/stable.xml'))/source/version"/>
  </td>
  </tr>
  </xsl:if>
  <xsl:if test="$hass-p-u">  
  <tr class="normalrow">
  <td class="labelcell">Stable Proposed Updates</td>
  <td class="contentcell">
  <xsl:value-of select="document(concat('../base/', $dir, '/s-p-u.xml'))/source/version"/>
  </td>
  </tr>
  </xsl:if>
 
  <tr class="titlerow">
  <td class="titlecell" colspan="2">
  Other links
  </td></tr>
  <tr>
  <td class="contentcell" colspan="2" style="text-align: left">
  <xsl:if test="architecture!='all'">
    <li><a href="http://buildd.debian.org/build.php?pkg={$package}">Buildd logs</a></li>
  </xsl:if>
    <li><a href="http://ddtp.debian.org/cgi-bin/ddtp.cgi?part=pdesc&amp;package={$package}">Description's translations (DDTP)</a></li>
  <xsl:if test="$other/@debconf='yes'">
    <li><a href="http://ddtp.debian.org/cgi-bin/ddtp.cgi?part=debconf&amp;package={$package}">Debconf templates's translations (DDTP)</a></li>
  </xsl:if>
  <xsl:if test="$hasunstable and $other/debcheck/@unstable='yes'">
    <li><a href="http://qa.debian.org/debcheck.php?dist=unstable&amp;package={$package}">Debcheck on unstable</a></li>
  </xsl:if>
  <xsl:if test="$hastesting and $other/debcheck/@testing='yes'">
    <li><a href="http://qa.debian.org/debcheck.php?dist=testing&amp;package={$package}">Debcheck on testing</a></li>
  </xsl:if>
  <xsl:if test="$hasstable and $other/debcheck/@stable='yes'">
    <li><a href="http://qa.debian.org/debcheck.php?dist=stable&amp;package={$package}">Debcheck on stable</a></li>
  </xsl:if>
  </td>
  </tr>

  <tr class="titlerow">
  <td class="titlecell" colspan="2">
  <xsl:element name="a">
    <xsl:attribute name="class">
      <xsl:text>titlelink</xsl:text>
    </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:attribute>
    <xsl:text>Source files</xsl:text>
  </xsl:element>
  </td></tr>
  <tr class="normalrow">
  <td class="normalcell" colspan="2" style="text-align: left">
  <xsl:for-each select="files/item">
    <li>
    <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="size"/>
	<xsl:text> bytes</xsl:text>
      </xsl:attribute>
      <xsl:value-of select="filename"/>
    </xsl:element>
    </li>
  </xsl:for-each>
  </td></tr>
 
  </table>
  <!-- END LEFT SIDE -->
  </td><td class="containercell">
  <!-- RIGHT SIDE -->
  <table class="righttable">


  <!-- 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>You should update the package to follow the last version of
      Debian Policy (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>
  </xsl:variable>
  <xsl:if test="count($todo)>0 and string($todo)!=''">  
  <tr class="titlerow">
  <td class="titlecell" style="background-color: blue">
  Todo
  </td></tr>
  <tr class="normalrow">
  <td class="contentcell2"><xsl:copy-of select="$todo"/>
  </td>
  </tr>
  </xsl:if>
  
  <!-- List of 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#{$package}">testing</a>
      even though the <xsl:value-of select="document(concat('../base/', $dir, '/excuse.xml'))/excuse/@limit"/>-day
      delay is over.</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="$hasother">
      <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" style="background-color: red">
  Problems
  </td></tr>
  <tr class="normalrow">
  <td class="contentcell2"><xsl:copy-of select="$problems"/>
  </td>
  </tr>
  </xsl:if>

  <xsl:if test="$hasexcuse">
  <tr class="titlerow">
  <td class="titlecell">
  Testing Status
  </td></tr>
  <tr class="normalrow">
  <td class="contentcell2" style="text-align: left">
  <xsl:for-each select="document(concat('../base/', $dir, '/excuse.xml'))/excuse/item">
    <xsl:call-template name="outputitem"/>
  </xsl:for-each>
  </td>
  </tr>
  </xsl:if>
  
  
  <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:if test="count($static)>0 and string($static)!=''">
    <tr class="titlerow">
    <td class="titlecell">
    Static Information
    </td></tr>
    <tr class="normalrow">
    <td class="contentcell2"><xsl:copy-of select="$static"/></td>
    </tr>
  </xsl:if>
  
  <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>
  <xsl:if test="count($news)>0 and string($news)!=''">
    <tr class="titlerow">
    <td class="titlecell">
    Latest News
    </td></tr>
    <tr class="normalrow">
    <td class="contentcell2"><xsl:copy-of select="$news"/></td>
    </tr>
  </xsl:if>

  </table>
  <!-- END RIGHT SIDE -->
  </td></tr>
  </table>
  Warning: the "Latest News" section is not yet automatically updated. I'm waiting
  that master.debian.org is upgraded to woody (stable) in order to be able
  to setup the required scripts. Those scripts will automatically update the
  "Latest News" and they'll let you add your own news items. Please be patient.
  <hr/>
  Debian Package Tracking System - Copyright 2002 Raphaël Hertzog<br/>
  Last modified : <xsl:value-of select="$date"/>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>
