Browse Source

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.
master
Alessandro Mauri 5 days ago
parent
commit
5ac9e2ae5f
1 changed files with 10 additions and 4 deletions
  1. +10
    -4
      rivet.sh

+ 10
- 4
rivet.sh View File

@ -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 "<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"
echo '</div>' >> "$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<entry>\n'
printf '\t\t<title>%s</title>\n' "$title"
@ -269,6 +275,6 @@ EOF
printf '</feed>\n' >> "$feed"
fi
rm -f "$objlist" "$linklist"
rm -f "$objlist" "$linklist" "$objdate"
exit

Loading…
Cancel
Save