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 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?xml version="1.0" encoding="ISO-8859-1"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  3. <xsl:output method="xml" encoding="ISO-8859-1" indent="yes" />
  4. <!-- $today = current date (given as <html date="...">) -->
  5. <xsl:variable name="today">
  6. <xsl:value-of select="/html/@date" />
  7. </xsl:variable>
  8. <!-- Basically, copy everything -->
  9. <xsl:template match="/">
  10. <xsl:copy>
  11. <xsl:apply-templates select="@*|node()" />
  12. </xsl:copy>
  13. </xsl:template>
  14. <!-- Show a single news item -->
  15. <xsl:template name="news">
  16. <div class="entry">
  17. <h3><xsl:value-of select="title" /></h3>
  18. <div class="date"><xsl:value-of select="@date" /></div>
  19. <div class="text">
  20. <xsl:apply-templates select="body/node()" />
  21. <xsl:variable name="link"><xsl:value-of select="link" /></xsl:variable>
  22. <xsl:if test="$link!=''">
  23. <xsl:text> </xsl:text>
  24. <a class="read_more" href="{link}"><xsl:value-of select="/html/text[@id='more']" /></a>
  25. </xsl:if>
  26. </div>
  27. </div>
  28. </xsl:template>
  29. <!-- Show a single event -->
  30. <xsl:template name="event">
  31. <xsl:variable name="start"><xsl:value-of select="@start" /></xsl:variable>
  32. <xsl:variable name="end"><xsl:value-of select="@end" /></xsl:variable>
  33. <xsl:variable name="link"><xsl:value-of select="link" /></xsl:variable>
  34. <div class="event">
  35. <h3><xsl:value-of select="title" /></h3>
  36. <div class="date">
  37. <xsl:value-of select="@start" />
  38. <xsl:if test="$start != $end">
  39. <br />
  40. <xsl:value-of select="@end" />
  41. </xsl:if>
  42. </div>
  43. <div class="text">
  44. <xsl:apply-templates select="body/node()" />
  45. <xsl:if test="$link!=''">
  46. <xsl:text> </xsl:text>
  47. <a class="read_more" href="{link}"><xsl:value-of select="/html/text[@id='more']" /></a>
  48. </xsl:if>
  49. </div>
  50. </div>
  51. </xsl:template>
  52. <!-- In /html/body node, append dynamic content -->
  53. <xsl:template match="/html/body">
  54. <body>
  55. <xsl:apply-templates />
  56. <div id="news">
  57. <h2><xsl:value-of select="/html/text[@id='news']" /></h2>
  58. <xsl:for-each select="/html/set/news
  59. [translate (@date, '-', '') &lt;= translate ($today, '-', '')]">
  60. <xsl:sort select="@date" order="descending" />
  61. <xsl:if test="position() &lt; 6">
  62. <xsl:call-template name="news" />
  63. </xsl:if>
  64. </xsl:for-each>
  65. <ul class="tools">
  66. <li><a class="more_news" href="news/news.html"><xsl:value-of select="/html/text[@id='morenews']" /></a></li>
  67. <li><a class="rss" href="news/news.rss">RSS</a></li>
  68. </ul>
  69. </div> <!-- /#news -->
  70. <div id="events">
  71. <h2><xsl:value-of select="/html/text[@id='events']" /></h2>
  72. <xsl:for-each select="/html/set/event
  73. [translate (@end, '-', '') &gt;= translate ($today, '-', '')]">
  74. <xsl:sort select="@start" />
  75. <xsl:if test="position() &lt; 6">
  76. <xsl:call-template name="event" />
  77. </xsl:if>
  78. </xsl:for-each>
  79. <ul class="tools">
  80. <li><a class="more_events" href="events/events.html"><xsl:value-of select="/html/text[@id='moreevents']" /></a></li>
  81. <li><a class="rss" href="events/events.rss">RSS</a></li>
  82. </ul>
  83. </div> <!-- /#events -->
  84. </body>
  85. </xsl:template>
  86. <!-- Do not copy <set> and <text> to output at all -->
  87. <xsl:template match="/html/text" />
  88. <xsl:template match="set" />
  89. <!-- For all other nodes, copy verbatim -->
  90. <xsl:template match="@*|node()" priority="-1">
  91. <xsl:copy>
  92. <xsl:apply-templates select="@*|node()"/>
  93. </xsl:copy>
  94. </xsl:template>
  95. </xsl:stylesheet>