Commit Diff


commit - 4c8aba72674fb58e33258d14b008b3bd333c8a30
commit + 0211eb7300d384fa29bde6c31686981761f84389
blob - /dev/null
blob + 966812fe783e97e2aa1a1679d3c83bcfd68506c0 (mode 644)
--- /dev/null
+++ site/Makefile
@@ -0,0 +1,51 @@
+MANPAGES =	../kamictl/kamictl.8	\
+		../kamid/9p.7		\
+		../kamid/kamid.8	\
+		../kamid/kamid.conf.5	\
+		../kamiftp/kamiftp.1
+
+PAGES =		index.gmi install.gmi tutorial.gmi
+
+TITLE_index.gmi =	home
+TITLE_install.gmi =	install-guide
+TITLE_tutorial.gmi =	tutorial
+
+SUBST_GEM =	./subst MANEXT=txt  EXT=gmi
+SUBST_WWW =	./subst MANEXT=html EXT=html
+
+.PHONY: all dirs manpages server-www serve-gemini upload clean
+
+all: dirs manpages pages
+	cp style.css www/
+
+dirs:
+	mkdir -p gemini
+	mkdir -p www
+
+manpages:
+.for m in ${MANPAGES}
+	./mdoc2html.sh $m www/${m:T}.html
+	man -O width=65 -Tutf8 -l $m | col -b > gemini/${m:T}.txt
+.endfor
+
+pages:
+.for p in ${PAGES}
+	${SUBST_GEM} $p > gemini/$p
+
+	${SUBST_WWW} TITLE=${TITLE_${p}:Q} header.html > www/${p:.gmi=.html}
+	${SUBST_WWW} $p | ./gem2html >> www/${p:.gmi=.html}
+	cat footer.html >> www/${p:.gmi=.html}
+.endfor
+
+serve-www:
+	python3 -m http.server --directory www 8888
+
+serve-gemini:
+	gmid -p 1966 ./gemini
+
+upload:
+	rsync --delete -a www/ op:sites/kamid.omarpolo.com
+	rsync --delete -a gemini/ op:gemini/kamid.omarpolo.com
+
+clean:
+	rm -rf gemini www
blob - b6be1ebc5963f08d2bd57afd1ae01594bf9857ab (mode 755)
blob + /dev/null
--- site/gem2html.awk
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/awk -f
-#
-# Copyright (c) 2022 Omar Polo <op@omarpolo.com>
-#
-# Permission to use, copy, modify, and distribute this software for any
-# purpose with or without fee is hereby granted, provided that the above
-# copyright notice and this permission notice appear in all copies.
-#
-# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-BEGIN {
-	in_pre = 0;
-	in_list = 0;
-}
-
-!in_pre && /^###/	{ output("<h3>", substr($0, 4), "</h3>"); next }
-!in_pre && /^##/	{ output("<h2>", substr($0, 3), "</h2>"); next }
-!in_pre && /^#/		{ output("<h1>", substr($0, 2), "</h1>"); next }
-!in_pre && /^>/		{ output("<blockquote>", substr($0, 2), "</blockquote>"); next }
-!in_pre && /^\* /	{ output("<li>", substr($0, 2), "</li>"); next }
-
-!in_pre && /^=>/ {
-	$0 = substr($0, 3);
-	link = $1;
-	$1 = "";
-	output_link(link, $0);
-	next;
-}
-
-!in_pre && /^```/ {
-	in_pre = 1;
-	if (in_list) {
-		in_list = 0;
-		print("</ul>");
-	}
-	print "<pre>";
-	next
-}
-
-in_pre && /^```/	{ in_pre = 0; print "</pre>"; next }
-!in_pre			{ output("<p>", $0, "</p>"); next }
-in_pre			{ print san($0); next }
-
-END {
-	if (in_list)
-		print "</ul>"
-	if (in_pre)
-		print "</pre>"
-}
-
-function trim(s) {
-	sub("^[ \t]*", "", s);
-	return s;
-}
-
-function san(s) {
-	gsub("&", "\\&amp;", s)
-	gsub("<", "\\&lt;", s)
-	gsub(">", "\\&gt;", s)
-	return s;
-}
-
-function output(ot, content, et) {
-	content = trim(content);
-
-	if (!in_list && ot == "<li>") {
-		in_list = 1;
-		print "<ul>";
-	}
-
-	if (in_list && ot != "<li>") {
-		in_list = 0;
-		print "</ul>";
-	}
-
-	if (ot == "<p>" && content == "")
-		return;
-
-	printf("%s%s%s\n", ot, san(content), et);
-}
-
-function output_link(link, content) {
-	if (in_list) {
-		in_list = 0;
-		print "</ul>";
-	}
-
-	if (content == "")
-		content = link;
-
-	printf("<p><a href=\"%s\">%s</a></p>\n", link, trim(san(content)));
-}
blob - /dev/null
blob + dcfe386471716f0505a0f91cab719e059411c680 (mode 755)
--- /dev/null
+++ site/gem2html
@@ -0,0 +1,102 @@
+#!/usr/bin/env perl
+#
+# Copyright (c) 2022 Omar Polo <op@openbsd.org>
+#
+# Permission to use, copy, modify, and distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+use v5.10;
+use strict;
+use warnings;
+
+my $in_pre = 0;
+my $in_list = 0;
+
+while (<>) {
+	chomp;
+	if ($in_pre && m/^```/) {
+		$in_pre = 0;
+		say "</pre>";
+	} elsif (!$in_pre && m/^```/) {
+		if ($in_list) {
+			$in_list = 0;
+			say "</ul>";
+		}
+		$in_pre = 1;
+		print "<pre>";
+	} elsif ($in_pre) {
+		say san($_);
+	} elsif ($in_list && m/^$/) {
+		say "</ul>";
+		$in_list = 0;
+	} elsif (m/^\*\s+(.*)/) { # NB: at least one space
+		if (!$in_list) {
+			$in_list = "item";
+			say "<ul>";
+		} elsif ($in_list eq "link") {
+			$in_list = "item";
+			say "</ul>";
+			say "<ul>";
+		}
+		output("li", $1);
+	} elsif (m/^=>\s*([^\s]*)\s*(.*)$/) {
+		if (!$in_list) {
+			$in_list = "link";
+			say "<ul class='link-list'>";
+		} elsif ($in_list eq "item") {
+			$in_list = "link";
+			say "</ul>";
+			say "<ul class='link-list'>";
+		}
+		my $href = $1;
+		$_ = $2 || $1;
+		say "<li><a href='$href'>". san() ."</a></li>";
+	} elsif (m/^###\s*(.*)$/) {
+		output("h3", $1);
+	} elsif (m/^##\s*(.*)$/) {
+		output("h2", $1);
+	} elsif (m/^#\s*(.*)$/) {
+		output("h1", $1);
+	} elsif (m/^>\s*(.*)$/) {
+		output("blockquote", $1);
+	} else {
+		output("p", $_);
+	}
+}
+
+sub san {
+	s/&/\&amp;/g;
+	s/</\\&lt;/g;
+	s/>/\\&gt;/g;
+	return $_;
+}
+
+sub output {
+	my ($tn, $content) = @_;
+
+	if (!$in_list && $tn eq "li") {
+		$in_list = 1;
+		say "<ul>";
+	}
+
+	if ($in_list && $tn ne "li") {
+		$in_list = 0;
+		say "</ul>";
+	}
+
+	if ($tn eq "p" && $content eq "") {
+		return;
+	}
+
+	$_ = $content;
+	say "<$tn>". san() ."</$tn>";
+}
blob - 1d563209b1bb1206fcab8623fae816f860ddacda
blob + c6fb24a0aa18eb13d4dae71bafb8ce0374f39fa0
--- site/style.css
+++ site/style.css
@@ -74,6 +74,10 @@ code, kbd {
   color: #9d109d;
 }
 
+ul.link-list {
+  list-style: disclosure-closed;
+}
+
 img {
   display: block;
   margin: 0 auto;