aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-31 00:56:53 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-31 00:57:42 +0800
commitf16f2caba7e516ba5a7e78f14be35a9e066c3fea (patch)
tree6a8b9347c99f9db8bc4e412a72a4041471b5411b
parentAdd repo tab navigation to all pages (diff)
downloadforge-f16f2caba7e516ba5a7e78f14be35a9e066c3fea.tar.gz
forge-f16f2caba7e516ba5a7e78f14be35a9e066c3fea.tar.zst
forge-f16f2caba7e516ba5a7e78f14be35a9e066c3fea.zip
Mandoc more
-rw-r--r--Makefile7
-rw-r--r--http_server.go3
-rw-r--r--man/.gitignore1
-rw-r--r--man/mandoc.css (renamed from static/mandoc.css)0
-rw-r--r--resources.go10
5 files changed, 17 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index e4a0743..0171a2c 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 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)))
}