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.

98 lines
3.3KB

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xsl:stylesheet version="1.0"
  3. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  4. xmlns:str="http://exslt.org/strings"
  5. extension-element-prefixes="str">
  6. <xsl:output method="text" encoding="UTF-8" indent="no" />
  7. <xsl:strip-space elements="body"/>
  8. <!-- new line template -->
  9. <xsl:template name="nl"><xsl:text>&#13;&#10;</xsl:text></xsl:template>
  10. <!-- Show a single event -->
  11. <xsl:template name="event">
  12. <xsl:param name="header" />
  13. <!-- Create variables -->
  14. <xsl:variable name="start">
  15. <xsl:value-of select="translate (@start, '-', '')" />
  16. </xsl:variable>
  17. <xsl:variable name="end">
  18. <xsl:value-of select="translate (@end, '-', '')" />
  19. </xsl:variable>
  20. <xsl:variable name="link">
  21. <xsl:value-of select="link" />
  22. </xsl:variable>
  23. <xsl:variable name="page">
  24. <xsl:value-of select="page" />
  25. </xsl:variable>
  26. <!-- Now, the event block -->
  27. <xsl:text>BEGIN:VEVENT</xsl:text><xsl:call-template name="nl" />
  28. <xsl:text>SUMMARY:</xsl:text>
  29. <xsl:call-template name="ical-escape">
  30. <xsl:with-param name="text" select="title" />
  31. </xsl:call-template>
  32. <xsl:call-template name="nl" />
  33. <xsl:text>DTSTART;VALUE=DATE:</xsl:text><xsl:value-of select="$start" /><xsl:call-template name="nl" />
  34. <xsl:if test="not($start = $end)">
  35. <xsl:text>DTEND;VALUE=DATE:</xsl:text><xsl:value-of select="$end" /><xsl:call-template name="nl" />
  36. </xsl:if>
  37. <xsl:text>URL:</xsl:text>
  38. <xsl:choose>
  39. <xsl:when test="$page != ''"><xsl:value-of select="$page" /></xsl:when>
  40. <xsl:otherwise>http://fsfe.org/events/events.<xsl:value-of select="/buildinfo/@language" />.html</xsl:otherwise>
  41. </xsl:choose>
  42. <xsl:call-template name="nl" />
  43. <xsl:text>DESCRIPTION:</xsl:text>
  44. <xsl:call-template name="ical-escape">
  45. <xsl:with-param name="text" select="normalize-space(body/node())" />
  46. </xsl:call-template>
  47. <xsl:call-template name="nl" />
  48. <xsl:text>END:VEVENT</xsl:text><xsl:call-template name="nl" />
  49. </xsl:template>
  50. <xsl:template match="/">
  51. <xsl:apply-templates select="/buildinfo/document" />
  52. </xsl:template>
  53. <xsl:template match="/buildinfo/document">
  54. <xsl:text>BEGIN:VCALENDAR</xsl:text><xsl:call-template name="nl" />
  55. <xsl:text>VERSION:2.0</xsl:text><xsl:call-template name="nl" />
  56. <xsl:text>PRODID:fsfe.org/events/events.ics.xsl</xsl:text><xsl:call-template name="nl" />
  57. <!-- $today = current date (given as <html date="...">) -->
  58. <xsl:variable name="today">
  59. <xsl:value-of select="/buildinfo/@date" />
  60. </xsl:variable>
  61. <!-- Future events -->
  62. <xsl:for-each select="/buildinfo/document/set/event[translate (@start, '-', '') &gt;= translate ($today, '-', '')]">
  63. <xsl:sort select="@start" order="descending" />
  64. <xsl:call-template name="event">
  65. <xsl:with-param name="header">current</xsl:with-param>
  66. </xsl:call-template>
  67. </xsl:for-each>
  68. <xsl:text>END:VCALENDAR</xsl:text>
  69. </xsl:template>
  70. <xsl:template name="ical-escape">
  71. <xsl:param name="text" />
  72. <!-- characters to be backslashed: \;, -->
  73. <xsl:value-of select="str:replace(str:replace(str:replace($text,'\','\\'),',','\,'),';','\;')" />
  74. </xsl:template>
  75. </xsl:stylesheet>