From 532d21d2a47c09b91cbcf2c500678e3fe91ad12b Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Thu, 23 Feb 2017 20:40:04 +0400 Subject: [PATCH] =?UTF-8?q?support=20de=20la=20g=C3=A9n=C3=A9ration=20de?= =?UTF-8?q?=20pages=20html=20avec=20bootstrap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/templates/www | 175 +++++++++++++++++++++++++++++++--------------- 1 file changed, 117 insertions(+), 58 deletions(-) diff --git a/lib/templates/www b/lib/templates/www index 0b7797a..b99c203 100755 --- a/lib/templates/www +++ b/lib/templates/www @@ -32,17 +32,16 @@ OPTIONS Spécifier le chemin sous BASURL à partir duquel charger blueprint ou bootstrap. La valeur par défaut est 'blueprint' pour l'option --bp, 'bootstrap' pour l'option --bs - -b, --bp, --blueprint - Activer le support de blueprint. L'option --bp est automatiquement - activée si l'option --bpurl n'est pas utilisée et le répertoire - [BASEURL/]blueprint/ existe -s, --bs, --bootstrap Activer le support de bootstrap. L'option --bs est automatiquement activée si l'option --bsurl n'est pas utilisée et le répertoire [BASEURL/]bootstrap/ existe - -n, --nobp, --no-blueprint, --nobs, --no-bootstrap - Désactiver le support de blueprint et bootstrap. Le fichier HTML est - généré. + -b, --bp, --blueprint + Activer le support de blueprint. L'option --bp est automatiquement + activée si l'option --bpurl n'est pas utilisée et le répertoire + [BASEURL/]blueprint/ existe + -n, --nobs, --no-bootstrap, --nobp, --no-blueprint + Désactiver le support de bootstrap et blueprint -j, --jquery -k, --no-jquery Activer (resp. désactiver) le chargement de jQuery à partir de BASEURL @@ -110,28 +109,114 @@ function __generate_html() { local dir="$(dirname "$file")" local nobpsuppl nobplocal nobpmobile - if [ "$blueprint" == auto ]; then - if [ -d "$dir/blueprint" ]; then - blueprint=1 - [ -f "$dir/bpsuppl.css" ] || nobpsuppl=1 - [ -f "$dir/bplocal.css" ] || nobplocal=1 - [ -f "$dir/bpmobile.css" ] || nobpmobile=1 + if [ "$csslib" == auto ]; then + if [ -n "$bpurl" ]; then + if [ "$bpurl" == bootstrap -o -z "${bpurl##*/bootstrap}" ]; then + csslib=bootstrap + elif [ "$bpurl" == blueprint -o -z "${bpurl##*/blueprint}" ]; then + csslib=blueprint + else + csslib= + fi + elif [ -d "$dir/${baseurl#/}bootstrap" ]; then + csslib=bootstrap + elif [ -d "$dir/${baseurl#/}blueprint" ]; then + csslib=blueprint else - blueprint= + csslib= fi fi + if [ "$csslib" == bootstrap ]; then + [ -n "$bpurl" ] || bpurl=bootstrap + elif [ "$csslib" == blueprint ]; then + [ -n "$bpurl" ] || bpurl=blueprint + [ -f "$dir/${baseurl#/}bpsuppl.css" ] || nobpsuppl=1 + [ -f "$dir/${baseurl#/}bplocal.css" ] || nobplocal=1 + [ -f "$dir/${baseurl#/}bpmobile.css" ] || nobpmobile=1 + fi + + bpurl="$baseurl$bpurl" + [ "${bpurl:$((-1)):1}" == / ] || bpurl="$bpurl/" + local jquerymin if [ "$jquery" == auto ]; then - if [ -f "$dir/jquery.min.js" ]; then + if [ "$csslib" == bootstrap ]; then + jquery= + elif [ -f "$dir/${baseurl#/}jquery.min.js" ]; then jquery=1 jquerymin=1 - elif [ -d "$dir/jquery.js" ]; then + elif [ -f "$dir/${baseurl#/}jquery.js" ]; then jquery=1 else jquery= fi fi + if [ "$doctype" == auto ]; then + if [ "$csslib" == bootstrap ]; then + doctype=html5 + else + doctype=html4 + fi + fi + head='' + if [ "$doctype" == html5 ]; then + head="$head +"'' + else + head="$head +"'' + fi + + if [ "$csslib" == bootstrap ]; then + head="$head +"' + + +' + csslib=' + + +' + startcl='
' + endcl='
' + elif [ "$csslib" == blueprint ]; then + head="$head +"' + +' + csslib=' + + +<'"${nobpsuppl:+!--}"'link rel="stylesheet" href="'"$baseurl"'bpsuppl.css" type="text/css" media="screen, projection" /'"${nobpsuppl:+--}"'> +<'"${nobplocal:+!--}"'link rel="stylesheet" href="'"$baseurl"'bplocal.css" type="text/css" media="screen, projection" /'"${nobplocal:+--}"'> +<'"${nobpmobile:+!--}"'link rel="stylesheet" href="'"$baseurl"'bpmobile.css" type="text/css" media="handheld, only screen and (max-device-width: 480px)" /'"${nobpmobile:+--}"'>' + startcl='
' + endcl='
' + else + # pas de csslib ou csslib non supporté + head="$head +"' + +' + csslib= + startcl= + endcl= + fi + if [ -n "$jquery" ]; then + jquery='' + fi + start=''"$head_title"' + +' + end=' +' + case "$doctype" in html4) doctype='' @@ -146,27 +231,6 @@ function __generate_html() { html='' ;; esac - head=' - - - -' - [ -n "$blueprint" ] && blueprint=' - - -<'"${nobpsuppl:+!--}"'link rel="stylesheet" href="bpsuppl.css" type="text/css" media="screen, projection" /'"${nobpsuppl:+--}"'> -<'"${nobplocal:+!--}"'link rel="stylesheet" href="bplocal.css" type="text/css" media="screen, projection" /'"${nobplocal:+--}"'> -<'"${nobpmobile:+!--}"'link rel="stylesheet" href="bpmobile.css" type="text/css" media="handheld, only screen and (max-device-width: 480px)" /'"${nobpmobile:+--}"'>' - [ -n "$jquery" ] && jquery='' - start=''"$head_title"' - -' - startbp='
' - endbp='
' - end=' -' } function __before_write_html() { doctype="$doctype