list

scripts

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

git clone https://dovel.email/scripts

aux.sh

  1. #!/bin/sh
  2. pagehead() {
  3. cat <<- EOF
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <title>$1's git</title>
  8. <meta charset="UTF-8">
  9. <meta name="author" content="Brian Lee Mayer">
  10. <meta name="description" content="This is the development homepage of the Dovel project. Find here all repos mailing lists. And latest development changes.">
  11. <meta name="language" content="english">
  12. <meta name="keywords" content="email, dovel, blmayer, self host, software, smtp, web, interface">
  13. <meta name="viewport" content="width=device-width, initial-scale=1">
  14. <meta name="color-scheme" content="light dark">
  15. $([ "$1" ] && echo "<meta name=\"go-import\" content=\"dovel.email/$1 mod https://dovel.email\">")
  16. <style>
  17. body {
  18. max-width: 43em;
  19. margin: 60px auto;
  20. padding: 20px;
  21. font-family: sans-serif;
  22. }
  23. pre {
  24. overflow-x: auto;
  25. font-family: mono,monospace;
  26. font-weight: bold;
  27. background: lightgray;
  28. padding: 8px;
  29. border-radius: 8px;
  30. }
  31. file > pre {
  32. line-height: 0.8;
  33. }
  34. table {width: 100%}
  35. th {text-align: left}
  36. ol {margin: 0}
  37. tt {font-weight: bold}
  38. @media (prefers-color-scheme: dark) {
  39. pre {background: darkslategray}
  40. }
  41. </style>
  42. </head>
  43. <body>
  44. EOF
  45. }
  46. pagesummary() {
  47. cat <<- EOF
  48. &larr; <a href=/git.html>list</a>
  49. <center>
  50. <h1>$1</h1>
  51. <nav>
  52. <a href=/$1/index.html>index</a> &emsp;
  53. <a href=/$1/refs.html>refs</a> &emsp;
  54. <a href=/$1/log.html>log</a> &emsp;
  55. <a href=/$1/tree.html>tree</a> &emsp;
  56. </nav>
  57. <p><i>$(cat description)</i></p>
  58. </center>
  59. <kbd>git clone https://dovel.email/$1</kbd>
  60. EOF
  61. }
  62. escapehtml() {
  63. sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'
  64. }
  65. type() {
  66. set -f
  67. for w in $*
  68. do
  69. [ "$DEBUG" = 1 ] && printf "\r[DEBUG] $w\n"
  70. if [ "$img" = 1 ] || [ "$link" = 1 ]
  71. then
  72. case "$w" in
  73. *']('*)
  74. alt="$alt ${w%%]*}"; w="${w#*](}"
  75. [ "$((img + link))" = "2" ] && ref="${w##*(}" && printf ' <a href="%s"><img src="%s" alt="%s"></a>' "${ref%)}" "${w%%)*}" "$alt"; img="0"; link=0
  76. [ "$img" = 1 ] && printf '<img src="%s" alt="%s">' "${w%)}" "$alt" && img="0"
  77. [ "$link" = 1 ] && printf '<a href="%s">%s</a>' "${w%)}" "$alt" && link="0"
  78. ;;
  79. *) alt="$alt $w" ;;
  80. esac
  81. continue
  82. fi
  83. case "$w" in
  84. # bold with **
  85. '**'*'**') w="${w#\*\*}" && printf "<strong>%s</strong>" "${w%\*\*}" ;;
  86. '**'*) printf "<strong>%s" "${w#\*\*}" ;;
  87. *'**') printf "%s</strong>" "${w%\*\*}" ;;
  88. # bold with __
  89. '__'*'__') w="${w#__}" && printf "<strong>%s</strong>" "${w%__}" ;;
  90. '__'*) printf "<strong>%s" "${w#__}" ;;
  91. *'__') printf "%s</strong>" "${w%__}" ;;
  92. # italics with *
  93. '*'*'*') w="${w#\*}" && printf "<em>%s</em>" "${w%\*}" ;;
  94. '*'*) printf "<em>%s" "${w#\*}" ;;
  95. *'*') printf "%s</em>" "${w%\*}" ;;
  96. # italics with _
  97. '_'*'_') w="${w#_}" && printf "<em>%s</em>" "${w%_}" ;;
  98. '_'*) printf "<em>%s" "${w#_}" ;;
  99. *'_') printf "%s</em>" "${w%_}" ;;
  100. # code with `
  101. '`'*'`') w="${w#\`}" && printf "<kbd>%s</kbd>" "${w%\`}" ;;
  102. '`'*) printf "<kbd>%s" "${w#\`}" ;;
  103. *'`') printf "%s</kbd>" "${w%\`}" ;;
  104. # one word linked images
  105. '[!['*']('*')]('*')'*)
  106. alt="${w#[![}"; iref="${w#*(}"; ref="${w##*(}"
  107. printf ' <a href="%s"><img src="%s" alt="%s"></a>' "${ref%)}" "${iref%%)*}" "${alt%%](*}"
  108. ;;
  109. # one word images
  110. '!['*']('*')'*)
  111. alt="${w#![}"; ref="${w#*(}"
  112. printf ' <img src="%s" alt="%s">' "${ref%)*}" "${alt%]*}"
  113. ;;
  114. # one word links
  115. '['*']('*')'*)
  116. alt="${w#[}"; ref="${w#*(}"
  117. printf ' <a href="%s">%s</a>' "${ref%)*}" "${alt%]*}"
  118. ;;
  119. # multi word links
  120. '[!['*) debug "begin link image"; link=1; img=1
  121. alt="${w#[![}"
  122. ;;
  123. '['*) debug "begin link"; link="1" && alt="${w#[}" ;;
  124. '!['*) debug "begin img"; img="1" && alt="${w#![}" ;;
  125. *) printf "$w" ;;
  126. esac
  127. printf " "
  128. done
  129. set +f
  130. }
  131. mdown() {
  132. set -f
  133. p="0"
  134. pre="0"
  135. ul="0"
  136. ol="0"
  137. while IFS= read -r l
  138. do
  139. if [ "$l" = '```' ]
  140. then
  141. if [ "$pre" = "0" ]
  142. then
  143. printf "<pre>\n"
  144. else
  145. printf "</pre>\n"
  146. fi
  147. pre=$((1-pre))
  148. continue
  149. fi
  150. [ "$pre" = "1" ] && printf "$l\n" && continue
  151. [ "$ul" -gt 0 ] && [ "${l%%- *}" != "" ] && { printf "</ul>\n"; ul="0"; }
  152. [ "$ol" -gt 0 ] && [ "${l%%[0-9]. *}" != "" ] && { printf "</ol>\n"; ol="0"; }
  153. case "$l" in
  154. "###### "*) printf "<h6>%s</h6>\n" "$(type ${l#*\# })";;
  155. "##### "*) printf "<h5>%s</h5>\n" "$(type ${l#*\# })" ;;
  156. "#### "*) printf "<h4>%s</h4>\n" "$(type ${l#*\# })" ;;
  157. "### "*) printf "<h3>%s</h3>\n" "$(type ${l#*\# })" ;;
  158. "## "*) printf "<h2>%s</h2>\n" "$(type ${l#*\# })" ;;
  159. "# "*) printf "<h1>%s</h1>\n" "$(type ${l#*\# })" ;;
  160. "***"|"---"|"___") printf "<hr>\n" ;;
  161. "- "*)
  162. [ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
  163. printf "\t<li>%s</li>\n" "$(type ${l#- })"
  164. ;;
  165. "* "*)
  166. [ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
  167. printf "\t<li>%s</li>\n" "$(type ${l#\* })"
  168. ;;
  169. "+ "*)
  170. [ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
  171. printf "\t<li>%s</li>\n" "$(type ${l#+ })"
  172. ;;
  173. [0-9]". "*)
  174. [ "$ol" = "0" ] && printf "<ol>\n" && ol="1"
  175. printf "\t<li>%s</li>\n" "$(type ${l#[0-9]. })"
  176. ;;
  177. "") [ "$p" -gt "0" ] && { printf "\n</p>\n"; p="0"; } ;;
  178. *) { [ "$p" = "0" ] && printf "<p>\n\t"; }; p="1"; type "$l" ;;
  179. esac
  180. done
  181. [ "$ul" -gt "0" ] && printf "\n</ul>\n"
  182. [ "$ol" -gt "0" ] && printf "\n</ol>\n"
  183. [ "$p" -gt "0" ] && printf "\n</p>\n"
  184. set +f
  185. }
  186. decode() {
  187. case "$1" in
  188. "=?iso-8859-1?Q?"*)
  189. printf "%s" "$@" | sed -e 's/=?iso-8859-1?Q?//Ig' \
  190. -e 's/?=//g' \
  191. -e 's/=E7/ç/g' \
  192. -e 's/=ED/í/g' \
  193. -e 's/_/ /g' \
  194. -e 's/=E3/ã/g'
  195. ;;
  196. "=?utf-8?q?"* | "=?utf-8?Q?"* | "=?UTF-8?q?"* | "=?utf-8; format?q?"*)
  197. printf "%s" "$@" | sed -e 's/.*=?utf-8\(; format\)\??q?//Ig' \
  198. -e 's/?=//g' \
  199. -e 's/=F0=9F=8F=AD=C2=A0/🏭/g' \
  200. -e 's/=C2=A0=F0=9F=91=87/👇/g' \
  201. -e 's/=F0=9F=94=A5/🔥/g' \
  202. -e 's/=e2=80=93/-/g' \
  203. -e 's/=E2=80=99/’/g' \
  204. -e 's/=CE=94/Δ/g' \
  205. -e 's/=C3=BA/ú/g' \
  206. -e 's/=C3=B5/õ/g' \
  207. -e 's/=C3=B4/ô/g' \
  208. -e 's/=C3=B3/ó/g' \
  209. -e 's/=C3=96/Ö/g' \
  210. -e 's/=C3=AD/í/g' \
  211. -e 's/=C3=A9/é/g' \
  212. -e 's/=C3=AA/ê/g' \
  213. -e 's/=C3=A7/ç/g' \
  214. -e 's/=C3=A3/ã/g' \
  215. -e 's/=C3=A2/â/g' \
  216. -e 's/=C3=A1/á/g' \
  217. -e 's/=C3=A0/à/g' \
  218. -e 's/=3F/?/g' \
  219. -e 's/=2D/-/g' \
  220. -e 's/=2C/,/g' \
  221. -e 's/=20/ /g' \
  222. -e 's/=20/ /g' \
  223. -e 's/=20/ /g' \
  224. -e "s/=27/\\'/g"
  225. -e 's/=28/(/g' \
  226. -e 's/=29/)/g' \
  227. -e 's/=21/!/g' \
  228. -e 's/_/ /g' \
  229. -e 's/=20/ /g'
  230. ;;
  231. "=?UTF-8?B?"* | "=?utf-8?B?"*)
  232. printf "%s" "$@" | sed -e 's/=?UTF-8?B?//Ig' \
  233. -e 's/?=//g' | base64 -d
  234. ;;
  235. *) printf "%s" "$@" ;;
  236. esac
  237. }