diff --git a/cmd/web/handlers_guestbook.go b/cmd/web/handlers_guestbook.go index 5234eb4..4d90132 100644 --- a/cmd/web/handlers_guestbook.go +++ b/cmd/web/handlers_guestbook.go @@ -42,79 +42,7 @@ func (app *application) getGuestbook(w http.ResponseWriter, r *http.Request) { return } data := app.newCommonData(r) - views.GuestbookView("Guestbook", data, website, website.Guestbook, comments, forms.CommentCreateForm{}).Render(r.Context(), w) -} - -func (app *application) getGuestbookSettings(w http.ResponseWriter, r *http.Request) { - slug := r.PathValue("id") - website, err := app.websites.Get(slugToShortId(slug)) - if err != nil { - if errors.Is(err, models.ErrNoRecord) { - http.NotFound(w, r) - } else { - app.serverError(w, r, err) - } - } - data := app.newCommonData(r) - views.GuestbookSettingsView(data, website).Render(r.Context(), w) -} - -func (app *application) putGuestbookSettings(w http.ResponseWriter, r *http.Request) { - slug := r.PathValue("id") - website, err := app.websites.Get(slugToShortId(slug)) - if err != nil { - if errors.Is(err, models.ErrNoRecord) { - http.NotFound(w, r) - } else { - app.serverError(w, r, err) - } - } - - var form forms.GuestbookSettingsForm - err = app.decodePostForm(r, &form) - if err != nil { - app.clientError(w, http.StatusBadRequest) - app.serverError(w, r, err) - return - } - form.CheckField(validator.PermittedValue(form.Visibility, "true", "false"), "gb_visible", "Invalid value") - form.CheckField(validator.PermittedValue(form.CommentingEnabled, models.ValidDisableDurations...), "gb_visible", "Invalid value") - form.CheckField(validator.PermittedValue(form.WidgetsEnabled, "true", "false"), "gb_remote", "Invalid value") - if !form.Valid() { - // TODO: rerender template with errors - app.clientError(w, http.StatusUnprocessableEntity) - } - - c, err := strconv.ParseBool(form.CommentingEnabled) - if err != nil { - website.Guestbook.Settings.IsCommentingEnabled = false - website.Guestbook.Settings.ReenableCommenting, err = app.durationToTime(form.CommentingEnabled) - if err != nil { - app.serverError(w, r, err) - } - } else { - website.Guestbook.Settings.IsCommentingEnabled = c - } - - // can skip error checking for these two since we verify valid values above - website.Guestbook.Settings.IsVisible, err = strconv.ParseBool(form.Visibility) - if err != nil { - app.serverError(w, r, err) - } - website.Guestbook.Settings.AllowRemoteHostAccess, err = strconv.ParseBool(form.WidgetsEnabled) - if err != nil { - app.serverError(w, r, err) - } - err = app.websites.UpdateGuestbookSettings(website.Guestbook.ID, website.Guestbook.Settings) - if err != nil { - app.serverError(w, r, err) - return - } - app.sessionManager.Put(r.Context(), "flash", "Settings changed successfully") - data := app.newCommonData(r) - w.Header().Add("HX-Refresh", "true") - views.GuestbookSettingsView(data, website).Render(r.Context(), w) - + views.GuestbookView(website.Name, data, website, website.Guestbook, comments, forms.CommentCreateForm{}).Render(r.Context(), w) } func (app *application) getGuestbookComments(w http.ResponseWriter, r *http.Request) { @@ -134,7 +62,7 @@ func (app *application) getGuestbookComments(w http.ResponseWriter, r *http.Requ return } data := app.newCommonData(r) - views.GuestbookDashboardCommentsView("Comments", data, website, website.Guestbook, comments).Render(r.Context(), w) + views.GuestbookDashboardCommentsView(fmt.Sprintf("%s - Comments", website.Name), data, website, website.Guestbook, comments).Render(r.Context(), w) } func (app *application) getGuestbookCommentsSerialized(w http.ResponseWriter, r *http.Request) { @@ -326,7 +254,7 @@ func (app *application) getCommentQueue(w http.ResponseWriter, r *http.Request) } data := app.newCommonData(r) - views.GuestbookDashboardCommentsView("Message Queue", data, website, website.Guestbook, comments).Render(r.Context(), w) + views.GuestbookDashboardCommentsView(fmt.Sprintf("%s - Comment Queue", website.Name), data, website, website.Guestbook, comments).Render(r.Context(), w) } func (app *application) getCommentTrash(w http.ResponseWriter, r *http.Request) { @@ -352,7 +280,7 @@ func (app *application) getCommentTrash(w http.ResponseWriter, r *http.Request) } data := app.newCommonData(r) - views.GuestbookDashboardCommentsView("Trash", data, website, website.Guestbook, comments).Render(r.Context(), w) + views.GuestbookDashboardCommentsView(fmt.Sprintf("%s - Comment Trash", website.Name), data, website, website.Guestbook, comments).Render(r.Context(), w) } func (app *application) putHideGuestbookComment(w http.ResponseWriter, r *http.Request) { diff --git a/cmd/web/handlers_user.go b/cmd/web/handlers_user.go index 132f099..391eb13 100644 --- a/cmd/web/handlers_user.go +++ b/cmd/web/handlers_user.go @@ -218,19 +218,6 @@ func (app *application) postUserLogout(w http.ResponseWriter, r *http.Request) { // http.Redirect(w, r, "/", http.StatusSeeOther) } -// func (app *application) getUsersList(w http.ResponseWriter, r *http.Request) { -// // skip templ conversion for this view, which will not be available in the final app -// // something similar will be available in the admin panel -// users, err := app.users.GetAll() -// if err != nil { -// app.serverError(w, r, err) -// return -// } -// data := app.newTemplateData(r) -// data.Users = users -// app.render(w, r, http.StatusOK, "userlist.view.tmpl.html", data) -// } - func (app *application) getUser(w http.ResponseWriter, r *http.Request) { slug := r.PathValue("id") user, err := app.users.Get(slugToShortId(slug)) diff --git a/cmd/web/handlers_website.go b/cmd/web/handlers_website.go index a2b8e9e..add16a1 100644 --- a/cmd/web/handlers_website.go +++ b/cmd/web/handlers_website.go @@ -71,7 +71,7 @@ func (app *application) getWebsiteDashboard(w http.ResponseWriter, r *http.Reque app.clientError(w, http.StatusUnauthorized) } data := app.newCommonData(r) - views.WebsiteDashboard("Guestbook", data, website).Render(r.Context(), w) + views.WebsiteDashboard(fmt.Sprintf("%s - Dashboard", website.Name), data, website).Render(r.Context(), w) } func (app *application) getWebsiteList(w http.ResponseWriter, r *http.Request) { @@ -103,3 +103,123 @@ func (app *application) getComingSoon(w http.ResponseWriter, r *http.Request) { } views.WebsiteDashboardComingSoon("Coming Soon", app.newCommonData(r), website).Render(r.Context(), w) } + +func (app *application) getWebsiteSettings(w http.ResponseWriter, r *http.Request) { + slug := r.PathValue("id") + website, err := app.websites.Get(slugToShortId(slug)) + if err != nil { + if errors.Is(err, models.ErrNoRecord) { + http.NotFound(w, r) + } else { + app.serverError(w, r, err) + } + return + } + var form forms.WebsiteSettingsForm + data := app.newCommonData(r) + views.WebsiteDashboardSettings(data, website, form).Render(r.Context(), w) +} + +func (app *application) putWebsiteSettings(w http.ResponseWriter, r *http.Request) { + slug := r.PathValue("id") + website, err := app.websites.Get(slugToShortId(slug)) + if err != nil { + if errors.Is(err, models.ErrNoRecord) { + http.NotFound(w, r) + } else { + app.serverError(w, r, err) + } + return + } + + var form forms.WebsiteSettingsForm + err = app.decodePostForm(r, &form) + if err != nil { + app.clientError(w, http.StatusBadRequest) + app.serverError(w, r, err) + return + } + form.CheckField(validator.NotBlank(form.AuthorName), "ws_author", "This field cannot be blank") + form.CheckField(validator.MaxChars(form.AuthorName, 256), "ws_author", "This field cannot exceed 256 characters") + form.CheckField(validator.NotBlank(form.SiteName), "ws_name", "This field cannot be blank") + form.CheckField(validator.MaxChars(form.SiteName, 256), "ws_name", "This field cannot exceed 256 characters") + form.CheckField(validator.NotBlank(form.SiteUrl), "ws_url", "This field cannot be blank") + form.CheckField(validator.MaxChars(form.SiteUrl, 512), "ws_url", "This field cannot exceed 512 characters") + form.CheckField(validator.Matches(form.SiteUrl, validator.WebRX), "ws_url", "This field must be a valid URL (including http:// or https://)") + form.CheckField(validator.PermittedValue(form.Visibility, "true", "false"), "gb_visible", "Invalid value") + form.CheckField(validator.PermittedValue(form.CommentingEnabled, models.ValidDisableDurations...), "gb_visible", "Invalid value") + form.CheckField(validator.PermittedValue(form.WidgetsEnabled, "true", "false"), "gb_remote", "Invalid value") + if !form.Valid() { + data := app.newCommonData(r) + views.SettingsForm(data, website, form, "").Render(r.Context(), w) + return + } + + gbSettings, err := convertFormToGuestbookSettings(form) + if err != nil { + app.serverError(w, r, err) + return + } + + err = app.websites.UpdateGuestbookSettings(website.Guestbook.ID, gbSettings) + if err != nil { + app.serverError(w, r, err) + return + } + + u, err := url.Parse(form.SiteUrl) + if err != nil { + app.serverError(w, r, err) + return + } + website.Name = form.SiteName + website.AuthorName = form.AuthorName + website.Url = u + + err = app.websites.Update(website) + if err != nil { + app.serverError(w, r, err) + return + } + + app.sessionManager.Put(r.Context(), "flash", "Settings changed successfully") + data := app.newCommonData(r) + views.SettingsForm(data, website, forms.WebsiteSettingsForm{}, "Settings changed successfully").Render(r.Context(), w) + +} + +func (app *application) deleteWebsite(w http.ResponseWriter, r *http.Request) { + slug := r.PathValue("id") + website, err := app.websites.Get(slugToShortId(slug)) + if err != nil { + if errors.Is(err, models.ErrNoRecord) { + http.NotFound(w, r) + } else { + app.serverError(w, r, err) + } + return + } + var form forms.WebsiteDeleteForm + err = app.decodePostForm(r, &form) + if err != nil { + app.serverError(w, r, err) + return + } + + form.CheckField(validator.Equals(website.Name, form.Delete), "delete", "Input must match site name exactly") + if !form.Valid() { + data := app.newCommonData(r) + views.DeleteForm(data, website, form).Render(r.Context(), w) + return + } + + err = app.websites.Delete(website.ID) + if err != nil { + app.serverError(w, r, err) + return + } + + app.sessionManager.Put(r.Context(), "flash", "Website Deleted") + w.Header().Add("HX-Redirect", "/websites") + w.WriteHeader(http.StatusOK) +} diff --git a/cmd/web/helpers.go b/cmd/web/helpers.go index 8e66c3c..8b8f06f 100644 --- a/cmd/web/helpers.go +++ b/cmd/web/helpers.go @@ -13,6 +13,7 @@ import ( "strconv" "time" + "git.32bit.cafe/32bitcafe/guestbook/internal/forms" "git.32bit.cafe/32bitcafe/guestbook/internal/models" "git.32bit.cafe/32bitcafe/guestbook/ui/views" "github.com/gorilla/schema" @@ -125,7 +126,7 @@ func DefaultUserSettings() models.UserSettings { } } -func (app *application) durationToTime(duration string) (time.Time, error) { +func durationToTime(duration string) (time.Time, error) { var result time.Time offset, err := time.ParseDuration(duration) if err != nil { @@ -164,3 +165,28 @@ func setCallbackCookie(w http.ResponseWriter, r *http.Request, name, value strin } http.SetCookie(w, c) } + +func convertFormToGuestbookSettings(form forms.WebsiteSettingsForm) (models.GuestbookSettings, error) { + var s models.GuestbookSettings + c, err := strconv.ParseBool(form.CommentingEnabled) + if err != nil { + s.IsCommentingEnabled = false + s.ReenableCommenting, err = durationToTime(form.CommentingEnabled) + if err != nil { + return s, err + } + } else { + s.IsCommentingEnabled = c + } + + // can skip error checking for these two since we verify valid values above + s.IsVisible, err = strconv.ParseBool(form.Visibility) + if err != nil { + return s, err + } + s.AllowRemoteHostAccess, err = strconv.ParseBool(form.WidgetsEnabled) + if err != nil { + return s, err + } + return s, nil +} diff --git a/cmd/web/main.go b/cmd/web/main.go index b15619b..26ff243 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -40,6 +40,7 @@ type applicationConfig struct { localAuthEnabled bool oauth applicationOauthConfig rootUrl string + environment string } type application struct { @@ -158,7 +159,15 @@ func setupConfig(addr string) (applicationConfig, error) { oauth2Provider = os.Getenv("OAUTH2_PROVIDER") clientID = os.Getenv("OAUTH2_CLIENT_ID") clientSecret = os.Getenv("OAUTH2_CLIENT_SECRET") + environment = os.Getenv("ENVIRONMENT") ) + + if environment != "" { + c.environment = environment + } else { + c.environment = "DEV" + } + if rootUrl != "" { c.rootUrl = rootUrl } else { @@ -214,6 +223,7 @@ func setupConfig(addr string) (applicationConfig, error) { } c.oauth = o + return c, nil } diff --git a/cmd/web/routes.go b/cmd/web/routes.go index 4f32a1b..c168a11 100644 --- a/cmd/web/routes.go +++ b/cmd/web/routes.go @@ -9,7 +9,12 @@ import ( func (app *application) routes() http.Handler { mux := http.NewServeMux() - mux.Handle("GET /static/", http.FileServerFS(ui.Files)) + if app.config.environment == "PROD" { + mux.Handle("GET /static/", http.FileServerFS(ui.Files)) + } else { + fileServer := http.FileServer(http.Dir("./ui/static/")) + mux.Handle("GET /static/", http.StripPrefix("/static", fileServer)) + } mux.HandleFunc("GET /ping", ping) @@ -49,8 +54,9 @@ func (app *application) routes() http.Handler { mux.Handle("GET /websites/{id}/dashboard/guestbook/comments/queue", protected.ThenFunc(app.getCommentQueue)) mux.Handle("DELETE /websites/{id}/dashboard/guestbook/comments/{commentId}", protected.ThenFunc(app.deleteGuestbookComment)) mux.Handle("PUT /websites/{id}/dashboard/guestbook/comments/{commentId}", protected.ThenFunc(app.putHideGuestbookComment)) - mux.Handle("GET /websites/{id}/dashboard/guestbook/settings", protected.ThenFunc(app.getGuestbookSettings)) - mux.Handle("PUT /websites/{id}/dashboard/guestbook/settings", protected.ThenFunc(app.putGuestbookSettings)) + mux.Handle("GET /websites/{id}/dashboard/settings", protected.ThenFunc(app.getWebsiteSettings)) + mux.Handle("PUT /websites/{id}/settings", protected.ThenFunc(app.putWebsiteSettings)) + mux.Handle("PUT /websites/{id}", protected.ThenFunc(app.deleteWebsite)) mux.Handle("GET /websites/{id}/dashboard/guestbook/comments/trash", protected.ThenFunc(app.getCommentTrash)) mux.Handle("GET /websites/{id}/dashboard/guestbook/themes", protected.ThenFunc(app.getComingSoon)) mux.Handle("GET /websites/{id}/dashboard/guestbook/customize", protected.ThenFunc(app.getComingSoon)) diff --git a/internal/forms/forms.go b/internal/forms/forms.go index 30abaa3..ebb7b25 100644 --- a/internal/forms/forms.go +++ b/internal/forms/forms.go @@ -31,12 +31,20 @@ type WebsiteCreateForm struct { validator.Validator `schema:"-"` } +type WebsiteDeleteForm struct { + Delete string `schema:"delete"` + validator.Validator `schema:"-"` +} + type UserSettingsForm struct { LocalTimezone string `schema:"timezones"` validator.Validator `schema:"-"` } -type GuestbookSettingsForm struct { +type WebsiteSettingsForm struct { + SiteName string `schema:"ws_name"` + SiteUrl string `schema:"ws_url"` + AuthorName string `schema:"ws_author"` Visibility string `schema:"gb_visible"` CommentingEnabled string `schema:"gb_commenting"` WidgetsEnabled string `schema:"gb_remote"` diff --git a/internal/models/mocks/website.go b/internal/models/mocks/website.go index 1e14872..bc50020 100644 --- a/internal/models/mocks/website.go +++ b/internal/models/mocks/website.go @@ -69,6 +69,13 @@ func (m *WebsiteModel) GetAll() ([]models.Website, error) { return []models.Website{mockWebsite}, nil } +func (m *WebsiteModel) Update(w models.Website) error { + return nil +} +func (m *WebsiteModel) Delete(websiteId int64) error { + return nil +} + func (m *WebsiteModel) InitializeSettingsMap() error { return nil } diff --git a/internal/models/website.go b/internal/models/website.go index 811bedf..6385530 100644 --- a/internal/models/website.go +++ b/internal/models/website.go @@ -97,9 +97,11 @@ type WebsiteModelInterface interface { Get(shortId uint64) (Website, error) GetAllUser(userId int64) ([]Website, error) GetAll() ([]Website, error) + Update(w Website) error InitializeSettingsMap() error UpdateGuestbookSettings(guestbookId int64, settings GuestbookSettings) error UpdateSetting(guestbookId int64, setting Setting, value string) error + Delete(websiteId int64) error } func (m *WebsiteModel) Insert(shortId uint64, userId int64, siteName, siteUrl, authorName string) (int64, error) { @@ -243,7 +245,7 @@ func (m *WebsiteModel) GetAllUser(userId int64) ([]Website, error) { stmt := `SELECT w.Id, w.ShortId, w.Name, w.SiteUrl, w.AuthorName, w.UserId, w.Created, g.Id, g.ShortId, g.Created, g.IsActive FROM websites AS w INNER JOIN guestbooks AS g ON w.Id = g.WebsiteId - WHERE w.UserId = ?` + WHERE w.UserId = ? AND w.Deleted IS NULL` rows, err := m.DB.Query(stmt, userId) if err != nil { return nil, err @@ -272,7 +274,7 @@ func (m *WebsiteModel) GetAllUser(userId int64) ([]Website, error) { func (m *WebsiteModel) GetAll() ([]Website, error) { stmt := `SELECT w.Id, w.ShortId, w.Name, w.SiteUrl, w.AuthorName, w.UserId, w.Created, g.Id, g.ShortId, g.Created, g.IsActive - FROM websites AS w INNER JOIN guestbooks AS g ON w.Id = g.WebsiteId` + FROM websites AS w INNER JOIN guestbooks AS g ON w.Id = g.WebsiteId WHERE w.Deleted IS NULL` rows, err := m.DB.Query(stmt) if err != nil { return nil, err @@ -298,6 +300,36 @@ func (m *WebsiteModel) GetAll() ([]Website, error) { return websites, nil } +func (m *WebsiteModel) Update(w Website) error { + stmt := `UPDATE websites SET Name = ?, SiteUrl = ?, AuthorName = ? WHERE ID = ?` + r, err := m.DB.Exec(stmt, w.Name, w.Url.String(), w.AuthorName, w.ID) + if err != nil { + return err + } + if rows, err := r.RowsAffected(); rows != 1 { + if err != nil { + return err + } + return errors.New("Failed to update website") + } + return nil +} + +func (m *WebsiteModel) Delete(websiteId int64) error { + stmt := `UPDATE websites SET Deleted = ? WHERE ID = ?` + r, err := m.DB.Exec(stmt, time.Now().UTC(), websiteId) + if err != nil { + return err + } + if rows, err := r.RowsAffected(); rows != 1 { + if err != nil { + return err + } + return errors.New("Failed to update website") + } + return nil +} + func (m *WebsiteModel) getGuestbookSettings(tx *sql.Tx, guestbookId int64) (GuestbookSettings, error) { stmt := `SELECT g.SettingId, a.ItemValue, g.UnconstrainedValue FROM guestbook_settings AS g LEFT JOIN allowed_setting_values AS a ON g.AllowedSettingValueId = a.Id diff --git a/internal/validator/validator.go b/internal/validator/validator.go index 62037b2..5991605 100644 --- a/internal/validator/validator.go +++ b/internal/validator/validator.go @@ -57,3 +57,7 @@ func MinChars(value string, n int) bool { func Matches(value string, rx *regexp.Regexp) bool { return rx.MatchString(value) } + +func Equals(expected, actual string) bool { + return expected == actual +} diff --git a/ui/static/css/style.css b/ui/static/css/style.css index 1f291a6..ceeac55 100644 --- a/ui/static/css/style.css +++ b/ui/static/css/style.css @@ -57,7 +57,7 @@ div#dashboard { div#dashboard nav { flex: 1 1 25%; - margin-top: 2rem; + /* margin-top: 2rem; */ min-width: 0; } diff --git a/ui/views/common.templ b/ui/views/common.templ index bafe90f..e17e270 100644 --- a/ui/views/common.templ +++ b/ui/views/common.templ @@ -87,6 +87,7 @@ templ base(title string, data CommonData) { if data.Flash != "" {
{ data.Flash }
} +

{ title }

{ children... } @commonFooter() diff --git a/ui/views/common_templ.go b/ui/views/common_templ.go index e4131f2..3d2d0dc 100644 --- a/ui/views/common_templ.go +++ b/ui/views/common_templ.go @@ -251,11 +251,28 @@ func base(title string, data CommonData) templ.Component { return templ_7745c5c3_Err } } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var9 string + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(title) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 90, Col: 15} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "

") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } templ_7745c5c3_Err = templ_7745c5c3_Var6.Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -263,7 +280,7 @@ func base(title string, data CommonData) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/ui/views/guestbooks.templ b/ui/views/guestbooks.templ index 080d947..ed3f8d1 100644 --- a/ui/views/guestbooks.templ +++ b/ui/views/guestbooks.templ @@ -111,7 +111,7 @@ templ GuestbookView(title string, data CommonData, website models.Website, guest
-

Guestbook for { website.Name }

+

{ website.Name } Guestbook

{ data.Flash }
@@ -148,62 +148,6 @@ templ settingRadio(selected bool, name, id, value string) { } -templ GuestbookSettingsView(data CommonData, website models.Website) { - {{ putUrl := fmt.Sprintf("/websites/%s/dashboard/guestbook/settings", shortIdToSlug(website.ShortId)) }} - {{ gb := website.Guestbook }} - @base("Guestbook Settings", data) { -
- @wSidebar(website) -
-

Guestbook Settings

- - -
- - - -
-
- - - if !website.Guestbook.CanComment() { - {{ localtime := gb.Settings.ReenableCommenting.In(data.CurrentUser.Settings.LocalTimezone) }} - - } -
-
- - - -
- - -
-
- } -} - templ EmbeddableGuestbookCommentForm(data CommonData, w models.Website, f forms.CommentCreateForm) { {{ postUrl := fmt.Sprintf("/websites/%s/guestbook/comments/create?headless=true", shortIdToSlug(w.ShortId)) }} @@ -223,7 +167,6 @@ templ EmbeddableGuestbookCommentForm(data CommonData, w models.Website, f forms. templ AllGuestbooksView(data CommonData, websites []models.Website) { @base("All Guestbooks", data) {
-

All Guestbooks

This page exists only for testing the service.

diff --git a/ui/views/guestbooks_templ.go b/ui/views/guestbooks_templ.go index 7d167f9..cb8c492 100644 --- a/ui/views/guestbooks_templ.go +++ b/ui/views/guestbooks_templ.go @@ -471,20 +471,20 @@ func GuestbookView(title string, data CommonData, website models.Website, guestb if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "

Guestbook for ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } var templ_7745c5c3_Var23 string templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(website.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 114, Col: 38} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 114, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, " Guestbook

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -711,7 +711,7 @@ func settingRadio(selected bool, name, id, value string) templ.Component { }) } -func GuestbookSettingsView(data CommonData, website models.Website) templ.Component { +func EmbeddableGuestbookCommentForm(data CommonData, w models.Website, f forms.CommentCreateForm) templ.Component { return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { @@ -732,236 +732,43 @@ func GuestbookSettingsView(data CommonData, website models.Website) templ.Compon templ_7745c5c3_Var37 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - putUrl := fmt.Sprintf("/websites/%s/dashboard/guestbook/settings", shortIdToSlug(website.ShortId)) - gb := website.Guestbook - templ_7745c5c3_Var38 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = wSidebar(website).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "

Guestbook Settings

") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if !website.Guestbook.CanComment() { - localtime := gb.Settings.ReenableCommenting.In(data.CurrentUser.Settings.LocalTimezone) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 78, "
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) - templ_7745c5c3_Err = base("Guestbook Settings", data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var38), templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -func EmbeddableGuestbookCommentForm(data CommonData, w models.Website, f forms.CommentCreateForm) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var44 := templ.GetChildren(ctx) - if templ_7745c5c3_Var44 == nil { - templ_7745c5c3_Var44 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) postUrl := fmt.Sprintf("/websites/%s/guestbook/comments/create?headless=true", shortIdToSlug(w.ShortId)) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 83, "") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var45 string - templ_7745c5c3_Var45, templ_7745c5c3_Err = templ.JoinStringErrs(data.Flash) + var templ_7745c5c3_Var38 string + templ_7745c5c3_Var38, templ_7745c5c3_Err = templ.JoinStringErrs(data.Flash) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 214, Col: 15} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 158, Col: 15} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var38)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 84, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "\">") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -969,7 +776,7 @@ func EmbeddableGuestbookCommentForm(data CommonData, w models.Website, f forms.C if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 87, "
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -993,12 +800,12 @@ func AllGuestbooksView(data CommonData, websites []models.Website) templ.Compone }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var48 := templ.GetChildren(ctx) - if templ_7745c5c3_Var48 == nil { - templ_7745c5c3_Var48 = templ.NopComponent + templ_7745c5c3_Var41 := templ.GetChildren(ctx) + if templ_7745c5c3_Var41 == nil { + templ_7745c5c3_Var41 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var49 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var42 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -1010,50 +817,50 @@ func AllGuestbooksView(data CommonData, websites []models.Website) templ.Compone }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 88, "

All Guestbooks

This page exists only for testing the service.

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = base("All Guestbooks", data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var49), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = base("All Guestbooks", data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var42), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1077,47 +884,47 @@ func GuestbookCommentCreateRemoteErrorView(url, err string) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var52 := templ.GetChildren(ctx) - if templ_7745c5c3_Var52 == nil { - templ_7745c5c3_Var52 = templ.NopComponent + templ_7745c5c3_Var45 := templ.GetChildren(ctx) + if templ_7745c5c3_Var45 == nil { + templ_7745c5c3_Var45 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 94, "

An error occurred while posting comment. ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, "\">

An error occurred while posting comment. ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var54 string - templ_7745c5c3_Var54, templ_7745c5c3_Err = templ.JoinStringErrs(err) + var templ_7745c5c3_Var47 string + templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(err) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 249, Col: 50} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 192, Col: 50} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var54)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var47)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 96, ". Redirecting.

