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.

fsfe.xsl 4.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. xmlns:dt="http://xsltsl.org/date-time"
  4. exclude-result-prefixes="dt"
  5. xmlns:str="http://exslt.org/strings"
  6. extension-element-prefixes="str">
  7. <xsl:import href="build/xslt/gettext.xsl" />
  8. <xsl:import href="tools/xsltsl/static-elements.xsl" />
  9. <xsl:import href="tools/xsltsl/tagging.xsl" />
  10. <xsl:import href="build/xslt/fsfe_head.xsl" />
  11. <xsl:import href="build/xslt/fsfe_body.xsl" />
  12. <!-- For pages used on external web servers, load the CSS from absolute URL -->
  13. <xsl:variable name="urlprefix">
  14. <xsl:if test="/buildinfo/document/@external">https://fsfe.org</xsl:if>
  15. </xsl:variable>
  16. <!-- EXTRACT / DESCRIPTION of each page -->
  17. <xsl:variable name="metadesc">
  18. <!-- Get the meta element description -->
  19. <xsl:value-of select="/buildinfo/document/head/meta[@name = 'description']/@content" />
  20. </xsl:variable>
  21. <!-- if there is a meta description, take that as an extract -->
  22. <xsl:variable name="extract">
  23. <xsl:choose>
  24. <!-- case 1: if there is a meta description, take that -->
  25. <xsl:when test="$metadesc != ''">
  26. <xsl:value-of select="$metadesc" />
  27. </xsl:when>
  28. <xsl:otherwise>
  29. <!-- take a first extract which should be sufficient for most pages -->
  30. <xsl:variable name="extract1">
  31. <!-- retrieve the first 200 letters of the first p element after h1 -->
  32. <xsl:value-of select="substring(normalize-space(/buildinfo/document/body/h1[1]/following::p[1]),1,155)" />
  33. </xsl:variable>
  34. <!-- define cases what happens with which extract length -->
  35. <xsl:choose>
  36. <!-- case 2: first paragraph is long enough -->
  37. <xsl:when test="string-length($extract1) &gt; 50">
  38. <xsl:value-of select="$extract1" />
  39. <xsl:text>...</xsl:text>
  40. </xsl:when>
  41. <!-- case 3: first paragraph is too short -->
  42. <xsl:otherwise>
  43. <xsl:variable name="extract2">
  44. <!-- retrieve the first 200 letters of the *second* p element after h1 -->
  45. <xsl:value-of select="substring(normalize-space(/buildinfo/document/body/h1[1]/following::p[2]),1,155)" />
  46. </xsl:variable>
  47. <xsl:choose>
  48. <!-- case 3a: second paragraph is long enough -->
  49. <xsl:when test="string-length($extract2) &gt; 50">
  50. <!-- Combine $extract1 and $extract2 with max. 155 characters -->
  51. <xsl:value-of select="substring(normalize-space(concat($extract1, ' ', $extract2)),1,155)" />
  52. <xsl:text>...</xsl:text>
  53. </xsl:when>
  54. <!-- case 3b: also second extract is too short, so take a default text -->
  55. <xsl:otherwise>
  56. <xsl:text>Free Software Foundation Europe is a charity that empowers users to control technology. We enable people to use, understand, adapt and share software.</xsl:text>
  57. </xsl:otherwise>
  58. </xsl:choose>
  59. </xsl:otherwise>
  60. </xsl:choose>
  61. </xsl:otherwise>
  62. </xsl:choose>
  63. </xsl:variable>
  64. <xsl:include href="build/xslt/fsfe_document.xsl" />
  65. <xsl:include href="build/xslt/fsfe_headings.xsl" />
  66. <xsl:include href="build/xslt/fsfe_localmenu.xsl" />
  67. <!-- Do not copy non-HTML elements to output -->
  68. <xsl:include href="build/xslt/fsfe_nolocal.xsl" />
  69. <!-- HTML 5 compatibility doctype, since our XSLT parser doesn't support disabling output escaping -->
  70. <xsl:output method="html" encoding="utf-8" indent="yes" doctype-system="about:legacy-compat" />
  71. <!-- Ignore "latin" tags, used only for printable material -->
  72. <xsl:template match="latin">
  73. <xsl:apply-templates select="@*|node()"/>
  74. </xsl:template>
  75. <!--FIXME ↓-->
  76. <xsl:template match="fetch-news">
  77. <xsl:call-template name="fetch-news">
  78. <xsl:with-param name="tag" select="'/buildinfo/document/sidebar/@news'"/>
  79. <xsl:with-param name="nb-items" select="4"/>
  80. </xsl:call-template>
  81. </xsl:template>
  82. <!-- Static elements which can be included everywhere -->
  83. <xsl:template match="static-element">
  84. <xsl:variable name="id"><xsl:value-of select="@id"/></xsl:variable>
  85. <xsl:copy-of select="/buildinfo/document/set/element[@id=$id]/node()" />
  86. </xsl:template>
  87. </xsl:stylesheet>