Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: brian (brian@myr.sh)
Date: Fri Apr 19 15:11:23 2024 -0300
Parent: 6fb88d0
Updated email hook
diff --git a/receive-dovel.email b/receive-dovel.email index b1297f9..6d3a1db 100755 --- a/receive-dovel.email +++ b/receive-dovel.email @@ -5,21 +5,20 @@ echo "reading aux file" inbox() { cat <<- EOF - $(pagehead "$repo") - $(pagesummary "$repo") - <hr> + $(pagehead dovel) <h2>mail</h2> EOF - ls -ogdt --time-style long-iso "$root/$repo/mail/"* | while read -r g x s d t f + ls -ogdt --time-style long-iso "$root/mail/"* | while read -r g x s d t f do [ -d "$f" ] || continue f="$(basename "$f")" - qty="$(ls -1 "$root/$repo/mail/$f" | wc -l)" + name="$(echo "$f" | base64 -d)" + qty="$(ls -1 "$root/mail/$f" | wc -l)" cat <<- EOF <p> - <a href="mail/$f.html">$f</a> + <a href="mail/$f.html">$name</a> <small>$t $d</small><br> <i>$qty emails</i> </p> @@ -34,14 +33,12 @@ inbox() { # update emails page emails() { cat <<- EOF - $(pagehead "$repo") - $(pagesummary "$repo") - <hr> - <h2>$subj</h2> + $(pagehead dovel) + <h2>$(echo "$subj" | base64 -d)</h2> EOF # print each email - ls -1rt "$root/$repo/mail/$subj/"*.mbox | while read -r f + ls -1rt "$root/mail/$subj/"*.mbox | while read -r f do { # print headers @@ -92,27 +89,27 @@ save() { do case "$k" in "To:") to="$v" ;; - "Subject:") subj="$v" ;; + "Subject:") subj="$(echo "$v" | sed 's/^(Re: ?)//g')" ;; "Message-ID:") eid="$v" ;; "") break ;; esac done eid="${eid:-$(date -Iseconds)}" - repo="${to%@*}" echo "email from $from to $to about $subj" + subj="$(echo "$subj | base64)" # now the rest is a body cat - > /dev/null # move temp file echo "moving mbox file" - [ -d "$root/$repo/mail/$subj" ] || mkdir -p "$root/$repo/mail/$subj" - mv "$tmp" "$root/$repo/mail/$subj/$eid.mbox" + [ -d "$root/mail/$subj" ] || mkdir -p "$root/mail/$subj" + mv "$tmp" "$root/mail/$subj/$eid.mbox" # create html pages echo "creating html pages" - inbox > "$root/$repo/mail.html" - emails > "$root/$repo/mail/$subj.html" + inbox > "$root/mail.html" + emails > "$root/mail/$subj.html" } root="$HOME/www/dovel.email"