Compare commits
No commits in common. "6482fcd6f1d3207ddd766e06744d238b017acace" and "44da256e1042263b2c6ac103ab72d3952e432ae7" have entirely different histories.
6482fcd6f1
...
44da256e10
13
src/bannerpanel.go
Normal file
13
src/bannerpanel.go
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
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()
|
||||||
|
}
|
@ -36,14 +36,13 @@ func (g *guestbook) OnMount(ctx app.Context) {
|
|||||||
g.LoadComments(ctx)
|
g.LoadComments(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
func (g *guestbook) OnNav(ctx app.Context) {
|
func (g *guestbook) OnNav(ctx app.Context) {
|
||||||
g.LoadComments(ctx)
|
g.LoadComments(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *guestbook) OnUpdate(ctx app.Context) {
|
func (g *guestbook) OnUpdate(ctx app.Context) {
|
||||||
g.LoadComments(ctx)
|
g.LoadComments(ctx)
|
||||||
}*/
|
}
|
||||||
|
|
||||||
func (g guestbook) Render() app.UI {
|
func (g guestbook) Render() app.UI {
|
||||||
return app.Div().Body(
|
return app.Div().Body(
|
||||||
|
105
src/guestbookform.go
Normal file
105
src/guestbookform.go
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
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"),
|
||||||
|
),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
*/
|
100
src/guestbookpanel.go
Normal file
100
src/guestbookpanel.go
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
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")
|
||||||
|
}
|
||||||
|
*/
|
@ -69,5 +69,10 @@ func (p *Homepage) Render() app.UI {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
/*
|
||||||
|
newUIBlock().
|
||||||
|
Class("right").
|
||||||
|
Class("contentblock").
|
||||||
|
UI(),*/
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
15
src/main.go
15
src/main.go
@ -57,20 +57,7 @@ func main() {
|
|||||||
"/web/static/havakana.css",
|
"/web/static/havakana.css",
|
||||||
"/web/static/form.css",
|
"/web/static/form.css",
|
||||||
},
|
},
|
||||||
CacheableResources: []string{
|
CacheableResources: []string{},
|
||||||
// Images
|
|
||||||
"/web/static/images/email3.gif",
|
|
||||||
"/web/static/images/rin-len1.webp",
|
|
||||||
"/web/static/images/background_star.gif",
|
|
||||||
"/web/static/images/kanata-1.gif",
|
|
||||||
"/web/static/images/rin-1.gif",
|
|
||||||
"/web/static/images/rin-2.gif",
|
|
||||||
// Pages
|
|
||||||
"/web/blocks/pages/about.html",
|
|
||||||
"/web/blocks/pages/galaxies.html",
|
|
||||||
"/web/blocks/pages/intro.html",
|
|
||||||
"/web/blocks/snippets/bannerpanel.html",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.GenerateStaticWebsite("./staticsite", handler)
|
app.GenerateStaticWebsite("./staticsite", handler)
|
||||||
|
38
src/updater.go
Normal file
38
src/updater.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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()
|
||||||
|
}
|
@ -20,9 +20,9 @@
|
|||||||
</p>
|
</p>
|
||||||
<br>
|
<br>
|
||||||
<p class="content-text">
|
<p class="content-text">
|
||||||
<img src="/web/static/images/rin-2.gif" alt="Kagamine Rin drawing" style="float:left; width:100px; margin-right: 20px;">
|
<img src="/web/static/images/rin-2.gif" alt="Kagamine Rin drawing" style="float:left; width:100px; margin-right: 10px;">
|
||||||
There is a lot of stuff I want to add to this website! In fact, there is also a "staging" website, which might
|
There is a lot of stuff I want to add to this website! In fact, there is also a "staging" website, which might
|
||||||
contain
|
contain
|
||||||
new features! It can be found at <a href="https://newsite.staging.dutchellie.nl">newsite.staging.dutchellie.nl</a>.
|
new features! It can be found at <a href="https://staging.newsite.dutchellie.nl">staging.newsite.dutchellie.nl</a>.
|
||||||
Don't worry about the invalid SSL certificate, that's normal!
|
Don't worry about the invalid SSL certificate, that's normal!
|
||||||
</p>
|
</p>
|
Loading…
Reference in New Issue
Block a user