diff options
author | Mikhail Kobuk <[email protected]> | 2024-04-13 07:17:27 +0300 |
---|---|---|
committer | Mikhail Kobuk <[email protected]> | 2024-04-13 07:17:27 +0300 |
commit | a078abfcfaf9ea87bd2f9223f4c8b4f6b76004ab (patch) | |
tree | e399b774d2c9d29a1f3818dedba18988d7c5c6e5 /mksite.sh | |
parent | a288b29ddc37eefeebf41ef25ec7cd60879e3c75 (diff) | |
download | linux-labs-a078abfcfaf9ea87bd2f9223f4c8b4f6b76004ab.tar.gz linux-labs-a078abfcfaf9ea87bd2f9223f4c8b4f6b76004ab.zip |
updated build system
Diffstat (limited to 'mksite.sh')
-rwxr-xr-x | mksite.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/mksite.sh b/mksite.sh new file mode 100755 index 0000000..c0bbc8f --- /dev/null +++ b/mksite.sh @@ -0,0 +1,48 @@ +#! /bin/bash + +# USE: ./build.sh <pandoc> <pandoc_flags> <pandoc_format> [sources] + +sources=${@} +echo "sources: ${sources}" + +function process_dir() { + pushd . + arg_dir=$1 + + cd ${arg_dir} + indir_src="$(find . -name '*.md')" + indir_out="${indir_src##*/}" + ${panexec} ${panflags} ${indir_src} ${panformat} -o ../${indir_out%.*}.html + + mkdir ../site/${arg_dir} + + cp -v ./*.png ../site/${arg_dir} + mv -v ../${indir_out%.*}.html ../site/${arg_dir}/index.html + + popd +} + +for src in ${sources}; do + if [ -d ${src} ]; then + printf "\tfound dir: ${src}\n" + + if [ "$(find ${src} -name '*.md' | wc -l)" != "1" ]; then + printf "\tToo many files in dir. Won't build. Skipping.\n" + continue + fi + + process_dir ${src} + + elif [ -f ${src} ] && [ "${src##*.}" == "md" ]; then + printf "\tfound md file: ${src}\n" + + printf "\tmv -v ${src%.*}.html ../site/${src%.*}.html\n" + mv -v ${src%.*}.html site/ + else + printf "Unknown source (%s) - skipping\n" "$src" + fi +done + +#for lab in $(find . -maxdepth 1 -name "lab*" -type d); do +# echo "Found directory ${lab}" +#done |