diff --git a/pkg/nebula/assets/config.pkl b/pkg/nebula/assets/config.pkl index 3d0a285ad..d8f6de5f5 100644 --- a/pkg/nebula/assets/config.pkl +++ b/pkg/nebula/assets/config.pkl @@ -16,7 +16,7 @@ hero = new Hero { image = new Image { src = "https://cdn.sonr.id/img/hero-clipped.svg"; width = "560"; - height = "560; + height = "560"; }; }; diff --git a/pkg/nebula/models/formstate/FormState.pkl.go b/pkg/nebula/models/formstate/FormState.pkl.go new file mode 100644 index 000000000..68199f2c1 --- /dev/null +++ b/pkg/nebula/models/formstate/FormState.pkl.go @@ -0,0 +1,40 @@ +// Code generated from Pkl module `models`. DO NOT EDIT. +package formstate + +import ( + "encoding" + "fmt" +) + +type FormState string + +const ( + Initial FormState = "initial" + Error FormState = "error" + Success FormState = "success" + Warning FormState = "warning" +) + +// String returns the string representation of FormState +func (rcv FormState) String() string { + return string(rcv) +} + +var _ encoding.BinaryUnmarshaler = new(FormState) + +// UnmarshalBinary implements encoding.BinaryUnmarshaler for FormState. +func (rcv *FormState) UnmarshalBinary(data []byte) error { + switch str := string(data); str { + case "initial": + *rcv = Initial + case "error": + *rcv = Error + case "success": + *rcv = Success + case "warning": + *rcv = Warning + default: + return fmt.Errorf(`illegal: "%s" is not a valid FormState`, str) + } + return nil +} diff --git a/pkg/nebula/nebula.go b/pkg/nebula/nebula.go index 518eac2db..617eeb43f 100644 --- a/pkg/nebula/nebula.go +++ b/pkg/nebula/nebula.go @@ -15,7 +15,7 @@ import ( var embeddedFiles embed.FS //go:embed assets/config.pkl -var config string +var config []byte func getHTTPFS() (http.FileSystem, error) { fsys, err := fs.Sub(embeddedFiles, "assets") @@ -27,7 +27,7 @@ func getHTTPFS() (http.FileSystem, error) { // UseAssets is a middleware that serves static files from the embedded assets func UseAssets(e *echo.Echo) error { - err := models.LoadFromString(context.Background(), config) + err := models.LoadFromString(context.Background(), string(config)) if err != nil { return err } @@ -38,5 +38,10 @@ func UseAssets(e *echo.Echo) error { assets := http.FileServer(fsys) e.GET("/", echo.WrapHandler(assets)) e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets))) + e.GET("/_nebula/config", handleGetConfig) return nil } + +func handleGetConfig(c echo.Context) error { + return c.Blob(http.StatusOK, "application/octet-stream", config) +} diff --git a/pkg/nebula/pages/register.templ b/pkg/nebula/pages/register.templ index 83c3c2120..7dbf62e14 100644 --- a/pkg/nebula/pages/register.templ +++ b/pkg/nebula/pages/register.templ @@ -3,15 +3,7 @@ package pages import ( "github.com/labstack/echo/v4" "github.com/onsonr/sonr/pkg/nebula/components/blocks" -) - -type FormState string - -const ( - InitialForm FormState = "initial" - ErrorForm FormState = "error" - SuccessForm FormState = "success" - WarningForm FormState = "warning" + "github.com/onsonr/sonr/pkg/nebula/models/formstate" ) func Register(c echo.Context) error { @@ -24,7 +16,7 @@ templ registerView(c echo.Context) { @blocks.H2("Account Registration") @blocks.Spacer() @blocks.Breadcrumbs() - @basicInfoForm(InitialForm) + @basicInfoForm(formstate.Initial) @blocks.Spacer() @blocks.Button(blocks.GET("/", "#register-view")) { @blocks.Text("Cancel") @@ -33,7 +25,7 @@ templ registerView(c echo.Context) { } } -templ basicInfoForm(state FormState) { +templ basicInfoForm(state formstate.FormState) { switch (state) { default: