diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2024-01-06 19:28:33 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2024-01-06 19:28:33 -0500 |
| commit | 49b009d60433ce0fb419644fecc4ea8f3afac27f (patch) | |
| tree | c839edf38dbd0fc60fb5528cde32c5f70cd04dbd | |
| parent | bd5a00c61b355c857b5c99323592ca432dea5d0a (diff) | |
| download | paste-htmx_wip.tar.gz paste-htmx_wip.tar.xz | |
wiphtmx_wip
| -rw-r--r-- | htmx/base.html | 2 | ||||
| -rw-r--r-- | htmx/error.html | 6 | ||||
| -rw-r--r-- | htmx/index.html | 6 | ||||
| -rw-r--r-- | main.go | 15 |
4 files changed, 14 insertions, 15 deletions
diff --git a/htmx/base.html b/htmx/base.html index c02e2c6..68aae76 100644 --- a/htmx/base.html +++ b/htmx/base.html @@ -22,7 +22,7 @@ </ul> <ul> <li> - <a href="/login">Login</a> | + <a href="/login">Login</a> </li> </ul> {{end}} diff --git a/htmx/error.html b/htmx/error.html new file mode 100644 index 0000000..2e12bdf --- /dev/null +++ b/htmx/error.html @@ -0,0 +1,6 @@ +{{define "title"}}{{.}}{{end}} +{{define "main"}} + +<h1>{{.}}</h1> + +{{end}} diff --git a/htmx/index.html b/htmx/index.html new file mode 100644 index 0000000..68d9f93 --- /dev/null +++ b/htmx/index.html @@ -0,0 +1,6 @@ +{{define "title"}}Index{{end}} +{{define "main"}} + +todo + +{{end}} @@ -317,20 +317,7 @@ func LoadUsersFromEnviron() UsersMap { func HandleIndex(f fs.FS) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - - pth := filepath.Clean(r.URL.Path) - fh, err := f.Open(pth) - if err != nil { - fh, err = f.Open("index.html") - if err != nil { - logger.Println(err) - sendPlain(Response{w, http.StatusInternalServerError, - "Internal server error", nil}, nil) - return - } - } - - _, _ = io.Copy(w, fh) + logIfErr(renderHX(f, isHTMX(r), w, nil, "index.html")) }) } |
