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.

news.xsl 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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="../fsfe.xsl" />
  6. <xsl:import href="../tools/xsltsl/date-time.xsl" />
  7. <xsl:output method="html"
  8. encoding="utf-8"
  9. indent="yes"
  10. doctype-system="about:legacy-compat" />
  11. <!-- in /html/body node, append dynamic content -->
  12. <xsl:template match="/buildinfo/document/body/include-news">
  13. <!-- first, include what's in the source file -->
  14. <xsl:apply-templates />
  15. <!-- $today = current date (given as <html date="...">) -->
  16. <xsl:variable name="today">
  17. <xsl:value-of select="/buildinfo/@date" />
  18. </xsl:variable>
  19. <!-- show news except those in the future, but no newsletters -->
  20. <xsl:for-each select="/buildinfo/document/set/news
  21. [translate (@date, '-', '') &lt;= translate ($today, '-', '')
  22. and not (@type = 'newsletter')]">
  23. <xsl:sort select="@date" order="descending" />
  24. <!-- begin: news entry -->
  25. <section class="archivenews">
  26. <!-- title (linked) -->
  27. <h3><xsl:choose><xsl:when test="link != ''">
  28. <a href="{link}"><xsl:value-of select="title" /></a>
  29. </xsl:when><xsl:otherwise>
  30. <xsl:value-of select="title" />
  31. </xsl:otherwise></xsl:choose></h3>
  32. <!-- date and author -->
  33. <ul class="archivemeta">
  34. <li> <!-- date -->
  35. <xsl:value-of select="substring(@date,9,2)" />
  36. <xsl:text> </xsl:text>
  37. <xsl:call-template name="dt:get-month-name">
  38. <xsl:with-param name="month" select="substring(@date,6,2)" />
  39. </xsl:call-template>
  40. <xsl:text> </xsl:text>
  41. <xsl:value-of select="substring(@date,1,4)" />
  42. </li> <!-- author -->
  43. <xsl:if test="/buildinfo/document/set/news/author">
  44. <xsl:apply-templates select="author" />
  45. </xsl:if></ul>
  46. <!-- text and read-more-link -->
  47. <p><xsl:apply-templates select="body/node()" />
  48. <xsl:apply-templates select="link" /></p>
  49. <!-- tags -->
  50. <xsl:if test="/buildinfo/document/set/news/tags/tag
  51. [not(. = 'front-page' or @key = 'front-page')]">
  52. <ul class="archivetaglist"><xsl:apply-templates select="tags" /></ul>
  53. </xsl:if>
  54. </section>
  55. <!-- end: news entry -->
  56. </xsl:for-each>
  57. </xsl:template>
  58. <!-- how to display: author -->
  59. <xsl:template match="buildinfo/document/set/news/author">
  60. <xsl:variable name="id" select="@id" />
  61. <xsl:if test="position() = 1">
  62. <li class="archiveauthor"><xsl:text>&#x2014;</xsl:text></li>
  63. </xsl:if>
  64. <li> <!-- if author is in fsfe's people.xml, take information from there -->
  65. <xsl:choose>
  66. <!-- author is in people.en.xml -->
  67. <xsl:when test="@id and document('../about/people/people.en.xml')/personset/person[@id=$id]">
  68. <xsl:choose>
  69. <!-- person has a link -->
  70. <xsl:when test="document('../about/people/people.en.xml')/personset/person[@id=$id]/link">
  71. <a rel="author" href="{document('../about/people/people.en.xml')/personset/person[@id=$id]/link}">
  72. <xsl:value-of select="document('../about/people/people.en.xml')/personset/person[@id=$id]/name" />
  73. </a></xsl:when>
  74. <!-- person has no link -->
  75. <xsl:otherwise>
  76. <span>
  77. <xsl:value-of select="document('../about/people/people.en.xml')/personset/person[@id=$id]/name" />
  78. </span></xsl:otherwise></xsl:choose>
  79. </xsl:when>
  80. <!-- author is not in people.en.xml -->
  81. <xsl:otherwise>
  82. <xsl:choose>
  83. <!-- person has a link -->
  84. <xsl:when test="link">
  85. <a rel="author" href="{link}"><xsl:value-of select="name" /></a>
  86. </xsl:when>
  87. <!-- person has no link -->
  88. <xsl:otherwise>
  89. <span class="author p-author"><xsl:value-of select="name" />
  90. </span></xsl:otherwise></xsl:choose>
  91. </xsl:otherwise></xsl:choose>
  92. <xsl:if test="not(position() = last())">
  93. <xsl:text>, </xsl:text>
  94. </xsl:if>
  95. </li>
  96. </xsl:template>
  97. <!-- how to display: read-more-link -->
  98. <xsl:template match="/buildinfo/document/set/news/link">
  99. <xsl:text>&#160;</xsl:text>
  100. <a class="learn-more" href="{text()}"></a>
  101. </xsl:template>
  102. <!-- how to display: tags -->
  103. <xsl:template match="buildinfo/document/set/news/tags">
  104. <xsl:for-each select="tag[not(. = 'front-page' or @key = 'front-page')]">
  105. <xsl:variable name="keyname"
  106. select="translate(@key,'ABCDEFGHIJKLMNOPQRSTUVWXYZ-_+ /','abcdefghijklmnopqrstuvwxyz')" />
  107. <xsl:variable name="tagname"
  108. select="translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ-_+ /','abcdefghijklmnopqrstuvwxyz')" />
  109. <xsl:choose>
  110. <xsl:when test="@key and .">
  111. <li><a href="/tags/tagged-{$keyname}.html"><xsl:value-of select="." /></a></li>
  112. </xsl:when><xsl:when test="@content and not(@content = '')"><!-- Legacy -->
  113. <li><a href="/tags/tagged-{$tagname}.html"><xsl:value-of select="@content" /></a></li>
  114. </xsl:when><xsl:when test="@key"><!-- bad style -->
  115. <li><a href="/tags/tagged-{$keyname}.html"><xsl:value-of select="@key" /></a></li>
  116. </xsl:when><xsl:otherwise><!-- Legacy and bad style -->
  117. <li><a href="/tags/tagged-{$tagname}.html"><xsl:value-of select="." /></a></li>
  118. </xsl:otherwise></xsl:choose>
  119. </xsl:for-each>
  120. </xsl:template>
  121. </xsl:stylesheet>