depsterr.com

The sources and build system for depsterr.com
git clone git://depsterr.com/git/depsterr.com
Log | Files | Refs | LICENSE

commit 8482020451bc125bbc1406d3af8f00ebad8968ac
parent 89ea8a8ef4309ab566b63dbd15769385ed038c65
Author: depsterr <depsterr@protonmail.com>
Date:   Thu, 25 Jun 2020 20:42:58 +0200

updated make pages

Diffstat:
Mmake_pages.sh | 50+++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 39 insertions(+), 11 deletions(-)

diff --git a/make_pages.sh b/make_pages.sh @@ -1,37 +1,45 @@ #! /bin/sh -cd "$(dirname "$0")" +cd "$(dirname "$0")" || exit DESTDIR=doc SRCDIR=src -HASHFILE=checksums -HEADER="$SRCDIR/header.html" -NAVBAR="$SRCDIR/navbar.html" -FOOTER="$SRCDIR/footer.html" +HEADER="header.html" +NAVBAR="navbar.html" +FOOTER="footer.html" # md to html program MD=smu +# clean old docs +mkdir -p "$DESTDIR" +rm -rf "${DESTDIR:?}"/* + # generate pages -for file in $(find "$SRCDIR" -maxdepth 1 -type f -name '*.md'); do +for file in "$SRCDIR"/*.md; do + [ -z "$file" ] && exit destination="$(echo "$file" | sed -e "s/$SRCDIR/$DESTDIR/g" -e 's/\.md/\.html/g')" "$MD" "$file" | cat "$HEADER" "$NAVBAR" - "$FOOTER" > "$destination" done # create dirs -for dir in $(find "$SRCDIR" -type d -not -name "$SRCDIR"); do - mkdir -p "${dir/$SRCDIR/$DESTDIR}" +find "$SRCDIR" -type d -not -name "$SRCDIR" | while read -r dir; do + mkdir -p "$(echo "$dir" | sed "s/$SRCDIR/$DESTDIR/g")" done # generate blog pages -for dir in $(find "$SRCDIR" -type d -not -name "$SRCDIR"); do +find "$SRCDIR" -type d -not -name "$SRCDIR" | while read -r dir; do sidebar="<aside id=\"sidebar\"><ul>" - for file in $(find "$dir" -type f -name '*.md' | sed 's/\.md/\.html/g'); do + for file in $(ls "$SRCDIR"/*.md | sed 's/\.md/\.html/g'); do file="$(basename "$file")" sidebar="${sidebar}<li><a href=\"$file\">${file%.html}</a></li>" done + for cdir in "$dir"/*/; do + cdir="$(basename "$cdir")" + sidebar="${sidebar}<li><a href=\"$cdir\">$cdir</a></li>" + done sidebar="${sidebar}</ul></aside>" - for file in $(find "$dir" -type f -name '*.md'); do + find "$dir" -type f -name '*.md' | while read -r file; do destination="$(echo "$file" | sed -e "s/$SRCDIR/$DESTDIR/g" -e 's/\.md/\.html/g')" cat "$HEADER" "$NAVBAR" - "$FOOTER" > "$destination" <<-EOF $sidebar @@ -40,3 +48,23 @@ EOF done done +# generate index pages +find "$SRCDIR" -type d -not -name "$SRCDIR" | while read -r dir; do + sidebar="<aside id=\"sidebar\"><ul>" + for file in $(ls "$SRCDIR"/*.md | sed 's/\.md/\.html/g'); do + file="$(basename "$file")" + sidebar="${sidebar}<li><a href=\"$file\">${file%.html}</a></li>" + done + for cdir in "$dir"/*/; do + cdir="$(basename "$cdir")" + sidebar="${sidebar}<li><a href=\"$cdir\">$cdir</a></li>" + done + sidebar="${sidebar}</ul></aside>" + find "$dir" -type f -name '*.md' | while read -r file; do + destination="$(echo "$file" | sed -e "s/$SRCDIR/$DESTDIR/g" -e 's/\.md/\.html/g')" + cat "$HEADER" "$NAVBAR" - "$FOOTER" > "$destination" <<-EOF +$sidebar +$("$MD" "$file") +EOF + done +done