From 16c91c1139d9f03f42c63298f2179822b8d50eb2 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 15 May 2023 18:47:06 +0000 Subject: properly implement subpath handling --- page/default.go | 56 ++++++++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 24 deletions(-) (limited to 'page/default.go') diff --git a/page/default.go b/page/default.go index 822f310..9598200 100644 --- a/page/default.go +++ b/page/default.go @@ -3,12 +3,16 @@ package page import ( "strings" "text/template" + "sanine.net/git/phlox/config" ) type page struct { Title string - Body string + Head string + FormMethod string + FormAction string + FormBody string } @@ -22,7 +26,12 @@ func buildPage(p page) (string, error) { {{ .Title }} - {{ .Body }} +

{{ .Head }}

+ {{ if .FormBody }} +
+ {{ .FormBody }} +
+ {{ end }} `) @@ -41,48 +50,47 @@ func buildPage(p page) (string, error) { } -func DefaultLogin() (string, error) { +func DefaultLogin(api config.Api) (string, error) { return buildPage(page{ Title: "Login", - Body: ` -
- - -
- - -
- -
+ Head : "Log In", + FormMethod: "POST", + FormAction: api.Prefix + api.Login, + FormBody: ` + + +
+ + +
+ `, }) } -func DefaultLoggedIn() (string, error) { +func DefaultLoggedIn(api config.Api) (string, error) { return buildPage(page{ Title: "Logged In", - Body: ` -

You are logged in.

-
- -
- `, + Head: "You are logged in.", + FormMethod: "GET", + FormAction: api.Prefix + api.Logout, + FormBody: ``, }) } -func DefaultError404() (string, error) { +func DefaultError404(api config.Api) (string, error) { return buildPage(page{ Title: "404 Not Found", - Body: "

Error 404: Page not found

", + Head: "Error 404: Page not found", }) } -func DefaultError500() (string, error) { +func DefaultError500(api config.Api) (string, error) { return buildPage(page{ Title: "500 Internal Server Error", - Body: "

Error 500: Internal server error

", + Head: "Error 500: Internal server error", }) } -- cgit v1.2.1