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 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. xmlns:content="http://purl.org/rss/1.0/modules/content/"
  9. xmlns:atom="http://www.w3.org/2005/Atom">
  10. <xsl:output method="xml" encoding="utf-8" indent="yes"/>
  11. <!-- $today = current date (given as <html date="...">) -->
  12. <xsl:variable name="today">
  13. <xsl:value-of select="/buildinfo/@date" />
  14. </xsl:variable>
  15. <!-- ====== -->
  16. <!-- Months -->
  17. <!-- ====== -->
  18. <months:month-names>
  19. <months:month ref="01">Jan</months:month>
  20. <months:month ref="02">Feb</months:month>
  21. <months:month ref="03">Mar</months:month>
  22. <months:month ref="04">Apr</months:month>
  23. <months:month ref="05">May</months:month>
  24. <months:month ref="06">Jun</months:month>
  25. <months:month ref="07">Jul</months:month>
  26. <months:month ref="08">Aug</months:month>
  27. <months:month ref="09">Sep</months:month>
  28. <months:month ref="10">Oct</months:month>
  29. <months:month ref="11">Nov</months:month>
  30. <months:month ref="12">Dec</months:month>
  31. </months:month-names>
  32. <!-- ============= -->
  33. <!-- Link handling -->
  34. <!-- ============= -->
  35. <xsl:template match="link">
  36. <xsl:param name="lang" />
  37. <!-- Original link text -->
  38. <xsl:variable name="link">
  39. <xsl:value-of select="normalize-space(.)" />
  40. </xsl:variable>
  41. <!-- Add leading "http://fsfe.org" if necessary -->
  42. <xsl:variable name="full-link">
  43. <xsl:choose>
  44. <xsl:when test="starts-with ($link, 'http:')">
  45. <xsl:value-of select="$link" />
  46. </xsl:when>
  47. <xsl:when test="starts-with ($link, 'https:')">
  48. <xsl:value-of select="$link" />
  49. </xsl:when>
  50. <xsl:otherwise>http://fsfe.org<xsl:value-of select="$link" />
  51. </xsl:otherwise>
  52. </xsl:choose>
  53. </xsl:variable>
  54. <!-- Insert language into link -->
  55. <xsl:choose>
  56. <xsl:when test="starts-with ($full-link, 'http://www.fsfeurope.org/')
  57. and substring-before ($full-link, '.html') != ''">
  58. <xsl:value-of select="concat (substring-before ($full-link, '.html'),
  59. '.', $lang, '.html')" />
  60. </xsl:when>
  61. <xsl:otherwise>
  62. <xsl:value-of select="$full-link" />
  63. </xsl:otherwise>
  64. </xsl:choose>
  65. </xsl:template>
  66. <!-- ============ -->
  67. <!-- Main routine -->
  68. <!-- ============ -->
  69. <xsl:template match="/buildinfo">
  70. <xsl:apply-templates select="document" />
  71. </xsl:template>
  72. <xsl:template match="/buildinfo/document">
  73. <!-- Language -->
  74. <xsl:variable name="lang">
  75. <xsl:value-of select="@language" />
  76. </xsl:variable>
  77. <!-- Header -->
  78. <rss version="2.0">
  79. <channel>
  80. <title>FSFE News</title>
  81. <description>News from the Free Software Foundation Europe</description>
  82. <link>http://fsfe.org/news/</link>
  83. <language><xsl:value-of select="$lang" /></language>
  84. <copyright>Copyright (c) Free Software Foundation Europe. Verbatim copying and distribution
  85. of this entire article is permitted in any medium, provided this
  86. notice is preserved.</copyright>
  87. <managingEditor>press@fsfeurope.org (FSFE Press Team)</managingEditor>
  88. <webMaster>web@fsfeurope.org (FSFE Webmaster Team)</webMaster>
  89. <image>
  90. <url>http://fsfe.org/news/fsfe-news.png</url>
  91. <title>FSFE News</title>
  92. <width>88</width>
  93. <height>31</height>
  94. <link>http://fsfe.org/news/</link>
  95. </image>
  96. <xsl:element name="atom:link">
  97. <xsl:attribute name="href">http://fsfe.org/news/news.<xsl:value-of select="$lang"/>.rss</xsl:attribute>
  98. <xsl:attribute name="rel">self</xsl:attribute>
  99. <xsl:attribute name="type">application/rss+xml</xsl:attribute>
  100. </xsl:element>
  101. <!-- News items -->
  102. <xsl:for-each select="/buildinfo/document/set/news[translate (@date, '-', '') &lt;= translate ($today, '-', '')]">
  103. <xsl:sort select="@date" order="descending"/>
  104. <xsl:if test="position() &lt; 11">
  105. <xsl:element name="item">
  106. <!-- guid -->
  107. <xsl:element name="guid">
  108. <xsl:attribute name="isPermaLink">false</xsl:attribute>
  109. <xsl:value-of select="@filename"/>
  110. </xsl:element>
  111. <!-- Title -->
  112. <xsl:element name="title">
  113. <xsl:value-of select="title"/>
  114. </xsl:element>
  115. <!-- News description -->
  116. <xsl:element name="description">
  117. <xsl:copy-of select="normalize-space(body)"/>
  118. <xsl:text>
  119. Support FSFE, join the Fellowship: https://fellowship.fsfe.org/login/join.php
  120. Make a one time donation: http://fsfe.org/donate/donate.html</xsl:text>
  121. </xsl:element>
  122. <!-- News body -->
  123. <xsl:element name="content:encoded">
  124. <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
  125. <xsl:choose>
  126. <xsl:when test="body-complete">
  127. <xsl:apply-templates select="body-complete/*"/>
  128. </xsl:when>
  129. <xsl:otherwise>
  130. <xsl:copy-of select="normalize-space(body)"/>
  131. </xsl:otherwise>
  132. </xsl:choose>
  133. <xsl:element name="p">
  134. <xsl:text>Support FSFE, </xsl:text>
  135. <xsl:element name="a">
  136. <xsl:attribute name="href">https://fellowship.fsfe.org/login/join.php</xsl:attribute>
  137. <xsl:text>join the Fellowship</xsl:text>
  138. </xsl:element>
  139. <xsl:element name="br" />
  140. <xsl:text>Make a </xsl:text>
  141. <xsl:element name="a">
  142. <xsl:attribute name="href">http://fsfe.org/donate/donate.html</xsl:attribute>
  143. <xsl:text>one time donation</xsl:text>
  144. </xsl:element>
  145. </xsl:element>
  146. <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  147. </xsl:element>
  148. <!-- Link -->
  149. <xsl:if test="link != ''">
  150. <xsl:variable name="link">
  151. <xsl:apply-templates select="link">
  152. <xsl:with-param name="lang" select="$lang" />
  153. </xsl:apply-templates>
  154. </xsl:variable>
  155. <xsl:element name="link">
  156. <xsl:value-of select="normalize-space($link)" />
  157. </xsl:element>
  158. </xsl:if>
  159. <!-- Date -->
  160. <xsl:element name="pubDate">
  161. <xsl:value-of select="substring-after(substring-after(@date, '-'), '-')" />
  162. <xsl:variable name="month">
  163. <xsl:value-of select="substring-before(substring-after(@date, '-'), '-')" />
  164. </xsl:variable>
  165. <xsl:text> </xsl:text>
  166. <xsl:value-of select="document('')/*/months:month-names/months:month[@ref=$month]" />
  167. <xsl:text> </xsl:text>
  168. <xsl:value-of select="substring-before(@date, '-')" />
  169. <xsl:text> 00:00:00 +0100</xsl:text>
  170. </xsl:element>
  171. </xsl:element>
  172. </xsl:if>
  173. </xsl:for-each>
  174. <!-- Footer -->
  175. </channel>
  176. </rss>
  177. </xsl:template>
  178. <!-- take care that links within <content:encoded> are not relative -->
  179. <xsl:template match="a">
  180. <xsl:element name="a">
  181. <xsl:attribute name="href">
  182. <xsl:choose>
  183. <xsl:when test="substring(@href,1,1) = '/'">
  184. <xsl:text>http://fsfe.org</xsl:text>
  185. <xsl:value-of select="@href" />
  186. </xsl:when>
  187. <xsl:otherwise>
  188. <xsl:value-of select="@href" />
  189. </xsl:otherwise>
  190. </xsl:choose>
  191. </xsl:attribute>
  192. <xsl:value-of select="." />
  193. </xsl:element>
  194. </xsl:template>
  195. <!-- remove newsteaser from <p> -->
  196. <xsl:template match="p">
  197. <xsl:copy>
  198. <xsl:apply-templates select="node()" />
  199. </xsl:copy>
  200. </xsl:template>
  201. <!-- as well as images -->
  202. <xsl:template match="img">
  203. <xsl:element name="img">
  204. <xsl:attribute name="src">
  205. <xsl:choose>
  206. <xsl:when test="substring(@src,1,1) = '/'">
  207. <xsl:text>http://fsfe.org</xsl:text>
  208. <xsl:value-of select="@src" />
  209. </xsl:when>
  210. <xsl:otherwise>
  211. <xsl:value-of select="@src" />
  212. </xsl:otherwise>
  213. </xsl:choose>
  214. </xsl:attribute>
  215. </xsl:element>
  216. </xsl:template>
  217. <!-- Do not copy <body-complete> to output at all -->
  218. <xsl:template match="body-complete"/>
  219. </xsl:stylesheet>