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.
typo
Alessandro Mauri 4 years ago
parent ac778f6537
commit 5ac9e2ae5f
  1. 14
      rivet.sh

@ -30,7 +30,7 @@ unset SKIP_SITEMAP
unset SKIP_FEED unset SKIP_FEED
usage() { 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-h: prints this message\n"
printf "\t-o [destdir]: specifies the output direcotory to be [destdir]\n" printf "\t-o [destdir]: specifies the output direcotory to be [destdir]\n"
printf "\t-p [string]: Rename the \"Pages\" section to [string]\n" printf "\t-p [string]: Rename the \"Pages\" section to [string]\n"
@ -104,6 +104,7 @@ unset src
headerfile=$srcdir/_header.html headerfile=$srcdir/_header.html
footerfile=$srcdir/_footer.html footerfile=$srcdir/_footer.html
objlist=objlist.tmp objlist=objlist.tmp
objdate=objdate.tmp
# Check if index.md is present # Check if index.md is present
if ! [ -e "$srcdir"/index.md ]; then 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 # Generate an ordered (by open time) file list
find "$srcdir" -type f -regex '.*\/[^_].+\..*' -exec ls -1t {} + | find "$srcdir" -type f -regex '.*\/[^_].+\..*' -exec ls -1t {} + |
awk '/.*\.(md|html)$/' > "$objlist" 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" sed -i -e "s,^\/*[^\/]*\/,$destdir/," "$objlist"
# Convert markdown files # Convert markdown files
@ -206,7 +211,8 @@ EOF
if [ -z "$title" ]; then if [ -z "$title" ]; then
title="${tfile##*/}" title="${tfile##*/}"
fi fi
printf "<p><a href=\"%s\">%s</a></p>\n" "$line" "$title" >> "$tmpfile" ldate="$(awk "NR==$count" "$objdate" | sed 's/\s.*$//')"
printf "<p><a href=\"%s\">%s - %s</a></p>\n" "$line" "$ldate" "$title" >> "$tmpfile"
done < "$linklist" done < "$linklist"
echo '</div>' >> "$tmpfile" echo '</div>' >> "$tmpfile"
sed -i '/<\/body>/i REPLACE' "$destdir"/index.html sed -i '/<\/body>/i REPLACE' "$destdir"/index.html
@ -255,7 +261,7 @@ EOF
if [ -z "$title" ]; then if [ -z "$title" ]; then
title="${tfile##*/}" title="${tfile##*/}"
fi fi
ldate="$(stat -c '%y' "$tfile")" ldate="$(awk "NR==$count" "$objdate")"
{ {
printf '\t<entry>\n' printf '\t<entry>\n'
printf '\t\t<title>%s</title>\n' "$title" printf '\t\t<title>%s</title>\n' "$title"
@ -269,6 +275,6 @@ EOF
printf '</feed>\n' >> "$feed" printf '</feed>\n' >> "$feed"
fi fi
rm -f "$objlist" "$linklist" rm -f "$objlist" "$linklist" "$objdate"
exit exit

Loading…
Cancel
Save