list

scripts

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

curl -O https://dovel.email/scripts.tar.gz tar.gz

18b2b22

Author: blmayer (bleemayer@gmail.com)

Date: Tue Nov 7 19:03:43 2023 -0300

Parent: 5396b89

Added markdown support

Diff

aux.sh

diff --git a/aux.sh b/aux.sh
index 7298c5d..f9aa180 100755
--- a/aux.sh
+++ b/aux.sh
@@ -63,11 +63,116 @@ pagesummary() {
 	</nav>
 	<p><i>$(cat description)</i></p>
 	</center>
-	<kbd>curl -O https://dovel.email/$1.tar</kbd>
-	<a style="float:right" href=/$1.tar filename=$1.tar>tar</a>
+	<kbd>curl -O https://dovel.email/$1.tar.gz</kbd>
+	<a style="float:right" href=/$1.tar.gz filename=$1.tar.gz>tar.gz</a>
 	EOF
 }
 
 escapehtml() {
 	sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'
 }
+
+type() {
+	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" = 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%\`}" ;;
+
+		# images
+                '!['*) img="1" && alt="${w#![}" ;;
+                # links
+                '['*) link="1" && alt="${w#[}" ;;
+		*) printf "$w" ;;
+		esac
+		printf " "
+	done
+}
+
+mdown() {
+	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#- })"
+			;;
+		[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
+
+	[ "$p" -gt "0" ] && printf "\n</p>\n"
+}

post-receive

diff --git a/post-receive b/post-receive
index 9514204..366ef0c 100755
--- a/post-receive
+++ b/post-receive
@@ -68,10 +68,15 @@ updateindex() {
 		$(pagesummary "$REPO")
 		<hr>
 		<p>Latest commit: $(git log -n 1 --format="(%h) by %an at %as: %s")</p>
-		<pre style="white-space:pre-line">$(cat "$OUT/raw/README"*)</pre>
-	</body>
-	</html>
+		<main>
+	EOF
+
+	[ -f "$OUT/raw/README.md" ] && mdown < "$OUT/raw/README.md" >> "$OUT/index.html"
+	[ -f "$OUT/raw/README" ] && cat <<- EOF >> "$OUT/index.html"
+	<pre>$(cat "$OUT/raw/README")</pre>
 	EOF
+	
+	printf "\t</main>\n</body>\n</html>\n" >> "$OUT/index.html"
 }
 
 createcommitpage() {