aboutsummaryrefslogtreecommitdiffstats
path: root/web/command/html/flags.go
blob: 61a1f505efec81c173062c43356e97ff8ba9d986 (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package html

import (
	"fmt"

	"github.com/LMBishop/scrapbook/pkg/config"
	. "github.com/LMBishop/scrapbook/web/skeleton"
	. "maragu.dev/gomponents"
	. "maragu.dev/gomponents/html"
)

func FlagsPage(success, err string, siteName string, flags config.SiteFlag) Node {
	return Page("Set flags for "+siteName,
		H1(Text("Set flags for "+siteName)),

		If(success != "", Group{
			AlertSuccess(success),
			Div(
				Class("control-group group-right"),
				NavButton("OK", fmt.Sprintf("/site/%s/", siteName)),
			),
		}),

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

			Form(
				Method("post"),

				P(Text("These flags affect the behaviour of scrapbook's internal web server. They will have no effect if you are serving the site using a different web server.")),

				FieldSet(
					Legend(Text("Flags")),
					Span(
						Input(
							ID("disable"),
							Name("disable"),
							Type("checkbox"),
							If(flags&config.FlagDisable != 0, Checked()),
						),
						Label(
							For("disable"),
							Text("Disable"),
						),
					),
					Span(
						Class("form-help"),
						Text("Disallow access to this site."),
					),

					Span(
						Input(
							ID("tls"),
							Name("tls"),
							Type("checkbox"),
							Disabled(),
							If(flags&config.FlagTLS != 0, Checked()),
						),
						Label(
							For("tls"),
							Text("TLS"),
						),
					),
					Span(
						Class("form-help"),
						Text("Serve this site on the HTTPS socket."),
					),

					Span(
						Input(
							ID("index"),
							Name("index"),
							Type("checkbox"),
							If(flags&config.FlagIndex != 0, Checked()),
						),
						Label(
							For("index"),
							Text("Automatic index"),
						),
					),
					Span(
						Class("form-help"),
						Text("Generate index.html files on the fly if they do not exist."),
					),

					Span(
						Input(
							ID("password"),
							Name("password"),
							Type("checkbox"),
							Disabled(),
							If(flags&config.FlagPassword != 0, Checked()),
						),
						Label(
							For("password"),
							Text("Password protect"),
						),
					),
					Span(
						Class("form-help"),
						Text("Require visitors to enter a password to view the site."),
					),

					Span(
						Input(
							ID("readonly"),
							Name("readonly"),
							Type("checkbox"),
							If(flags&config.FlagReadOnly != 0, Checked()),
						),
						Label(
							For("readonly"),
							Text("Read only"),
						),
					),
					Span(
						Class("form-help"),
						Text("Disallow new site revisions or modification."),
					),
				),

				Div(
					Class("control-group group-right"),
					NavButton("Go back", fmt.Sprintf("/site/%s/", siteName)),
					Input(
						Type("submit"),
						Value("Submit"),
					),
				),
			),
		}),
	)
}