(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 21 Mar 2006 15:40:27 +0000 (15:40 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 21 Mar 2006 15:40:27 +0000 (15:40 +0000)
crawler/kiss/conf/kiss/programs.xml
crawler/kiss/conf/kiss/reportToHtml.xsl [new file with mode: 0644]
crawler/kiss/conf/kiss/reportToText.xsl [new file with mode: 0644]
crawler/kiss/conf/kiss/utilities.xsl

index ec1355fc8c246e402a41ea2938acfea46f84c826..b99436fe92daca5f9166cb844c5697abe8527f66 100644 (file)
@@ -1,5 +1,19 @@
 <programs>
   
+  <notification>
+    <from>erik@brakkee.org</from>
+    <to>erik@brakkee.org</to>
+    <subject>KiSS Crawler Update</subject>
+    <smtp>
+      <host>falcon</host>
+      <port>25</port>
+    </smtp>
+    <format>
+      <html>reportToHtml.xsl</html>
+      <text>reportToText.xsl</text>
+    </format>
+  </notification>
+  
   <program>
     <category>horror</category>
     <action>notify</action>
diff --git a/crawler/kiss/conf/kiss/reportToHtml.xsl b/crawler/kiss/conf/kiss/reportToHtml.xsl
new file mode 100644 (file)
index 0000000..f3901ea
--- /dev/null
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+
+    <xsl:template match="report">
+        <html>
+            <head>
+                <title>KiSS crawler report</title>
+            </head>
+            <body>
+                <h1>KiSS crawler report</h1>
+                <xsl:apply-templates select="recorded"/>
+                <xsl:if test="count(interesting) > 0">
+                    <h2>Possibly interesting programs</h2>
+                    <xsl:apply-templates select="interesting"/>
+                </xsl:if>
+                <xsl:if test="count(//program) = 0">
+                    <xsl:text>No suitable programs found </xsl:text>
+                </xsl:if>
+            </body>
+        </html>
+
+    </xsl:template>
+
+    <xsl:template name="programTable">
+        <table align="left" cellpadding="5">
+            <!-- 
+            <tr align="left">
+                <th align="left">Time</th>
+                <th align="left">Channel</th>
+                <th align="left">Program</th>
+            </tr>
+            -->
+            <xsl:apply-templates select="program"/>
+        </table>
+        <br clear="left"/>
+    </xsl:template>
+
+    <xsl:template match="recorded">
+        <h2>
+            <xsl:choose>
+                <xsl:when test="@result = 'OK'">
+                    <xsl:text>Successfully recorded programs </xsl:text>
+                </xsl:when>
+                <xsl:when test="@result = 'DUPLICATE'">
+                    <xsl:text>Already recorded programs</xsl:text>
+                </xsl:when>
+                <xsl:when test="@result='ERROR'">
+                    <xsl:text>Programs that could not be recorded for
+                    technical reasons.</xsl:text>
+                </xsl:when>
+            </xsl:choose>
+        </h2>
+        <p>
+            <xsl:call-template name="programTable"/>
+        </p>
+    </xsl:template>
+
+    <xsl:template name="addProgramInfo">
+        <tr align="left">
+            <td><xsl:value-of select="interval/begin"/> - <xsl:value-of select="interval/end"/>: <strong>
+                    <xsl:value-of select="name"/>
+                </strong> (<xsl:value-of select="channel"/>/<xsl:value-of select="keywords"/>)</td>
+
+        </tr>
+        <tr>
+            <td>
+                <blockquote>
+                        <font size="-1">
+                            <xsl:value-of select="description"/>
+                        </font>
+                </blockquote>
+            </td>
+
+
+        </tr>
+    </xsl:template>
+
+    <xsl:template match="program">
+        <xsl:call-template name="addProgramInfo"/>
+    </xsl:template>
+
+    <xsl:template match="interesting">
+        <xsl:call-template name="programTable"/>
+        <xsl:apply-templates select="category"/>
+    </xsl:template>
+
+    <xsl:template match="category">
+        <h3>Category: <xsl:value-of select="@name"/></h3>
+        <xsl:call-template name="programTable"/>
+    </xsl:template>
+</xsl:stylesheet>
+
diff --git a/crawler/kiss/conf/kiss/reportToText.xsl b/crawler/kiss/conf/kiss/reportToText.xsl
new file mode 100644 (file)
index 0000000..bb5fba2
--- /dev/null
@@ -0,0 +1,96 @@
+<?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:include href="utilities.xsl"/>
+  <xsl:template match="report">
+    <xsl:text>KiSS crawler report</xsl:text>
+    <xsl:value-of select="$newline"/>
+    <xsl:value-of select="$newline"/>
+    
+    <xsl:apply-templates select="recorded"/>
+    <xsl:if test="count(interesting) > 0">
+      <xsl:text>Possibly interesting programs</xsl:text>
+      <xsl:value-of select="$newline"/>
+      <xsl:value-of select="$newline"/>
+      
+      <xsl:apply-templates select="interesting"/>
+    </xsl:if>
+  </xsl:template>
+  
+  <xsl:template name="programTable">
+    <xsl:apply-templates select="program"/>
+  </xsl:template>
+  <xsl:template match="recorded">
+    <xsl:choose>
+      <xsl:when test="@result = 'OK'">
+        <xsl:text>Successfully recorded programs </xsl:text>
+        <xsl:value-of select="$newline"/>
+        <xsl:value-of select="$newline"/>
+      </xsl:when>
+      <xsl:when test="@result = 'DUPLICATE'">
+        <xsl:text>Already recorded programs</xsl:text>
+        <xsl:value-of select="$newline"/>
+        <xsl:value-of select="$newline"/>
+      </xsl:when>
+      <xsl:when test="@result='ERROR'">
+        <xsl:text>Programs that could not be recorded for technical reasons.</xsl:text>
+        <xsl:value-of select="$newline"/>
+        <xsl:value-of select="$newline"/>
+      </xsl:when>
+    </xsl:choose>
+    
+    <xsl:call-template name="programTable"/>
+    
+  </xsl:template>
+  
+  <xsl:template name="addProgramInfo">
+    <xsl:text>*</xsl:text>
+    <xsl:value-of select="interval/begin"/> - <xsl:value-of select="interval/end"/>
+    <xsl:text>: </xsl:text>
+    <xsl:value-of select="name"/>
+    <xsl:text>(</xsl:text>
+    <xsl:value-of select="channel"/>
+    <xsl:text>/</xsl:text><xsl:value-of select="keywords"/>
+    <xsl:text>)</xsl:text>
+    <xsl:value-of select="$newline"/> 
+    <xsl:variable name="indent">
+      <xsl:text>    </xsl:text>
+    </xsl:variable>
+    <xsl:call-template name="indent">
+      <xsl:with-param name="src">
+        <xsl:call-template name="word-wrap">
+          <xsl:with-param name="src"><xsl:value-of select="description"/></xsl:with-param>
+          <xsl:with-param name="width"><xsl:value-of select="72"/></xsl:with-param>
+        </xsl:call-template>    
+      </xsl:with-param>
+      <xsl:with-param name="indentString">
+        <xsl:text>    </xsl:text>
+      </xsl:with-param>
+      
+    </xsl:call-template>
+    
+    <!-- 
+    <xsl:value-of select="$indent"/>
+    <xsl:call-template name="string-replace">
+      <xsl:with-param name="src"><xsl:value-of select="description"/></xsl:with-param>
+      <xsl:with-param name="from"><xsl:value-of select="$newline"/></xsl:with-param>
+      <xsl:with-param name="to"><xsl:value-of select="$newline"/><xsl:value-of select="$indent"/></xsl:with-param>
+    </xsl:call-template>
+      -->
+    <xsl:value-of select="$newline"/>
+    <xsl:value-of select="$newline"/>  
+  </xsl:template>
+  
+  <xsl:template match="program">
+    <xsl:call-template name="addProgramInfo"/>
+  </xsl:template>
+  <xsl:template match="interesting">
+    <xsl:call-template name="programTable"/>
+    <xsl:apply-templates select="category"/>
+  </xsl:template>
+  <xsl:template match="category">
+    <xsl:text>Category: </xsl:text><xsl:value-of select="@name"/>
+    <xsl:call-template name="programTable"/>
+  </xsl:template>
+</xsl:stylesheet>
index 04e4c6867de8d65bf3df096b275c645e92156f70..4e465a0a32bab3fc8b44faf7580d558848c56d97 100644 (file)
@@ -12,7 +12,7 @@
   <xsl:variable name="carriageReturn">
     <xsl:text>&#13;&#10;</xsl:text>
   </xsl:variable>
-
+  
   <!-- =====================================================
     Replace one string by another
     - src: string to do substituion in
     </xsl:choose>
   </xsl:template>
   
+  <xsl:template name="indent">
+    <xsl:param name="src"/>
+    <xsl:param name="indentString"/>
+    <xsl:value-of select="$indentString"/>
+    <xsl:call-template name="string-replace">
+      <xsl:with-param name="src"><xsl:value-of select="$src"/></xsl:with-param>
+      <xsl:with-param name="from"><xsl:value-of select="$newline"/></xsl:with-param>
+      <xsl:with-param name="to">
+        <xsl:value-of select="$newline"/>
+        <xsl:value-of select="$indentString"/>
+      </xsl:with-param>
+    </xsl:call-template>
+  </xsl:template>
+  
+  <xsl:template name="word-wrap">
+    <xsl:param name="src"/>
+    <xsl:param name="width"/>
+    
+    <xsl:call-template name="word-wrap-impl">
+      <xsl:with-param name="src">
+        <xsl:call-template name="string-replace">
+          <xsl:with-param name="src">
+            <xsl:value-of select="$src"/>     
+          </xsl:with-param>
+          <xsl:with-param name="from"><xsl:text>  </xsl:text></xsl:with-param>
+          <xsl:with-param name="to"><xsl:text> </xsl:text></xsl:with-param>
+        </xsl:call-template>
+      </xsl:with-param>
+      <xsl:with-param name="width"><xsl:value-of select="$width"/></xsl:with-param>
+      <xsl:with-param name="index"><xsl:value-of select="0"/></xsl:with-param>
+    </xsl:call-template>
+  </xsl:template>
+  
+  <xsl:template name="word-wrap-impl">
+    <xsl:param name="src"/>
+    <xsl:param name="index"/>
+    <xsl:param name="width"/>
+    
+    <xsl:variable name="word">
+      <xsl:value-of select="substring-before($src, ' ')"></xsl:value-of>
+    </xsl:variable>
+    <xsl:variable name="wordlength">
+      <xsl:value-of select="string-length($word)"/>
+    </xsl:variable>
+    <xsl:variable name="remainder">
+      <xsl:value-of select="substring($src, $wordlength+2)"/>
+    </xsl:variable>
+    
+    <xsl:if test="string-length($remainder) > 0">
+      
+      <!-- xsl:value-of select="$wordlength"></xsl:value-of -->
+      <xsl:value-of select="$word"/><xsl:text> </xsl:text>
+      <!-- xsl:value-of select="$index"/ -->
+      <xsl:choose>
+        <xsl:when test="$index + $wordlength + 1 &gt; $width">
+          <xsl:value-of select="$newline"/>
+          <xsl:call-template name="word-wrap-impl">
+            <xsl:with-param name="src"><xsl:value-of select="$remainder"></xsl:value-of></xsl:with-param>
+            <xsl:with-param name="index"><xsl:value-of select="0"/></xsl:with-param>
+            <xsl:with-param name="width"><xsl:value-of select="$width"></xsl:value-of></xsl:with-param>
+          </xsl:call-template>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:call-template name="word-wrap-impl">
+            <xsl:with-param name="src"><xsl:value-of select="$remainder"></xsl:value-of></xsl:with-param>
+            <xsl:with-param name="index"><xsl:value-of select="$index + $wordlength+1"/></xsl:with-param>
+            <xsl:with-param name="width"><xsl:value-of select="$width"></xsl:value-of></xsl:with-param>
+          </xsl:call-template>
+        </xsl:otherwise>
+      </xsl:choose>
+     
+      
+    </xsl:if>
+  </xsl:template>
+  
 </xsl:stylesheet>