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/labstack/gommon v0.4.2
github.com/sirupsen/logrus v1.9.3 github.com/sirupsen/logrus v1.9.3
github.com/tkuchiki/go-timezone v0.2.3 github.com/tkuchiki/go-timezone v0.2.3
golang.org/x/net v0.50.0
golang.org/x/text v0.34.0 golang.org/x/text v0.34.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )
@@ -31,7 +32,6 @@ require (
github.com/valyala/fasttemplate v1.2.2 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect
golang.org/x/crypto v0.48.0 // indirect golang.org/x/crypto v0.48.0 // indirect
golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 // 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/sys v0.41.0 // indirect
golang.org/x/time v0.11.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 { if n.Type == html.ElementNode {
switch n.Data { switch n.Data {
case "title": case "title":
body = extractPlainText(n) title = extractPlainText(n)
case "body": case "body":
body = extractInnerHTML(n) body = extractInnerHTML(n)
} }
@@ -95,13 +95,20 @@ func breakUpHTML(r io.Reader) (string, string, error) {
*/ */
func AmStaticFramePage(staticFS fs.FS, prefix string) AmPageFunc { func AmStaticFramePage(staticFS fs.FS, prefix string) AmPageFunc {
return func(ctxt AmContext) (string, any) { return func(ctxt AmContext) (string, any) {
// Cut the prefix off the path.
fname := ctxt.URLPath() fname := ctxt.URLPath()
if strings.HasPrefix(fname, prefix) { if strings.HasPrefix(fname, prefix) {
fname = fname[len(prefix):] fname = fname[len(prefix):]
} else { } else {
return "error", "invalid path name" return "error", "invalid path name"
} }
// Extract the basic MIME type.
mtype := mimeTypeFromFilename(fname) 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) ctxt.VarMap().Set("mimeType", mtype)
switch mtype { switch mtype {
case "text/html": case "text/html":