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.5KB

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