Redirect

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, "\">Redirect

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -1141,34 +948,34 @@ func GuestbookCommentCreateRemoteSuccessView(url string) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var56 := templ.GetChildren(ctx) - if templ_7745c5c3_Var56 == nil { - templ_7745c5c3_Var56 = templ.NopComponent + templ_7745c5c3_Var49 := templ.GetChildren(ctx) + if templ_7745c5c3_Var49 == nil { + templ_7745c5c3_Var49 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, "

Comment successfully posted. Redirecting.

Comment successfully posted. Redirecting.

Redirect

") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, "\">Redirect

") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } diff --git a/ui/views/users.templ b/ui/views/users.templ index 299d282..92c5a19 100644 --- a/ui/views/users.templ +++ b/ui/views/users.templ @@ -86,7 +86,6 @@ templ UserSettingsView(data CommonData, timezones []string) { {{ user := data.CurrentUser }} @base("User Settings", data) {
-

User Settings

diff --git a/ui/views/users_templ.go b/ui/views/users_templ.go index ec96f47..d57378d 100644 --- a/ui/views/users_templ.go +++ b/ui/views/users_templ.go @@ -444,14 +444,14 @@ func UserSettingsView(data CommonData, timezones []string) templ.Component { }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "

User Settings

-

{ website.Name }

Guestbook

@@ -26,11 +29,10 @@ templ wSidebar(website models.Website) {
  • Manage messages
  • Review message queue
  • Trash
  • -
  • Settings
  • @@ -48,20 +50,6 @@ templ wSidebar(website models.Website) { } -templ displayWebsites(websites []models.Website) { - if len(websites) == 0 { -

    No Websites yet. Register a website.

    - } else { -
      - for _, w := range websites { -
    • - { w.Name } -
    • - } -
    - } -} - templ websiteCreateForm(csrfToken string, form forms.WebsiteCreateForm) {
    @@ -95,12 +83,21 @@ templ websiteCreateForm(csrfToken string, form forms.WebsiteCreateForm) { templ WebsiteList(title string, data CommonData, websites []models.Website) { @base(title, data) { -

    My Websites

    - @displayWebsites(websites) + if len(websites) == 0 { +

    No Websites yet. Register a website.

    + } else { +
      + for _, w := range websites { +
    • + { w.Name } +
    • + } +
    + }
    } } @@ -110,8 +107,7 @@ templ WebsiteDashboard(title string, data CommonData, website models.Website) {
    @wSidebar(website)
    -

    { website.Name }

    -

    Embed your Guestbook

    +

    Embed your Guestbook

    Upload this JavaScript WebComponent to your site and include it in your { `` } tag.

    @@ -152,12 +148,139 @@ templ WebsiteDashboard(title string, data CommonData, website models.Website) { } } +templ websiteSettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm) { +

    Website Settings

    +
    + {{ err, exists := form.FieldErrors["ws_name"] }} + + if exists { + + } + if form.SiteName != "" { + + } else { + + } +
    +
    + {{ err, exists = form.FieldErrors["ws_url"] }} + + if exists { + + } + if form.SiteUrl != "" { + + } else { + + } +
    +
    + {{ err, exists = form.FieldErrors["ws_author"] }} + + if exists { + + } + if form.AuthorName != "" { + + } else { + + } +
    +} + +templ guestbookSettingsForm(data CommonData, website models.Website, gb models.Guestbook, form forms.WebsiteSettingsForm) { +

    Guestbook Settings

    +
    + + + +
    +
    + + + if !website.Guestbook.CanComment() { + {{ localtime := gb.Settings.ReenableCommenting.In(data.CurrentUser.Settings.LocalTimezone) }} + + } +
    +
    + + + +
    +} + +templ SettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm, msg string) { + {{ putUrl := fmt.Sprintf("/websites/%s/settings", shortIdToSlug(website.ShortId)) }} + {{ gb := website.Guestbook }} + +

    + { msg } +

    + +
    + @websiteSettingsForm(data, website, form) + @guestbookSettingsForm(data, website, gb, form) +
    + + +} + +templ DeleteForm(data CommonData, website models.Website, form forms.WebsiteDeleteForm) { + {{ putUrl := fmt.Sprintf("/websites/%s", shortIdToSlug(website.ShortId)) }} +
    + +

    Delete Website

    +

    Deleting a website is permanent. Be absolutely sure before proceeding.

    + {{ err, exists := form.FieldErrors["delete"] }} + + if exists { + + } + + +
    +} + +templ WebsiteDashboardSettings(data CommonData, website models.Website, form forms.WebsiteSettingsForm) { + {{ title := fmt.Sprintf("%s - Settings", website.Name) }} + @base(title, data) { +
    + @wSidebar(website) +
    + @SettingsForm(data, website, form, "") + @DeleteForm(data, website, forms.WebsiteDeleteForm{}) +
    +
    + } +} + templ WebsiteDashboardComingSoon(title string, data CommonData, website models.Website) { @base(title, data) {
    @wSidebar(website)
    -

    { website.Name }

    Coming Soon

    diff --git a/ui/views/websites_hx.templ b/ui/views/websites_hx.templ deleted file mode 100644 index 28ba2eb..0000000 --- a/ui/views/websites_hx.templ +++ /dev/null @@ -1,7 +0,0 @@ -package views - -import "git.32bit.cafe/32bitcafe/guestbook/internal/models" - -templ HxWebsiteList(websites []models.Website) { - @displayWebsites(websites) -} diff --git a/ui/views/websites_hx_templ.go b/ui/views/websites_hx_templ.go deleted file mode 100644 index cb3cbf2..0000000 --- a/ui/views/websites_hx_templ.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by templ - DO NOT EDIT. - -// templ: version: v0.3.833 -package views - -//lint:file-ignore SA4006 This context is only used if a nested component is present. - -import "github.com/a-h/templ" -import templruntime "github.com/a-h/templ/runtime" - -import "git.32bit.cafe/32bitcafe/guestbook/internal/models" - -func HxWebsiteList(websites []models.Website) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var1 := templ.GetChildren(ctx) - if templ_7745c5c3_Var1 == nil { - templ_7745c5c3_Var1 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = displayWebsites(websites).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -var _ = templruntime.GeneratedTemplate diff --git a/ui/views/websites_templ.go b/ui/views/websites_templ.go index 83e490a..e22ed5c 100644 --- a/ui/views/websites_templ.go +++ b/ui/views/websites_templ.go @@ -8,9 +8,12 @@ package views import "github.com/a-h/templ" import templruntime "github.com/a-h/templ/runtime" -import "fmt" -import "git.32bit.cafe/32bitcafe/guestbook/internal/models" -import "git.32bit.cafe/32bitcafe/guestbook/internal/forms" +import ( + "fmt" + "git.32bit.cafe/32bitcafe/guestbook/internal/forms" + "git.32bit.cafe/32bitcafe/guestbook/internal/models" + "time" +) func wUrl(w models.Website) string { return fmt.Sprintf("/websites/%s", shortIdToSlug(w.ShortId)) @@ -39,29 +42,25 @@ func wSidebar(website models.Website) templ.Component { ctx = templ.ClearChildren(ctx) dashUrl := wUrl(website) + "/dashboard" gbUrl := wUrl(website) + "/guestbook" - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - return nil - }) -} - -func displayWebsites(websites []models.Website) templ.Component { - return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { - templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context - if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { - return templ_7745c5c3_CtxErr - } - templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) - if !templ_7745c5c3_IsBuffer { - defer func() { - templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) - if templ_7745c5c3_Err == nil { - templ_7745c5c3_Err = templ_7745c5c3_BufErr - } - }() - } - ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var12 := templ.GetChildren(ctx) - if templ_7745c5c3_Var12 == nil { - templ_7745c5c3_Var12 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - if len(websites) == 0 { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "

    No Websites yet. Register a website.

    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } else { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } return nil }) } @@ -225,148 +129,148 @@ func websiteCreateForm(csrfToken string, form forms.WebsiteCreateForm) templ.Com }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var15 := templ.GetChildren(ctx) - if templ_7745c5c3_Var15 == nil { - templ_7745c5c3_Var15 = templ.NopComponent + templ_7745c5c3_Var9 := templ.GetChildren(ctx) + if templ_7745c5c3_Var9 == nil { + templ_7745c5c3_Var9 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + err, exists := form.FieldErrors["sitename"] + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if exists { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + err, exists = form.FieldErrors["siteurl"] + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if exists { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + err, exists = form.FieldErrors["authorname"] + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if exists { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "
    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - err, exists := form.FieldErrors["sitename"] - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if exists { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "
    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - err, exists = form.FieldErrors["siteurl"] - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if exists { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "
    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - err, exists = form.FieldErrors["authorname"] - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - if exists { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, " ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "\" required>
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -390,12 +294,12 @@ func WebsiteList(title string, data CommonData, websites []models.Website) templ }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var23 := templ.GetChildren(ctx) - if templ_7745c5c3_Var23 == nil { - templ_7745c5c3_Var23 = templ.NopComponent + templ_7745c5c3_Var17 := templ.GetChildren(ctx) + if templ_7745c5c3_Var17 == nil { + templ_7745c5c3_Var17 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var24 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var18 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -407,21 +311,60 @@ func WebsiteList(title string, data CommonData, websites []models.Website) templ }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "

    My Websites

    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = displayWebsites(websites).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err + if len(websites) == 0 { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "

    No Websites yet. Register a website.

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var24), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var18), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -445,12 +388,12 @@ func WebsiteDashboard(title string, data CommonData, website models.Website) tem }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var25 := templ.GetChildren(ctx) - if templ_7745c5c3_Var25 == nil { - templ_7745c5c3_Var25 = templ.NopComponent + templ_7745c5c3_Var21 := templ.GetChildren(ctx) + if templ_7745c5c3_Var21 == nil { + templ_7745c5c3_Var21 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var26 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var22 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -462,7 +405,7 @@ func WebsiteDashboard(title string, data CommonData, website models.Website) tem }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -470,87 +413,671 @@ func WebsiteDashboard(title string, data CommonData, website models.Website) tem if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "

    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "

    Embed your Guestbook

    Upload this JavaScript WebComponent to your site and include it in your ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var27 string - templ_7745c5c3_Var27, templ_7745c5c3_Err = templ.JoinStringErrs(website.Name) + var templ_7745c5c3_Var23 string + templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(``) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 113, Col: 22} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 112, Col: 140} } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var27)) + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23)) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "

    Embed your Guestbook

    Upload this JavaScript WebComponent to your site and include it in your ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 36, " tag.

    ")
     			if templ_7745c5c3_Err != nil {
     				return templ_7745c5c3_Err
     			}
    -			var templ_7745c5c3_Var28 string
    -			templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(``)
    -			if templ_7745c5c3_Err != nil {
    -				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 116, Col: 140}
    -			}
    -			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
    -			if templ_7745c5c3_Err != nil {
    -				return templ_7745c5c3_Err
    -			}
    -			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, " tag.

    ")
    -			if templ_7745c5c3_Err != nil {
    -				return templ_7745c5c3_Err
    -			}
    -			var templ_7745c5c3_Var29 string
    -			templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(
    +			var templ_7745c5c3_Var24 string
    +			templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(
     				`
         
     `)
     			if templ_7745c5c3_Err != nil {
    -				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 125, Col: 8}
    +				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 121, Col: 8}
     			}
    -			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29))
    +			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
     			if templ_7745c5c3_Err != nil {
     				return templ_7745c5c3_Err
     			}
    -			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "

    Then add the custom elements where you want your form and comments to show up

    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 37, "

    Then add the custom elements where you want your form and comments to show up

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } gbUrl := fmt.Sprintf("https://%s/websites/%s/guestbook", data.RootUrl, shortIdToSlug(website.ShortId)) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, "
    ")
    +			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 38, "
    ")
     			if templ_7745c5c3_Err != nil {
     				return templ_7745c5c3_Err
     			}
    -			var templ_7745c5c3_Var30 string
    -			templ_7745c5c3_Var30, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(`
    +			var templ_7745c5c3_Var25 string
    +			templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(`
     `, gbUrl, gbUrl))
     			if templ_7745c5c3_Err != nil {
    -				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 136, Col: 72}
    +				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 132, Col: 72}
     			}
    -			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var30))
    +			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
     			if templ_7745c5c3_Err != nil {
     				return templ_7745c5c3_Err
     			}
    -			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, "

    If your web host does not allow CORS requests, use an iframe instead

    ")
    +			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 39, "

    If your web host does not allow CORS requests, use an iframe instead

    ")
     			if templ_7745c5c3_Err != nil {
     				return templ_7745c5c3_Err
     			}
    -			var templ_7745c5c3_Var31 string
    -			templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(``, gbUrl))
    +			var templ_7745c5c3_Var26 string
    +			templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf(``, gbUrl))
     			if templ_7745c5c3_Err != nil {
    -				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 146, Col: 75}
    +				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 142, Col: 75}
     			}
    -			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31))
    +			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
     			if templ_7745c5c3_Err != nil {
     				return templ_7745c5c3_Err
     			}
    -			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 44, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var26), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var22), templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func websiteSettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var27 := templ.GetChildren(ctx) + if templ_7745c5c3_Var27 == nil { + templ_7745c5c3_Var27 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, "

    Website Settings

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + err, exists := form.FieldErrors["ws_name"] + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 42, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if exists { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 43, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if form.SiteName != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + err, exists = form.FieldErrors["ws_url"] + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 50, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if exists { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 51, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if form.SiteUrl != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 53, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 55, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 57, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + err, exists = form.FieldErrors["ws_author"] + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if exists { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 59, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + if form.AuthorName != "" { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } else { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func guestbookSettingsForm(data CommonData, website models.Website, gb models.Guestbook, form forms.WebsiteSettingsForm) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var37 := templ.GetChildren(ctx) + if templ_7745c5c3_Var37 == nil { + templ_7745c5c3_Var37 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "

    Guestbook Settings

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if !website.Guestbook.CanComment() { + localtime := gb.Settings.ReenableCommenting.In(data.CurrentUser.Settings.LocalTimezone) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, "") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func SettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm, msg string) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var41 := templ.GetChildren(ctx) + if templ_7745c5c3_Var41 == nil { + templ_7745c5c3_Var41 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + putUrl := fmt.Sprintf("/websites/%s/settings", shortIdToSlug(website.ShortId)) + gb := website.Guestbook + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 84, "

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + var templ_7745c5c3_Var43 string + templ_7745c5c3_Var43, templ_7745c5c3_Err = templ.JoinStringErrs(msg) + if templ_7745c5c3_Err != nil { + return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 239, Col: 8} + } + _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var43)) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 86, "

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = websiteSettingsForm(data, website, form).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = guestbookSettingsForm(data, website, gb, form).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 88, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func DeleteForm(data CommonData, website models.Website, form forms.WebsiteDeleteForm) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var45 := templ.GetChildren(ctx) + if templ_7745c5c3_Var45 == nil { + templ_7745c5c3_Var45 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + putUrl := fmt.Sprintf("/websites/%s", shortIdToSlug(website.ShortId)) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 89, "

    Delete Website

    Deleting a website is permanent. Be absolutely sure before proceeding.

    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + err, exists := form.FieldErrors["delete"] + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 92, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + if exists { + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 93, " ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 95, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +func WebsiteDashboardSettings(data CommonData, website models.Website, form forms.WebsiteSettingsForm) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var49 := templ.GetChildren(ctx) + if templ_7745c5c3_Var49 == nil { + templ_7745c5c3_Var49 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + title := fmt.Sprintf("%s - Settings", website.Name) + templ_7745c5c3_Var50 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 96, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = wSidebar(website).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 97, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = SettingsForm(data, website, form, "").Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = DeleteForm(data, website, forms.WebsiteDeleteForm{}).Render(ctx, templ_7745c5c3_Buffer) + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 98, "
    ") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) + templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var50), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -574,12 +1101,12 @@ func WebsiteDashboardComingSoon(title string, data CommonData, website models.We }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var32 := templ.GetChildren(ctx) - if templ_7745c5c3_Var32 == nil { - templ_7745c5c3_Var32 = templ.NopComponent + templ_7745c5c3_Var51 := templ.GetChildren(ctx) + if templ_7745c5c3_Var51 == nil { + templ_7745c5c3_Var51 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var33 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var52 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -591,7 +1118,7 @@ func WebsiteDashboardComingSoon(title string, data CommonData, website models.We }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 45, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 99, "
    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -599,26 +1126,13 @@ func WebsiteDashboardComingSoon(title string, data CommonData, website models.We if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 46, "

    ") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - var templ_7745c5c3_Var34 string - templ_7745c5c3_Var34, templ_7745c5c3_Err = templ.JoinStringErrs(website.Name) - if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/websites.templ`, Line: 160, Col: 22} - } - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var34)) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 47, "

    Coming Soon

    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "

    Coming Soon

    ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var33), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var52), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -642,12 +1156,12 @@ func WebsiteCreate(title string, data CommonData, form forms.WebsiteCreateForm) }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Var35 := templ.GetChildren(ctx) - if templ_7745c5c3_Var35 == nil { - templ_7745c5c3_Var35 = templ.NopComponent + templ_7745c5c3_Var53 := templ.GetChildren(ctx) + if templ_7745c5c3_Var53 == nil { + templ_7745c5c3_Var53 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Var36 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_Var54 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) if !templ_7745c5c3_IsBuffer { @@ -659,7 +1173,7 @@ func WebsiteCreate(title string, data CommonData, form forms.WebsiteCreateForm) }() } ctx = templ.InitializeContext(ctx) - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 48, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 101, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -667,13 +1181,13 @@ func WebsiteCreate(title string, data CommonData, form forms.WebsiteCreateForm) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 49, "
    ") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 102, "") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } return nil }) - templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var36), templ_7745c5c3_Buffer) + templ_7745c5c3_Err = base(title, data).Render(templ.WithChildren(ctx, templ_7745c5c3_Var54), templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err }