danw
committed
on 12 Apr 01
rearranged subsite dirs for new dir structure
openacs.org-dev/.../data/default.xsl (+55 -4)
1 1 <?xml version="1.0" encoding="UTF-8"?>
2 2 <xsl:stylesheet version="1.0"
3 3   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
4     xmlns="http://www.w3.org/TR/xhtml1/strict"
5 4   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6 5   xmlns:dc="http://purl.org/dc/elements/1.1/"
7 6   xmlns:wn="http://xmlns.com/wordnet/1.6/"
8 7   xmlns:foaf="http://xmlns.com/foaf/0.1/"
9     xmlns:irc="irc::logger">
  8   xmlns:irc="irc::logger"
  9   exclude-result-prefixes="xsl rdf dc wn foaf irc">
10 10  
  11   <!-- Process each ChatChannel in the RDF file -->
11 12   <xsl:template match="foaf:ChatChannel">
12 13     <xsl:apply-templates/>
13 14   </xsl:template>
14 15
  16   <!-- Create table per ChatChannel listing the events -->
15 17   <xsl:template match="foaf:chatEventList">
16 18     <table>
17 19       <tbody>
18 20         <xsl:apply-templates/>
19 21       </tbody>
20 22     </table>
21 23   </xsl:template>
22 24
  25   <!-- One event per table row, listing date/time, nick and event description. -->
23 26   <xsl:template match="foaf:chatEvent">
24 27     <tr>
25 28       <td nowrap="true" valign="top">
26 29         <a name="{@rdf:ID}">
27 30           <xsl:apply-templates select="dc:date"/>
28 31         </a>
29 32       </td>
30 33       <xsl:apply-templates select="dc:creator/wn:Person"/>
31 34       <xsl:apply-templates select="dc:description"/>
32 35     </tr>
33 36   </xsl:template>
34 37
  38   <!-- Display the time only but with the full date/time in the
  39        title. The title pops up in tooltip when the mouse pointer
  40        rests on the time. -->
35 41   <xsl:template match="dc:date">
36 42     <xsl:variable name="formatted_date"><xsl:value-of select="translate(.,'TZ',' ')"/> GMT</xsl:variable>
37 43     <font size="-1" color="grey" title="{$formatted_date}">[<xsl:value-of select="substring-before(substring-after(.,'T'), 'Z')"/>]</font>
38 44   </xsl:template>
39 45
  46   <!-- List the nick with a link to the OpenACS account if there is
  47        an account with screen name 'nick'. -->
40 48   <xsl:template match="dc:creator/wn:Person">
41 49     <td align="right" valign="top">
42 50       <font color="grey">&lt;</font>
43 51       <b><xsl:value-of select="irc:user_link(@foaf:nick)" disable-output-escaping="yes"/></b>
44 52       <font color="grey">&gt;</font>
45 53     </td>
46 54   </xsl:template>
47 55
  56   <!-- Parse the description -->
48 57   <xsl:template match="dc:description">
49 58     <td valign="top">
50 59       <xsl:choose>
  60
  61         <!-- Display users joining/leaving less prominent -->
51 62         <xsl:when test="contains(.,'has joined #openacs') or contains(.,'has left #openacs')">
52 63           <font color="grey"><xsl:value-of select="."/></font>
53 64         </xsl:when>
  65
  66         <!-- Make http: links active hyperlinks -->
54 67         <xsl:when test="contains(.,'http:')">
55 68           <xsl:if test="contains(substring-after(.,'http:'),' ')">
56 69             <xsl:value-of select="substring-before(.,'http:')"/>
57               <a href="http:{substring-before(substring-after(.,'http:'),' ')}">http:<xsl:value-of select="substring-before(substring-after(.,'http:'),' ')"/></a>
  70             <a href="http:{substring-before(substring-after(.,'http:'),' ')}">http:<xsl:call-template name="split_string">
  71                 <xsl:with-param name="string" select="substring-before(substring-after(.,'http:'),' ')"/>
  72               </xsl:call-template>
  73             </a>
58 74             <xsl:value-of select="concat(' ',substring-after(substring-after(.,'http:'),' '))"/>
59 75           </xsl:if>
60 76           <xsl:if test="not(contains(substring-after(.,'http:'),' '))">
61 77             <xsl:value-of select="substring-before(.,'http:')"/>
62               <a href="http:{substring-after(.,'http:')}">http:<xsl:value-of select="substring-after(.,'http:')"/></a>
  78             <a href="http:{substring-after(.,'http:')}">http:<xsl:call-template name="split_string">
  79                 <xsl:with-param name="string" select="substring-after(.,'http:')"/>
  80               </xsl:call-template>
  81             </a>
63 82           </xsl:if>
64 83         </xsl:when>
  84
  85         <!-- Display /me ... actions in a different style -->
65 86         <xsl:when test="starts-with(.,'*')">
66 87           <i><xsl:value-of select="substring-after(.,'* ')"/></i>
67 88         </xsl:when>
  89
  90         <!-- For other events just copy the description from the log -->
68 91         <xsl:otherwise>
69 92           <xsl:value-of select="."/>
70 93         </xsl:otherwise>
71 94       </xsl:choose>
72 95     </td>
73 96   </xsl:template>
74 97
  98   <!-- Insert spaces in long strings (e.g. href) so that they wrap and
  99        no longer mess with the page layout. One space after each 50
  100        characters.-->
  101   <xsl:template name="split_string">
  102     <xsl:param name="string"></xsl:param>
  103     <xsl:param name="return"></xsl:param>
  104     <xsl:variable name="max_length" select="50"/>
  105
  106     <xsl:choose>
  107       <xsl:when test="string-length($string) != 0">
  108         <xsl:choose>
  109           <xsl:when test="string-length($string) > $max_length">
  110             <xsl:call-template name="split_string">
  111               <xsl:with-param name="string" select="substring($string, $max_length)"/>
  112               <xsl:with-param name="return" select="concat($return, substring($string, 1, $max_length), ' ')"/>
  113             </xsl:call-template>
  114           </xsl:when>
  115           <xsl:otherwise>
  116             <xsl:value-of select="concat($return, $string)"/>
  117           </xsl:otherwise>
  118       </xsl:choose>
  119       </xsl:when>
  120       <xsl:otherwise>
  121         <xsl:value-of select="$return"/>
  122       </xsl:otherwise>
  123     </xsl:choose>
  124   </xsl:template>
  125  
75 126 </xsl:stylesheet>