divzeroweb

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

config.sh (506B)


      1 #!/bin/sh
      2 
      3 # Usage: config.sh page base [menuitem ...]
      4 
      5 PAGE=$1
      6 NAME="ctx->$(echo ${PAGE%.*} | sed 's|/|->|g')"
      7 shift
      8 BASE=$1
      9 shift
     10 MENUPAGES="$@"
     11 
     12 for P in $MENUPAGES; do
     13     I=$(basename $P .html)
     14     test $P == $PAGE && CUR=' class="active"' || CUR=''
     15     test -n "$MENU" && SEP="NEWL" # the newline hack
     16     MENU="$MENU$SEP<li$CUR><a href=\"$BASE$P\">$I</a></li>"
     17 done
     18 
     19 sed "s|\${PAGE}|$PAGE|" | \
     20 sed "s|\${NAME}|$NAME|" | \
     21 sed "s|\${BASE}|$BASE|" | \
     22 sed "s|\${MENU}|$MENU|" | \
     23 sed "s|$SEP|"'\
     24 |g'