package views import "fmt" import "git.32bit.cafe/32bitcafe/guestbook/internal/models" import "git.32bit.cafe/32bitcafe/guestbook/internal/forms" func gbUrl(gb models.Guestbook) string { return fmt.Sprintf("/guestbooks/%s", shortIdToSlug(gb.ShortId)) } templ gbCreateForm(csrf_token string) { } templ gbList(guestbooks []models.Guestbook) { if len(guestbooks) == 0 {

No Guestbooks yet

} else { } } templ GuestbookList(title string, data CommonData, guestbooks []models.Guestbook) { if data.IsHtmx { @gbList(guestbooks) } else { @base(title, data) {

My Guestbooks

@gbList(guestbooks) } } } templ GuestbookCreate(title string, data CommonData) { if data.IsHtmx {
@gbCreateForm(data.CSRFToken)
} else { @base(title, data) {
@gbCreateForm(data.CSRFToken)
} } } templ sidebar(guestbook models.Guestbook) { {{ dashUrl := gbUrl(guestbook) + "/dashboard" }} } templ GuestbookDashboardView(title string, data CommonData, guestbook models.Guestbook, comments []models.GuestbookComment) { @base(title, data) {
@sidebar(guestbook)

Guestbook for { guestbook.SiteUrl }

Stats and stuff will go here

} } templ GuestbookDashboardCommentsView(title string, data CommonData, guestbook models.Guestbook, comments []models.GuestbookComment) { @base(title, data) {
@sidebar(guestbook)

Comments on { guestbook.SiteUrl }

if len(comments) == 0 {

No comments yet!

} for _, c := range comments {
{ c.AuthorName } { c.Created.Format("01-02-2006 03:04PM") }

{ c.CommentText }

}
} } templ commentForm(data CommonData, gb models.Guestbook, form forms.CommentCreateForm) { {{ postUrl := fmt.Sprintf("/guestbooks/%s/comments/create", shortIdToSlug(gb.ShortId)) }}
{{ error, exists := form.FieldErrors["authorName"] }} if exists { }
{{ error, exists = form.FieldErrors["authorEmail"] }} if exists { }
{{ error, exists = form.FieldErrors["authorSite"] }} if exists { }
{{ error, exists = form.FieldErrors["content"] }} if exists { }
} templ GuestbookView(title string, data CommonData, guestbook models.Guestbook, comments []models.GuestbookComment, form forms.CommentCreateForm) {

Guestbook for { guestbook.SiteUrl }

@commentForm(data, guestbook, form) if len(comments) == 0 {

No comments yet!

} for _, c := range comments {
{ c.AuthorName } { c.Created.Format("01-02-2006 03:04PM") }

{ c.CommentText }

}
}