Proposals for the "less live build" pull request #960

Merged
mweimann merged 3 commits from feature/dev-less-reinhard into feature/dev-less 2019-05-28 17:33:11 +00:00
9 changed files with 66 additions and 55 deletions

1
.gitignore vendored
View File

@@ -17,3 +17,4 @@ news/????/index.xsl
news/*/.*.??.xml
about/printable/archive/printable.en.xml
look/fsfe.min.css
look/valentine.min.css

View File

@@ -10,6 +10,18 @@
.PHONY: all .FORCE
.FORCE:
# -----------------------------------------------------------------------------
# Update CSS files
# -----------------------------------------------------------------------------
# This step recompiles the less files into the final CSS files to be
# distributed to the web server.
all: look/fsfe.min.css look/valentine.min.css
look/%.min.css: $(shell find "look" -name '*.less')
echo "* Compiling $@"
lessc "look/$*.less" -x "$@"
# -----------------------------------------------------------------------------
# Update XSL stylesheets
# -----------------------------------------------------------------------------

View File

@@ -58,3 +58,13 @@ OPTIONS
information will be written to stdout. The directory will also be used
to store some temporary files, which would otherwise be set up in the
system wide temp directory.
--build-env "selection"
Indicate the current build environment. "selection" can be one of:
* "fsfe.org": building https://fsfe.org on the production server
* "test.fsfe.org": building https://test.fsfe.org on the production server
* "development" (default): local development build
In a local development build, code to dynamically compile the less files into
CSS will be included in the HTML output, while in the other environments, the
precompiles fsfe.min.css (or valentine.min.css) will be referenced from the
generated web pages.

View File

@@ -23,6 +23,9 @@ if [ -z "$inc_arguments" ]; then
-d|--dest|--destination)
[ "$#" -gt 0 ] && shift 1 && target="$1"
;;
--build-env)
[ "$#" -gt 0 ] && shift 1 && build_env="$1"
;;
-h|--help)
command="help"
;;

View File

@@ -17,7 +17,7 @@ process_file(){
set -o pipefail
build_xmlstream "$shortname" "$lang" \
| xsltproc "$processor" - \
| xsltproc --stringparam "build-env" "${build_env:-development}" "$processor" - \
| sed -r ':X; N; $!bX;
s;<[\r\n\t ]*(a|link)([\r\n\t ][^>]*)?[\r\n\t ]href="(https?:)?//'"$domain"'/([^"]*)";<\1\2 href="/\4";gI
s;<[\r\n\t ]*(a|link)([\r\n\t ][^>]*)?[\r\n\t ]href='\''(https?:)?//'"$domain"'/([^'\'']*)'\'';<\1\2 href='\''/\4'\'';gI

View File

@@ -2,13 +2,11 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="../../config.xsl" />
<xsl:template name="body_scripts">
<script src="{$urlprefix}/scripts/bootstrap-3.0.3.custom.js"></script>
<script src="{$urlprefix}/scripts/placeholder.js"></script>
<xsl:if test="$css-mode = 'browser'">
<xsl:if test="$build-env = 'development'">
<xsl:element name="script">
<xsl:attribute name="src"><xsl:value-of select="$urlprefix"/>/scripts/less.min.js</xsl:attribute>
</xsl:element>

View File

@@ -2,8 +2,6 @@
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="../../config.xsl" />
<xsl:variable name="mode">
<!-- here you can set the mode to switch between normal and IloveFS style -->
<xsl:value-of select="'normal'" /> <!-- can be either 'normal' or 'valentine' -->
@@ -34,37 +32,45 @@
</xsl:element>
<xsl:choose>
<xsl:when test="$css-mode = 'browser' and $mode = 'normal'">
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet/less</xsl:attribute>
<xsl:attribute name="media">all</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/fsfe.less</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
<xsl:when test="$build-env = 'development'">
<xsl:choose>
<xsl:when test="$mode = 'valentine'">
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet/less</xsl:attribute>
<xsl:attribute name="media">all</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/valentine.less</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise><!-- not valentine -->
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet/less</xsl:attribute>
<xsl:attribute name="media">all</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/fsfe.less</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:when test="$css-mode = 'browser' and $mode = 'valentine'">
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet/less</xsl:attribute>
<xsl:attribute name="media">all</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/valentine.less</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:when test="$css-mode = 'compiled' and $mode = 'valentine'">
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet</xsl:attribute>
<xsl:attribute name="media">all</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/valentine.min.css</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet</xsl:attribute>
<xsl:attribute name="media">all</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/fsfe.min.css</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
<xsl:otherwise><!-- not development -->
<xsl:choose>
<xsl:when test="$mode = 'valentine'">
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet</xsl:attribute>
<xsl:attribute name="media">all</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/valentine.min.css</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
</xsl:when>
<xsl:otherwise><!-- not valentine -->
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet</xsl:attribute>
<xsl:attribute name="media">all</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/fsfe.min.css</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>

View File

@@ -1,15 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!--
"css-mode" controls the type of style processing.
It can have the following values:
- "browser" for local development.
Styles are compiled live in the browser using the JavaScript less compiler.
- "compiled" The website includes the "fsfe.min.css" file
that has to be compiled by the build script.
For fsfe.org itself the value is replaced server side before build.
-->
<xsl:variable name="css-mode" select="'browser'" />
</xsl:stylesheet>

File diff suppressed because one or more lines are too long