aboutsummaryrefslogtreecommitdiffstats
path: root/web/command/html/create.go
blob: 47de92ff758c7438f13aef0d2feb719c55401dca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package html

import (
	. "github.com/LMBishop/scrapbook/web/skeleton"
	. "maragu.dev/gomponents"
	. "maragu.dev/gomponents/html"
)

type CreatePageForm struct {
	Name string
	Host string
}

func CreatePage(success, err string, formValues CreatePageForm) Node {
	return Page("Create site",
		H1(Text("Create site")),

		If(success != "", Group{
			AlertSuccess(success),
			Div(
				Class("control-group group-right"),
				NavButton("OK", "/"),
			),
		}),

		If(success == "", Group{
			If(err != "", AlertError(err)),

			Form(
				Action("/create"),
				Method("post"),

				FieldSet(
					Legend(Text("Site details")),
					Label(
						For("name"),
						Text("Name"),
					),
					Input(
						ID("name"),
						Name("name"),
						Value(formValues.Name),
					),
					Span(
						Class("form-help"),
						Text("The unique identifier for this site. This must be a valid directory name, and should be lower case with no spaces."),
					),

					Label(
						For("host"),
						Text("Host"),
					),
					Input(
						ID("host"),
						Name("host"),
						Value(formValues.Host),
					),
					Span(
						Class("form-help"),
						Text("The fully qualified domain name for which this site is to be served on. If this site is not to be served by scrapbook, leave blank."),
					),
				),

				Div(
					Class("control-group group-right"),
					NavButton("Go back", "/"),
					Input(
						Type("submit"),
						Value("Submit"),
					),
				),
			),
		}),
	)
}