diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2025-07-08 23:26:05 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2025-07-08 23:26:05 +0100 |
| commit | cdb75d3fcbc9339b897f8c6ff4d69a577f017393 (patch) | |
| tree | 5e757cd236540c2cea9874c1bc09f19548db05d5 /web/command/html/create.go | |
| parent | b56101f1a11552067f594679a497ebd4cf7427d4 (diff) | |
Rewrite in Go
Diffstat (limited to 'web/command/html/create.go')
| -rw-r--r-- | web/command/html/create.go | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/web/command/html/create.go b/web/command/html/create.go new file mode 100644 index 0000000..a0b77d1 --- /dev/null +++ b/web/command/html/create.go @@ -0,0 +1,74 @@ +package html + +import ( + . "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."), + ), + ), + + Div( + Class("control-group group-right"), + navButton("Go back", "/"), + Input( + Type("submit"), + Value("Submit"), + ), + ), + ), + }), + ) +} |
