commit 0211eb7300d384fa29bde6c31686981761f84389 from: Omar Polo date: Sun Jan 23 20:29:44 2022 UTC change script for gmi->html, update style; add makefile 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 -# -# 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("

", substr($0, 4), "

"); next } -!in_pre && /^##/ { output("

", substr($0, 3), "

"); next } -!in_pre && /^#/ { output("

", substr($0, 2), "

"); next } -!in_pre && /^>/ { output("
", substr($0, 2), "
"); next } -!in_pre && /^\* / { output("
  • ", substr($0, 2), "
  • "); 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(""); - } - print "
    ";
    -	next
    -}
    -
    -in_pre && /^```/	{ in_pre = 0; print "
    "; next } -!in_pre { output("

    ", $0, "

    "); next } -in_pre { print san($0); next } - -END { - if (in_list) - print "" - if (in_pre) - print "" -} - -function trim(s) { - sub("^[ \t]*", "", s); - return s; -} - -function san(s) { - gsub("&", "\\&", s) - gsub("<", "\\<", s) - gsub(">", "\\>", s) - return s; -} - -function output(ot, content, et) { - content = trim(content); - - if (!in_list && ot == "
  • ") { - in_list = 1; - print "
      "; - } - - if (in_list && ot != "
    • ") { - in_list = 0; - print "
    "; - } - - if (ot == "

    " && content == "") - return; - - printf("%s%s%s\n", ot, san(content), et); -} - -function output_link(link, content) { - if (in_list) { - in_list = 0; - print ""; - } - - if (content == "") - content = link; - - printf("

    %s

    \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 +# +# 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 ""; + } elsif (!$in_pre && m/^```/) { + if ($in_list) { + $in_list = 0; + say ""; + } + $in_pre = 1; + print "
    ";
    +	} elsif ($in_pre) {
    +		say san($_);
    +	} elsif ($in_list && m/^$/) {
    +		say "";
    +		$in_list = 0;
    +	} elsif (m/^\*\s+(.*)/) { # NB: at least one space
    +		if (!$in_list) {
    +			$in_list = "item";
    +			say "
      "; + } elsif ($in_list eq "link") { + $in_list = "item"; + say "
    "; + say "
      "; + } + output("li", $1); + } elsif (m/^=>\s*([^\s]*)\s*(.*)$/) { + if (!$in_list) { + $in_list = "link"; + say ""; + say "