From f16f2caba7e516ba5a7e78f14be35a9e066c3fea Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Mon, 31 Mar 2025 00:56:53 +0800 Subject: [PATCH] Mandoc more --- Makefile | 7 +++++-- http_server.go | 3 +++ man/.gitignore | 1 + resources.go | 10 ++++++++-- static/mandoc.css => man/mandoc.css | 0 diff --git a/Makefile b/Makefile index e4a0743c06faa00707fa3b903a96f3a1bff4cf6d..0171a2c534699f81be3c37a69730b75419b7b713 100644 --- a/Makefile +++ b/Makefile @@ -10,10 +10,13 @@ forge: version.go hookc/*.c hookc/hookc man # TODO go mod vendor go build . -man: $(MAN_PAGES:%=man/%.html) +man: $(MAN_PAGES:%=man/%.html) $(MAN_PAGES:%=man/%.txt) man/%.html: man/% - mandoc -Thtml -O style=static/mandoc.css $< > $@ + mandoc -Thtml -O style=./mandoc.css $< > $@ + +man/%.txt: man/% + mandoc $< | col -b > $@ hookc/hookc: diff --git a/http_server.go b/http_server.go index de78650824ea93745d6a4cb17350f13e6a2f8167..24be7e41fe9b75bfdb2a7677aea7d2bbde50a903 100644 --- a/http_server.go +++ b/http_server.go @@ -75,6 +75,9 @@ return } switch segments[1] { + case "man": + manHandler.ServeHTTP(writer, request) + return case "static": staticHandler.ServeHTTP(writer, request) return diff --git a/man/.gitignore b/man/.gitignore index 9b61c8c0423824bbec12a1b3862a4a7a8a0d79a1..44e13d59620285acb0e2ca2c03a4707c590325e1 100644 --- a/man/.gitignore +++ b/man/.gitignore @@ -1 +1,2 @@ /*.html +/*.txt diff --git a/resources.go b/resources.go index 6d32136831da37796c480617210fbea5f4610850..995fb2e1072c18f619a1d7ccc40ce2b2eb54feb4 100644 --- a/resources.go +++ b/resources.go @@ -20,7 +20,7 @@ //go:embed LICENSE README.md //go:embed *.go go.mod go.sum //go:embed *.scfg //go:embed Makefile -//go:embed static/* templates/* scripts/* sql/* +//go:embed static/* templates/* scripts/* sql/* man/* //go:embed hookc/*.c //go:embed vendor/* var sourceFS embed.FS @@ -30,7 +30,7 @@ "/:/source/", http.FileServer(http.FS(sourceFS)), ) -//go:embed templates/* static/* hookc/hookc +//go:embed templates/* static/* hookc/hookc man/*.html man/*.txt man/*.css var resourcesFS embed.FS var templates *template.Template @@ -78,6 +78,7 @@ return err } var staticHandler http.Handler +var manHandler http.Handler func init() { staticFS, err := fs.Sub(resourcesFS, "static") @@ -85,4 +86,9 @@ if err != nil { panic(err) } staticHandler = http.StripPrefix("/:/static/", http.FileServer(http.FS(staticFS))) + manFS, err := fs.Sub(resourcesFS, "man") + if err != nil { + panic(err) + } + manHandler = http.StripPrefix("/:/man/", http.FileServer(http.FS(manFS))) } diff --git a/static/mandoc.css b/man/mandoc.css rename from static/mandoc.css rename to man/mandoc.css -- 2.48.1