diff options
| author | Leonardo Bishop <me@leonardobishop.net> | 2025-07-13 21:23:34 +0100 |
|---|---|---|
| committer | Leonardo Bishop <me@leonardobishop.net> | 2025-07-13 21:23:34 +0100 |
| commit | 684787bcb72aece2aa914597a3bc8788432e66f7 (patch) | |
| tree | a55fdcfc6f7f4d2f7ae86ba0a94e8d366f5c5cda /web/command/html | |
| parent | cdb75d3fcbc9339b897f8c6ff4d69a577f017393 (diff) | |
Add flags
Diffstat (limited to 'web/command/html')
| -rw-r--r-- | web/command/html/error.go | 13 | ||||
| -rw-r--r-- | web/command/html/flags.go | 130 | ||||
| -rw-r--r-- | web/command/html/home.go | 8 | ||||
| -rw-r--r-- | web/command/html/site.go | 9 | ||||
| -rw-r--r-- | web/command/html/style.css | 14 |
5 files changed, 168 insertions, 6 deletions
diff --git a/web/command/html/error.go b/web/command/html/error.go new file mode 100644 index 0000000..b39cc19 --- /dev/null +++ b/web/command/html/error.go @@ -0,0 +1,13 @@ +package html + +import ( + . "maragu.dev/gomponents" +) + +func ErrorPage(err string) Node { + return page("Error", + alertError(err), + + navButton("Home", "/"), + ) +} diff --git a/web/command/html/flags.go b/web/command/html/flags.go new file mode 100644 index 0000000..a7fb99f --- /dev/null +++ b/web/command/html/flags.go @@ -0,0 +1,130 @@ +package html + +import ( + "fmt" + + "github.com/LMBishop/scrapbook/pkg/config" + . "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"), + 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"), + 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"), + ), + ), + ), + }), + ) +} diff --git a/web/command/html/home.go b/web/command/html/home.go index f0e783d..490b2b8 100644 --- a/web/command/html/home.go +++ b/web/command/html/home.go @@ -25,6 +25,10 @@ func HomePage(siteIndex *index.SiteIndex) Node { Text("Status"), ), Span( + Class("header flags"), + Text("Flags"), + ), + Span( Class("header actions"), Text("Actions"), ), @@ -41,6 +45,10 @@ func HomePage(siteIndex *index.SiteIndex) Node { Text(site.EvaluateSiteStatus()), ), Span( + Class("flags"), + Text(site.ConvertFlagsToString()), + ), + Span( Class("actions"), navButton("Details", fmt.Sprintf("/site/%s/", site.Name)), ), diff --git a/web/command/html/site.go b/web/command/html/site.go index b4239b1..7616e6b 100644 --- a/web/command/html/site.go +++ b/web/command/html/site.go @@ -25,7 +25,7 @@ func SitePage(mainConfig *config.MainConfig, site *site.Site) Node { Class("control-group"), navButton("Upload new version", "upload"), - navButton("Disable site", "disable"), + navButton("Set flags", "flags"), navButton("Delete site", "delete"), ), ), @@ -65,8 +65,11 @@ func SitePage(mainConfig *config.MainConfig, site *site.Site) Node { ), }), - H2(Text("API endpoints")), - P(Code(Text(fmt.Sprintf("http://%s/api/site/%s/upload", mainConfig.Command.Host, site.Name)))), + H2(Text("Information")), + + P(Text("API endpoint for new versions: "), Code(Text(fmt.Sprintf("POST https://%s/api/site/%s/upload", mainConfig.Command.Host, site.Name)))), + + P(Text("Data directory on system: "), Code(Text(site.Path))), navButton("Go back", "/"), ) diff --git a/web/command/html/style.css b/web/command/html/style.css index 7e40ad4..fbefaa1 100644 --- a/web/command/html/style.css +++ b/web/command/html/style.css @@ -49,10 +49,14 @@ legend { font-style: italic; } -label { +label:not(input[type=checkbox]+label) { font-weight: bold; } +input[type=checkbox] { + margin: 0 0.25rem 0 0; +} + footer { margin-top: 2rem; color: gray; @@ -61,7 +65,7 @@ footer { button, input[type=submit] { background: none!important; - font-family: arial, sans-serif; + font-family: sans-serif; font-size: medium; cursor: pointer; } @@ -98,7 +102,7 @@ a:hover, button:hover, input[type=submit]:hover, button:active, a:active, input[ .sites-table { width: 100%; display: grid; - grid-template-columns: 50% 1fr 1fr; + grid-template-columns: 40% 1fr 1fr 1fr; align-items: center; gap: 1rem; margin-bottom: 1rem; @@ -113,6 +117,10 @@ a:hover, button:hover, input[type=submit]:hover, button:active, a:active, input[ flex-direction: column; } +.sites-table > .flags:not(.header) { + font-family: monospace; +} + .sites-table > .name > span:nth-child(2) { font-size: smaller; } |
