<?xml version="1.0"?>
<!--
  torrentdb - Copyright (C) 2004 - r00t
  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2, or (at your option)
  any later version.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xsl:version="1.0">

  <!-- store for later use -->
  <xsl:variable name="time" select="torrentdb/time"/>

  <xsl:template match="desc">
    <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
    <xsl:apply-templates mode="copy"/>
    <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  </xsl:template>

  <!-- template for copying nodes to output, usually for html -->
  <xsl:template match="*" mode="copy">
    <xsl:copy-of select="."/>
  </xsl:template>

  <!-- output list of torrents -->
  <xsl:template match="torrents">
      <xsl:for-each select="torrent">
        <item>
	  <title><xsl:value-of select="name"/> (<xsl:number value="size" grouping-size="3" grouping-separator="."/> bytes<xsl:if test="updated"><xsl:if test="seeds">, <xsl:value-of select="seeds"/>/<xsl:value-of select="peers"/>(seeds/peers), updated<xsl:value-of select="format-number(($time - updated) div 60 ,'#')"/> mins ago</xsl:if><xsl:if test="not(seeds) and status"><xsl:value-of select="status"/>, <xsl:value-of select="format-number(($time - updated) div 60 ,'#')"/> mins ago</xsl:if></xsl:if><xsl:if test="not(updated)"></xsl:if>) </title>
	  <link><xsl:value-of select="link"/></link>
	  <pubDate><xsl:value-of select="date"/></pubDate>
        </item>
	
      </xsl:for-each>
  </xsl:template>
 
  <!-- MAIN -->
  <xsl:template match="/torrentdb">
    <rss version="2.0">
    <channel>
    <title><xsl:value-of select="name"/></title>
    <link><xsl:value-of select="link"/></link>
    <description><xsl:apply-templates select="desc"/></description>
    <language>en-us</language>
    <copyright>none, public domain</copyright>
    <xsl:apply-templates select="torrents"/>
    </channel>
    </rss>
  </xsl:template>
  
  <xsl:template match="*">
    <xsl:comment>
      warning, default template was used
    </xsl:comment>
  </xsl:template>



</xsl:stylesheet>
