#! /bin/sh # decogen - Generate deco.gs CSS grid system # Copyright (C) 2011 Matous J. Fialka, # Released under the terms of The MIT License DECO_GS_PRECISION=${DECO_GS_PRECISION:-'5'} DECO_GS_COLUMNS=${DECO_GS_COLUMNS:-'16'} DECO_GS_COLUMN_MARGINS=${DECO_GS_COLUMN_MARGINS:-'2.083333333333'} DECO_GS_COLUMN_MARGINS=` echo "${DECO_GS_COLUMN_MARGINS} / 1.0" | bc -l | sed ' s/^\./0./ s/^\([^.]\+\..\{'$DECO_GS_PRECISION'\}\).*/\1/ ' ` column_width=` echo "100 / $DECO_GS_COLUMNS" | bc -l | sed ' s/^\./0./ s/^\([^.]\+\..\{'$DECO_GS_PRECISION'\}\).*/\1/ ' ` cell_width=` echo "$column_width - $DECO_GS_COLUMN_MARGINS" | bc -l | sed ' s/^\./0./ s/^\([^.]\+\..\{'$DECO_GS_PRECISION'\}\).*/\1/ ' ` cat << eof /** * DECO.GS (CSS GRID SYSTEM) * ------------------------------------------------------- * * Number of columns: $DECO_GS_COLUMNS * Column margin width: $DECO_GS_COLUMN_MARGINS percent * Cell width: $cell_width percent * Column width: $column_width percent * */ div.row { /* Single row class */ float:left; position:relative; width:100%; display:block; } div.cell { /* Single cell class */ float:left; position:relative; left:100%; } /** * Cell width classes formula: * * div.width_ width = * - */ eof for n in `seq 1 $DECO_GS_COLUMNS` do width=` echo "$column_width * $n - $DECO_GS_COLUMN_MARGINS" | bc -l | sed ' s/^\./0./ s/^\([^.]\+\..\{'$DECO_GS_PRECISION'\}\).*/\1/ ' ` sed 's/^\t//' << eof div.width-$n { width:${width}%; } eof done cat << eof /** * Cell position classes formula: * * div.position_ left margin = * n - 100 */ eof for n in `seq 1 $DECO_GS_COLUMNS` do n=` echo "$n - 1" | bc -l ` left_margin=` echo "$column_width * $n - 100" | bc -l | sed ' s/^\./0./ s/^\([^.]\+\..\{'$DECO_GS_PRECISION'\}\).*/\1/ ' ` sed 's/^\t//' << eof div.position-$n { margin-left:${left_margin}%; } eof done cat << eof /** * Example usage (for 16 columns): * *
*
...
*
...
*
...
*
* * Generated by decogen `date '+on %F at %R'`. */ eof