Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
- #!/bin/sh
- pagehead() {
- cat <<- EOF
- <!DOCTYPE html>
- <html>
- <head>
- <title>$1's git</title>
- <meta charset="UTF-8">
- <meta name="author" content="Brian Lee Mayer">
- <meta name="description" content="This is the development homepage of the Dovel project. Find here all repos mailing lists. And latest development changes.">
- <meta name="language" content="english">
- <meta name="keywords" content="email, dovel, blmayer, self host, software, smtp, web, interface">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="color-scheme" content="light dark">
- $([ "$1" ] && echo "<meta name=\"go-import\" content=\"dovel.email/$1 mod https://dovel.email\">")
- <style>
- body {
- max-width: 43em;
- margin: 60px auto;
- padding: 20px;
- font-family: sans-serif;
- }
- pre {
- overflow-x: auto;
- font-family: mono,monospace;
- font-weight: bold;
- background: lightgray;
- padding: 8px;
- border-radius: 8px;
- }
- file > pre {
- line-height: 0.8;
- }
- table {width: 100%}
- th {text-align: left}
- ol {margin: 0}
- tt {font-weight: bold}
- @media (prefers-color-scheme: dark) {
- pre {background: darkslategray}
- }
- </style>
- </head>
- <body>
- EOF
- }
- pagesummary() {
- cat <<- EOF
- ← <a href=/git.html>list</a>
- <center>
- <h1>$1</h1>
- <nav>
- <a href=/$1/index.html>index</a>  
- <a href=/$1/refs.html>refs</a>  
- <a href=/$1/log.html>log</a>  
- <a href=/$1/tree.html>tree</a>  
- </nav>
- <p><i>$(cat description)</i></p>
- </center>
- <kbd>git clone https://dovel.email/$1</kbd>
- EOF
- }
- escapehtml() {
- sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g'
- }
- type() {
- set -f
- for w in $*
- do
- [ "$DEBUG" = 1 ] && printf "\r[DEBUG] $w\n"
- if [ "$img" = 1 ] || [ "$link" = 1 ]
- then
- case "$w" in
- *']('*)
- alt="$alt ${w%%]*}"; w="${w#*](}"
- [ "$((img + link))" = "2" ] && ref="${w##*(}" && printf ' <a href="%s"><img src="%s" alt="%s"></a>' "${ref%)}" "${w%%)*}" "$alt"; img="0"; link=0
- [ "$img" = 1 ] && printf '<img src="%s" alt="%s">' "${w%)}" "$alt" && img="0"
- [ "$link" = 1 ] && printf '<a href="%s">%s</a>' "${w%)}" "$alt" && link="0"
- ;;
- *) alt="$alt $w" ;;
- esac
- continue
- fi
- case "$w" in
- # bold with **
- '**'*'**') w="${w#\*\*}" && printf "<strong>%s</strong>" "${w%\*\*}" ;;
- '**'*) printf "<strong>%s" "${w#\*\*}" ;;
- *'**') printf "%s</strong>" "${w%\*\*}" ;;
- # bold with __
- '__'*'__') w="${w#__}" && printf "<strong>%s</strong>" "${w%__}" ;;
- '__'*) printf "<strong>%s" "${w#__}" ;;
- *'__') printf "%s</strong>" "${w%__}" ;;
- # italics with *
- '*'*'*') w="${w#\*}" && printf "<em>%s</em>" "${w%\*}" ;;
- '*'*) printf "<em>%s" "${w#\*}" ;;
- *'*') printf "%s</em>" "${w%\*}" ;;
- # italics with _
- '_'*'_') w="${w#_}" && printf "<em>%s</em>" "${w%_}" ;;
- '_'*) printf "<em>%s" "${w#_}" ;;
- *'_') printf "%s</em>" "${w%_}" ;;
- # code with `
- '`'*'`') w="${w#\`}" && printf "<kbd>%s</kbd>" "${w%\`}" ;;
- '`'*) printf "<kbd>%s" "${w#\`}" ;;
- *'`') printf "%s</kbd>" "${w%\`}" ;;
- # one word linked images
- '[]('*')'*)
- alt="${w#['*)
- alt="${w#![}"; ref="${w#*(}"
- printf ' <img src="%s" alt="%s">' "${ref%)*}" "${alt%]*}"
- ;;
- # one word links
- '['*']('*')'*)
- alt="${w#[}"; ref="${w#*(}"
- printf ' <a href="%s">%s</a>' "${ref%)*}" "${alt%]*}"
- ;;
- # multi word links
- '[!['*) debug "begin link image"; link=1; img=1
- alt="${w#[![}"
- ;;
- '['*) debug "begin link"; link="1" && alt="${w#[}" ;;
- '!['*) debug "begin img"; img="1" && alt="${w#![}" ;;
- *) printf "$w" ;;
- esac
- printf " "
- done
- set +f
- }
- mdown() {
- set -f
- p="0"
- pre="0"
- ul="0"
- ol="0"
- while IFS= read -r l
- do
- if [ "$l" = '```' ]
- then
- if [ "$pre" = "0" ]
- then
- printf "<pre>\n"
- else
- printf "</pre>\n"
- fi
- pre=$((1-pre))
- continue
- fi
- [ "$pre" = "1" ] && printf "$l\n" && continue
- [ "$ul" -gt 0 ] && [ "${l%%- *}" != "" ] && { printf "</ul>\n"; ul="0"; }
- [ "$ol" -gt 0 ] && [ "${l%%[0-9]. *}" != "" ] && { printf "</ol>\n"; ol="0"; }
- case "$l" in
- "###### "*) printf "<h6>%s</h6>\n" "$(type ${l#*\# })";;
- "##### "*) printf "<h5>%s</h5>\n" "$(type ${l#*\# })" ;;
- "#### "*) printf "<h4>%s</h4>\n" "$(type ${l#*\# })" ;;
- "### "*) printf "<h3>%s</h3>\n" "$(type ${l#*\# })" ;;
- "## "*) printf "<h2>%s</h2>\n" "$(type ${l#*\# })" ;;
- "# "*) printf "<h1>%s</h1>\n" "$(type ${l#*\# })" ;;
- "***"|"---"|"___") printf "<hr>\n" ;;
- "- "*)
- [ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
- printf "\t<li>%s</li>\n" "$(type ${l#- })"
- ;;
- "* "*)
- [ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
- printf "\t<li>%s</li>\n" "$(type ${l#\* })"
- ;;
- "+ "*)
- [ "$ul" = "0" ] && printf "<ul>\n" && ul="1"
- printf "\t<li>%s</li>\n" "$(type ${l#+ })"
- ;;
- [0-9]". "*)
- [ "$ol" = "0" ] && printf "<ol>\n" && ol="1"
- printf "\t<li>%s</li>\n" "$(type ${l#[0-9]. })"
- ;;
- "") [ "$p" -gt "0" ] && { printf "\n</p>\n"; p="0"; } ;;
- *) { [ "$p" = "0" ] && printf "<p>\n\t"; }; p="1"; type "$l" ;;
- esac
- done
- [ "$ul" -gt "0" ] && printf "\n</ul>\n"
- [ "$ol" -gt "0" ] && printf "\n</ol>\n"
- [ "$p" -gt "0" ] && printf "\n</p>\n"
- set +f
- }
- decode() {
- case "$1" in
- "=?iso-8859-1?Q?"*)
- printf "%s" "$@" | sed -e 's/=?iso-8859-1?Q?//Ig' \
- -e 's/?=//g' \
- -e 's/=E7/ç/g' \
- -e 's/=ED/í/g' \
- -e 's/_/ /g' \
- -e 's/=E3/ã/g'
- ;;
- "=?utf-8?q?"* | "=?utf-8?Q?"* | "=?UTF-8?q?"* | "=?utf-8; format?q?"*)
- printf "%s" "$@" | sed -e 's/.*=?utf-8\(; format\)\??q?//Ig' \
- -e 's/?=//g' \
- -e 's/=F0=9F=8F=AD=C2=A0/🏭/g' \
- -e 's/=C2=A0=F0=9F=91=87/👇/g' \
- -e 's/=F0=9F=94=A5/🔥/g' \
- -e 's/=e2=80=93/-/g' \
- -e 's/=E2=80=99/’/g' \
- -e 's/=CE=94/Δ/g' \
- -e 's/=C3=BA/ú/g' \
- -e 's/=C3=B5/õ/g' \
- -e 's/=C3=B4/ô/g' \
- -e 's/=C3=B3/ó/g' \
- -e 's/=C3=96/Ö/g' \
- -e 's/=C3=AD/í/g' \
- -e 's/=C3=A9/é/g' \
- -e 's/=C3=AA/ê/g' \
- -e 's/=C3=A7/ç/g' \
- -e 's/=C3=A3/ã/g' \
- -e 's/=C3=A2/â/g' \
- -e 's/=C3=A1/á/g' \
- -e 's/=C3=A0/à/g' \
- -e 's/=3F/?/g' \
- -e 's/=2D/-/g' \
- -e 's/=2C/,/g' \
- -e 's/=20/ /g' \
- -e 's/=20/ /g' \
- -e 's/=20/ /g' \
- -e "s/=27/\\'/g"
- -e 's/=28/(/g' \
- -e 's/=29/)/g' \
- -e 's/=21/!/g' \
- -e 's/_/ /g' \
- -e 's/=20/ /g'
- ;;
- "=?UTF-8?B?"* | "=?utf-8?B?"*)
- printf "%s" "$@" | sed -e 's/=?UTF-8?B?//Ig' \
- -e 's/?=//g' | base64 -d
- ;;
- *) printf "%s" "$@" ;;
- esac
- }