diff options
-rw-r--r-- | Makefile | 7 | ||||
-rw-r--r-- | http_server.go | 3 | ||||
-rw-r--r-- | man/.gitignore | 1 | ||||
-rw-r--r-- | man/mandoc.css (renamed from static/mandoc.css) | 0 | ||||
-rw-r--r-- | resources.go | 10 |
5 files changed, 17 insertions, 4 deletions
@@ -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 de78650..24be7e4 100644 --- a/http_server.go +++ b/http_server.go @@ -75,6 +75,9 @@ func (router *forgeHTTPRouter) ServeHTTP(writer http.ResponseWriter, request *ht } 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 9b61c8c..44e13d5 100644 --- a/man/.gitignore +++ b/man/.gitignore @@ -1 +1,2 @@ /*.html +/*.txt diff --git a/static/mandoc.css b/man/mandoc.css index a2c5ae4..a2c5ae4 100644 --- a/static/mandoc.css +++ b/man/mandoc.css diff --git a/resources.go b/resources.go index 6d32136..995fb2e 100644 --- a/resources.go +++ b/resources.go @@ -20,7 +20,7 @@ import ( //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 @@ var sourceHandler = http.StripPrefix( 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 @@ func loadTemplates() (err error) { } var staticHandler http.Handler +var manHandler http.Handler func init() { staticFS, err := fs.Sub(resourcesFS, "static") @@ -85,4 +86,9 @@ func init() { 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))) } |