Source files of fsfe.org, pdfreaders.org, freeyourandroid.org, ilovefs.org, drm.info, and test.fsfe.org. Contribute: https://fsfe.org/contribute/web/ https://fsfe.org
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.

242 lines
8.3KB

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