Less live build → test #963

Merged
mweimann merged 10 commits from dev-less-test into test 4 years ago
  1. 2
      .gitignore
  2. 12
      Makefile
  3. 10
      build/HELP
  4. 3
      build/arguments.sh
  5. 2
      build/processor.sh
  6. 7
      build/xslt/body_scripts.xsl
  7. 86
      build/xslt/fsfe_head.xsl
  8. 4
      look/valentine.min.css
  9. 18
      scripts/less.min.js

2
.gitignore vendored

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

@ -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
# -----------------------------------------------------------------------------

@ -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.

@ -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"
;;

@ -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

@ -5,6 +5,13 @@
<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="$build-env = 'development'">
<xsl:element name="script">
<xsl:attribute name="src"><xsl:value-of select="$urlprefix"/>/scripts/less.min.js</xsl:attribute>
</xsl:element>
</xsl:if>
</xsl:template>
</xsl:stylesheet>

@ -30,29 +30,57 @@
<xsl:attribute name="http-equiv">X-UA-Compatible</xsl:attribute>
<xsl:attribute name="content">IE=edge</xsl:attribute>
</xsl:element>
<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:if 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:if>
<xsl:choose>
<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: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>
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet</xsl:attribute>
<xsl:attribute name="media">print</xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/look/print.css</xsl:attribute>
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
<xsl:if test="/buildinfo/@language='ar'">
<xsl:element name="link">
<xsl:attribute name="rel">stylesheet</xsl:attribute>
@ -61,7 +89,7 @@
<xsl:attribute name="type">text/css</xsl:attribute>
</xsl:element>
</xsl:if>
<xsl:element name="link">
<xsl:attribute name="rel">icon</xsl:attribute>
<xsl:attribute name="href">
@ -73,17 +101,17 @@
</xsl:attribute>
<xsl:attribute name="type">image/x-icon</xsl:attribute>
</xsl:element>
<link rel="apple-touch-icon" href="{$urlprefix}/graphics/touch-icon.png" type="image/png" />
<link rel="apple-touch-icon-precomposed" href="{$urlprefix}/graphics/touch-icon.png" type="image/png" />
<xsl:element name="link">
<xsl:attribute name="rel">alternate</xsl:attribute>
<xsl:attribute name="title">FSFE <xsl:call-template name="fsfe-gettext"><xsl:with-param name="id" select="'menu1/news'" /></xsl:call-template></xsl:attribute>
<xsl:attribute name="href"><xsl:value-of select="$urlprefix"/>/news/news.<xsl:value-of select="/buildinfo/@language"/>.rss</xsl:attribute>
<xsl:attribute name="type">application/rss+xml</xsl:attribute>
</xsl:element>
<xsl:element name="link">
<xsl:attribute name="rel">alternate</xsl:attribute>
<xsl:attribute name="title">FSFE <xsl:call-template name="fsfe-gettext"><xsl:with-param name="id" select="'menu1/events'" /></xsl:call-template></xsl:attribute>
@ -102,7 +130,7 @@
<xsl:attribute name="title"><xsl:value-of select="." disable-output-escaping="yes" /></xsl:attribute>
</xsl:element>
</xsl:for-each>
<xsl:for-each select="/buildinfo/document/author">
<xsl:variable name="id">
<xsl:value-of select="@id" />
@ -121,7 +149,7 @@
</xsl:attribute>
</xsl:element>
</xsl:for-each>
<!-- Twitter and Facebook sharing cards -->
<xsl:variable name="metadesc">
<!-- Get the meta element description -->
@ -131,7 +159,7 @@
<!-- Get the meta element description -->
<xsl:value-of select="head/meta[@name = 'image']/@content" />
</xsl:variable>
<!-- EXTRACT -->
<!-- take a first extract which should be sufficient for most pages -->
<xsl:variable name="extract1">
@ -172,7 +200,7 @@
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Twitter cards -->
<xsl:element name="meta">
<xsl:attribute name="name">twitter:card</xsl:attribute>
@ -183,7 +211,7 @@
<xsl:otherwise>summary</xsl:otherwise>
</xsl:choose>
</xsl:attribute>
</xsl:element>
</xsl:element>
<meta name="twitter:site" content="@fsfe" />
<xsl:element name="meta">
<xsl:attribute name="name">twitter:image</xsl:attribute>
@ -214,7 +242,7 @@
<xsl:choose>
<!-- if not, try to get the short extract -->
<xsl:when test="$extract != ''"><xsl:value-of select="$extract" /><xsl:text>...</xsl:text></xsl:when>
<!-- if even that isn't available, return a default text
<!-- if even that isn't available, return a default text
(not language sensitive). This should never be the case... -->
<xsl:otherwise>Non profit organisation working to create general understanding and support for software freedom. Includes news, events, and campaigns.</xsl:otherwise>
</xsl:choose>
@ -262,7 +290,7 @@
<xsl:choose>
<!-- if not, try to get the short extract -->
<xsl:when test="$extract != ''"><xsl:value-of select="$extract" /><xsl:text>...</xsl:text></xsl:when>
<!-- if even that isn't available, return a default text
<!-- if even that isn't available, return a default text
(not language sensitive). This should never be the case... -->
<xsl:otherwise>Non profit organisation working to create general understanding and support for software freedom. Includes news, events, and campaigns.</xsl:otherwise>
</xsl:choose>
@ -281,7 +309,7 @@
<xsl:comment><![CDATA[[if (lt IE 9) & (!IEMobile)]>
<link rel="stylesheet" media="all" href="/look/ie.min.css" type="text/css">
<![endif]]]></xsl:comment>
<!-- Copy head element from the xhtml source file (and possibly from external xsl rules) -->
<xsl:apply-templates select="head/node()" />
</xsl:element></xsl:template>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save