#!/bin/sh # ZODIAC - a simple static site generator # Copyright (c) 2011 Chase Allen James zod_lib=ZODLIB_PATH proj="$1" target="$2" _zod_error() { echo -e ">>> ERROR: $*" >&2 exit 1 } _zod_config() { cat - "$cfg" < "$destination/$page" } _zod_copy() { file="$1" destination="$(_zod_destination "$file")" cp "$file" "$destination" } _zod_exec() { phase="$@" set -- "$proj" -type f for instruction in $(_zod_find_opt_builder "$phase" "$cfg"); do inst=$(echo $instruction | sed 's/"//g') case $inst in or ) set -- "$@" -o;; not ) set -- "$@" !;; * ) set -- "$@" -name "$inst";; esac done find "$@" | while read -r file; do case "$phase" in render ) _zod_render "$file";; copy ) _zod_copy "$file";; esac done } [ "$#" -ne 2 ] && { echo "usage: zod projectdir targetdir"; exit; } [ ! -d "$proj" ] && _zod_error "project directory does not exist" [ ! -d "$target" ] && _zod_error "target directory does not exist" [ -f "$proj/.zod/config" ] && cfg="$proj/.zod/config" _zod_exec "render" _zod_exec "copy"