divzeroweb

2f30.org website
git clone git://git.2f30.org/divzeroweb
Log | Files | Refs | README | LICENSE

commit d0813b113f4dd9919b29e4e1f89dcec66b71ca57
parent a1dc0e2c17a79704346ee752c20e0dd4e9cd273f
Author: lostd <lostd@2f30.org>
Date:   Thu, 20 Feb 2014 14:44:19 +0200

Cleaner script writing

Diffstat:
Mconfig.sh | 18++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/config.sh b/config.sh @@ -1,6 +1,6 @@ #!/bin/sh -# Usage: config page base [menuitem ...] +# Usage: config.sh page base [menuitem ...] PAGE=$1 NAME="ctx->$(echo ${PAGE%.*} | sed 's|/|->|g')" @@ -9,17 +9,11 @@ BASE=$1 shift MENUPAGES="$@" -for P in $MENUPAGES -do - I=$(basename $P .html) - if [ $P == $PAGE ] - then CUR=' class="active"' - else CUR='' - fi - if [ -n "$MENU" ] - then SEP="NEWL" # the newline hack - fi - MENU="$MENU$SEP<li$CUR><a href=\"$BASE$P\">$I</a></li>" +for P in $MENUPAGES; do + I=$(basename $P .html) + test $P == $PAGE && CUR=' class="active"' || CUR='' + test -n "$MENU" && SEP="NEWL" # the newline hack + MENU="$MENU$SEP<li$CUR><a href=\"$BASE$P\">$I</a></li>" done sed "s|\${PAGE}|$PAGE|" | \