Compare commits

...

10 Commits
typo ... master

Author SHA1 Message Date
3deaa11a76 Merge pull request 'master' (#4) from EmaMaker/rivet:master into master
Reviewed-on: alema/rivet#4
2025-06-12 20:40:57 +02:00
0101078c5e ignore md/html files starting in __
consider them as drafts and not to be published
2025-06-12 11:21:22 +02:00
EmaMaker
8b6f300189 index pages use source file birth instead of output
this was a bug introduced with index pages for subsections
2023-08-12 10:01:38 +02:00
f830437dfb Merge pull request 'correctly update title for current index page' (#3) from EmaMaker/rivet:master into master
Reviewed-on: http://git.alemauri.eu/alema/rivet/pulls/3
2023-05-29 11:36:09 +02:00
emamaker
a03113d112 correctly update title for current index page 2023-05-19 23:56:22 +02:00
2a8437d7a7 Merge pull request 'Pages list for index files in subdirectories' (#2) from EmaMaker/rivet:master into master
Reviewed-on: http://git.alemauri.eu/alema/rivet/pulls/2
2023-05-18 11:05:32 +02:00
6b49f03e02 Merge pull request 'fix typo in comment' (#1) from EmaMaker/rivet:typo into master
Reviewed-on: http://git.alemauri.eu/alema/rivet/pulls/1
2023-05-18 00:30:12 +02:00
emamaker
52b4b836f2 "Pages in this section" -> "Pages in *file title*" 2023-05-17 23:53:18 +02:00
emamaker
4536162c42 "Pages in this section" instead of "Pages" in subdirectories index file list 2023-05-17 23:52:55 +02:00
emamaker
5538ba5c59 "Pages" list also for index.html files in subdirectories 2023-05-17 23:52:16 +02:00

67
rivet.sh Normal file → Executable file
View File

@ -169,11 +169,8 @@ cp -r "$srcdir"/* "$destdir"
rm -f "$destdir"/_header.html "$destdir"/_footer.html "$destdir"/_metadata.html
# Generate an ordered (by open time) file list
find "$srcdir" -type f -exec ls -1t {} + | awk '/^.*\/[^_].+\.(md|html)$/' > "$objlist"
rm -f "$objdate"
while IFS="" read -r file; do
stat -c '%y' "$file" >> "$objdate"
done < "$objlist"
find "$srcdir" -type f -not -iname "__*" -exec ls -1t {} + | awk '/^.*\/[^_].+\.(md|html)$/' > "$objlist"
sed -e "s,^\/*[^\/]*\/,$destdir/," "$objlist" > "$tmpsed"
mv "$tmpsed" "$objlist"
@ -201,13 +198,48 @@ if ! [ "$SKIP_META" ]; then
done
fi
# Prepare index file list
# For every file named "index.html", prepare index file list
if ! [ "$SKIP_LIST" ]; then
lobjlist=$(mktemp)
lobjdate=$(mktemp)
llinklist=$(mktemp)
lmdlist=$(mktemp)
for indexf in $(find "$destdir" -mindepth 1 -type f -iname "index.html"); do
outdir=$(echo $(dirname "$indexf") | sed "s/$destdir//g")
# Generate an ordered (by open time) list of files in the subdirectory by filtering the global list
# Filter global list
grep "$outdir" "$objlist" > "$lobjlist"
sed -e "s,^\/*[^\/]*\/,$destdir/," "$lobjlist" > "$tmpsed"
mv "$tmpsed" "$lobjlist"
# Get the corresponding .md source file for every .html file, so that the file date is referring to
# the source and not to the output
sed -e 's/\.html$/\.md/' "$lobjlist" > "$tmpsed"
sed -e "s/$destdir/$srcdir/" "$tmpsed" > "$lmdlist"
# Generate the list of dates for each file (open time)
rm -f "$lobjdate"
while IFS="" read -r file; do
stat -c '%y' "$file" >> "$lobjdate"
done < "$lmdlist"
grep "$outdir" "$linklist" > "$llinklist"
# Modify "Pages" header to show the current section
if [ "$indexf" = "$destdir/index.html" ]; then
llinksec=$linksec
else
title="$(sed -E -n 's/.*<title>\s*(.+)\s*<\/title>.*/\1/p' "$indexf")"
llinksec="$linksec in $title"
fi
tmpfile="$(mktemp)"
rm -f "$tmpfile"
cat << EOF >> "$tmpfile"
<div id="map">
<h2 id="Pages">$linksec</h2>
<h2 id="Pages">$llinksec</h2>
EOF
count='0'
while IFS="" read -r line; do
@ -215,22 +247,23 @@ EOF
if echo "$line" | grep -q 'index\.html'; then
continue
fi
tfile="$(awk "NR==$count" "$objlist")"
tfile="$(awk "NR==$count" "$lobjlist")"
title="$(sed -E -n 's/.*<title>\s*(.+)\s*<\/title>.*/\1/p' "$tfile")"
if [ -z "$title" ]; then
title="${tfile##*/}"
fi
ldate="$(awk "NR==$count" "$objdate" | sed 's/\s.*$//')"
printf "<p><a href=\"%s\">%s - %s</a></p>\n" "$line" "$ldate" "$title" >> "$tmpfile"
done < "$linklist"
ldate="$(awk "NR==$count" "$lobjdate" | sed 's/\s.*$//')"
printf "<p><a href=\"%s\">%s - %s</a></p>\n" "$line" "$ldate" "$title" >> "$tmpfile"
done < "$llinklist"
echo '</div>' >> "$tmpfile"
sed '/<\/body>/i REPLACE' "$destdir"/index.html > "$tmpsed"
mv "$tmpsed" "$destdir"/index.html
sed "/^REPLACE/r $tmpfile" "$destdir"/index.html > "$tmpsed"
mv "$tmpsed" "$destdir"/index.html
sed 's/^REPLACE//' "$destdir"/index.html > "$tmpsed"
mv "$tmpsed" "$destdir"/index.html
sed '/<\/body>/i REPLACE' $indexf > "$tmpsed"
mv "$tmpsed" $indexf
sed "/^REPLACE/r $tmpfile" $indexf > "$tmpsed"
mv "$tmpsed" $indexf
sed 's/^REPLACE//' $indexf > "$tmpsed"
mv "$tmpsed" $indexf
rm -f "$tmpfile"
done;
fi
# enclose article inside <article></article>