From 5538ba5c593b4dc97d97df227c751a07e58f627e Mon Sep 17 00:00:00 2001 From: emamaker Date: Wed, 17 May 2023 23:42:09 +0200 Subject: [PATCH 1/6] "Pages" list also for index.html files in subdirectories --- rivet.sh | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) mode change 100644 => 100755 rivet.sh diff --git a/rivet.sh b/rivet.sh old mode 100644 new mode 100755 index 969995d..c97ca66 --- a/rivet.sh +++ b/rivet.sh @@ -201,8 +201,25 @@ if ! [ "$SKIP_META" ]; then done fi -# Prepare index file list +# For every file named "index.html", prepare index file list if ! [ "$SKIP_LIST" ]; then + lobjlist=$(mktemp) + lobjdate=$(mktemp) + llinklist=$(mktemp) + for indexf in $(find "$destdir" -type f -iname "index.html"); do + outdir=$(echo $(dirname "$indexf") | sed "s/$destdir//g") + +# Generate an ordered (by open time) list of files in the subdirectory by filtering the global list + grep "$outdir" "$objlist" > "$lobjlist" + sed -e "s,^\/*[^\/]*\/,$destdir/," "$lobjlist" > "$tmpsed" + rm -f "$lobjdate" + while IFS="" read -r file; do + stat -c '%y' "$file" >> "$lobjdate" + done < "$lobjlist" + mv "$tmpsed" "$lobjlist" + + grep "$outdir" "$linklist" > "$llinklist" + tmpfile="$(mktemp)" rm -f "$tmpfile" cat << EOF >> "$tmpfile" @@ -215,22 +232,23 @@ EOF if echo "$line" | grep -q 'index\.html'; then continue fi - tfile="$(awk "NR==$count" "$objlist")" + tfile="$(awk "NR==$count" "$lobjlist")" title="$(sed -E -n 's/.*\s*(.+)\s*<\/title>.*/\1/p' "$tfile")" if [ -z "$title" ]; then title="${tfile##*/}" fi - ldate="$(awk "NR==$count" "$objdate" | sed 's/\s.*$//')" - printf "<p><a href=\"%s\">%s - %s</a></p>\n" "$line" "$ldate" "$title" >> "$tmpfile" - done < "$linklist" +ldate="$(awk "NR==$count" "$lobjdate" | sed 's/\s.*$//')" + printf "<p><a href=\"%s\">%s - %s</a></p>\n" "$line" "$ldate" "$title" >> "$tmpfile" + done < "$llinklist" echo '</div>' >> "$tmpfile" - sed '/<\/body>/i REPLACE' "$destdir"/index.html > "$tmpsed" - mv "$tmpsed" "$destdir"/index.html - sed "/^REPLACE/r $tmpfile" "$destdir"/index.html > "$tmpsed" - mv "$tmpsed" "$destdir"/index.html - sed 's/^REPLACE//' "$destdir"/index.html > "$tmpsed" - mv "$tmpsed" "$destdir"/index.html + sed '/<\/body>/i REPLACE' $indexf > "$tmpsed" + mv "$tmpsed" $indexf + sed "/^REPLACE/r $tmpfile" $indexf > "$tmpsed" + mv "$tmpsed" $indexf + sed 's/^REPLACE//' $indexf > "$tmpsed" + mv "$tmpsed" $indexf rm -f "$tmpfile" + done; fi # enclose article inside <article></article> -- 2.49.1 From 4536162c42a533f6b406b8a46cdc275234fec461 Mon Sep 17 00:00:00 2001 From: emamaker <emamaker0@gmail.com> Date: Wed, 17 May 2023 23:50:29 +0200 Subject: [PATCH 2/6] "Pages in this section" instead of "Pages" in subdirectories index file list --- rivet.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rivet.sh b/rivet.sh index c97ca66..e7b45aa 100755 --- a/rivet.sh +++ b/rivet.sh @@ -219,12 +219,19 @@ if ! [ "$SKIP_LIST" ]; then mv "$tmpsed" "$lobjlist" grep "$outdir" "$linklist" > "$llinklist" + +# Modify "Pages" header to show the current section + if [ "$indexf" = "$destdir/index.html" ]; then + llinksec=$linksec + else + llinksec="$linksec in this section" + fi tmpfile="$(mktemp)" rm -f "$tmpfile" cat << EOF >> "$tmpfile" <div id="map"> -<h2 id="Pages">$linksec</h2> +<h2 id="Pages">$llinksec</h2> EOF count='0' while IFS="" read -r line; do -- 2.49.1 From 52b4b836f2bd87b5d13c6804d91c4311b00a2252 Mon Sep 17 00:00:00 2001 From: emamaker <emamaker0@gmail.com> Date: Wed, 17 May 2023 23:51:20 +0200 Subject: [PATCH 3/6] "Pages in this section" -> "Pages in *file title*" --- rivet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivet.sh b/rivet.sh index e7b45aa..69c58d9 100755 --- a/rivet.sh +++ b/rivet.sh @@ -224,7 +224,7 @@ if ! [ "$SKIP_LIST" ]; then if [ "$indexf" = "$destdir/index.html" ]; then llinksec=$linksec else - llinksec="$linksec in this section" + llinksec="$linksec in $title" fi tmpfile="$(mktemp)" -- 2.49.1 From a03113d112da9c4eef947f0784ea9e5e04ff1fa5 Mon Sep 17 00:00:00 2001 From: emamaker <emamaker0@gmail.com> Date: Fri, 19 May 2023 23:51:47 +0200 Subject: [PATCH 4/6] correctly update title for current index page --- rivet.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/rivet.sh b/rivet.sh index 69c58d9..0f0dce0 100755 --- a/rivet.sh +++ b/rivet.sh @@ -224,6 +224,7 @@ if ! [ "$SKIP_LIST" ]; then if [ "$indexf" = "$destdir/index.html" ]; then llinksec=$linksec else + title="$(sed -E -n 's/.*<title>\s*(.+)\s*<\/title>.*/\1/p' "$indexf")" llinksec="$linksec in $title" fi -- 2.49.1 From 8b6f3001897e8b6630d427a10bb212ea2bb40c06 Mon Sep 17 00:00:00 2001 From: EmaMaker <emamaker0@gmail.com> Date: Sat, 12 Aug 2023 10:01:38 +0200 Subject: [PATCH 5/6] index pages use source file birth instead of output this was a bug introduced with index pages for subsections --- rivet.sh | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/rivet.sh b/rivet.sh index 0f0dce0..b860249 100755 --- a/rivet.sh +++ b/rivet.sh @@ -170,10 +170,7 @@ rm -f "$destdir"/_header.html "$destdir"/_footer.html "$destdir"/_metadata.html # Generate an ordered (by open time) file list find "$srcdir" -type f -exec ls -1t {} + | awk '/^.*\/[^_].+\.(md|html)$/' > "$objlist" -rm -f "$objdate" -while IFS="" read -r file; do - stat -c '%y' "$file" >> "$objdate" -done < "$objlist" + sed -e "s,^\/*[^\/]*\/,$destdir/," "$objlist" > "$tmpsed" mv "$tmpsed" "$objlist" @@ -206,17 +203,27 @@ if ! [ "$SKIP_LIST" ]; then lobjlist=$(mktemp) lobjdate=$(mktemp) llinklist=$(mktemp) - for indexf in $(find "$destdir" -type f -iname "index.html"); do + lmdlist=$(mktemp) + + for indexf in $(find "$destdir" -mindepth 1 -type f -iname "index.html"); do outdir=$(echo $(dirname "$indexf") | sed "s/$destdir//g") # Generate an ordered (by open time) list of files in the subdirectory by filtering the global list +# Filter global list grep "$outdir" "$objlist" > "$lobjlist" sed -e "s,^\/*[^\/]*\/,$destdir/," "$lobjlist" > "$tmpsed" + mv "$tmpsed" "$lobjlist" + +# Get the corresponding .md source file for every .html file, so that the file date is referring to +# the source and not to the output + sed -e 's/\.html$/\.md/' "$lobjlist" > "$tmpsed" + sed -e "s/$destdir/$srcdir/" "$tmpsed" > "$lmdlist" + +# Generate the list of dates for each file (open time) rm -f "$lobjdate" while IFS="" read -r file; do stat -c '%y' "$file" >> "$lobjdate" - done < "$lobjlist" - mv "$tmpsed" "$lobjlist" + done < "$lmdlist" grep "$outdir" "$linklist" > "$llinklist" -- 2.49.1 From 0101078c5e1f3348acd9315375ff66f09d001661 Mon Sep 17 00:00:00 2001 From: EmaMaker <emamaker@tutanota.com> Date: Thu, 12 Jun 2025 11:21:22 +0200 Subject: [PATCH 6/6] ignore md/html files starting in __ consider them as drafts and not to be published --- rivet.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivet.sh b/rivet.sh index b860249..3aa6a98 100755 --- a/rivet.sh +++ b/rivet.sh @@ -169,7 +169,7 @@ cp -r "$srcdir"/* "$destdir" rm -f "$destdir"/_header.html "$destdir"/_footer.html "$destdir"/_metadata.html # Generate an ordered (by open time) file list -find "$srcdir" -type f -exec ls -1t {} + | awk '/^.*\/[^_].+\.(md|html)$/' > "$objlist" +find "$srcdir" -type f -not -iname "__*" -exec ls -1t {} + | awk '/^.*\/[^_].+\.(md|html)$/' > "$objlist" sed -e "s,^\/*[^\/]*\/,$destdir/," "$objlist" > "$tmpsed" mv "$tmpsed" "$objlist" -- 2.49.1