root/trunk/deployment/feeder/webapp/resources/demoskins/MainCampus/default/default/list-rss.xsl

Revision 2583 (checked in by johnsa, 3 years ago)

feeder: validate and clean RSS

  • Property svn:mime-type set to text/plain
Line 
1 <?xml version="1.0" encoding="UTF-8"?>
2 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3   <xsl:output method="xml" omit-xml-declaration="no" indent="yes"
4     media-type="text/xml" encoding="UTF-8" />
5
6    <!-- =========================================================
7
8                       BEDEWORK RSS FEED
9
10      RSS for the Bedework events calendar.
11
12      Call the feed with the listEvents action to return
13      the discrete events in the next seven days (seven days is default):
14      http://localhost:8080/cal/main/listEvents.do?setappvar=summaryMode(details)&skinName=rss-list
15
16      _________________________________________________________
17      Optional parameters that may be added to the query string:
18
19      days=n    To return n days from today into the future add this to the paramater list: &days=5
20
21      ===============================================================  -->
22 <!-- **********************************************************************
23     Copyright 2008 Rensselaer Polytechnic Institute. All worldwide rights reserved.
24
25     Redistribution and use of this distribution in source and binary forms,
26     with or without modification, are permitted provided that:
27        The above copyright notice and this permission notice appear in all
28         copies and supporting documentation;
29
30         The name, identifiers, and trademarks of Rensselaer Polytechnic
31         Institute are not used in advertising or publicity without the
32         express prior written permission of Rensselaer Polytechnic Institute;
33
34     DISCLAIMER: The software is distributed" AS IS" without any express or
35     implied warranty, including but not limited to, any implied warranties
36     of merchantability or fitness for a particular purpose or any warrant)'
37     of non-infringement of any current or pending patent rights. The authors
38     of the software make no representations about the suitability of this
39     software for any particular purpose. The entire risk as to the quality
40     and performance of the software is with the user. Should the software
41     prove defective, the user assumes the cost of all necessary servicing,
42     repair or correction. In particular, neither Rensselaer Polytechnic
43     Institute, nor the authors of the software are liable for any indirect,
44     special, consequential, or incidental damages related to the software,
45     to the maximum extent the law permits. -->
46
47    <!-- Provides category filter templates -->
48    <xsl:include href="./xsl/categoryFiltering.xsl"/>
49
50    <xsl:include href="globals.xsl"/>
51    <xsl:include href="../strings.xsl"/>
52
53    <xsl:template match="/">
54      <rss version="2.0">
55       <channel>
56         <title>Bedework Events Calendar</title>
57         <link><xsl:value-of select="substring-before($urlPrefix,$feeder)"/><xsl:value-of select="$publicCal"/></link>
58         <description>
59           <xsl:choose>
60             <xsl:when test="/bedework/now/longdate = /bedework/events/event[position()=last()]/start/longdate"><xsl:value-of select="/bedework/now/longdate"/></xsl:when>
61             <xsl:otherwise><xsl:value-of select="/bedework/now/longdate"/> - <xsl:value-of select="/bedework/events/event[position()=last()]/start/longdate"/></xsl:otherwise>
62           </xsl:choose>
63         </description>
64         <pubDate><!-- takes the form: 11 Jan 2008 17:00:00 UT (note - do not output dayname - we only provide dayname in local time).
65           --><xsl:value-of select="substring(/bedework/now/utc,7,2)"/><xsl:text> </xsl:text><!--
66           --><xsl:call-template name="monthNumToName"><xsl:with-param name="monthNum" select="substring(/bedework/now/utc,5,2)"/></xsl:call-template><xsl:text> </xsl:text><!--
67           --><xsl:value-of select="substring(/bedework/now/utc,1,4)"/><xsl:text> </xsl:text><!--
68           --><xsl:value-of select="substring(/bedework/now/utc,10,2)"/>:<xsl:value-of select="substring(/bedework/now/utc,11,2)"/>:00 UT</pubDate>
69         <language>en-US</language>
70         <copyright>Copyright <xsl:value-of select="substring(/bedework/now/utc,1,4)"/>, Bedework</copyright>
71         <managingEditor>editor@mysite.edu (Editor Name)</managingEditor>
72         <xsl:choose>
73           <xsl:when test="/bedework/page='searchResult'">
74             <xsl:apply-templates select="/bedework/searchResults/searchResult" />
75           </xsl:when>
76           <xsl:otherwise>
77             <xsl:choose>
78               <xsl:when test="/bedework/appvar/key = 'filter'">
79                 <xsl:variable name="filterName" select="substring-before(/bedework/appvar[key='filter']/value,':')" />
80                 <xsl:variable name="filterVal" select="substring-after(/bedework/appvar[key='filter']/value,':')" />
81                 <!-- Define filters here: -->
82                 <xsl:choose>
83                   <xsl:when test="$filterName = 'grpAndCats'">
84                     <xsl:call-template name="preprocessCats">
85                       <xsl:with-param name="allCats" select="$filterVal" />
86                     </xsl:call-template>
87                   </xsl:when>
88                   <xsl:otherwise>
89                     <!-- Filter name not defined? Turn off filtering. -->
90                     <xsl:apply-templates select="/bedework/events/event" />
91                   </xsl:otherwise>
92                 </xsl:choose>
93               </xsl:when>
94               <xsl:otherwise>
95                 <xsl:apply-templates select="/bedework/events/event" />
96               </xsl:otherwise>
97             </xsl:choose>
98           </xsl:otherwise>
99         </xsl:choose>
100       </channel>
101     </rss>
102   </xsl:template>
103
104   <xsl:template match="event">
105     <item>
106       <title><xsl:if test="status = 'CANCELLED'">CANCELED: </xsl:if><xsl:value-of select="summary"/></title>
107       <link><xsl:value-of select="substring-before($urlPrefix,$feeder)"/><xsl:value-of select="$publicCal"/>/event/eventView.do?calPath=<xsl:value-of select="calendar/encodedPath"/>&amp;guid=<xsl:value-of select="guid"/>&amp;recurrenceId=<xsl:value-of select="recurrenceId"/></link>
108       <guid><xsl:value-of select="substring-before($urlPrefix,$feeder)"/><xsl:value-of select="$publicCal"/>/event/eventView.do?calPath=<xsl:value-of select="calendar/encodedPath"/>&amp;guid=<xsl:value-of select="guid"/>&amp;recurrenceId=<xsl:value-of select="recurrenceId"/></guid>
109       <pubDate><!-- takes the form: 11 Jan 2008 17:00:00 UT (note - do not output dayname - we only provide dayname in local time).
110         --><xsl:value-of select="substring(start/utcdate,7,2)"/><xsl:text> </xsl:text><!--
111         --><xsl:call-template name="monthNumToName"><xsl:with-param name="monthNum" select="substring(start/utcdate,5,2)"/></xsl:call-template><xsl:text> </xsl:text><!--
112         --><xsl:value-of select="substring(start/utcdate,1,4)"/><xsl:text> </xsl:text><!--
113         --><xsl:value-of select="substring(start/utcdate,10,2)"/>:<xsl:value-of select="substring(start/utcdate,11,2)"/>:00 UT</pubDate>
114       <description>
115         <xsl:value-of select="start/dayname" />,
116         <xsl:value-of select="start/longdate" />
117         <xsl:text> </xsl:text>
118         <xsl:if test="start/allday = 'false'">
119           <xsl:value-of select="start/time" />
120         </xsl:if>
121         <xsl:if
122           test="(end/longdate != start/longdate) or
123                 ((end/longdate = start/longdate) and (end/time != start/time))">
124           -
125         </xsl:if>
126         <xsl:if test="end/longdate != start/longdate">
127           <xsl:value-of select="substring(end/dayname,1,3)" />
128           ,
129           <xsl:value-of select="end/longdate" />
130           <xsl:text> </xsl:text>
131         </xsl:if>
132         <xsl:choose>
133           <xsl:when test="start/allday = 'true'">
134             <xsl:copy-of select="$bwStr-SgEv-AllDay"/>
135           </xsl:when>
136           <xsl:when test="end/longdate != start/longdate">
137             <xsl:value-of select="end/time" />
138           </xsl:when>
139           <xsl:when test="end/time != start/time">
140
141               <xsl:value-of select="end/time" />
142
143           </xsl:when>
144         </xsl:choose>
145         <!-- if timezones are not local, or if floating add labels: -->
146         <xsl:if test="start/timezone/islocal = 'false' or end/timezone/islocal = 'false'">
147           <xsl:text> </xsl:text>
148           --
149           <xsl:choose>
150             <xsl:when test="start/floating = 'true'">
151               <xsl:copy-of select="$bwStr-SgEv-FloatingTime"/>
152             </xsl:when>
153             <xsl:otherwise>
154               <xsl:copy-of select="$bwStr-SgEv-LocalTime"/>
155             </xsl:otherwise>
156           </xsl:choose>
157         </xsl:if>
158         <!-- display in timezone if not local or floating time) -->
159         <xsl:if test="(start/timezone/islocal = 'false' or end/timezone/islocal = 'false') and start/floating = 'false'">
160           <xsl:choose>
161             <xsl:when test="start/timezone/id != end/timezone/id">
162               <!-- need to display both timezones if they differ from start to end -->
163               <div class="tzdates">
164                 <xsl:copy-of select="$bwStr-SgEv-Start"/><xsl:text> </xsl:text>
165                 <xsl:choose>
166                   <xsl:when test="start/timezone/islocal='true'">
167                     <xsl:value-of select="start/dayname"/>,
168                     <xsl:value-of select="start/longdate"/>
169                     <xsl:text> </xsl:text>
170                     <xsl:value-of select="start/time"/>
171                   </xsl:when>
172                   <xsl:otherwise>
173                     <xsl:value-of select="start/timezone/dayname"/>,
174                     <xsl:value-of select="start/timezone/longdate"/>
175                     <xsl:text> </xsl:text>
176                     <xsl:value-of select="start/timezone/time"/>
177                   </xsl:otherwise>
178                 </xsl:choose>
179                 --
180                 <strong><xsl:value-of select="start/timezone/id"/></strong>
181                 <xsl:copy-of select="$bwStr-SgEv-End"/><xsl:text> </xsl:text>
182                 <xsl:choose>
183                   <xsl:when test="end/timezone/islocal='true'">
184                     <xsl:value-of select="end/dayname"/>,
185                     <xsl:value-of select="end/longdate"/>
186                     <xsl:text> </xsl:text>
187                     <xsl:value-of select="end/time"/>
188                   </xsl:when>
189                   <xsl:otherwise>
190                     <xsl:value-of select="end/timezone/dayname"/>,
191                     <xsl:value-of select="end/timezone/longdate"/>
192                     <xsl:text> </xsl:text>
193                     <xsl:value-of select="end/timezone/time"/>
194                   </xsl:otherwise>
195                 </xsl:choose>
196                 --
197                 <strong><xsl:value-of select="end/timezone/id"/></strong>
198               </div>
199             </xsl:when>
200             <xsl:otherwise>
201               <!-- otherwise, timezones are the same: display as a single line  -->
202               <xsl:value-of select="start/timezone/dayname"/>, <xsl:value-of select="start/timezone/longdate"/><xsl:text> </xsl:text>
203               <xsl:if test="start/allday = 'false'">
204                 <xsl:value-of select="start/timezone/time"/>
205               </xsl:if>
206               <xsl:if test="(end/timezone/longdate != start/timezone/longdate) or
207                             ((end/timezone/longdate = start/timezone/longdate) and (end/timezone/time != start/timezone/time))"> - </xsl:if>
208               <xsl:if test="end/timezone/longdate != start/timezone/longdate">
209                 <xsl:value-of select="substring(end/timezone/dayname,1,3)"/>, <xsl:value-of select="end/timezone/longdate"/><xsl:text> </xsl:text>
210               </xsl:if>
211               <xsl:choose>
212                 <xsl:when test="start/allday = 'true'">
213                    <xsl:copy-of select="$bwStr-SgEv-AllDay"/>
214                 </xsl:when>
215                 <xsl:when test="end/timezone/longdate != start/timezone/longdate">
216                   <xsl:value-of select="end/timezone/time"/>
217                 </xsl:when>
218                 <xsl:when test="end/timezone/time != start/timezone/time">
219                   <xsl:value-of select="end/timezone/time"/>
220                 </xsl:when>
221               </xsl:choose>
222               <xsl:text> </xsl:text>
223               --
224               <strong><xsl:value-of select="start/timezone/id"/></strong>
225             </xsl:otherwise>
226           </xsl:choose>
227         </xsl:if>
228
229         <![CDATA[
230           <br/>
231         ]]>
232
233         <xsl:copy-of select="$bwStr-SgEv-Where"/><xsl:text> </xsl:text>
234         <xsl:choose>
235           <xsl:when test="location/link=''">
236             <xsl:value-of select="location/address" />
237             <xsl:text> </xsl:text>
238             <xsl:if test="location/subaddress!=''">
239               <xsl:text> </xsl:text>
240               <xsl:value-of select="location/subaddress" />
241             </xsl:if>
242           </xsl:when>
243           <xsl:otherwise>
244             <a>
245               <xsl:attribute name="href"><xsl:value-of select="location/link"/></xsl:attribute>
246               <xsl:value-of select="location/address"/>
247               <xsl:if test="location/subaddress!=''">
248                 <xsl:text> </xsl:text>
249                 <xsl:value-of select="location/subaddress" />
250               </xsl:if>
251             </a>
252           </xsl:otherwise>
253         </xsl:choose>
254
255         <![CDATA[
256           <br/>
257         ]]>
258
259         <xsl:if test="cost!=''">
260           <xsl:copy-of select="$bwStr-SgEv-Cost"/><xsl:text> </xsl:text>
261           <xsl:value-of select="cost" />
262           <![CDATA[
263             <br/>
264           ]]>
265         </xsl:if>
266
267         <xsl:copy-of select="$bwStr-SgEv-Description"/><xsl:text> </xsl:text>
268         <xsl:value-of select="description"/>
269
270         <![CDATA[
271           <br/>
272         ]]>
273
274         <xsl:if test="status !='' and status != 'CONFIRMED'">
275           <xsl:copy-of select="$bwStr-SgEv-STATUS"/><xsl:text> </xsl:text>
276           <xsl:value-of select="status" />
277           <![CDATA[
278             <br/>
279           ]]>
280         </xsl:if>
281
282         <xsl:if test="contact/name!='None'">
283           <xsl:copy-of select="$bwStr-SgEv-Contact"/><xsl:text> </xsl:text>
284           <xsl:value-of select="contact/name" />
285           <xsl:if test="contact/phone!=''">
286             <xsl:text> </xsl:text>
287             <xsl:value-of select="contact/phone" />
288           </xsl:if>
289           <![CDATA[
290             <br/>
291           ]]>
292         </xsl:if>
293
294         <xsl:if test="categories[1]/category">
295           <xsl:copy-of select="$bwStr-SgEv-Categories"/><xsl:text> </xsl:text>
296           <xsl:for-each select="categories/category">
297             <xsl:value-of select="value"/><xsl:if test="position() != last()">, </xsl:if>
298           </xsl:for-each>
299           <![CDATA[
300             <br/>
301           ]]>
302         </xsl:if>
303       </description>
304     </item>
305   </xsl:template>
306
307   <!-- convert 2-digit utc month numeric values to
308        short month names as expected by RFC 822 -->
309   <xsl:template name="monthNumToName">
310     <xsl:param name="monthNum">00</xsl:param>
311     <xsl:choose>
312       <xsl:when test="$monthNum = '01'">Jan</xsl:when>
313       <xsl:when test="$monthNum = '02'">Feb</xsl:when>
314       <xsl:when test="$monthNum = '03'">Mar</xsl:when>
315       <xsl:when test="$monthNum = '04'">Apr</xsl:when>
316       <xsl:when test="$monthNum = '05'">May</xsl:when>
317       <xsl:when test="$monthNum = '06'">Jun</xsl:when>
318       <xsl:when test="$monthNum = '07'">Jul</xsl:when>
319       <xsl:when test="$monthNum = '08'">Aug</xsl:when>
320       <xsl:when test="$monthNum = '09'">Sep</xsl:when>
321       <xsl:when test="$monthNum = '10'">Oct</xsl:when>
322       <xsl:when test="$monthNum = '11'">Nov</xsl:when>
323       <xsl:when test="$monthNum = '12'">Dec</xsl:when>
324       <xsl:otherwise>badMonthNum</xsl:otherwise>
325     </xsl:choose>
326   </xsl:template>
327 </xsl:stylesheet>
Note: See TracBrowser for help on using the browser.