2011-10-06 23:28:51 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# render a zodiac page
|
|
|
|
|
2011-10-06 23:52:34 +02:00
|
|
|
zod_lib="$1"
|
|
|
|
proj="$2"
|
|
|
|
target="$3"
|
|
|
|
f="$4"
|
2011-10-06 23:28:51 +02:00
|
|
|
|
2011-10-06 23:49:17 +02:00
|
|
|
markdown_filter_cmd="awk -f $zod_lib/markdown.awk"
|
|
|
|
|
|
|
|
[ -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"
|
2011-10-06 23:28:51 +02:00
|
|
|
|
|
|
|
# Find the target directory if one must be created
|
|
|
|
subdir=${f%/*}
|
2011-10-06 23:49:17 +02:00
|
|
|
subdir=${subdir#$proj}
|
2011-10-06 23:28:51 +02:00
|
|
|
if [ "$subdir" ]; then
|
2011-10-06 23:49:17 +02:00
|
|
|
destination="$target$subdir"
|
2011-10-06 23:28:51 +02:00
|
|
|
mkdir -p "$destination"
|
|
|
|
else
|
|
|
|
# There is no directory to create in target,
|
|
|
|
# i.e. file is in the root of the project
|
2011-10-06 23:49:17 +02:00
|
|
|
destination="$target"
|
2011-10-06 23:28:51 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
ext=${f##*.}
|
|
|
|
if [ $ext == "md" ] || [ $ext == "html" ]; then
|
|
|
|
|
|
|
|
meta=${f%.$ext}.meta
|
|
|
|
[ -f "$meta" ] && page_meta_opts="$meta"
|
|
|
|
|
2011-10-06 23:49:17 +02:00
|
|
|
set -- -f "$zod_lib/render.awk"
|
2011-10-06 23:28:51 +02:00
|
|
|
[ "$helper_opts" ] && set -- "$@" -f "$helper_opts"
|
|
|
|
set -- "$@" -v markdown_filter_cmd="$markdown_filter_cmd" \
|
|
|
|
"$global_meta_opts" \
|
|
|
|
"$page_meta_opts" \
|
|
|
|
"$f" \
|
|
|
|
"$layout_opts"
|
|
|
|
|
2011-10-06 23:55:18 +02:00
|
|
|
page=${f##*/}
|
|
|
|
page=${page%.$ext}.html
|
|
|
|
|
2011-10-06 23:28:51 +02:00
|
|
|
awk "$@" > "$destination/$page"
|
|
|
|
|
|
|
|
else
|
|
|
|
cp "$f" "$destination" # Copying a non-template file
|
|
|
|
fi
|