link list is now in date order (hopefully)

pull/1/head
Alessandro Mauri 4 years ago
parent fe464d2aed
commit 81fd16023d
  1. 19
      rivet.sh

@ -46,10 +46,10 @@ convert() {
tmpfile="tmpconvfile.tmp" tmpfile="tmpconvfile.tmp"
infile="$1" infile="$1"
outfile="${infile%???}.html" outfile="${infile%???}.html"
cp "$1" "$tmpfile" cp "$infile" "$tmpfile"
# TODO: convert links to .md to .html # TODO: convert links to .md to .html
lowdown -s -Thtml -o "$outfile" "$tmpfile" lowdown -s -Thtml -o "$outfile" "$tmpfile"
rm -f "$tmpfile" "$1" rm -f "$tmpfile" "$infile"
} }
# Check dependencies # Check dependencies
@ -87,6 +87,7 @@ srcdir=${src%%\/}
unset src unset src
headerfile=$srcdir/_header.html headerfile=$srcdir/_header.html
footerfile=$srcdir/_footer.html footerfile=$srcdir/_footer.html
filelist=filelist.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
@ -132,11 +133,15 @@ mkdir -p "$destdir"
cp -r "$srcdir"/* "$destdir" cp -r "$srcdir"/* "$destdir"
rm -f "$destdir"/_header.html "$destdir"/_footer.html rm -f "$destdir"/_header.html "$destdir"/_footer.html
# Generate an ordered (by open time) file list
find "$srcdir" -type f -name "*.md" -exec ls -1t {} + > "$filelist"
sed -i "s,^\/*[^\/]*\/,$destdir/," "$filelist"
# Convert markdown files # Convert markdown files
find "$destdir" -name "*.md" |
while IFS="" read -r file; do while IFS="" read -r file; do
convert "$file" convert "$file"
done done < "$filelist"
sed -i 's/\.md$/\.html/' "$filelist"
# Prepare the header # Prepare the header
if ! [ "$SKIP_HEADER" ]; then if ! [ "$SKIP_HEADER" ]; then
@ -161,12 +166,10 @@ fi
# Prepare the sitemap & file list # Prepare the sitemap & file list
if ! [ "$SKIP_SITEMAP" ] || ! [ "$SKIP_LIST" ]; then if ! [ "$SKIP_SITEMAP" ] || ! [ "$SKIP_LIST" ]; then
linklist="linklist.tmp" linklist="linklist.tmp"
# echo "" > "$linklist"
rm -f "$linklist" "$destdir"/sitemap.xml rm -f "$linklist" "$destdir"/sitemap.xml
find "$destdir" -name "*.html" |
while IFS="" read -r file; do while IFS="" read -r file; do
echo "${file#$destdir/}" >> "$linklist" echo "${file#$destdir/}" >> "$linklist"
done done < "$filelist"
if ! [ "$SKIP_LIST" ]; then if ! [ "$SKIP_LIST" ]; then
tmpfile="linkindex.tmp" tmpfile="linkindex.tmp"
@ -206,7 +209,7 @@ EOF
done < "$linklist" done < "$linklist"
sed -i 's/^<url>/\t<url>/' "$destdir"/sitemap.xml sed -i 's/^<url>/\t<url>/' "$destdir"/sitemap.xml
fi fi
rm -f "$linklist" rm -f "$linklist" "$filelist"
fi fi
exit exit

Loading…
Cancel
Save