Allow users to modify/delete websites #36
@ -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) {
 | 
			
		||||
 | 
			
		||||
@ -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))
 | 
			
		||||
 | 
			
		||||
@ -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)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -9,7 +9,12 @@ import (
 | 
			
		||||
 | 
			
		||||
func (app *application) routes() http.Handler {
 | 
			
		||||
	mux := http.NewServeMux()
 | 
			
		||||
	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))
 | 
			
		||||
 | 
			
		||||
@ -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"`
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -57,7 +57,7 @@ div#dashboard {
 | 
			
		||||
 | 
			
		||||
div#dashboard nav {
 | 
			
		||||
  flex: 1 1 25%;
 | 
			
		||||
  margin-top: 2rem;
 | 
			
		||||
  /* margin-top: 2rem; */
 | 
			
		||||
  min-width: 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -87,6 +87,7 @@ templ base(title string, data CommonData) {
 | 
			
		||||
				if data.Flash != "" {
 | 
			
		||||
					<div class="flash">{ data.Flash }</div>
 | 
			
		||||
				}
 | 
			
		||||
				<h1>{ title }</h1>
 | 
			
		||||
				{ children... }
 | 
			
		||||
			</main>
 | 
			
		||||
			@commonFooter()
 | 
			
		||||
 | 
			
		||||
@ -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, "<h1>")
 | 
			
		||||
		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, "</h1>")
 | 
			
		||||
		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, "</main>")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</main>")
 | 
			
		||||
		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, "</body></html>")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</body></html>")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -111,7 +111,7 @@ templ GuestbookView(title string, data CommonData, website models.Website, guest
 | 
			
		||||
			<body>
 | 
			
		||||
				<main>
 | 
			
		||||
					<div>
 | 
			
		||||
						<h1>Guestbook for { website.Name }</h1>
 | 
			
		||||
						<h1>{ website.Name } Guestbook</h1>
 | 
			
		||||
						{ data.Flash }
 | 
			
		||||
						<form action={ templ.URL(postUrl) } method="post">
 | 
			
		||||
							<input type="hidden" name="csrf_token" value={ data.CSRFToken }/>
 | 
			
		||||
