Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

news.rss.xsl 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- XSL stylesheet for generation RSS feeds. It's currently using RSS 2.0. -->
  3. <xsl:stylesheet version="1.0"
  4. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  5. xmlns:dt="http://xsltsl.org/date-time"
  6. xmlns:weekdays="."
  7. xmlns:months=".">
  8. <xsl:import href="date-time.xsl" />
  9. <xsl:output method="xml" encoding="utf-8" indent="yes" />
  10. <!-- $today = current date (given as <html date="...">) -->
  11. <xsl:variable name="today">
  12. <xsl:value-of select="/html/@date" />
  13. </xsl:variable>
  14. <!-- ======== -->
  15. <!-- Weekdays -->
  16. <!-- ======== -->
  17. <weekdays:weekday-names>
  18. <weekdays:day ref="1">Mon</weekdays:day>
  19. <weekdays:day ref="2">Tue</weekdays:day>
  20. <weekdays:day ref="3">Wed</weekdays:day>
  21. <weekdays:day ref="4">Thu</weekdays:day>
  22. <weekdays:day ref="5">Fri</weekdays:day>
  23. <weekdays:day ref="6">Sat</weekdays:day>
  24. <weekdays:day ref="7">Sun</weekdays:day>
  25. </weekdays:weekday-names>
  26. <!-- ====== -->
  27. <!-- Months -->
  28. <!-- ====== -->
  29. <months:month-names>
  30. <months:month ref="01">Jan</months:month>
  31. <months:month ref="02">Feb</months:month>
  32. <months:month ref="03">Mar</months:month>
  33. <months:month ref="04">Apr</months:month>
  34. <months:month ref="05">May</months:month>
  35. <months:month ref="06">Jun</months:month>
  36. <months:month ref="07">Jul</months:month>
  37. <months:month ref="08">Aug</months:month>
  38. <months:month ref="09">Sep</months:month>
  39. <months:month ref="10">Oct</months:month>
  40. <months:month ref="11">Nov</months:month>
  41. <months:month ref="12">Dec</months:month>
  42. </months:month-names>
  43. <!-- ============= -->
  44. <!-- Link handling -->
  45. <!-- ============= -->
  46. <xsl:template match="link">
  47. <xsl:param name="lang" />
  48. <!-- Original link text -->
  49. <xsl:variable name="link">
  50. <xsl:value-of select="normalize-space(.)" />
  51. </xsl:variable>
  52. <!-- Add leading "http://www.fsfeurope.org" if necessary -->
  53. <xsl:variable name="full-link">
  54. <xsl:choose>
  55. <xsl:when test="starts-with ($link, 'http:')">
  56. <xsl:value-of select="$link" />
  57. </xsl:when>
  58. <xsl:when test="starts-with ($link, 'https:')">
  59. <xsl:value-of select="$link" />
  60. </xsl:when>
  61. <xsl:otherwise>http://www.fsfeurope.org<xsl:value-of select="$link" />
  62. </xsl:otherwise>
  63. </xsl:choose>
  64. </xsl:variable>
  65. <!-- Insert language into link -->
  66. <xsl:choose>
  67. <xsl:when test="starts-with ($full-link, 'http://www.fsfeurope.org/')
  68. and substring-before ($full-link, '.html') != ''">
  69. <xsl:value-of select="concat (substring-before ($full-link, '.html'),
  70. '.', $lang, '.html')" />
  71. </xsl:when>
  72. <xsl:otherwise>
  73. <xsl:value-of select="$full-link" />
  74. </xsl:otherwise>
  75. </xsl:choose>
  76. </xsl:template>
  77. <!-- ============ -->
  78. <!-- Main routine -->
  79. <!-- ============ -->
  80. <xsl:template match="html">
  81. <!-- Language -->
  82. <xsl:variable name="lang">
  83. <xsl:value-of select="@lang" />
  84. </xsl:variable>
  85. <!-- Header -->
  86. <rss version="2.0">
  87. <channel>
  88. <title>FSFE News</title>
  89. <description>News from the Free Software Foundation Europe</description>
  90. <link>http://www.fsfeurope.org/news/</link>
  91. <language><xsl:value-of select="$lang" /></language>
  92. <copyright>Copyright (c) FSF Europe. Verbatim copying and distribution
  93. of this entire article is permitted in any medium, provided this
  94. notice is preserved.</copyright>
  95. <managingEditor>press@fsfeurope.org (FSFE Press Team)</managingEditor>
  96. <webMaster>web@fsfeurope.org (FSFE Webmaster Team)</webMaster>
  97. <image>
  98. <url>http://fsfeurope.org/news/fsfe-news.png</url>
  99. <title>FSFE News</title>
  100. <width>88</width>
  101. <height>31</height>
  102. <link>http://www.fsfeurope.org/news/</link>
  103. </image>
  104. <!-- News items -->
  105. <xsl:for-each select="/html/set/news
  106. [translate (@date, '-', '') &lt;= translate ($today, '-', '')]">
  107. <xsl:sort select="@date" order="descending"/>
  108. <xsl:if test="position() &lt; 11">
  109. <xsl:element name="item">
  110. <!-- Title -->
  111. <xsl:element name="title">
  112. <xsl:value-of select="title"/>
  113. </xsl:element>
  114. <!-- News body -->
  115. <xsl:element name="description">
  116. <xsl:value-of select="normalize-space(body)"/>
  117. </xsl:element>
  118. <!-- Link -->
  119. <xsl:if test="link != ''">
  120. <xsl:variable name="link">
  121. <xsl:apply-templates select="link">
  122. <xsl:with-param name="lang" select="$lang" />
  123. </xsl:apply-templates>
  124. </xsl:variable>
  125. <xsl:element name="link">
  126. <xsl:value-of select="normalize-space($link)" />
  127. </xsl:element>
  128. </xsl:if>
  129. <!-- Date -->
  130. <xsl:element name="pubDate">
  131. <xsl:variable name="day-of-week">
  132. <xsl:call-template name="dt:calculate-day-of-the-week">
  133. <xsl:with-param name="year" select="substring(@date, 0, 5)" />
  134. <xsl:with-param name="month" select="substring(@date, 6, 2)" />
  135. <xsl:with-param name="day" select="substring(@date, 9, 2)" />
  136. </xsl:call-template>
  137. </xsl:variable>
  138. <xsl:value-of select="document('')/*/weekdays:weekday-names/weekdays:day[@ref=$day-of-week]" />
  139. <xsl:text>, </xsl:text>
  140. <xsl:value-of select="substring-after(substring-after(@date, '-'), '-')" />
  141. <xsl:variable name="month">
  142. <xsl:value-of select="substring-before(substring-after(@date, '-'), '-')" />
  143. </xsl:variable>
  144. <xsl:text> </xsl:text>
  145. <xsl:value-of select="document('')/*/months:month-names/months:month[@ref=$month]" />
  146. <xsl:text> </xsl:text>
  147. <xsl:value-of select="substring-before(@date, '-')" />
  148. <xsl:text> 00:00:00 +0100</xsl:text>
  149. </xsl:element>
  150. </xsl:element>
  151. </xsl:if>
  152. </xsl:for-each>
  153. <!-- Footer -->
  154. </channel>
  155. </rss>
  156. </xsl:template>
  157. </xsl:stylesheet>