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.

news.rss.xsl 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  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@fsfe.org (FSFE Press Team)</managingEditor>
  88. <webMaster>web@lists.fsfe.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>Support FSFE: https://my.fsfe.org/support</xsl:text>
  119. </xsl:element>
  120. <!-- News body -->
  121. <xsl:element name="content:encoded">
  122. <xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text>
  123. <xsl:choose>
  124. <xsl:when test="body-complete">
  125. <xsl:apply-templates select="body-complete/*"/>
  126. </xsl:when>
  127. <xsl:otherwise>
  128. <xsl:copy-of select="normalize-space(body)"/>
  129. </xsl:otherwise>
  130. </xsl:choose>
  131. <xsl:element name="p">
  132. <xsl:element name="a">
  133. <xsl:attribute name="href">https://my.fsfe.org/support</xsl:attribute>
  134. <xsl:text>Support FSFE</xsl:text>
  135. </xsl:element>
  136. </xsl:element>
  137. <xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
  138. </xsl:element>
  139. <!-- Link -->
  140. <xsl:if test="link != ''">
  141. <xsl:variable name="link">
  142. <xsl:apply-templates select="link">
  143. <xsl:with-param name="lang" select="$lang" />
  144. </xsl:apply-templates>
  145. </xsl:variable>
  146. <xsl:element name="link">
  147. <xsl:value-of select="normalize-space($link)" />
  148. </xsl:element>
  149. </xsl:if>
  150. <!-- Date -->
  151. <xsl:element name="pubDate">
  152. <xsl:value-of select="substring-after(substring-after(@date, '-'), '-')" />
  153. <xsl:variable name="month">
  154. <xsl:value-of select="substring-before(substring-after(@date, '-'), '-')" />
  155. </xsl:variable>
  156. <xsl:text> </xsl:text>
  157. <xsl:value-of select="document('')/*/months:month-names/months:month[@ref=$month]" />
  158. <xsl:text> </xsl:text>
  159. <xsl:value-of select="substring-before(@date, '-')" />
  160. <xsl:text> 00:00:00 +0100</xsl:text>
  161. </xsl:element>
  162. </xsl:element>
  163. </xsl:if>
  164. </xsl:for-each>
  165. <!-- Footer -->
  166. </channel>
  167. </rss>
  168. </xsl:template>
  169. <!-- take care that links within <content:encoded> are not relative -->
  170. <xsl:template match="a">
  171. <xsl:element name="a">
  172. <xsl:attribute name="href">
  173. <xsl:choose>
  174. <xsl:when test="substring(@href,1,1) = '/'">
  175. <xsl:text>http://fsfe.org</xsl:text>
  176. <xsl:value-of select="@href" />
  177. </xsl:when>
  178. <xsl:otherwise>
  179. <xsl:value-of select="@href" />
  180. </xsl:otherwise>
  181. </xsl:choose>
  182. </xsl:attribute>
  183. <xsl:value-of select="." />
  184. </xsl:element>
  185. </xsl:template>
  186. <!-- remove newsteaser from <p> -->
  187. <xsl:template match="p">
  188. <xsl:copy>
  189. <xsl:apply-templates select="node()" />
  190. </xsl:copy>
  191. </xsl:template>
  192. <!-- as well as images -->
  193. <xsl:template match="img">
  194. <xsl:element name="img">
  195. <xsl:attribute name="src">
  196. <xsl:choose>
  197. <xsl:when test="substring(@src,1,1) = '/'">
  198. <xsl:text>http://fsfe.org</xsl:text>
  199. <xsl:value-of select="@src" />
  200. </xsl:when>
  201. <xsl:otherwise>
  202. <xsl:value-of select="@src" />
  203. </xsl:otherwise>
  204. </xsl:choose>
  205. </xsl:attribute>
  206. </xsl:element>
  207. </xsl:template>
  208. <!-- Do not copy <body-complete> to output at all -->
  209. <xsl:template match="body-complete"/>
  210. </xsl:stylesheet>