@ -148,62 +148,6 @@ templ settingRadio(selected bool, name, id, value string) {
 | 
			
		||||
	<input type="radio" name={ name } id={ id } value={ value } selected?={ selected }/>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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) {
 | 
			
		||||
		<div id="dashboard">
 | 
			
		||||
			@wSidebar(website)
 | 
			
		||||
			<div>
 | 
			
		||||
				<h1>Guestbook Settings</h1>
 | 
			
		||||
				<form hx-put={ putUrl }>
 | 
			
		||||
					<input type="hidden" name="csrf_token" value={ data.CSRFToken }/>
 | 
			
		||||
					<div>
 | 
			
		||||
						<label>Guestbook Visibility</label>
 | 
			
		||||
						<label for="gb_visible_true">
 | 
			
		||||
							<input type="radio" name="gb_visible" id="gb_visible_true" value="true" checked?={ gb.Settings.IsVisible }/>
 | 
			
		||||
							Public
 | 
			
		||||
						</label>
 | 
			
		||||
						<label for="gb_visible_false">
 | 
			
		||||
							<input type="radio" name="gb_visible" id="gb_visible_false" value="false" checked?={ !gb.Settings.IsVisible }/>
 | 
			
		||||
							Private
 | 
			
		||||
						</label>
 | 
			
		||||
					</div>
 | 
			
		||||
					<div>
 | 
			
		||||
						<label>Guestbook Commenting</label>
 | 
			
		||||
						<select name="gb_commenting" id="gb-commenting">
 | 
			
		||||
							<option value="true" selected?={ gb.Settings.IsCommentingEnabled }>Enabled</option>
 | 
			
		||||
							<option value="1h">Disabled for 1 Hour</option>
 | 
			
		||||
							<option value="4h">Disabled for 4 Hours</option>
 | 
			
		||||
							<option value="8h">Disabled for 8 Hours</option>
 | 
			
		||||
							<option value="24h">Disabled for 1 Day</option>
 | 
			
		||||
							<option value="72h">Disabled for 3 Days</option>
 | 
			
		||||
							<option value="168h">Disabled for 7 Days</option>
 | 
			
		||||
							<option value="false" selected?={ !gb.Settings.IsCommentingEnabled }>Disabled</option>
 | 
			
		||||
						</select>
 | 
			
		||||
						if !website.Guestbook.CanComment() {
 | 
			
		||||
							{{ localtime := gb.Settings.ReenableCommenting.In(data.CurrentUser.Settings.LocalTimezone) }}
 | 
			
		||||
							<label>Commenting re-enabled on <time value={ localtime.Format(time.RFC3339) }>{ localtime.Format("2 January 2006") } at { localtime.Format("3:04PM MST") }</time></label>
 | 
			
		||||
						}
 | 
			
		||||
					</div>
 | 
			
		||||
					<div>
 | 
			
		||||
						<label>Enable Widgets</label>
 | 
			
		||||
						<label for="gb_remote_true">
 | 
			
		||||
							<input type="radio" name="gb_remote" id="gb_remote_true" value="true" checked?={ gb.Settings.AllowRemoteHostAccess }/>
 | 
			
		||||
							Yes
 | 
			
		||||
						</label>
 | 
			
		||||
						<label for="gb_remote_false">
 | 
			
		||||
							<input type="radio" name="gb_remote" id="gb_remote_false" value="false" checked?={ !gb.Settings.AllowRemoteHostAccess }/>
 | 
			
		||||
							No
 | 
			
		||||
						</label>
 | 
			
		||||
					</div>
 | 
			
		||||
					<input type="submit" value="Submit"/>
 | 
			
		||||
				</form>
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ EmbeddableGuestbookCommentForm(data CommonData, w models.Website, f forms.CommentCreateForm) {
 | 
			
		||||
	{{ postUrl := fmt.Sprintf("/websites/%s/guestbook/comments/create?headless=true", shortIdToSlug(w.ShortId)) }}
 | 
			
		||||
	<html>
 | 
			
		||||
@ -223,7 +167,6 @@ templ EmbeddableGuestbookCommentForm(data CommonData, w models.Website, f forms.
 | 
			
		||||
templ AllGuestbooksView(data CommonData, websites []models.Website) {
 | 
			
		||||
	@base("All Guestbooks", data) {
 | 
			
		||||
		<div>
 | 
			
		||||
			<h1>All Guestbooks</h1>
 | 
			
		||||
			<p>
 | 
			
		||||
				This page exists only for testing the service.
 | 
			
		||||
			</p>
 | 
			
		||||
 | 
			
		||||
@ -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, "</title><link href=\"/static/css/classless.min.css\" rel=\"stylesheet\"><script src=\"/static/js/main.js\" defer></script></head><body><main><div><h1>Guestbook for ")
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 40, "</title><link href=\"/static/css/classless.min.css\" rel=\"stylesheet\"><script src=\"/static/js/main.js\" defer></script></head><body><main><div><h1>")
 | 
			
		||||
			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, "</h1>")
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 41, " Guestbook</h1>")
 | 
			
		||||
			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, "<div id=\"dashboard\">")
 | 
			
		||||
		postUrl := fmt.Sprintf("/websites/%s/guestbook/comments/create?headless=true", shortIdToSlug(w.ShortId))
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 62, "<html><head><link href=\"/static/css/classless.min.css\" rel=\"stylesheet\"></head><body>")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
			templ_7745c5c3_Err = wSidebar(website).Render(ctx, templ_7745c5c3_Buffer)
 | 
			
		||||
		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: 158, Col: 15}
 | 
			
		||||
		}
 | 
			
		||||
		_, 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, 63, "<div><h1>Guestbook Settings</h1><form hx-put=\"")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 63, "<form action=\"")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
			var templ_7745c5c3_Var39 string
 | 
			
		||||
			templ_7745c5c3_Var39, templ_7745c5c3_Err = templ.JoinStringErrs(putUrl)
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 159, Col: 25}
 | 
			
		||||
			}
 | 
			
		||||
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var39))
 | 
			
		||||
		var templ_7745c5c3_Var39 templ.SafeURL = templ.URL(postUrl)
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var39)))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "\"><input type=\"hidden\" name=\"csrf_token\" value=\"")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 64, "\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		var templ_7745c5c3_Var40 string
 | 
			
		||||
		templ_7745c5c3_Var40, templ_7745c5c3_Err = templ.JoinStringErrs(data.CSRFToken)
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 160, Col: 66}
 | 
			
		||||
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 160, Col: 65}
 | 
			
		||||
		}
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var40))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, "\"><div><label>Guestbook Visibility</label> <label for=\"gb_visible_true\"><input type=\"radio\" name=\"gb_visible\" id=\"gb_visible_true\" value=\"true\"")
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ_7745c5c3_Err
 | 
			
		||||
			}
 | 
			
		||||
			if gb.Settings.IsVisible {
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, " checked")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "> Public</label> <label for=\"gb_visible_false\"><input type=\"radio\" name=\"gb_visible\" id=\"gb_visible_false\" value=\"false\"")
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ_7745c5c3_Err
 | 
			
		||||
			}
 | 
			
		||||
			if !gb.Settings.IsVisible {
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, " checked")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, "> Private</label></div><div><label>Guestbook Commenting</label> <select name=\"gb_commenting\" id=\"gb-commenting\"><option value=\"true\"")
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ_7745c5c3_Err
 | 
			
		||||
			}
 | 
			
		||||
			if gb.Settings.IsCommentingEnabled {
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, " selected")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, ">Enabled</option> <option value=\"1h\">Disabled for 1 Hour</option> <option value=\"4h\">Disabled for 4 Hours</option> <option value=\"8h\">Disabled for 8 Hours</option> <option value=\"24h\">Disabled for 1 Day</option> <option value=\"72h\">Disabled for 3 Days</option> <option value=\"168h\">Disabled for 7 Days</option> <option value=\"false\"")
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ_7745c5c3_Err
 | 
			
		||||
			}
 | 
			
		||||
			if !gb.Settings.IsCommentingEnabled {
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, " selected")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, ">Disabled</option></select> ")
 | 
			
		||||
			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, "<label>Commenting re-enabled on <time value=\"")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				var templ_7745c5c3_Var41 string
 | 
			
		||||
				templ_7745c5c3_Var41, templ_7745c5c3_Err = templ.JoinStringErrs(localtime.Format(time.RFC3339))
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 186, Col: 83}
 | 
			
		||||
				}
 | 
			
		||||
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var41))
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, "\">")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				var templ_7745c5c3_Var42 string
 | 
			
		||||
				templ_7745c5c3_Var42, templ_7745c5c3_Err = templ.JoinStringErrs(localtime.Format("2 January 2006"))
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 186, Col: 122}
 | 
			
		||||
				}
 | 
			
		||||
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var42))
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, " at ")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				var templ_7745c5c3_Var43 string
 | 
			
		||||
				templ_7745c5c3_Var43, templ_7745c5c3_Err = templ.JoinStringErrs(localtime.Format("3:04PM MST"))
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 186, Col: 160}
 | 
			
		||||
				}
 | 
			
		||||
				_, 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, 77, "</time></label>")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 78, "</div><div><label>Enable Widgets</label> <label for=\"gb_remote_true\"><input type=\"radio\" name=\"gb_remote\" id=\"gb_remote_true\" value=\"true\"")
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ_7745c5c3_Err
 | 
			
		||||
			}
 | 
			
		||||
			if gb.Settings.AllowRemoteHostAccess {
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, " checked")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 80, "> Yes</label> <label for=\"gb_remote_false\"><input type=\"radio\" name=\"gb_remote\" id=\"gb_remote_false\" value=\"false\"")
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ_7745c5c3_Err
 | 
			
		||||
			}
 | 
			
		||||
			if !gb.Settings.AllowRemoteHostAccess {
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 81, " checked")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 82, "> No</label></div><input type=\"submit\" value=\"Submit\"></form></div></div>")
 | 
			
		||||
			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, "<html><head><link href=\"/static/css/classless.min.css\" rel=\"stylesheet\"></head><body>")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		var templ_7745c5c3_Var45 string
 | 
			
		||||
		templ_7745c5c3_Var45, 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}
 | 
			
		||||
		}
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var45))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 84, "<form action=\"")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		var templ_7745c5c3_Var46 templ.SafeURL = templ.URL(postUrl)
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var46)))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 85, "\" method=\"post\"><input type=\"hidden\" name=\"csrf_token\" value=\"")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		var templ_7745c5c3_Var47 string
 | 
			
		||||
		templ_7745c5c3_Var47, templ_7745c5c3_Err = templ.JoinStringErrs(data.CSRFToken)
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 216, Col: 65}
 | 
			
		||||
		}
 | 
			
		||||
		_, 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, 86, "\">")
 | 
			
		||||
		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, "</form></body></html>")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "</form></body></html>")
 | 
			
		||||
		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, "<div><h1>All Guestbooks</h1><p>This page exists only for testing the service.</p><ul>")
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "<div><p>This page exists only for testing the service.</p><ul>")
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ_7745c5c3_Err
 | 
			
		||||
			}
 | 
			
		||||
			for _, w := range websites {
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 89, "<li>")
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 68, "<li>")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				gbUrl := fmt.Sprintf("/websites/%s/guestbook", shortIdToSlug(w.ShortId))
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 90, "<a href=\"")
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 69, "<a href=\"")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				var templ_7745c5c3_Var50 templ.SafeURL = templ.URL(gbUrl)
 | 
			
		||||
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var50)))
 | 
			
		||||
				var templ_7745c5c3_Var43 templ.SafeURL = templ.URL(gbUrl)
 | 
			
		||||
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var43)))
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 91, "\" target=\"_blank\">")
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 70, "\" target=\"_blank\">")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				var templ_7745c5c3_Var51 string
 | 
			
		||||
				templ_7745c5c3_Var51, templ_7745c5c3_Err = templ.JoinStringErrs(w.Name)
 | 
			
		||||
				var templ_7745c5c3_Var44 string
 | 
			
		||||
				templ_7745c5c3_Var44, templ_7745c5c3_Err = templ.JoinStringErrs(w.Name)
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 234, Col: 59}
 | 
			
		||||
					return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 177, Col: 59}
 | 
			
		||||
				}
 | 
			
		||||
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var51))
 | 
			
		||||
				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var44))
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 92, "</a></li>")
 | 
			
		||||
				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 71, "</a></li>")
 | 
			
		||||
				if templ_7745c5c3_Err != nil {
 | 
			
		||||
					return templ_7745c5c3_Err
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 93, "</ul></div>")
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 72, "</ul></div>")
 | 
			
		||||
			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, "<html><head><meta http-equiv=\"refresh\" content=\"")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 73, "<html><head><meta http-equiv=\"refresh\" content=\"")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		var templ_7745c5c3_Var53 string
 | 
			
		||||
		templ_7745c5c3_Var53, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("3; url='%s'", templ.URL(externalUrl(url))))
 | 
			
		||||
		var templ_7745c5c3_Var46 string
 | 
			
		||||
		templ_7745c5c3_Var46, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("3; url='%s'", templ.URL(externalUrl(url))))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 245, Col: 95}
 | 
			
		||||
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 188, Col: 95}
 | 
			
		||||
		}
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var53))
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var46))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 95, "\"></head><body><p>An error occurred while posting comment. ")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 74, "\"></head><body><p>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.</p><p><a href=\"")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 75, ". Redirecting.</p><p><a href=\"")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		var templ_7745c5c3_Var55 templ.SafeURL = templ.URL(url)
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var55)))
 | 
			
		||||
		var templ_7745c5c3_Var48 templ.SafeURL = templ.URL(url)
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var48)))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 97, "\">Redirect</a></p></body></html>")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 76, "\">Redirect</a></p></body></html>")
 | 
			
		||||
		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, "<html><head><meta http-equiv=\"refresh\" content=\"")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 77, "<html><head><meta http-equiv=\"refresh\" content=\"")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		var templ_7745c5c3_Var57 string
 | 
			
		||||
		templ_7745c5c3_Var57, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("3; url='%s'", templ.URL(externalUrl(url))))
 | 
			
		||||
		var templ_7745c5c3_Var50 string
 | 
			
		||||
		templ_7745c5c3_Var50, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("3; url='%s'", templ.URL(externalUrl(url))))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 261, Col: 95}
 | 
			
		||||
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/guestbooks.templ`, Line: 204, Col: 95}
 | 
			
		||||
		}
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var57))
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var50))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 99, "\"></head><body><p>Comment successfully posted. Redirecting.</p><p><a href=\"")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 78, "\"></head><body><p>Comment successfully posted. Redirecting.</p><p><a href=\"")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		var templ_7745c5c3_Var58 templ.SafeURL = templ.URL(url)
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var58)))
 | 
			
		||||
		var templ_7745c5c3_Var51 templ.SafeURL = templ.URL(url)
 | 
			
		||||
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var51)))
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 100, "\">Redirect</a></p></body></html>")
 | 
			
		||||
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 79, "\">Redirect</a></p></body></html>")
 | 
			
		||||
		if templ_7745c5c3_Err != nil {
 | 
			
		||||
			return templ_7745c5c3_Err
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@ -86,7 +86,6 @@ templ UserSettingsView(data CommonData, timezones []string) {
 | 
			
		||||
	{{ user := data.CurrentUser }}
 | 
			
		||||
	@base("User Settings", data) {
 | 
			
		||||
		<div>
 | 
			
		||||
			<h1>User Settings</h1>
 | 
			
		||||
			<form hx-put="/users/settings">
 | 
			
		||||
				<input type="hidden" name="csrf_token" value={ data.CSRFToken }/>
 | 
			
		||||
				<label>Local Timezone</label>
 | 
			
		||||
 | 
			
		||||
@ -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, "<div><h1>User Settings</h1><form hx-put=\"/users/settings\"><input type=\"hidden\" name=\"csrf_token\" value=\"")
 | 
			
		||||
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "<div><form hx-put=\"/users/settings\"><input type=\"hidden\" name=\"csrf_token\" value=\"")
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ_7745c5c3_Err
 | 
			
		||||
			}
 | 
			
		||||
			var templ_7745c5c3_Var22 string
 | 
			
		||||
			templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(data.CSRFToken)
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 91, Col: 65}
 | 
			
		||||
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 90, Col: 65}
 | 
			
		||||
			}
 | 
			
		||||
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22))
 | 
			
		||||
			if templ_7745c5c3_Err != nil {
 | 
			
		||||
@ -470,7 +470,7 @@ func UserSettingsView(data CommonData, timezones []string) templ.Component {
 | 
			
		||||
					var templ_7745c5c3_Var23 string
 | 
			
		||||
					templ_7745c5c3_Var23, templ_7745c5c3_Err = templ.JoinStringErrs(tz)
 | 
			
		||||
					if templ_7745c5c3_Err != nil {
 | 
			
		||||
						return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 96, Col: 25}
 | 
			
		||||
						return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 95, Col: 25}
 | 
			
		||||
					}
 | 
			
		||||
					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var23))
 | 
			
		||||
					if templ_7745c5c3_Err != nil {
 | 
			
		||||
@ -483,7 +483,7 @@ func UserSettingsView(data CommonData, timezones []string) templ.Component {
 | 
			
		||||
					var templ_7745c5c3_Var24 string
 | 
			
		||||
					templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(tz)
 | 
			
		||||
					if templ_7745c5c3_Err != nil {
 | 
			
		||||
						return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 96, Col: 48}
 | 
			
		||||
						return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 95, Col: 48}
 | 
			
		||||
					}
 | 
			
		||||
					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24))
 | 
			
		||||
					if templ_7745c5c3_Err != nil {
 | 
			
		||||
@ -501,7 +501,7 @@ func UserSettingsView(data CommonData, timezones []string) templ.Component {
 | 
			
		||||
					var templ_7745c5c3_Var25 string
 | 
			
		||||
					templ_7745c5c3_Var25, templ_7745c5c3_Err = templ.JoinStringErrs(tz)
 | 
			
		||||
					if templ_7745c5c3_Err != nil {
 | 
			
		||||
						return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 98, Col: 25}
 | 
			
		||||
						return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 97, Col: 25}
 | 
			
		||||
					}
 | 
			
		||||
					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var25))
 | 
			
		||||
					if templ_7745c5c3_Err != nil {
 | 
			
		||||
@ -514,7 +514,7 @@ func UserSettingsView(data CommonData, timezones []string) templ.Component {
 | 
			
		||||
					var templ_7745c5c3_Var26 string
 | 
			
		||||
					templ_7745c5c3_Var26, templ_7745c5c3_Err = templ.JoinStringErrs(tz)
 | 
			
		||||
					if templ_7745c5c3_Err != nil {
 | 
			
		||||
						return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 98, Col: 32}
 | 
			
		||||
						return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/users.templ`, Line: 97, Col: 32}
 | 
			
		||||
					}
 | 
			
		||||
					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var26))
 | 
			
		||||
					if templ_7745c5c3_Err != nil {
 | 
			
		||||
 | 
			
		||||
@ -1,8 +1,11 @@
 | 
			
		||||
package views
 | 
			
		||||
 | 
			
		||||
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))
 | 
			
		||||
