From 5ac9e2ae5f6f7874eaaeda5b0d0b6f186617a215 Mon Sep 17 00:00:00 2001 From: Alessandro Mauri Date: Fri, 11 Jun 2021 16:01:05 +0200 Subject: [PATCH] fixed date Before the date was taken on the destination files, since they are generated in the right order, lists based on last modified date were right but with the wrong date. Now rivet creates another list during the creation of the main object list just for storing dates of the source files. There is a 1:1 correspondance between the files in the objlist and the dates in the objdate lists so they can be retrived with the same counter. Another change is that now shortened dates are displayed in the index link list. --- rivet.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/rivet.sh b/rivet.sh index d1dd9a3..e4c2524 100644 --- a/rivet.sh +++ b/rivet.sh @@ -30,7 +30,7 @@ unset SKIP_SITEMAP unset SKIP_FEED usage() { - printf "Usage: rivet [-hovelfsu] [-p string] [-o destdir] srcdir domain\n" + printf "Usage: rivet [-hvelfsu] [-p string] [-o destdir] srcdir domain\n" printf "\t-h: prints this message\n" printf "\t-o [destdir]: specifies the output direcotory to be [destdir]\n" printf "\t-p [string]: Rename the \"Pages\" section to [string]\n" @@ -104,6 +104,7 @@ unset src headerfile=$srcdir/_header.html footerfile=$srcdir/_footer.html objlist=objlist.tmp +objdate=objdate.tmp # Check if index.md is present if ! [ -e "$srcdir"/index.md ]; then @@ -152,6 +153,10 @@ rm -f "$destdir"/_header.html "$destdir"/_footer.html # Generate an ordered (by open time) file list find "$srcdir" -type f -regex '.*\/[^_].+\..*' -exec ls -1t {} + | awk '/.*\.(md|html)$/' > "$objlist" +rm -f "$objdate" +while IFS="" read -r file; do + stat -c '%y' "$file" >> "$objdate" +done < "$objlist" sed -i -e "s,^\/*[^\/]*\/,$destdir/," "$objlist" # Convert markdown files @@ -206,7 +211,8 @@ EOF if [ -z "$title" ]; then title="${tfile##*/}" fi - printf "

%s

\n" "$line" "$title" >> "$tmpfile" + ldate="$(awk "NR==$count" "$objdate" | sed 's/\s.*$//')" + printf "

%s - %s

\n" "$line" "$ldate" "$title" >> "$tmpfile" done < "$linklist" echo '' >> "$tmpfile" sed -i '/<\/body>/i REPLACE' "$destdir"/index.html @@ -255,7 +261,7 @@ EOF if [ -z "$title" ]; then title="${tfile##*/}" fi - ldate="$(stat -c '%y' "$tfile")" + ldate="$(awk "NR==$count" "$objdate")" { printf '\t\n' printf '\t\t%s\n' "$title" @@ -269,6 +275,6 @@ EOF printf '\n' >> "$feed" fi -rm -f "$objlist" "$linklist" +rm -f "$objlist" "$linklist" "$objdate" exit