working out zod phases
This commit is contained in:
@@ -1,59 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
# render a zodiac page
|
||||
# zod_render zodlibdir projdir targetdir md_builtin [files]
|
||||
|
||||
zod_lib="$1"
|
||||
proj="$2"
|
||||
target="$3"
|
||||
f="$4"
|
||||
md_builtin="$4"
|
||||
f="$5"
|
||||
|
||||
md_builtin="awk -f $zod_lib/markdown.awk"
|
||||
|
||||
[ -f "$proj/helpers.awk" ] && helper_opts="$proj/helpers.awk"
|
||||
[ -f "$proj/filters.config" ] && filter_opts="$proj/filters.config"
|
||||
[ -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
|
||||
subdir=${f%/*}
|
||||
subdir=${subdir#$proj}
|
||||
if [ "$subdir" ]; then
|
||||
destination="$target$subdir"
|
||||
mkdir -p "$destination"
|
||||
else
|
||||
# There is no directory to create in target,
|
||||
# i.e. file is in the root of the project
|
||||
destination="$target"
|
||||
fi
|
||||
# source zod sh functions
|
||||
. $zod_lib/zod_functions
|
||||
|
||||
ext=${f##*.}
|
||||
meta=${f%.$ext}.meta
|
||||
|
||||
# Add filter support provided by the filters.config file
|
||||
[ "$filter_opts" ] && supported="$supported $(zod_supported_extensions "$zod_lib" "$filter_opts")"
|
||||
set -- -f "$zod_lib/render.awk"
|
||||
[ -f "$proj/helpers.awk" ] && set -- "$@" -f "$proj/helpers.awk"
|
||||
set -- "$@" -v markdown_filter_cmd="$md_builtin"
|
||||
[ -f "$proj/global.meta" ] && set -- "$@" $proj/global.meta
|
||||
[ -f "$meta" ] && set -- "$@" $meta
|
||||
set -- "$@" "$f"
|
||||
|
||||
for supported_ext in "$supported"; do
|
||||
[ $ext == "$supported_ext" ] && { is_supported=true; break }
|
||||
find "$proj" -type f -name "*.partial" -o -name "*.layout"
|
||||
while read -r part; do
|
||||
set -- "$@" "$part"
|
||||
done
|
||||
|
||||
if [ "$is_supported" ]; then
|
||||
|
||||
meta=${f%.$ext}.meta
|
||||
[ -f "$meta" ] && page_meta_opts="$meta"
|
||||
|
||||
set -- -f "$zod_lib/render.awk"
|
||||
[ "$helper_opts" ] && set -- "$@" -f "$helper_opts"
|
||||
set -- "$@" -v markdown_filter_cmd="$md_builtin" \
|
||||
"$filter_opts" \
|
||||
"$global_meta_opts" \
|
||||
"$page_meta_opts" \
|
||||
"$f" \
|
||||
"$layout_opts"
|
||||
|
||||
page=${f##*/}
|
||||
page=${page%.$ext}.html
|
||||
|
||||
awk "$@" > "$destination/$page"
|
||||
|
||||
else
|
||||
cp "$f" "$destination" # Copying a non-template file
|
||||
fi
|
||||
page=${f##*/}
|
||||
page=${page%.$ext}.html
|
||||
__zod_destination "$proj" "$target" "$f"
|
||||
awk "$@" > "$destination/$page"
|
||||
|
||||
0
bin/zod_supported_extensions
Normal file → Executable file
0
bin/zod_supported_extensions
Normal file → Executable file
Reference in New Issue
Block a user