From 66bd5d2f7fd84eec39d69f4a8f5c435fc978804f Mon Sep 17 00:00:00 2001 From: Leonardo Bishop Date: Thu, 19 Mar 2026 17:14:20 +0000 Subject: Add site passwords --- web/command/html/authenticate.go | 2 +- web/command/html/flags.go | 1 - web/command/html/password.go | 53 ++++++++++++++++++++++++++++++++++++++++ web/command/html/site.go | 1 + 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 web/command/html/password.go (limited to 'web/command/html') diff --git a/web/command/html/authenticate.go b/web/command/html/authenticate.go index 3d85325..fde99c1 100644 --- a/web/command/html/authenticate.go +++ b/web/command/html/authenticate.go @@ -6,7 +6,7 @@ import ( . "maragu.dev/gomponents/html" ) -func AuthenticatePage(err string) Node { +func AuthenticateScrapbookPage(err string) Node { return Page("Authenticate", H1(Text("Welcome to scrapbook")), diff --git a/web/command/html/flags.go b/web/command/html/flags.go index 61a1f50..cb19baf 100644 --- a/web/command/html/flags.go +++ b/web/command/html/flags.go @@ -88,7 +88,6 @@ func FlagsPage(success, err string, siteName string, flags config.SiteFlag) Node ID("password"), Name("password"), Type("checkbox"), - Disabled(), If(flags&config.FlagPassword != 0, Checked()), ), Label( diff --git a/web/command/html/password.go b/web/command/html/password.go new file mode 100644 index 0000000..3c53048 --- /dev/null +++ b/web/command/html/password.go @@ -0,0 +1,53 @@ +package html + +import ( + "fmt" + + . "github.com/LMBishop/scrapbook/web/skeleton" + . "maragu.dev/gomponents" + . "maragu.dev/gomponents/html" +) + +func PasswordPage(success, err, siteName, passwordValue string) Node { + return Page("Change password for "+siteName, + H1(Text("Change password 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"), + + FieldSet( + Legend(Text("Password")), + Input( + ID("password"), + Name("password"), + Value(passwordValue), + ), + Span( + Class("form-help"), + Text("The password visitors must enter to be able to view the site."), + ), + ), + + 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/site.go b/web/command/html/site.go index e9bfbac..bd91c12 100644 --- a/web/command/html/site.go +++ b/web/command/html/site.go @@ -27,6 +27,7 @@ func SitePage(mainConfig *config.MainConfig, site *site.Site) Node { NavButton("Change host", "host"), NavButton("Set flags", "flags"), + NavButton("Change password", "password"), NavButton("Delete site", "delete"), ), ), -- cgit v1.2.3-70-g09d2