From 81fd16023d7d97e31ca32290a40ce5ebd9b81aae Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Mon, 23 Nov 2020 23:44:24 +0100 Subject: [PATCH] link list is now in date order (hopefully) --- rivet.sh | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/rivet.sh b/rivet.sh index 2dc67a6..22c102a 100644 --- a/rivet.sh +++ b/rivet.sh @@ -46,10 +46,10 @@ convert() { tmpfile="tmpconvfile.tmp" infile="$1" outfile="${infile%???}.html" - cp "$1" "$tmpfile" + cp "$infile" "$tmpfile" # TODO: convert links to .md to .html lowdown -s -Thtml -o "$outfile" "$tmpfile" - rm -f "$tmpfile" "$1" + rm -f "$tmpfile" "$infile" } # Check dependencies @@ -87,6 +87,7 @@ srcdir=${src%%\/} unset src headerfile=$srcdir/_header.html footerfile=$srcdir/_footer.html +filelist=filelist.tmp # Check if index.md is present if ! [ -e "$srcdir"/index.md ]; then @@ -132,11 +133,15 @@ mkdir -p "$destdir" cp -r "$srcdir"/* "$destdir" rm -f "$destdir"/_header.html "$destdir"/_footer.html +# Generate an ordered (by open time) file list +find "$srcdir" -type f -name "*.md" -exec ls -1t {} + > "$filelist" +sed -i "s,^\/*[^\/]*\/,$destdir/," "$filelist" + # Convert markdown files -find "$destdir" -name "*.md" | while IFS="" read -r file; do convert "$file" -done +done < "$filelist" +sed -i 's/\.md$/\.html/' "$filelist" # Prepare the header if ! [ "$SKIP_HEADER" ]; then @@ -161,12 +166,10 @@ fi # Prepare the sitemap & file list if ! [ "$SKIP_SITEMAP" ] || ! [ "$SKIP_LIST" ]; then linklist="linklist.tmp" - # echo "" > "$linklist" rm -f "$linklist" "$destdir"/sitemap.xml - find "$destdir" -name "*.html" | while IFS="" read -r file; do echo "${file#$destdir/}" >> "$linklist" - done + done < "$filelist" if ! [ "$SKIP_LIST" ]; then tmpfile="linkindex.tmp" @@ -206,7 +209,7 @@ EOF done < "$linklist" sed -i 's/^/\t/' "$destdir"/sitemap.xml fi - rm -f "$linklist" + rm -f "$linklist" "$filelist" fi exit