@ -13,9 +16,9 @@ templ wSidebar(website models.Website) {
 | 
			
		||||
	{{ gbUrl := wUrl(website) + "/guestbook" }}
 | 
			
		||||
	<nav>
 | 
			
		||||
		<div>
 | 
			
		||||
			<h2>{ website.Name }</h2>
 | 
			
		||||
			<ul>
 | 
			
		||||
				<li><a href={ templ.URL(dashUrl) }>Dashboard</a></li>
 | 
			
		||||
				<li><a href={ templ.URL(dashUrl + "/settings") }>Settings</a></li>
 | 
			
		||||
				<li><a href={ templ.URL(externalUrl(website.Url.String())) } target="_blank">View Website</a></li>
 | 
			
		||||
			</ul>
 | 
			
		||||
			<h3>Guestbook</h3>
 | 
			
		||||
@ -26,11 +29,10 @@ templ wSidebar(website models.Website) {
 | 
			
		||||
				<li><a href={ templ.URL(dashUrl + "/guestbook/comments") }>Manage messages</a></li>
 | 
			
		||||
				<li><a href={ templ.URL(dashUrl + "/guestbook/comments/queue") }>Review message queue</a></li>
 | 
			
		||||
				<li><a href={ templ.URL(dashUrl + "/guestbook/comments/trash") }>Trash</a></li>
 | 
			
		||||
				<li><a href={ templ.URL(dashUrl + "/guestbook/settings") }>Settings</a></li>
 | 
			
		||||
			</ul>
 | 
			
		||||
			<ul>
 | 
			
		||||
				<li><a href={ templ.URL(dashUrl + "/guestbook/themes") }>Themes</a></li>
 | 
			
		||||
				<li><a href={ templ.URL(dashUrl + "/guestbook/customize") }>Custom CSS</a></li>
 | 
			
		||||
				//<li><a href={ templ.URL(dashUrl + "/guestbook/themes") }>Themes</a></li>
 | 
			
		||||
				//<li><a href={ templ.URL(dashUrl + "/guestbook/customize") }>Custom CSS</a></li>
 | 
			
		||||
			</ul>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div>
 | 
			
		||||
@ -48,20 +50,6 @@ templ wSidebar(website models.Website) {
 | 
			
		||||
	</nav>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ displayWebsites(websites []models.Website) {
 | 
			
		||||
	if len(websites) == 0 {
 | 
			
		||||
		<p>No Websites yet. <a href="">Register a website.</a></p>
 | 
			
		||||
	} else {
 | 
			
		||||
		<ul id="websites" hx-get="/websites" hx-trigger="newWebsite from:body" hx-swap="outerHTML">
 | 
			
		||||
			for _, w := range websites {
 | 
			
		||||
				<li>
 | 
			
		||||
					<a href={ templ.URL(wUrl(w) + "/dashboard") }>{ w.Name }</a>
 | 
			
		||||
				</li>
 | 
			
		||||
			}
 | 
			
		||||
		</ul>
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ websiteCreateForm(csrfToken string, form forms.WebsiteCreateForm) {
 | 
			
		||||
	<input type="hidden" name="csrf_token" value={ csrfToken }/>
 | 
			
		||||
	<div>
 | 
			
		||||
@ -95,12 +83,21 @@ templ websiteCreateForm(csrfToken string, form forms.WebsiteCreateForm) {
 | 
			
		||||
 | 
			
		||||
templ WebsiteList(title string, data CommonData, websites []models.Website) {
 | 
			
		||||
	@base(title, data) {
 | 
			
		||||
		<h1>My Websites</h1>
 | 
			
		||||
		<div>
 | 
			
		||||
			<a href="/websites/create">Add Website</a>
 | 
			
		||||
		</div>
 | 
			
		||||
		<div>
 | 
			
		||||
			@displayWebsites(websites)
 | 
			
		||||
			if len(websites) == 0 {
 | 
			
		||||
				<p>No Websites yet. <a href="">Register a website.</a></p>
 | 
			
		||||
			} else {
 | 
			
		||||
				<ul id="websites" hx-get="/websites" hx-trigger="newWebsite from:body" hx-swap="outerHTML">
 | 
			
		||||
					for _, w := range websites {
 | 
			
		||||
						<li>
 | 
			
		||||
							<a href={ templ.URL(wUrl(w) + "/dashboard") }>{ w.Name }</a>
 | 
			
		||||
						</li>
 | 
			
		||||
					}
 | 
			
		||||
				</ul>
 | 
			
		||||
			}
 | 
			
		||||
		</div>
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@ -110,8 +107,7 @@ templ WebsiteDashboard(title string, data CommonData, website models.Website) {
 | 
			
		||||
		<div id="dashboard">
 | 
			
		||||
			@wSidebar(website)
 | 
			
		||||
			<div>
 | 
			
		||||
				<h1>{ website.Name }</h1>
 | 
			
		||||
				<h2>Embed your Guestbook</h2>
 | 
			
		||||
				<h1>Embed your Guestbook</h1>
 | 
			
		||||
				<p>
 | 
			
		||||
					Upload <a href="/static/js/guestbook.js" download>this JavaScript WebComponent</a> to your site and include it in your <code>{ `<head>` }</code> tag.
 | 
			
		||||
				</p>
 | 
			
		||||
@ -152,12 +148,139 @@ templ WebsiteDashboard(title string, data CommonData, website models.Website) {
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ websiteSettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm) {
 | 
			
		||||
	<h3>Website Settings</h3>
 | 
			
		||||
	<div>
 | 
			
		||||
		{{ err, exists := form.FieldErrors["ws_name"] }}
 | 
			
		||||
		<label for="ws_name">Site Name: </label>
 | 
			
		||||
		if exists {
 | 
			
		||||
			<label class="error">{ err }</label>
 | 
			
		||||
		}
 | 
			
		||||
		if form.SiteName != "" {
 | 
			
		||||
			<input type="text" name="ws_name" id="sitename" value={ form.SiteName } required/>
 | 
			
		||||
		} else {
 | 
			
		||||
			<input type="text" name="ws_name" id="sitename" value={ website.Name } required/>
 | 
			
		||||
		}
 | 
			
		||||
	</div>
 | 
			
		||||
	<div>
 | 
			
		||||
		{{ err, exists = form.FieldErrors["ws_url"] }}
 | 
			
		||||
		<label for="ws_url">Site URL: </label>
 | 
			
		||||
		if exists {
 | 
			
		||||
			<label class="error">{ err }</label>
 | 
			
		||||
		}
 | 
			
		||||
		if form.SiteUrl != "" {
 | 
			
		||||
			<input type="text" name="ws_url" id="ws_url" value={ form.SiteUrl } required/>
 | 
			
		||||
		} else {
 | 
			
		||||
			<input type="text" name="ws_url" id="ws_url" value={ website.Url.String() } required/>
 | 
			
		||||
		}
 | 
			
		||||
	</div>
 | 
			
		||||
	<div>
 | 
			
		||||
		{{ err, exists = form.FieldErrors["ws_author"] }}
 | 
			
		||||
		<label for="ws_author">Site Author: </label>
 | 
			
		||||
		if exists {
 | 
			
		||||
			<label class="error">{ err }</label>
 | 
			
		||||
		}
 | 
			
		||||
		if form.AuthorName != "" {
 | 
			
		||||
			<input type="text" name="ws_author" id="authorname" value={ form.AuthorName } required/>
 | 
			
		||||
		} else {
 | 
			
		||||
			<input type="text" name="ws_author" id="authorname" value={ website.AuthorName } required/>
 | 
			
		||||
		}
 | 
			
		||||
	</div>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ guestbookSettingsForm(data CommonData, website models.Website, gb models.Guestbook, form forms.WebsiteSettingsForm) {
 | 
			
		||||
	<h3>Guestbook Settings</h3>
 | 
			
		||||
	<div>
 | 
			
		||||
		<label>Guestbook Visibility</label>
 | 
			
		||||
		<label for="gb_visible_true">
 | 
			
		||||
			<input type="radio" name="gb_visible" id="gb_visible_true" value="true" checked?={ gb.Settings.IsVisible }/>
 | 
			
		||||
			Public
 | 
			
		||||
		</label>
 | 
			
		||||
		<label for="gb_visible_false">
 | 
			
		||||
			<input type="radio" name="gb_visible" id="gb_visible_false" value="false" checked?={ !gb.Settings.IsVisible }/>
 | 
			
		||||
			Private
 | 
			
		||||
		</label>
 | 
			
		||||
	</div>
 | 
			
		||||
	<div>
 | 
			
		||||
		<label>Guestbook Commenting</label>
 | 
			
		||||
		<select name="gb_commenting" id="gb-commenting">
 | 
			
		||||
			<option value="true" selected?={ gb.Settings.IsCommentingEnabled }>Enabled</option>
 | 
			
		||||
			<option value="1h">Disabled for 1 Hour</option>
 | 
			
		||||
			<option value="4h">Disabled for 4 Hours</option>
 | 
			
		||||
			<option value="8h">Disabled for 8 Hours</option>
 | 
			
		||||
			<option value="24h">Disabled for 1 Day</option>
 | 
			
		||||
			<option value="72h">Disabled for 3 Days</option>
 | 
			
		||||
			<option value="168h">Disabled for 7 Days</option>
 | 
			
		||||
			<option value="false" selected?={ !gb.Settings.IsCommentingEnabled }>Disabled</option>
 | 
			
		||||
		</select>
 | 
			
		||||
		if !website.Guestbook.CanComment() {
 | 
			
		||||
			{{ localtime := gb.Settings.ReenableCommenting.In(data.CurrentUser.Settings.LocalTimezone) }}
 | 
			
		||||
			<label>Commenting re-enabled on <time value={ localtime.Format(time.RFC3339) }>{ localtime.Format("2 January 2006") } at { localtime.Format("3:04PM MST") }</time></label>
 | 
			
		||||
		}
 | 
			
		||||
	</div>
 | 
			
		||||
	<div>
 | 
			
		||||
		<label>Enable Widgets</label>
 | 
			
		||||
		<label for="gb_remote_true">
 | 
			
		||||
			<input type="radio" name="gb_remote" id="gb_remote_true" value="true" checked?={ gb.Settings.AllowRemoteHostAccess }/>
 | 
			
		||||
			Yes
 | 
			
		||||
		</label>
 | 
			
		||||
		<label for="gb_remote_false">
 | 
			
		||||
			<input type="radio" name="gb_remote" id="gb_remote_false" value="false" checked?={ !gb.Settings.AllowRemoteHostAccess }/>
 | 
			
		||||
			No
 | 
			
		||||
		</label>
 | 
			
		||||
	</div>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ SettingsForm(data CommonData, website models.Website, form forms.WebsiteSettingsForm, msg string) {
 | 
			
		||||
	{{ putUrl := fmt.Sprintf("/websites/%s/settings", shortIdToSlug(website.ShortId)) }}
 | 
			
		||||
	{{ gb := website.Guestbook }}
 | 
			
		||||
	<form hx-put={ putUrl } hx-swap="outerHTML">
 | 
			
		||||
		<p>
 | 
			
		||||
			{ msg }
 | 
			
		||||
		</p>
 | 
			
		||||
		<input type="hidden" name="csrf_token" value={ data.CSRFToken }/>
 | 
			
		||||
		<div id="settings_form">
 | 
			
		||||
			@websiteSettingsForm(data, website, form)
 | 
			
		||||
			@guestbookSettingsForm(data, website, gb, form)
 | 
			
		||||
		</div>
 | 
			
		||||
		<input type="submit" value="Submit"/>
 | 
			
		||||
	</form>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ DeleteForm(data CommonData, website models.Website, form forms.WebsiteDeleteForm) {
 | 
			
		||||
	{{ putUrl := fmt.Sprintf("/websites/%s", shortIdToSlug(website.ShortId)) }}
 | 
			
		||||
	<form hx-put={ putUrl } hx-swap="outerHTML">
 | 
			
		||||
		<input type="hidden" name="csrf_token" value={ data.CSRFToken }/>
 | 
			
		||||
		<h3>Delete Website</h3>
 | 
			
		||||
		<p>Deleting a website is permanent. Be absolutely sure before proceeding.</p>
 | 
			
		||||
		{{ err, exists := form.FieldErrors["delete"] }}
 | 
			
		||||
		<label for="delete">Type your site name in the form.</label>
 | 
			
		||||
		if exists {
 | 
			
		||||
			<label class="error">{ err }</label>
 | 
			
		||||
		}
 | 
			
		||||
		<input type="text" name="delete" id="delete" required/>
 | 
			
		||||
		<input type="submit" value="Delete" class="danger"/>
 | 
			
		||||
	</form>
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ WebsiteDashboardSettings(data CommonData, website models.Website, form forms.WebsiteSettingsForm) {
 | 
			
		||||
	{{ title := fmt.Sprintf("%s - Settings", website.Name) }}
 | 
			
		||||
	@base(title, data) {
 | 
			
		||||
		<div id="dashboard">
 | 
			
		||||
			@wSidebar(website)
 | 
			
		||||
			<div>
 | 
			
		||||
				@SettingsForm(data, website, form, "")
 | 
			
		||||
				@DeleteForm(data, website, forms.WebsiteDeleteForm{})
 | 
			
		||||
			</div>
 | 
			
		||||
		</div>
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
templ WebsiteDashboardComingSoon(title string, data CommonData, website models.Website) {
 | 
			
		||||
	@base(title, data) {
 | 
			
		||||
		<div id="dashboard">
 | 
			
		||||
			@wSidebar(website)
 | 
			
		||||
			<div>
 | 
			
		||||
				<h1>{ website.Name }</h1>
 | 
			
		||||
				<p>
 | 
			
		||||
					Coming Soon
 | 
			
		||||
				</p>
 | 
			
		||||
 | 
			
		||||
@ -1,7 +0,0 @@
 | 
			
		||||
package views
 | 
			
		||||
 | 
			
		||||
import "git.32bit.cafe/32bitcafe/guestbook/internal/models"
 | 
			
		||||
 | 
			
		||||
templ HxWebsiteList(websites []models.Website) {
 | 
			
		||||
	@displayWebsites(websites)
 | 
			
		||||
}
 | 
			
		||||
@ -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
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user