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.
 
 
 
 
 
 

82 lines
3.7 KiB

  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. <!-- For pages used on external web servers, load the CSS from absolute URL -->
  8. <xsl:variable name="urlprefix">
  9. <xsl:if test="/buildinfo/document/@external">https://fsfe.org</xsl:if>
  10. </xsl:variable>
  11. <xsl:include href="build/xslt/fsfe_head.xsl" />
  12. <xsl:include href="build/xslt/fsfe_body.xsl" />
  13. <xsl:include href="build/xslt/gettext.xsl" />
  14. <xsl:include href="build/xslt/static-elements.xsl" />
  15. <xsl:include href="build/xslt/fsfe-cd.xsl" />
  16. <xsl:include href="build/xslt/module.xsl" />
  17. <xsl:include href="build/xslt/related.xsl" />
  18. <!-- HTML 5 compatibility doctype, since our XSLT parser doesn't support disabling output escaping -->
  19. <xsl:output method="html" encoding="utf-8" indent="yes" doctype-system="about:legacy-compat" />
  20. <!-- EXTRACT / DESCRIPTION of each page -->
  21. <xsl:variable name="metadesc">
  22. <!-- Get the meta element description -->
  23. <xsl:value-of select="/buildinfo/document/head/meta[@name = 'description']/@content" />
  24. </xsl:variable>
  25. <!-- if there is a meta description, take that as an extract -->
  26. <xsl:variable name="extract">
  27. <xsl:choose>
  28. <!-- case 1: if there is a meta description, take that -->
  29. <xsl:when test="$metadesc != ''">
  30. <xsl:value-of select="$metadesc" />
  31. </xsl:when>
  32. <xsl:otherwise>
  33. <!-- take a first extract which should be sufficient for most pages -->
  34. <xsl:variable name="extract1">
  35. <!-- retrieve the first 200 letters of the first p element after h1 -->
  36. <xsl:value-of select="substring(normalize-space(/buildinfo/document/body/h1[1]/following::p[1]),1,155)" />
  37. </xsl:variable>
  38. <!-- define cases what happens with which extract length -->
  39. <xsl:choose>
  40. <!-- case 2: first paragraph is long enough -->
  41. <xsl:when test="string-length($extract1) &gt; 50">
  42. <xsl:value-of select="$extract1" />
  43. <xsl:text>...</xsl:text>
  44. </xsl:when>
  45. <!-- case 3: first paragraph is too short -->
  46. <xsl:otherwise>
  47. <xsl:variable name="extract2">
  48. <!-- retrieve the first 200 letters of the *second* p element after h1 -->
  49. <xsl:value-of select="substring(normalize-space(/buildinfo/document/body/h1[1]/following::p[2]),1,155)" />
  50. </xsl:variable>
  51. <xsl:choose>
  52. <!-- case 3a: second paragraph is long enough -->
  53. <xsl:when test="string-length($extract2) &gt; 50">
  54. <!-- Combine $extract1 and $extract2 with max. 155 characters -->
  55. <xsl:value-of select="substring(normalize-space(concat($extract1, ' ', $extract2)),1,155)" />
  56. <xsl:text>...</xsl:text>
  57. </xsl:when>
  58. <!-- case 3b: also second extract is too short, so take a default text -->
  59. <xsl:otherwise>
  60. <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>
  61. </xsl:otherwise>
  62. </xsl:choose>
  63. </xsl:otherwise>
  64. </xsl:choose>
  65. </xsl:otherwise>
  66. </xsl:choose>
  67. </xsl:variable>
  68. <xsl:include href="build/xslt/fsfe_document.xsl" />
  69. <xsl:include href="build/xslt/fsfe_headings.xsl" />
  70. <xsl:include href="build/xslt/fsfe_localmenu.xsl" />
  71. <!-- Do not copy non-HTML elements to output -->
  72. <xsl:include href="build/xslt/fsfe_nolocal.xsl" />
  73. </xsl:stylesheet>