summaryrefslogtreecommitdiff
path: root/page/default.go
diff options
context:
space:
mode:
Diffstat (limited to 'page/default.go')
-rw-r--r--page/default.go56
1 files changed, 32 insertions, 24 deletions
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>{{ .Title }}</title>
</head>
<body>
- {{ .Body }}
+ <h1>{{ .Head }}</h1>
+ {{ if .FormBody }}
+ <form method="{{ .FormMethod }}" action="{{ .FormAction }}">
+ {{ .FormBody }}
+ </form>
+ {{ end }}
</body>
</html>
`)
@@ -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: `
- <form method="post">
- <label for="username">Username</label>
- <input type="text" id="username" name="username">
- <br>
- <label for="password">Password</label>
- <input type="password" id="password" name="password">
- <br>
- <input type="submit" value="Submit">
- </form>
+ Head : "Log In",
+ FormMethod: "POST",
+ FormAction: api.Prefix + api.Login,
+ FormBody: `
+ <label for="username">Username</label>
+ <input type="text" id="username" name="username">
+ <br>
+ <label for="password">Password</label>
+ <input type="password" id="password" name="password">
+ <br>
+ <input type="submit" value="Submit">
`,
})
}
-func DefaultLoggedIn() (string, error) {
+func DefaultLoggedIn(api config.Api) (string, error) {
return buildPage(page{
Title: "Logged In",
- Body: `
- <h1>You are logged in.</h1>
- <form method="get" action="/phlox/logout">
- <input type="submit" value="Log Out">
- </form>
- `,
+ Head: "You are logged in.",
+ FormMethod: "GET",
+ FormAction: api.Prefix + api.Logout,
+ FormBody: `<input type="submit" value="Log Out">`,
})
}
-func DefaultError404() (string, error) {
+func DefaultError404(api config.Api) (string, error) {
return buildPage(page{
Title: "404 Not Found",
- Body: "<h1>Error 404: Page not found</h1>",
+ 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: "<h1>Error 500: Internal server error</h1>",
+ Head: "Error 500: Internal server error",
})
}