From 739bb7b18002975e61ca867f55e2a96fee3f6c5d Mon Sep 17 00:00:00 2001 From: DutchEllie Date: Wed, 16 Mar 2022 12:49:52 +0100 Subject: [PATCH] Fixed some layout --- src/bannerpanel.go | 13 ----- src/guestbookform.go | 105 ------------------------------------ src/guestbookpanel.go | 100 ---------------------------------- src/updater.go | 38 ------------- web/blocks/pages/intro.html | 4 +- 5 files changed, 2 insertions(+), 258 deletions(-) delete mode 100644 src/bannerpanel.go delete mode 100644 src/guestbookform.go delete mode 100644 src/guestbookpanel.go delete mode 100644 src/updater.go diff --git a/src/bannerpanel.go b/src/bannerpanel.go deleted file mode 100644 index 8ed8fc1..0000000 --- a/src/bannerpanel.go +++ /dev/null @@ -1,13 +0,0 @@ -package main - -import "github.com/maxence-charriere/go-app/v9/pkg/app" - -type bannerPanel struct { - app.Compo -} - -func (b *bannerPanel) Render() app.UI { - return app.Div(). - Class("leftbar"). - Body() -} diff --git a/src/guestbookform.go b/src/guestbookform.go deleted file mode 100644 index ab8263a..0000000 --- a/src/guestbookform.go +++ /dev/null @@ -1,105 +0,0 @@ -package main - -import ( - "fmt" - - "github.com/maxence-charriere/go-app/v9/pkg/app" -) - -type guestbookForm struct { - app.Compo - - name string - message string - - gbModalOpen bool - OnSubmit func( - ctx app.Context, - name string, - message string, - ) // Handler to implement which calls the api -} - -func (g *guestbookForm) Render() app.UI { - return app.Div().Body( - app.Form().Body( - app.Input(). - Type("text"). - Name("name"). - Placeholder("Name"). - Required(true). - OnChange(g.ValueTo(&g.name)). - Value(g.name), - app.Input(). - Type("text"). - Name("message"). - Placeholder("Message"). - Required(true). - OnChange(g.ValueTo(&g.message)). - Value(g.message), - app.Input(). - Type("submit"). - Name("submit"), - ).ID("form"). - OnSubmit(func(ctx app.Context, e app.Event) { - // This was to prevent the page from reloading - e.PreventDefault() - if g.name == "" || g.message == "" { - fmt.Printf("Error: one or more field(s) are empty. For now unhandled\n") - return - } - if len(g.name) > 40 || len(g.message) > 360 { - fmt.Printf("Error: Your message is too long fucker\n") - g.gbModalOpen = true - return - } - g.OnSubmit(ctx, g.name, g.message) - g.clear() - }), - app.If( - g.gbModalOpen, - &guestbookAlertModal{ - OnClose: func() { - g.gbModalOpen = false - g.Update() - }, - }, - ), - ) -} - -func (g *guestbookForm) clear() { - g.name = "" - g.message = "" -} - -/* -type guestbookAlertModal struct { - app.Compo - - PreviousAttempts int - OnClose func() // For when we close the modal -} - -func (g *guestbookAlertModal) Render() app.UI { - return app.Div(). - Class("gb-modal"). - ID("gbModal"). - OnClick(func(ctx app.Context, e app.Event) { - g.OnClose() - }). - Body( - app.Div(). - Class("gb-modal-content"). - Body( - app.Span().Class("close").Text("X"). - OnClick(func(ctx app.Context, e app.Event) { - //modal := app.Window().GetElementByID("gbModal") - //modal.Set("style", "none") - g.OnClose() - }), - app.P().Text("Your name must be <= 40 and your message must be <= 360 characters"), - ), - ) -} -*/ diff --git a/src/guestbookpanel.go b/src/guestbookpanel.go deleted file mode 100644 index 6cbd7af..0000000 --- a/src/guestbookpanel.go +++ /dev/null @@ -1,100 +0,0 @@ -package main - -import ( - "encoding/json" - "io" - "net/http" - - "dutchellie.nl/DutchEllie/proper-website-2/entity" - "github.com/maxence-charriere/go-app/v9/pkg/app" -) - -/* -What is this supposed to do: -- It should call on the API to give it a certain number of comments, in the range x to y (this has to be implemented in the api) -- When it has called that, it should display those -- Dynamic links are there to navigate the user along the pages -- Comments are shown dynamically -- This panel can be shown or hidden (maybe) - -AND VERY IMPORTANT! -- If a user submits a new comment, automatically put it on the page, no reloading - -*/ -type guestbookPanel struct { - app.Compo - - comments []entity.Comment -} - -func (g *guestbookPanel) OnMount(ctx app.Context) { - g.LoadComments(ctx) -} - -func (g *guestbookPanel) OnNav(ctx app.Context) { - g.LoadComments(ctx) -} - -func (g *guestbookPanel) OnUpdate(ctx app.Context) { - g.LoadComments(ctx) -} - -func (g *guestbookPanel) Render() app.UI { - return app.Div().Body( - app.Range(g.comments).Slice(func(i int) app.UI { - return &guestbookComment{ - Comment: g.comments[i], - } - }, - ), - ).OnSubmit(func(ctx app.Context, e app.Event) { - g.LoadComments(ctx) - }) -} - -func (g *guestbookPanel) LoadComments(ctx app.Context) { - // TODO: maybe you can put this in a localbrowser storage? - url := ApiURL - ctx.Async(func() { - res, err := http.Get(url) - if err != nil { - app.Log(err) - return - } - defer res.Body.Close() - jsondata, err := io.ReadAll(res.Body) - if err != nil { - app.Log(err) - return - } - - ctx.Dispatch(func(ctx app.Context) { - err = json.Unmarshal(jsondata, &g.comments) - if err != nil { - app.Log(err) - return - } - }) - }) -} - -/*type guestbookComment struct { - app.Compo - - Comment entity.Comment - time string -} - -func (c *guestbookComment) Render() app.UI { - c.time = c.Comment.PostDate.Format(time.RFC1123) - return app.Div().Body( - app.Div().Class().Body( - app.P().Text(c.Comment.Name).Class("name"), - app.P().Text(c.time).Class("date"), - ).Class("comment-header"), - app.Div().Class("comment-message").Body( - app.P().Text(c.Comment.Message), - ), - ).Class("comment") -} -*/ diff --git a/src/updater.go b/src/updater.go deleted file mode 100644 index 445767c..0000000 --- a/src/updater.go +++ /dev/null @@ -1,38 +0,0 @@ -package main - -import "github.com/maxence-charriere/go-app/v9/pkg/app" - -type updater struct { - app.Compo - - updateAvailable bool -} - -func (u *updater) OnAppUpdate(ctx app.Context) { - u.updateAvailable = ctx.AppUpdateAvailable() -} - -func (u *updater) Render() app.UI { - return app.Div().Body( - app.If(u.updateAvailable, - app.Div(). - Class("update-box"). - Body( - app.Img(). - Class("pulsing"). - Height(50). - Src("/web/static/images/hot1.gif"), - app.P(). - Class("update-message"). - Text("An update is available! Click here to reload!"), - ). - OnClick(func(ctx app.Context, e app.Event) { - u.onUpdateClick(ctx, e) - }), - ), - ) -} - -func (u *updater) onUpdateClick(ctx app.Context, e app.Event) { - ctx.Reload() -} diff --git a/web/blocks/pages/intro.html b/web/blocks/pages/intro.html index ee5d453..2a7f3f0 100644 --- a/web/blocks/pages/intro.html +++ b/web/blocks/pages/intro.html @@ -20,9 +20,9 @@


- Kagamine Rin drawing + Kagamine Rin drawing There is a lot of stuff I want to add to this website! In fact, there is also a "staging" website, which might contain - new features! It can be found at staging.newsite.dutchellie.nl. + new features! It can be found at newsite.staging.dutchellie.nl. Don't worry about the invalid SSL certificate, that's normal!

\ No newline at end of file