tested static and framed serving, it works

This commit is contained in:
2026-02-25 15:13:32 -07:00
parent 4652569aee
commit b370ba73d6
2 changed files with 9 additions and 2 deletions
+1 -1
View File
@@ -17,6 +17,7 @@ require (
github.com/labstack/gommon v0.4.2
github.com/sirupsen/logrus v1.9.3
github.com/tkuchiki/go-timezone v0.2.3
golang.org/x/net v0.50.0
golang.org/x/text v0.34.0
gopkg.in/yaml.v3 v3.0.1
)
@@ -31,7 +32,6 @@ require (
github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.48.0 // indirect
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // indirect
golang.org/x/net v0.50.0 // indirect
golang.org/x/sys v0.41.0 // indirect
golang.org/x/time v0.11.0 // indirect
)
+8 -1
View File
@@ -72,7 +72,7 @@ func breakUpHTML(r io.Reader) (string, string, error) {
if n.Type == html.ElementNode {
switch n.Data {
case "title":
body = extractPlainText(n)
title = extractPlainText(n)
case "body":
body = extractInnerHTML(n)
}
@@ -95,13 +95,20 @@ func breakUpHTML(r io.Reader) (string, string, error) {
*/
func AmStaticFramePage(staticFS fs.FS, prefix string) AmPageFunc {
return func(ctxt AmContext) (string, any) {
// Cut the prefix off the path.
fname := ctxt.URLPath()
if strings.HasPrefix(fname, prefix) {
fname = fname[len(prefix):]
} else {
return "error", "invalid path name"
}
// Extract the basic MIME type.
mtype := mimeTypeFromFilename(fname)
p := strings.Index(mtype, ";")
if p >= 0 {
mtype = mtype[:p]
}
// Decide from there how to render it.
ctxt.VarMap().Set("mimeType", mtype)
switch mtype {
case "text/html":