list

scripts

Repo containing scripts to be used with dovel, and git hooks that powers our web interface.

git clone https://dovel.email/scripts

receive-dovel.email

  1. #!/bin/sh
  2. echo "reading aux file"
  3. . ./aux.sh
  4. inbox() {
  5. cat <<- EOF
  6. $(pagehead dovel)
  7. <h2>Mailling list</h2>
  8. This is the one and only mailling list for the Dovel project, all repos
  9. use this and old mail is also here.
  10. <h2>Instructions</h2>
  11. To send contributions use <kbd>REPO@dovel.email</kbd> format,
  12. i.e. to contribute to the server project send email to server
  13. _AT_ dovel.email, with the subject you want, maybe git will
  14. create a line for you. Please CC me as well so I can reply
  15. faster: dovel _AT_ terminal.pink.
  16. <h3>Replying</h3>
  17. To send email to an ongoing conversation simply use the same
  18. address and subject, do not append "Re:" to the subject.
  19. <h3>More info</h3>
  20. See <a href=git.html>our git</a> page.
  21. <hr>
  22. <h2>Mail</h2>
  23. EOF
  24. ls -ogdt --time-style long-iso "$root/mail/"* | while read -r g x s d t f
  25. do
  26. [ -d "$f" ] || continue
  27. f="$(basename "$f")"
  28. name="$(echo "$f" | base64 -d)"
  29. cat <<- EOF
  30. <p>
  31. <a href="mail/$f.html">$name</a>
  32. <small>$t $d</small><br>
  33. </p>
  34. EOF
  35. done
  36. cat <<- EOF
  37. </body>
  38. </html>
  39. EOF
  40. }
  41. # update emails page
  42. emails() {
  43. cat <<- EOF
  44. $(pagehead dovel)
  45. <h2>$subj</h2>
  46. EOF
  47. # print each email
  48. ls -1rt "$root/mail/$dir/"*.mbox | while read -r f
  49. do
  50. {
  51. # print headers
  52. read -r foo from date
  53. cat <<- EOF
  54. <details>
  55. <summary>
  56. From: $from<br>
  57. Date: $date
  58. </summary>
  59. <ul>
  60. EOF
  61. while read -r k v
  62. do
  63. case "$k" in
  64. "") break ;;
  65. *) printf "<li>$k $v</li>\n" ;;
  66. esac
  67. done
  68. # print body
  69. cat <<- EOF
  70. </ul>
  71. </details>
  72. <pre>
  73. EOF
  74. escapehtml
  75. printf "</pre>\n<br>\n"
  76. } < "$f"
  77. done
  78. # finish
  79. cat <<- EOF
  80. </body>
  81. </html>
  82. EOF
  83. }
  84. save() {
  85. echo "reading email"
  86. # first line is From email date:
  87. read -r foo from date
  88. # read headers
  89. while read -r k v
  90. do
  91. case "$k" in
  92. "To:") to="$v" ;;
  93. "Subject:") subj="$(echo "$v" | sed 's/^(Re: ?)//g')" ;;
  94. "Message-ID:") eid="$v" ;;
  95. "") break ;;
  96. esac
  97. done
  98. eid="${eid:-$(date -Iseconds)}"
  99. echo "email from $from to $to about $subj"
  100. subj="$(decode "$subj" | escapehtml)"
  101. dir="$(echo "$subj" | base64)"
  102. # now the rest is a body
  103. cat - > /dev/null
  104. # move temp file
  105. echo "moving mbox file"
  106. [ -d "$root/mail/$dir" ] || mkdir -p "$root/mail/$dir"
  107. mv "$tmp" "$root/mail/$dir/$eid.mbox"
  108. # create html pages
  109. echo "creating html pages"
  110. inbox > "$root/mail.html"
  111. emails > "$root/mail/$dir.html"
  112. }
  113. root="$HOME/dovel.email"
  114. # copy to temp file
  115. tmp="$(mktemp)"
  116. tee "$tmp" -a "$HOME/mail.mbox" | save