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