commit ac42bb6c7f9f30028fbc63f623bf4bba99b725ad from: Omar Polo date: Fri Jan 28 08:34:22 2022 UTC change how the site is built copy the kamid/site "framework" here too; in other words: don't maintain two copies of every page! \o/ commit - 964686ce0b77d06b8c954366db56e9a8d098b1d5 commit + ac42bb6c7f9f30028fbc63f623bf4bba99b725ad blob - f1521270a295bd429b4e962e82efeea04b0b269d blob + 7431a6328c8f7d85d30e234b2d9bf0a5d8b1b36d --- site/Makefile +++ site/Makefile @@ -1,19 +1,70 @@ -.PHONY: all serve-www serve-gemini upload +MANPAGES = ../gmid.1 \ + ../gg.1 -all: gmid.1.html gmid.1.txt +PAGES = index.gmi \ + changelog.gmi \ + contrib.gmi \ + quickstart.gmi -gmid.1.html: ../gmid.1 - ./mdoc2html.sh $? $@ +TITLE_index.gmi = home +TITLE_changelog.gmi = changelog +TITLE_contrib.gmi = contrib +TITLE_quickstart.gmi = quickstart -gmid.1.txt: ../gmid.1 - MANWIDTH=72 man -Tutf8 -l $? | col -b > $@ +REPOLOGY_BANNER = https://repology.org/badge/vertical-allrepos/gmid.svg +REPOLOGY_URL = https://repology.org/project/gmid/versions +SUBST = ./subst GITHUB=https://github.com/omar-polo/gmid \ + VERS=1.7.5 \ + CURV=1.7 \ + NEXTV=1.8 + +SUBST_GEM = ${SUBST} MANEXT=txt EXT=gmi REPOLOGY=${REPOLOGY_URL} +SUBST_WWW = ${SUBST} MANEXT=html EXT=html REPOLOGY=${REPOLOGY_BANNER} + +.PHONY: all dirs manpages serve-www serve-gemini upload clean titles + +all: dirs manpages pages + cp style.css www/ + cp vim-screenshot.png www/ + cp vim-screenshot.png gemini/ + +dirs: + mkdir -p gemini 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} + ${MAKE} titles-gem | ./menu.pl $p gemini > gemini/$p + ${SUBST_GEM} $p >> gemini/$p + + ${SUBST_WWW} TITLE=${TITLE_${p}:Q} header.html > www/${p:.gmi=.html} + ${MAKE} titles-www | ./menu.pl "${p:.gmi=.html}" 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 8888 + python3 -m http.server --directory www 8888 serve-gemini: - ../gmid -p 1966 . + gmid -p 1966 ./gemini upload: - rsync --delete -a . op:sites/gmid.omarpolo.com - rsync --delete -a . op:gemini/gmid.omarpolo.com + rsync --delete -a www/ op:sites/gmid.omarpolo.com + rsync --delete -a gemini/ op:gemini/gmid.omarpolo.com + +titles-gem: +.for p in ${PAGES} + @printf "%s %s\n" "${p}" ${TITLE_${p}:Q} +.endfor + +titles-www: +.for p in ${PAGES} + @printf "%s %s\n" "${p:.gmi=.html}" ${TITLE_${p}:Q} +.endfor blob - b505e2ab00a63ed0957a8915891166cdeccd02b2 (mode 644) blob + /dev/null --- site/contrib.html +++ /dev/null @@ -1,232 +0,0 @@ - - - - gmid | contrib - - - - - -
- -
-

contrib

-

- This directory is for additional contributed files which may be - useful. -

-

Contents:

- -
-

Dockerfile

-

- contrib/Dockerfile - is a simple Dockerfile. The resulting image is a classic alpine - linux image with a statically linked gmid installed as - /bin/gmid. -

-

To build the image:

-
# docker build -f contrib/Dockerfile -t gmid .
-

and then run it with something along the lines of:

-
# docker run --rm -it -p 1965:1965      \
-        -v gmid.conf:/etc/gmid.conf:ro  \
-        -v path/to/keys:/tls:ro         \
-        -v /var/gemini:/var/gemini:ro   \
-        gmid -c /etc/gmid.conf
-

gencert

-

- contrib/gencert - is a simple script to generate self-signed certificates. -

-

OpenBSD rc file

-

- contrib/gmid - is a sample service file for OpenBSD rc(8). - To install it: -

-
# cp contrib/gmid /etc/rc.d
-

- then the usual - rcctl [start|stop|enable|restart] gmid - are available. -

-

Systemd unit file

-

- contrib/gmid.service - is a simple service file for - systemd. To install it: -

-
# cp contrib/gmid.service /lib/systemd/system/gmid.service
-

- then the usual - systemctl [status|start|enable|stop] gmid - commands can be used to manage the server. -

-

Some things to keep in mind:

- -

renew certificates automatically

-

- NB: this script requires features that are - currently available only in the master branch. -

-

- contrib/renew-certs - is a script meant to be run in a crontab that watch for - certificate expiration. It can optionally renew the certs and - restart gmid too. -

-

Read the documentation with: perldoc renew-certs.

-

Vim syntax files

-

- contrib/vim - contains a syntax highlighting for vim. To install it, just - copy the files to ~/.vim - or /usr/share/vim/vimfiles, e.g. -

-
$ mkdir -p ~/.vim
-$ cp -R contrib/vim/* ~/.vim/
-

To enable Syntastic checker, add to your vimrc:

-
let g:syntastic_gmid_checkers = ['gmid']
-

The end result is something like this:

- - Screenshot of vim editing gmid.conf with syntax highlighting - - - blob - /dev/null blob + 2ab5c0d1fc7b0e6c12fb00bf177037f64450298c (mode 644) --- /dev/null +++ site/footer.html @@ -0,0 +1,2 @@ + + blob - /dev/null blob + b9f03d2884972722553225322c70853137453486 (mode 755) --- /dev/null +++ site/gem2html @@ -0,0 +1,114 @@ +#!/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*(.*)$/) { + my $href = $1; + my $alt = $2; + + # special case: images + if ($1 =~ /\.(png|jpg|svg)$/) { + if ($in_list) { + say "
"; + $in_list = 0; + } + say "$alt"; + next; + } + + if (!$in_list) { + $in_list = "link"; + say ""; + say "