no need to export vars

This commit is contained in:
nuex 2011-10-06 17:49:17 -04:00
parent 3e47b37b02
commit 47baacf52a
2 changed files with 21 additions and 16 deletions

View File

@ -3,9 +3,10 @@
# ZODIAC - a simple static site generator # ZODIAC - a simple static site generator
# Copyright (c) 2011 Chase Allen James <nx-zodiac@nu-ex.com> # Copyright (c) 2011 Chase Allen James <nx-zodiac@nu-ex.com>
export ZOD_LIB=ZODLIB_PATH zod_lib=ZODLIB_PATH
export ZOD_PROJECT=$1
export ZOD_TARGET=$2 proj=$1
target=$2
_zod_error() { _zod_error() {
echo -e ">>> ERROR: $*" >&2 echo -e ">>> ERROR: $*" >&2
@ -13,11 +14,11 @@ _zod_error() {
} }
[ "$#" -ne 2 ] && { echo "usage: zod projectdir targetdir"; exit; } [ "$#" -ne 2 ] && { echo "usage: zod projectdir targetdir"; exit; }
[ ! -d "$ZOD_PROJECT" ] && _zod_error "project directory does not exist" [ ! -d "$proj" ] && _zod_error "project directory does not exist"
[ ! -d "$ZOD_TARGET" ] && _zod_error "target directory does not exist" [ ! -d "$target" ] && _zod_error "target directory does not exist"
find "$ZOD_PROJECT" -type f \ find "$proj" -type f \
! -name "*.layout" \ ! -name "*.layout" \
! -name "*.meta" \ ! -name "*.meta" \
! -name "helpers.awk" \ ! -name "helpers.awk" \
-exec zod_render {} \; -exec zod_render $zod_lib $proj $target {} \;

View File

@ -3,23 +3,27 @@
# render a zodiac page # render a zodiac page
# used internally by zod (uses file as single argument) # used internally by zod (uses file as single argument)
f="$*" zod_lib=$1
markdown_filter_cmd="awk -f $ZOD_LIB/markdown.awk" proj=$2
target=$3
f=$4
[ -f "$ZOD_PROJECT/helpers.awk" ] && helper_opts="$ZOD_PROJECT/helpers.awk" markdown_filter_cmd="awk -f $zod_lib/markdown.awk"
[ -f "$ZOD_PROJECT/global.meta" ] && global_meta_opts="$ZOD_PROJECT/global.meta"
[ -f "$ZOD_PROJECT/main.layout" ] && layout_opts="$ZOD_PROJECT/main.layout" [ -f "$proj/helpers.awk" ] && helper_opts="$proj/helpers.awk"
[ -f "$proj/global.meta" ] && global_meta_opts="$proj/global.meta"
[ -f "$proj/main.layout" ] && layout_opts="$proj/main.layout"
# Find the target directory if one must be created # Find the target directory if one must be created
subdir=${f%/*} subdir=${f%/*}
subdir=${subdir#$ZOD_PROJECT} subdir=${subdir#$proj}
if [ "$subdir" ]; then if [ "$subdir" ]; then
destination="$ZOD_TARGET$subdir" destination="$target$subdir"
mkdir -p "$destination" mkdir -p "$destination"
else else
# There is no directory to create in target, # There is no directory to create in target,
# i.e. file is in the root of the project # i.e. file is in the root of the project
destination="$ZOD_TARGET" destination="$target"
fi fi
ext=${f##*.} ext=${f##*.}
@ -31,7 +35,7 @@ if [ $ext == "md" ] || [ $ext == "html" ]; then
page=${f##*/} page=${f##*/}
page=${page%.$ext}.html page=${page%.$ext}.html
set -- -f "$ZOD_LIB/render.awk" set -- -f "$zod_lib/render.awk"
[ "$helper_opts" ] && set -- "$@" -f "$helper_opts" [ "$helper_opts" ] && set -- "$@" -f "$helper_opts"
set -- "$@" -v markdown_filter_cmd="$markdown_filter_cmd" \ set -- "$@" -v markdown_filter_cmd="$markdown_filter_cmd" \
"$global_meta_opts" \ "$global_meta_opts" \