build/xslt (#5299)
All checks were successful
continuous-integration/drone/push Build is passing

This properly separtes out the python build process (theoretically portable and useable for different sites) and the xslt (custom to the fsfe sites, not really portable as a whole)

It also moves some thirdparty tooling around to make it clearer its thirdparty and unify xslt sources.

Co-authored-by: Darragh Elliott <me@delliott.net>
Reviewed-on: #5299
Reviewed-by: tobiasd <tobiasd@fsfe.org>
Co-authored-by: delliott <delliott@fsfe.org>
Co-committed-by: delliott <delliott@fsfe.org>
This commit was merged in pull request #5299.
This commit is contained in:
2025-09-15 06:23:57 +00:00
committed by tobiasd
parent b195bb1f0f
commit 1315a7d481
55 changed files with 68 additions and 81 deletions

View File

@@ -39,9 +39,9 @@ This repository also contains the source files of other websites the FSFE hosts:
Notable top level directories are:
- `build`: Mostly custom Bash and XSL scripts to build the website
- `global`: Globally used data files and modules, also the static translated strings.
- `tools`: Contains miscellaneous XML, XSL, and SH files.
- `build`: Python build tooling.
- `global`: Globally used data files, modules, XSl, also the static translated strings. Generally contains data used in multiple sites, but not suitable to place in build process.
- `tools`: Contains miscellaneous scripts and tools, usually not used as part of the build process. Rather for contributor use.
And of course the different website folders.

View File

@@ -110,12 +110,9 @@ def get_version(file: Path) -> int:
"""
Get the version tag of an xhtml|xml file
"""
xslt_tree = etree.parse(Path("build/xslt/get_version.xsl"))
transform = etree.XSLT(xslt_tree)
result_tree = transform(etree.parse(file))
result = str(result_tree).strip()
if result == "":
result = str(0)
xml = etree.parse(file)
result_list = xml.xpath("/*/version")
result = result_list[0].text if result_list else str(0)
logger.debug("Got version: %s", result)
return int(result)

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- ====================================================================== -->
<!-- Extract the content of <version> element from an XML file -->
<!-- ====================================================================== -->
<!-- This XSL script processes the <version> elements of an XML file and -->
<!-- outputs its content. It is used to check for outdated translations. -->
<!-- ====================================================================== -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output doctype-system="about:legacy-compat" encoding="utf-8" indent="no" method="text" omit-xml-declaration="yes"/>
<xsl:template match="version">
<xsl:value-of select="."/>
</xsl:template>
<!-- Suppress output of text nodes, which would be the default -->
<xsl:template match="text()"/>
</xsl:stylesheet>

View File

@@ -3,6 +3,6 @@
<xsl:import href="xslt/drm_info_head.xsl"/>
<xsl:import href="xslt/drm_info_body.xsl"/>
<xsl:output doctype-system="about:legacy-compat" encoding="utf-8" indent="no" method="html" omit-xml-declaration="yes"/>
<xsl:include href="../build/xslt/fsfe_document.xsl"/>
<xsl:include href="../build/xslt/fsfe_nolocal.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_document.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_nolocal.xsl"/>
</xsl:stylesheet>

View File

@@ -2,10 +2,10 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Prefix for links to FSFE's main website -->
<xsl:variable name="urlprefix">https://fsfe.org</xsl:variable>
<xsl:include href="../../build/xslt/notifications.xsl"/>
<xsl:include href="../../build/xslt/translation_list.xsl"/>
<xsl:include href="../../build/xslt/gettext.xsl"/>
<xsl:include href="../../build/xslt/static-elements.xsl"/>
<xsl:include href="../../global/xslt/internal/notifications.xsl"/>
<xsl:include href="../../global/xslt/internal/translation_list.xsl"/>
<xsl:include href="../../global/xslt/internal/gettext.xsl"/>
<xsl:include href="../../global/xslt/internal/static-elements.xsl"/>
<xsl:template name="page-body">
<xsl:element name="body">
<xsl:element name="header">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../fsfe.xsl"/>
<xsl:import href="../../build/xslt/people.xsl"/>
<xsl:import href="../../global/xslt/internal/people.xsl"/>
<!-- All people with council tag -->
<xsl:template match="care-team-list">
<xsl:call-template name="country-people-list">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../../fsfe.xsl"/>
<xsl:import href="../../../build/xslt/people.xsl"/>
<xsl:import href="../../../global/xslt/internal/people.xsl"/>
<!-- Fill dynamic content -->
<!-- All people with council tag -->
<xsl:template match="council-members">

View File

@@ -62,7 +62,7 @@
- /about/people/index.xsl: In this file, tags like <council-members /> are defined.
- /about/people/index.sources: Where to look for people-files, translations of functions/activities/countries and so on
- /about/people/avatars/: Place for all avatar pictures
- /build/xslt/people.xsl: The building of the team lists itself: Links, Background colors, inclusion of avatars etc
- /xslt/internal/people.xsl: The building of the team lists itself: Links, Background colors, inclusion of avatars etc
-->
<!--
Improvement ideas:

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../../fsfe.xsl"/>
<xsl:import href="../../../build/xslt/countries.xsl"/>
<xsl:import href="../../../global/xslt/internal/countries.xsl"/>
<xsl:template match="/buildinfo/document/body/include-signatures">
<xsl:apply-templates/>
<h3 id="organisations"><xsl:call-template name="fsfe-gettext"><xsl:with-param name="id" select="'osig'"/></xsl:call-template>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../../fsfe.xsl"/>
<xsl:import href="../../../build/xslt/countries.xsl"/>
<xsl:import href="../../../global/xslt/internal/countries.xsl"/>
<xsl:template match="sigtable">
<xsl:copy-of select="document('sigtable.en.xml')"/>
</xsl:template>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../../fsfe.xsl"/>
<xsl:import href="../../../build/xslt/countries.xsl"/>
<xsl:import href="../../../global/xslt/internal/countries.xsl"/>
<!-- Dropdown list of countries requiring a choice -->
<!-- when copying this, remember importing the xsl, and editing the .source file -->
<xsl:template match="country-list">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../fsfe.xsl"/>
<xsl:import href="../../build/xslt/countries.xsl"/>
<xsl:import href="../../global/xslt/internal/countries.xsl"/>
<!-- Fill dynamic content -->
<xsl:template match="dynamic-content">
<xsl:variable name="type">

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../../fsfe.xsl"/>
<xsl:import href="../../../build/xslt/people.xsl"/>
<xsl:import href="../../../global/xslt/internal/people.xsl"/>
<xsl:template match="translation-coordinators-list">
<xsl:call-template name="country-people-list">
<xsl:with-param name="team" select="'translation-coordinators'"/>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../../fsfe.xsl"/>
<xsl:import href="../../../build/xslt/countries.xsl"/>
<xsl:import href="../../../global/xslt/internal/countries.xsl"/>
<!-- Dropdown list of countries requiring a choice -->
<!-- when copying this, remember importing the xsl, and editing the .source file -->
<xsl:template match="country-list">

View File

@@ -4,15 +4,15 @@
<xsl:variable name="urlprefix">
<xsl:if test="/buildinfo/document/@external">https://fsfe.org</xsl:if>
</xsl:variable>
<xsl:include href="../build/xslt/fsfe_head.xsl"/>
<xsl:include href="../build/xslt/fsfe_body.xsl"/>
<xsl:include href="../build/xslt/gettext.xsl"/>
<xsl:include href="../build/xslt/static-elements.xsl"/>
<xsl:include href="../build/xslt/fsfe-cd.xsl"/>
<xsl:include href="../build/xslt/module.xsl"/>
<xsl:include href="../build/xslt/related.xsl"/>
<xsl:include href="../build/xslt/email-obfuscate.xsl"/>
<xsl:include href="../build/xslt/peertube.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_head.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_body.xsl"/>
<xsl:include href="../global/xslt/internal/gettext.xsl"/>
<xsl:include href="../global/xslt/internal/static-elements.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe-cd.xsl"/>
<xsl:include href="../global/xslt/internal/module.xsl"/>
<xsl:include href="../global/xslt/internal/related.xsl"/>
<xsl:include href="../global/xslt/internal/email-obfuscate.xsl"/>
<xsl:include href="../global/xslt/internal/peertube.xsl"/>
<!-- HTML 5 compatibility doctype, since our XSLT parser doesn't support disabling output escaping -->
<xsl:output doctype-system="about:legacy-compat" encoding="utf-8" indent="no" method="html" omit-xml-declaration="yes"/>
<!-- EXTRACT / DESCRIPTION of each page -->
@@ -63,9 +63,9 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:include href="../build/xslt/fsfe_document.xsl"/>
<xsl:include href="../build/xslt/fsfe_headings.xsl"/>
<xsl:include href="../build/xslt/fsfe_localmenu.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_document.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_headings.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_localmenu.xsl"/>
<!-- Do not copy non-HTML elements to output -->
<xsl:include href="../build/xslt/fsfe_nolocal.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_nolocal.xsl"/>
</xsl:stylesheet>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../fsfe.xsl"/>
<xsl:import href="../../build/xslt/static-elements.xsl"/>
<xsl:import href="../../global/xslt/internal/static-elements.xsl"/>
<xsl:template match="/buildinfo/document/body/include-newsletter">
<xsl:apply-templates/>
<xsl:for-each select="/buildinfo/document/set/news[ translate(@date, '-', '') &lt;= translate(/buildinfo/@date, '-', '') ]">

View File

@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- XSL stylesheet for generating podcast RSS feeds -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dt="http://xsltsl.org/date-time" xmlns:weekdays="." xmlns:months="." xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:psc="http://podlove.org/simple-chapters" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:podcast="https://podcastindex.org/namespace/1.0" version="1.0">
<xsl:import href="../../build/xslt/gettext.xsl"/>
<xsl:import href="../../build/xslt/fsfe-cd.xsl"/>
<xsl:import href="../../global/xslt/internal/gettext.xsl"/>
<xsl:import href="../../global/xslt/internal/fsfe-cd.xsl"/>
<xsl:output doctype-system="about:legacy-compat" encoding="utf-8" indent="no" method="xml" omit-xml-declaration="yes"/>
<!-- ====== -->
<!-- Months -->

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:import href="../fsfe.xsl"/>
<xsl:import href="../../build/xslt/countries.xsl"/>
<xsl:import href="../../global/xslt/internal/countries.xsl"/>
<!-- Fill dynamic content -->
<xsl:template match="dynamic-content">
<xsl:variable name="type">

3
global/README.md Normal file
View File

@@ -0,0 +1,3 @@
# Global folder
This folder contains stuff common to all sites, but that is not necessarily portable for use for sites outside of the FSFE.

3
global/xslt/README.md Normal file
View File

@@ -0,0 +1,3 @@
# XSLT
This folder contains xslt used in multiple sites, both inhouse and thirdparty

View File

@@ -1,5 +1,4 @@
this directory is reserved for xls files, that were developed for the fsfe page in particular
if you download xslt libraries from external sources, put them into
tools/xsltsl/ (deprecated)
build/xsltlib/
../thirdparty

View File

@@ -3,7 +3,7 @@
<!-- XML tag for obfuscating an email address against scaper bots -->
<!-- ====================================================================== -->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" version="1.0">
<xsl:import href="../../tools/xsltsl/tokenize.xsl"/>
<xsl:import href="../thirdparty/tokenize.xsl"/>
<!-- plain email is the input -->
<xsl:template name="email" match="email">
<xsl:param name="email" select="."/>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dt="http://xsltsl.org/date-time" version="1.0" exclude-result-prefixes="dt">
<xsl:import href="../../tools/xsltsl/date-time.xsl"/>
<xsl:import href="../thirdparty/date-time.xsl"/>
<!-- ==================================================================== -->
<!-- Event title with or without link -->
<!-- ==================================================================== -->

View File

@@ -124,8 +124,8 @@
<xsl:attribute name="name">author</xsl:attribute>
<xsl:attribute name="content">
<xsl:choose>
<xsl:when test="@id and document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]">
<xsl:value-of select="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/name"/>
<xsl:when test="@id and document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]">
<xsl:value-of select="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/name"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="name"/>

View File

@@ -65,36 +65,36 @@
<xsl:value-of select="@id"/>
</xsl:variable>
<xsl:choose>
<xsl:when test="@id and document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]">
<xsl:when test="@id and document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]">
<!-- if the author is in fsfe's people.xml then we take information from there -->
<xsl:choose>
<!-- person has a link -->
<xsl:when test="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/link">
<xsl:when test="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/link">
<xsl:element name="a">
<xsl:attribute name="class">author p-author h-card</xsl:attribute>
<xsl:attribute name="rel">author</xsl:attribute>
<xsl:attribute name="href">
<xsl:value-of select="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/link"/>
<xsl:value-of select="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/link"/>
</xsl:attribute>
<xsl:if test="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/avatar">
<xsl:if test="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/avatar">
<xsl:element name="img">
<xsl:attribute name="alt"/>
<xsl:attribute name="src">/about/people/avatars/<xsl:value-of select="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/avatar"/></xsl:attribute>
<xsl:attribute name="src">/about/people/avatars/<xsl:value-of select="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/avatar"/></xsl:attribute>
</xsl:element>
</xsl:if>
<xsl:value-of select="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/name"/>
<xsl:value-of select="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/name"/>
</xsl:element>
</xsl:when>
<!-- person has no link -->
<xsl:otherwise>
<xsl:if test="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/avatar">
<xsl:if test="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/avatar">
<xsl:element name="img">
<xsl:attribute name="alt"/>
<xsl:attribute name="src">/about/people/avatars/<xsl:value-of select="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/avatar"/></xsl:attribute>
<xsl:attribute name="src">/about/people/avatars/<xsl:value-of select="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/avatar"/></xsl:attribute>
</xsl:element>
</xsl:if>
<span class="author p-author">
<xsl:value-of select="document('../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/name"/>
<xsl:value-of select="document('../../../fsfe.org/about/people/people.en.xml')/personset/person[@id=$id]/name"/>
</span>
</xsl:otherwise>
</xsl:choose>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dt="http://xsltsl.org/date-time" xmlns:str="http://xsltsl.org/string" version="1.0" exclude-result-prefixes="dt">
<xsl:import href="../../tools/xsltsl/date-time.xsl"/>
<xsl:import href="../../tools/xsltsl/string.xsl"/>
<xsl:import href="../thirdparty/date-time.xsl"/>
<xsl:import href="../thirdparty/string.xsl"/>
<!-- ==================================================================== -->
<!-- News image with or without link -->
<!-- ==================================================================== -->

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dt="http://xsltsl.org/date-time" xmlns:weekdays="." xmlns:months="." xmlns:nl="." xmlns:str="http://xsltsl.org/string" version="1.0" exclude-result-prefixes="dt weekdays months nl str">
<xsl:import href="../../tools/xsltsl/string.xsl"/>
<xsl:import href="../thirdparty/string.xsl"/>
<xsl:template name="subscribe-nl">
<xsl:variable name="lang">
<xsl:value-of select="/buildinfo/document/@language"/>

View File

@@ -3,7 +3,7 @@
<xsl:import href="xslt/pdfreaders_head.xsl"/>
<xsl:import href="xslt/pdfreaders_body.xsl"/>
<xsl:output doctype-system="about:legacy-compat" encoding="utf-8" indent="no" method="html" omit-xml-declaration="yes"/>
<xsl:include href="../build/xslt/fsfe_document.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_document.xsl"/>
<xsl:include href="xslt/pdfreaders_list.xsl"/>
<xsl:include href="../build/xslt/fsfe_nolocal.xsl"/>
<xsl:include href="../global/xslt/internal/fsfe_nolocal.xsl"/>
</xsl:stylesheet>

View File

@@ -2,11 +2,11 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- Prefix for links to FSFE's main website -->
<xsl:variable name="urlprefix">https://fsfe.org</xsl:variable>
<xsl:include href="../../build/xslt/notifications.xsl"/>
<xsl:include href="../../build/xslt/translation_list.xsl"/>
<xsl:include href="../../build/xslt/fsfe_pagefooter.xsl"/>
<xsl:include href="../../build/xslt/gettext.xsl"/>
<xsl:include href="../../build/xslt/static-elements.xsl"/>
<xsl:include href="../../global/xslt/internal/notifications.xsl"/>
<xsl:include href="../../global/xslt/internal/translation_list.xsl"/>
<xsl:include href="../../global/xslt/internal/fsfe_pagefooter.xsl"/>
<xsl:include href="../../global/xslt/internal/gettext.xsl"/>
<xsl:include href="../../global/xslt/internal/static-elements.xsl"/>
<xsl:template name="page-body">
<xsl:element name="body">
<xsl:element name="header">