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.5KB

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