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.

index.xsl 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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:import href="tools/xsltsl/date-time.xsl" />
  6. <xsl:output method="xml" encoding="UTF-8" indent="yes" />
  7. <!-- $today = current date (given as <html date="...">) -->
  8. <xsl:variable name="today">
  9. <xsl:value-of select="/html/@date" />
  10. </xsl:variable>
  11. <!-- Basically, copy everything -->
  12. <xsl:template match="/">
  13. <xsl:copy>
  14. <xsl:apply-templates select="@*|node()" />
  15. </xsl:copy>
  16. </xsl:template>
  17. <!-- Show a single news item -->
  18. <xsl:template name="news">
  19. <xsl:variable name="link"><xsl:value-of select="link" /></xsl:variable>
  20. <div class="entry">
  21. <xsl:choose>
  22. <xsl:when test="$link != ''">
  23. <h3><a href="{link}"><xsl:value-of select="title" /></a></h3>
  24. </xsl:when>
  25. <xsl:otherwise>
  26. <h3><xsl:value-of select="title" /></h3>
  27. </xsl:otherwise>
  28. </xsl:choose>
  29. <div class="text">
  30. <xsl:apply-templates select="body/node()" />
  31. </div>
  32. </div>
  33. </xsl:template>
  34. <!-- Show a single event -->
  35. <xsl:template name="event">
  36. <!-- Create variables -->
  37. <xsl:variable name="start">
  38. <xsl:value-of select="@start" />
  39. </xsl:variable>
  40. <xsl:variable name="start_day">
  41. <xsl:value-of select="substring($start,9,2)" />
  42. </xsl:variable>
  43. <xsl:variable name="start_month">
  44. <xsl:call-template name="dt:get-month-abbreviation">
  45. <xsl:with-param name="month" select="substring($start,6,2)" />
  46. </xsl:call-template>
  47. </xsl:variable>
  48. <xsl:variable name="end">
  49. <xsl:value-of select="@end" />
  50. </xsl:variable>
  51. <xsl:variable name="end_day">
  52. <xsl:value-of select="substring($end,9,2)" />
  53. </xsl:variable>
  54. <xsl:variable name="end_month">
  55. <xsl:call-template name="dt:get-month-abbreviation">
  56. <xsl:with-param name="month" select="substring($end,6,2)" />
  57. </xsl:call-template>
  58. </xsl:variable>
  59. <xsl:variable name="link">
  60. <xsl:value-of select="link" />
  61. </xsl:variable>
  62. <div class="event">
  63. <xsl:choose>
  64. <xsl:when test="$link != ''">
  65. <h3><a href="{link}"><xsl:value-of select="title" /></a></h3>
  66. </xsl:when>
  67. <xsl:otherwise>
  68. <h3><xsl:value-of select="title" /></h3>
  69. </xsl:otherwise>
  70. </xsl:choose>
  71. <xsl:choose>
  72. <xsl:when test="$start != $end">
  73. <p class="date multiple">
  74. <span class="n">(</span>
  75. <span class="from">
  76. <span class="day"><xsl:value-of select="$start_day" /></span>
  77. <xsl:text> </xsl:text>
  78. <span class="month"><xsl:value-of select="$start_month" /></span>
  79. </span>
  80. <xsl:text> </xsl:text>
  81. <span class="conjunction">
  82. </span>
  83. <xsl:text> </xsl:text>
  84. <span class="to">
  85. <span class="day"><xsl:value-of select="$end_day" /></span>
  86. <xsl:text> </xsl:text>
  87. <span class="month"><xsl:value-of select="$end_month" /></span>
  88. </span>
  89. <span class="n">)</span>
  90. </p>
  91. </xsl:when>
  92. <xsl:otherwise>
  93. <p class="date">
  94. <span class="n">(</span>
  95. <span class="day"><xsl:value-of select="$start_day" /></span>
  96. <xsl:text> </xsl:text>
  97. <span class="month"><xsl:value-of select="$start_month" /></span>
  98. <span class="n">)</span>
  99. </p>
  100. </xsl:otherwise>
  101. </xsl:choose>
  102. <div class="details">
  103. <xsl:apply-templates select="body/node()" />
  104. </div>
  105. </div>
  106. </xsl:template>
  107. <!-- In /html/body node, append dynamic content -->
  108. <xsl:template match="/html/body">
  109. <body>
  110. <!--
  111. <p id="banner">
  112. <a href="http://documentfreedom.org"><img alt="Document Freedom Day" src="http://www.documentfreedom.org/images/2/2c/2010-banner-120x60.png"/></a>
  113. </p>
  114. -->
  115. <xsl:apply-templates />
  116. <div id="news">
  117. <h2><a href="/news/news.html"><xsl:value-of select="/html/text[@id='news']"/></a></h2>
  118. <xsl:for-each select="/html/set/news
  119. [translate (@date, '-', '') &lt;= translate ($today, '-', '')]">
  120. <xsl:sort select="@date" order="descending" />
  121. <xsl:if test="position() &lt; 6">
  122. <xsl:call-template name="news" />
  123. </xsl:if>
  124. </xsl:for-each>
  125. <ul class="tools">
  126. <li><a class="more_news" href="/news/news.html"><xsl:value-of select="/html/text[@id='morenews']" /></a></li>
  127. <li><a class="rss feed" href="/news/news.rss">RSS</a></li>
  128. </ul>
  129. </div> <!-- /#news -->
  130. <div id="events">
  131. <h2><a href="/events/events.html"><xsl:value-of select="/html/text[@id='events']"/></a></h2>
  132. <xsl:for-each select="/html/set/event
  133. [translate (@end, '-', '') &gt;= translate ($today, '-', '')]">
  134. <xsl:sort select="@start" />
  135. <xsl:if test="position() &lt; 6">
  136. <xsl:call-template name="event" />
  137. </xsl:if>
  138. </xsl:for-each>
  139. <ul class="tools">
  140. <li><a class="more_events" href="/events/events.html"><xsl:value-of select="/html/text[@id='moreevents']" /></a></li>
  141. <li><a class="rss feed" href="/events/events.rss">RSS</a></li>
  142. </ul>
  143. </div> <!-- /#events -->
  144. </body>
  145. </xsl:template>
  146. <!-- Do not copy <set> and <text> to output at all -->
  147. <xsl:template match="/html/text" />
  148. <xsl:template match="set" />
  149. <!-- For all other nodes, copy verbatim -->
  150. <xsl:template match="@*|node()" priority="-1">
  151. <xsl:copy>
  152. <xsl:apply-templates select="@*|node()"/>
  153. </xsl:copy>
  154. </xsl:template>
  155. </xsl:stylesheet>