Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
- #!/bin/sh
- echo "reading aux file"
- . ./aux.sh
- inbox() {
- cat <<- EOF
- $(pagehead dovel)
- <h2>Mailling list</h2>
- This is the one and only mailling list for the Dovel project, all repos
- use this and old mail is also here.
- <h2>Instructions</h2>
- To send contributions use <kbd>REPO@dovel.email</kbd> format,
- i.e. to contribute to the server project send email to server
- _AT_ dovel.email, with the subject you want, maybe git will
- create a line for you. Please CC me as well so I can reply
- faster: dovel _AT_ terminal.pink.
- <h3>Replying</h3>
- To send email to an ongoing conversation simply use the same
- address and subject, do not append "Re:" to the subject.
- <h3>More info</h3>
- See <a href=git.html>our git</a> page.
- <hr>
- <h2>Mail</h2>
- EOF
- ls -ogdt --time-style long-iso "$root/mail/"* | while read -r g x s d t f
- do
- [ -d "$f" ] || continue
- f="$(basename "$f")"
- name="$(echo "$f" | base64 -d)"
- cat <<- EOF
- <p>
- <a href="mail/$f.html">$name</a>
- <small>$t $d</small><br>
- </p>
- EOF
- done
- cat <<- EOF
- </body>
- </html>
- EOF
- }
- # update emails page
- emails() {
- cat <<- EOF
- $(pagehead dovel)
- <h2>$subj</h2>
- EOF
- # print each email
- ls -1rt "$root/mail/$dir/"*.mbox | 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
- escapehtml
- printf "</pre>\n<br>\n"
- } < "$f"
- done
- # finish
- cat <<- EOF
- </body>
- </html>
- EOF
- }
- save() {
- echo "reading email"
- # 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="$(echo "$v" | sed 's/^(Re: ?)//g')" ;;
- "Message-ID:") eid="$v" ;;
- "") break ;;
- esac
- done
- eid="${eid:-$(date -Iseconds)}"
- echo "email from $from to $to about $subj"
- subj="$(decode "$subj" | escapehtml)"
- dir="$(echo "$subj" | base64)"
- # now the rest is a body
- cat - > /dev/null
- # move temp file
- echo "moving mbox file"
- [ -d "$root/mail/$dir" ] || mkdir -p "$root/mail/$dir"
- mv "$tmp" "$root/mail/$dir/$eid.mbox"
- # create html pages
- echo "creating html pages"
- inbox > "$root/mail.html"
- emails > "$root/mail/$dir.html"
- }
- root="$HOME/dovel.email"
- # copy to temp file
- tmp="$(mktemp)"
- tee "$tmp" -a "$HOME/mail.mbox" | save