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.

events.xsl 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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:dt="http://xsltsl.org/date-time">
  5. <xsl:include href="../tools/xsltsl/date-time.xsl" />
  6. <xsl:output method="xml" encoding="UTF-8" indent="yes" />
  7. <!-- Basically, copy everything -->
  8. <xsl:template match="/">
  9. <xsl:copy>
  10. <xsl:apply-templates select="@*|node()" />
  11. </xsl:copy>
  12. </xsl:template>
  13. <!-- Show a single event -->
  14. <xsl:template name="event">
  15. <xsl:param name="header" />
  16. <!-- Create variables -->
  17. <xsl:variable name="start">
  18. <xsl:value-of select="@start" />
  19. </xsl:variable>
  20. <xsl:variable name="start_day">
  21. <xsl:value-of select="substring($start,9,2)" />
  22. </xsl:variable>
  23. <xsl:variable name="start_month">
  24. <xsl:call-template name="dt:get-month-name-abbreviation">
  25. <xsl:with-param name="month" select="substring($start,6,2)" />
  26. </xsl:call-template>
  27. </xsl:variable>
  28. <xsl:variable name="end">
  29. <xsl:value-of select="@end" />
  30. </xsl:variable>
  31. <xsl:variable name="end_day">
  32. <xsl:value-of select="substring($end,9,2)" />
  33. </xsl:variable>
  34. <xsl:variable name="end_month">
  35. <xsl:call-template name="dt:get-month-name-abbreviation">
  36. <xsl:with-param name="month" select="substring($end,6,2)" />
  37. </xsl:call-template>
  38. </xsl:variable>
  39. <xsl:variable name="link">
  40. <xsl:value-of select="link" />
  41. </xsl:variable>
  42. <xsl:variable name="page">
  43. <xsl:value-of select="page" />
  44. </xsl:variable>
  45. <!-- Before the first event, include the header -->
  46. <xsl:if test="position() = 1">
  47. <h2><xsl:value-of select="/html/text [@id = $header]" /></h2>
  48. </xsl:if>
  49. <!-- Now, the event block -->
  50. <div class="event">
  51. <h3><xsl:value-of select="title" /></h3>
  52. <xsl:choose>
  53. <xsl:when test="$start != $end">
  54. <p class="date multiple">
  55. <span class="n">(</span>
  56. <span class="from">
  57. <span class="day"><xsl:value-of select="$start_day" /> </span>
  58. <span class="month"><xsl:value-of select="$start_month" /></span>
  59. </span>
  60. <span class="conjunction"><xsl:value-of select="/html/text [@id = 'to']" /></span>
  61. <span class="to">
  62. <span class="day"><xsl:value-of select="$end_day" /> </span>
  63. <span class="month"><xsl:value-of select="$end_month" /></span>
  64. </span>
  65. <span class="n">)</span>
  66. </p>
  67. </xsl:when>
  68. <xsl:otherwise>
  69. <p class="date">
  70. <span class="n">(</span>
  71. <span class="day">14 </span>
  72. <span class="month">Jan</span>
  73. <span class="n">)</span>
  74. </p>
  75. </xsl:otherwise>
  76. </xsl:choose>
  77. <xsl:apply-templates select="body/node()" />
  78. <xsl:if test="$link != ''">
  79. <p class="read_more">
  80. <a href="{link}"><xsl:value-of select="/html/text [@id = 'more']" /></a>
  81. </p>
  82. </xsl:if>
  83. <xsl:if test="$page != ''">
  84. <p class="read_more">
  85. <a href="{page}"><xsl:value-of select="/html/text [@id = 'page']" /></a>
  86. </p>
  87. </xsl:if>
  88. </div>
  89. </xsl:template>
  90. <!-- In /html/body node, append dynamic content -->
  91. <xsl:template match="/html/body">
  92. <body>
  93. <!-- First, include what's in the source file -->
  94. <xsl:apply-templates />
  95. <!-- $today = current date (given as <html date="...">) -->
  96. <xsl:variable name="today">
  97. <xsl:value-of select="/html/@date" />
  98. </xsl:variable>
  99. <!-- Current events -->
  100. <xsl:for-each select="/html/set/event
  101. [translate (@start, '-', '') &lt;= translate ($today, '-', '') and
  102. translate (@end, '-', '') &gt;= translate ($today, '-', '')]">
  103. <xsl:sort select="@start" order="descending" />
  104. <xsl:call-template name="event">
  105. <xsl:with-param name="header">current</xsl:with-param>
  106. </xsl:call-template>
  107. </xsl:for-each>
  108. <!-- Future events -->
  109. <xsl:for-each select="/html/set/event
  110. [translate (@start, '-', '') &gt; translate ($today, '-', '')]">
  111. <xsl:sort select="@start" />
  112. <xsl:call-template name="event">
  113. <xsl:with-param name="header">future</xsl:with-param>
  114. </xsl:call-template>
  115. </xsl:for-each>
  116. <!-- Past events -->
  117. <xsl:for-each select="/html/set/event
  118. [translate (@end, '-', '') &lt; translate ($today, '-', '')]">
  119. <xsl:sort select="@end" order="descending" />
  120. <xsl:call-template name="event">
  121. <xsl:with-param name="header">past</xsl:with-param>
  122. </xsl:call-template>
  123. </xsl:for-each>
  124. </body>
  125. </xsl:template>
  126. <!-- Do not copy <set> and <text> to output at all -->
  127. <xsl:template match="set" />
  128. <xsl:template match="text" />
  129. <!-- For all other nodes, copy verbatim -->
  130. <xsl:template match="@*|node()" priority="-1">
  131. <xsl:copy>
  132. <xsl:apply-templates select="@*|node()"/>
  133. </xsl:copy>
  134. </xsl:template>
  135. </xsl:stylesheet>