Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: brian (git@myr.sh)
Date: Wed Dec 27 10:24:05 2023 -0300
Parent: d288fbe
Removed file
diff --git a/receive-localhost b/receive-localhost
deleted file mode 100755
index 9cc1e84..0000000
--- a/receive-localhost
+++ /dev/null
@@ -1,177 +0,0 @@
-#!/bin/sh
-
-# update index page
-index() {
- cat <<- EOF
- <!DOCTYPE html>
- <html>
- <head>
- <title>dovel</title>
- <link rel=icon href=/assets/favicon.ico>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <meta name="color-scheme" content="light dark"/>
- <style>body{max-width:600px;padding:0 15px;margin:40px auto;font-family:sans-serif;}a{color:#888}small{float:right;}</style>
- <link rel="manifest" href="/assets/manifest.json">
- <link rel="apple-touch-icon" sizes="200x200" href="/logo.png">
- </head>
- <body>
- <center>
- <pre>
- _________ ______
- ______ /________ _________ /
- _ __ /_ __ \_ | / / _ \_ /
- / /_/ / / /_/ /_ |/ // __/ /
- \__,_/ \____/_____/ \___//_/
-
- </pre>
- </center>
- <a href=compose.html>compose</a> 
- <a href=logout.html>logout</a>
- EOF
-
- ls -ogdt --time-style long-iso * | while read -r g x s d t f
- do
- cat <<- EOF
- <p>
- <a href="$f/index.html">$f</a>
- <small>$t $d</small>
- </p>
- EOF
- done
- cat <<- EOF
- </body>
- </html>
- EOF
-}
-
-# update inbox page
-inbox() {
- cat <<- EOF
- <!DOCTYPE html>
- <html>
- <head>
- <title>dovel</title>
- <link rel=icon href=/assets/favicon.ico>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <meta name="color-scheme" content="light dark"/>
- <style>body{max-width:600px;padding:0 15px;margin:40px auto;font-family:sans-serif}a{color:#888}small{float:right}</style>
- <link rel="manifest" href="/assets/manifest.json">
- <link rel="apple-touch-icon" sizes="200x200" href="/logo.png">
- </head>
- <body>
- <h1>$to</h1>
- <a href=/index.html>go back</a>
- EOF
-
- ls -ogdt --time-style long-iso "$to"/* | while read -r g x s d t f
- do
- f="$(basename "$f")"
- qty="$(ls -1 "$to/$f" | wc -l)"
- cat <<- EOF
- <p>
- <a href="$f/index.html">$f</a>
- <small>$t $d</small><br>
- <i>$qty emails</i>
- </p>
- EOF
- done
- cat <<- EOF
- </body>
- </html>
- EOF
-}
-
-# update emails page
-emails() {
- cat <<- EOF
- <!DOCTYPE html>
- <html>
- <head>
- <title>dovel</title>
- <link rel=icon href=/assets/favicon.ico>
- <meta name="viewport" content="width=device-width, initial-scale=1"/>
- <meta name="color-scheme" content="light dark"/>
- <style>body{max-width:600px;padding:0 15px;margin:40px auto;font-family:sans-serif}a{color:#888}small{float:right}</style>
- <link rel="manifest" href="/assets/manifest.json">
- <link rel="apple-touch-icon" sizes="200x200" href="/logo.png">
- </head>
- <body>
- <h1>$subj</h1>
- <a href="/$to/$subj/index.html">go back</a><br><br>
- EOF
-
- # print each email
- ls -1rt "$to/$subj"/* | while read -r f
- do
- {
- # print headers
- read -r foo from date
- cat <<- EOF
- <details>
- <summary>
- From: $from<br>
- Date: $date
- </summary>
- <ul>
- EOF
-
- while read -r k v
- do
- case "$k" in
- "") break ;;
- *) printf "<li>$k $v</li>\n" ;;
- esac
- done
-
- # print body
- cat <<- EOF
- </ul>
- </details>
- <pre>
- EOF
- cat -
- printf "</pre>\n<br>\n"
- } < "$f"
- done
-
- # finish
- cat <<- EOF
- </body>
- </html>
- EOF
-}
-
-save() {
- # first line is From email date:
- read -r foo from date
-
- # read headers
- while read -r k v
- do
- case "$k" in
- "To:") to="$v" ;;
- "Subject:") subj="$v" ;;
- "Message-Id:") eid="$v" ;;
- "") break ;;
- esac
- done
- eid="${eid:-$(date -Iseconds)}"
-
- # now the rest is a body
- cat - > /dev/null
-
- # move temp file
- mkdir -p "$to/$subj"
- mv "$tmp" "$to/$subj/$eid.mbox"
-
- # create html pages
- mkdir -p "out/$to/$subj"
- index > out/index.html
- inbox > "out/$to/index.html"
- emails > "out/$to/$subj/index.html"
-}
-
-# copy to temp file
-tmp="$(mktemp)"
-tee "$tmp" | save
-