From cb1a9b84338cf95c90b134997d1ae2a55ada179f Mon Sep 17 00:00:00 2001 From: Leo Audibert Date: Sat, 28 Sep 2024 12:09:52 -0700 Subject: [PATCH 1/3] Create new router package --- cmd/web/main.go | 2 +- cmd/worker/main.go | 2 +- pkg/routing/router/routenames.go | 1 + pkg/{ => routing}/routes/about.go | 0 pkg/{ => routing}/routes/about_test.go | 0 pkg/{ => routing}/routes/clear_site_cookie.go | 0 pkg/{ => routing}/routes/contact.go | 0 pkg/{ => routing}/routes/delete_account.go | 0 pkg/{ => routing}/routes/docs.go | 0 pkg/{ => routing}/routes/email_subscribe.go | 0 pkg/{ => routing}/routes/error.go | 0 pkg/{ => routing}/routes/forgot_password.go | 0 pkg/{ => routing}/routes/healthcheck.go | 0 pkg/{ => routing}/routes/helpers.go | 0 pkg/{ => routing}/routes/home.go | 0 pkg/{ => routing}/routes/home_feed.go | 0 pkg/{ => routing}/routes/install_app.go | 0 pkg/{ => routing}/routes/landing.go | 0 pkg/{ => routing}/routes/login.go | 0 pkg/{ => routing}/routes/logout.go | 0 pkg/{ => routing}/routes/notifications.go | 0 pkg/{ => routing}/routes/payments.go | 0 pkg/{ => routing}/routes/preferences.go | 0 pkg/{ => routing}/routes/privacy.go | 0 pkg/{ => routing}/routes/profile.go | 0 pkg/{ => routing}/routes/profile_photo.go | 0 pkg/{ => routing}/routes/push_notifs.go | 0 pkg/{ => routing}/routes/realtime.go | 0 pkg/{ => routing}/routes/register.go | 0 pkg/{ => routing}/routes/register_test.go | 0 pkg/{ => routing}/routes/reset_password.go | 0 pkg/{ => routing}/routes/router.go | 0 pkg/{ => routing}/routes/routes_test.go | 0 pkg/{ => routing}/routes/upload_photo.go | 0 pkg/{ => routing}/routes/verify_email.go | 0 pkg/{ => routing}/routes/verify_email_subscription.go | 0 static/styles_bundle.css | 8 ++++++++ 37 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 pkg/routing/router/routenames.go rename pkg/{ => routing}/routes/about.go (100%) rename pkg/{ => routing}/routes/about_test.go (100%) rename pkg/{ => routing}/routes/clear_site_cookie.go (100%) rename pkg/{ => routing}/routes/contact.go (100%) rename pkg/{ => routing}/routes/delete_account.go (100%) rename pkg/{ => routing}/routes/docs.go (100%) rename pkg/{ => routing}/routes/email_subscribe.go (100%) rename pkg/{ => routing}/routes/error.go (100%) rename pkg/{ => routing}/routes/forgot_password.go (100%) rename pkg/{ => routing}/routes/healthcheck.go (100%) rename pkg/{ => routing}/routes/helpers.go (100%) rename pkg/{ => routing}/routes/home.go (100%) rename pkg/{ => routing}/routes/home_feed.go (100%) rename pkg/{ => routing}/routes/install_app.go (100%) rename pkg/{ => routing}/routes/landing.go (100%) rename pkg/{ => routing}/routes/login.go (100%) rename pkg/{ => routing}/routes/logout.go (100%) rename pkg/{ => routing}/routes/notifications.go (100%) rename pkg/{ => routing}/routes/payments.go (100%) rename pkg/{ => routing}/routes/preferences.go (100%) rename pkg/{ => routing}/routes/privacy.go (100%) rename pkg/{ => routing}/routes/profile.go (100%) rename pkg/{ => routing}/routes/profile_photo.go (100%) rename pkg/{ => routing}/routes/push_notifs.go (100%) rename pkg/{ => routing}/routes/realtime.go (100%) rename pkg/{ => routing}/routes/register.go (100%) rename pkg/{ => routing}/routes/register_test.go (100%) rename pkg/{ => routing}/routes/reset_password.go (100%) rename pkg/{ => routing}/routes/router.go (100%) rename pkg/{ => routing}/routes/routes_test.go (100%) rename pkg/{ => routing}/routes/upload_photo.go (100%) rename pkg/{ => routing}/routes/verify_email.go (100%) rename pkg/{ => routing}/routes/verify_email_subscription.go (100%) diff --git a/cmd/web/main.go b/cmd/web/main.go index 20cc222..70b0e21 100644 --- a/cmd/web/main.go +++ b/cmd/web/main.go @@ -10,7 +10,7 @@ import ( "os/signal" "time" - "github.com/mikestefanello/pagoda/pkg/routes" + "github.com/mikestefanello/pagoda/pkg/routing/routes" "github.com/mikestefanello/pagoda/pkg/services" ) diff --git a/cmd/worker/main.go b/cmd/worker/main.go index 3985c46..64c77ff 100644 --- a/cmd/worker/main.go +++ b/cmd/worker/main.go @@ -10,7 +10,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" storagerepo "github.com/mikestefanello/pagoda/pkg/repos/storage" "github.com/mikestefanello/pagoda/pkg/repos/subscriptions" - "github.com/mikestefanello/pagoda/pkg/routes" + "github.com/mikestefanello/pagoda/pkg/routing/routes" "github.com/mikestefanello/pagoda/pkg/services" "github.com/mikestefanello/pagoda/pkg/tasks" ) diff --git a/pkg/routing/router/routenames.go b/pkg/routing/router/routenames.go new file mode 100644 index 0000000..7ef135b --- /dev/null +++ b/pkg/routing/router/routenames.go @@ -0,0 +1 @@ +package router diff --git a/pkg/routes/about.go b/pkg/routing/routes/about.go similarity index 100% rename from pkg/routes/about.go rename to pkg/routing/routes/about.go diff --git a/pkg/routes/about_test.go b/pkg/routing/routes/about_test.go similarity index 100% rename from pkg/routes/about_test.go rename to pkg/routing/routes/about_test.go diff --git a/pkg/routes/clear_site_cookie.go b/pkg/routing/routes/clear_site_cookie.go similarity index 100% rename from pkg/routes/clear_site_cookie.go rename to pkg/routing/routes/clear_site_cookie.go diff --git a/pkg/routes/contact.go b/pkg/routing/routes/contact.go similarity index 100% rename from pkg/routes/contact.go rename to pkg/routing/routes/contact.go diff --git a/pkg/routes/delete_account.go b/pkg/routing/routes/delete_account.go similarity index 100% rename from pkg/routes/delete_account.go rename to pkg/routing/routes/delete_account.go diff --git a/pkg/routes/docs.go b/pkg/routing/routes/docs.go similarity index 100% rename from pkg/routes/docs.go rename to pkg/routing/routes/docs.go diff --git a/pkg/routes/email_subscribe.go b/pkg/routing/routes/email_subscribe.go similarity index 100% rename from pkg/routes/email_subscribe.go rename to pkg/routing/routes/email_subscribe.go diff --git a/pkg/routes/error.go b/pkg/routing/routes/error.go similarity index 100% rename from pkg/routes/error.go rename to pkg/routing/routes/error.go diff --git a/pkg/routes/forgot_password.go b/pkg/routing/routes/forgot_password.go similarity index 100% rename from pkg/routes/forgot_password.go rename to pkg/routing/routes/forgot_password.go diff --git a/pkg/routes/healthcheck.go b/pkg/routing/routes/healthcheck.go similarity index 100% rename from pkg/routes/healthcheck.go rename to pkg/routing/routes/healthcheck.go diff --git a/pkg/routes/helpers.go b/pkg/routing/routes/helpers.go similarity index 100% rename from pkg/routes/helpers.go rename to pkg/routing/routes/helpers.go diff --git a/pkg/routes/home.go b/pkg/routing/routes/home.go similarity index 100% rename from pkg/routes/home.go rename to pkg/routing/routes/home.go diff --git a/pkg/routes/home_feed.go b/pkg/routing/routes/home_feed.go similarity index 100% rename from pkg/routes/home_feed.go rename to pkg/routing/routes/home_feed.go diff --git a/pkg/routes/install_app.go b/pkg/routing/routes/install_app.go similarity index 100% rename from pkg/routes/install_app.go rename to pkg/routing/routes/install_app.go diff --git a/pkg/routes/landing.go b/pkg/routing/routes/landing.go similarity index 100% rename from pkg/routes/landing.go rename to pkg/routing/routes/landing.go diff --git a/pkg/routes/login.go b/pkg/routing/routes/login.go similarity index 100% rename from pkg/routes/login.go rename to pkg/routing/routes/login.go diff --git a/pkg/routes/logout.go b/pkg/routing/routes/logout.go similarity index 100% rename from pkg/routes/logout.go rename to pkg/routing/routes/logout.go diff --git a/pkg/routes/notifications.go b/pkg/routing/routes/notifications.go similarity index 100% rename from pkg/routes/notifications.go rename to pkg/routing/routes/notifications.go diff --git a/pkg/routes/payments.go b/pkg/routing/routes/payments.go similarity index 100% rename from pkg/routes/payments.go rename to pkg/routing/routes/payments.go diff --git a/pkg/routes/preferences.go b/pkg/routing/routes/preferences.go similarity index 100% rename from pkg/routes/preferences.go rename to pkg/routing/routes/preferences.go diff --git a/pkg/routes/privacy.go b/pkg/routing/routes/privacy.go similarity index 100% rename from pkg/routes/privacy.go rename to pkg/routing/routes/privacy.go diff --git a/pkg/routes/profile.go b/pkg/routing/routes/profile.go similarity index 100% rename from pkg/routes/profile.go rename to pkg/routing/routes/profile.go diff --git a/pkg/routes/profile_photo.go b/pkg/routing/routes/profile_photo.go similarity index 100% rename from pkg/routes/profile_photo.go rename to pkg/routing/routes/profile_photo.go diff --git a/pkg/routes/push_notifs.go b/pkg/routing/routes/push_notifs.go similarity index 100% rename from pkg/routes/push_notifs.go rename to pkg/routing/routes/push_notifs.go diff --git a/pkg/routes/realtime.go b/pkg/routing/routes/realtime.go similarity index 100% rename from pkg/routes/realtime.go rename to pkg/routing/routes/realtime.go diff --git a/pkg/routes/register.go b/pkg/routing/routes/register.go similarity index 100% rename from pkg/routes/register.go rename to pkg/routing/routes/register.go diff --git a/pkg/routes/register_test.go b/pkg/routing/routes/register_test.go similarity index 100% rename from pkg/routes/register_test.go rename to pkg/routing/routes/register_test.go diff --git a/pkg/routes/reset_password.go b/pkg/routing/routes/reset_password.go similarity index 100% rename from pkg/routes/reset_password.go rename to pkg/routing/routes/reset_password.go diff --git a/pkg/routes/router.go b/pkg/routing/routes/router.go similarity index 100% rename from pkg/routes/router.go rename to pkg/routing/routes/router.go diff --git a/pkg/routes/routes_test.go b/pkg/routing/routes/routes_test.go similarity index 100% rename from pkg/routes/routes_test.go rename to pkg/routing/routes/routes_test.go diff --git a/pkg/routes/upload_photo.go b/pkg/routing/routes/upload_photo.go similarity index 100% rename from pkg/routes/upload_photo.go rename to pkg/routing/routes/upload_photo.go diff --git a/pkg/routes/verify_email.go b/pkg/routing/routes/verify_email.go similarity index 100% rename from pkg/routes/verify_email.go rename to pkg/routing/routes/verify_email.go diff --git a/pkg/routes/verify_email_subscription.go b/pkg/routing/routes/verify_email_subscription.go similarity index 100% rename from pkg/routes/verify_email_subscription.go rename to pkg/routing/routes/verify_email_subscription.go diff --git a/static/styles_bundle.css b/static/styles_bundle.css index e7bd0d6..f387ae4 100644 --- a/static/styles_bundle.css +++ b/static/styles_bundle.css @@ -5828,6 +5828,14 @@ details.collapse summary::-webkit-details-marker{ font-weight: 600; } +.uppercase{ + text-transform: uppercase; +} + +.capitalize{ + text-transform: capitalize; +} + .leading-5{ line-height: 1.25rem; } From 297224db723115c5dab0bee50c37e21e8abe3070 Mon Sep 17 00:00:00 2001 From: Leo Audibert Date: Sun, 29 Sep 2024 11:25:30 -0700 Subject: [PATCH 2/3] No more errors, routenames moved --- pkg/routing/routenames/routenames.go | 73 ++++++++++ pkg/routing/router/routenames.go | 1 - pkg/routing/routes/about_test.go | 3 +- pkg/routing/routes/delete_account.go | 3 +- pkg/routing/routes/forgot_password.go | 3 +- pkg/routing/routes/login.go | 5 +- pkg/routing/routes/logout.go | 11 +- pkg/routing/routes/notifications.go | 68 +++++---- pkg/routing/routes/payments.go | 9 +- pkg/routing/routes/preferences.go | 17 +-- pkg/routing/routes/push_notifs.go | 13 +- pkg/routing/routes/realtime.go | 14 +- pkg/routing/routes/register.go | 16 +-- pkg/routing/routes/reset_password.go | 3 +- pkg/routing/routes/router.go | 190 ++++++++------------------ pkg/routing/routes/verify_email.go | 20 +-- 16 files changed, 242 insertions(+), 207 deletions(-) create mode 100644 pkg/routing/routenames/routenames.go delete mode 100644 pkg/routing/router/routenames.go diff --git a/pkg/routing/routenames/routenames.go b/pkg/routing/routenames/routenames.go new file mode 100644 index 0000000..5150afb --- /dev/null +++ b/pkg/routing/routenames/routenames.go @@ -0,0 +1,73 @@ +package routeNames + +const ( + RouteNameForgotPassword = "forgot_password" + RouteNameForgotPasswordSubmit = "forgot_password.submit" + RouteNameLogin = "login" + RouteNameLoginSubmit = "login.submit" + RouteNameLogout = "logout" + RouteNameRegister = "register" + RouteNameRegisterSubmit = "register.post" // TODO: rename to "register.submit" as was done in pagoda + RouteNameResetPassword = "reset_password" + RouteNameResetPasswordSubmit = "reset_password.post" // TODO: rename to "register.submit" as was done in pagoda + RouteNameVerifyEmail = "verify_email" + RouteNameContact = "contact" + RouteNameContactSubmit = "contact.submit" + RouteNameAboutUs = "about" + RouteNameLandingPage = "landing_page" + RouteNameSearch = "search" + RouteNamePreferences = "preferences" + RouteNameGetPhone = "phone.get" + RouteNameUpdatePhoneNum = "phone.save" + RouteNameGetDisplayName = "display_name.get" + RouteNameUpdateDisplayName = "display_name.save" + RouteNameGetPhoneVerification = "phone.verification" + RouteNameSubmitPhoneVerification = "phone.verification.submit" + RouteNameDeleteAccountPage = "delete_account.page" + RouteNameDeleteAccountRequest = "delete_account.request" + RouteNamePrivacyPolicy = "privacy_policy" + + RouteNameHomeFeed = "home_feed" + RouteNameGetHomeFeedButtons = "home_feed.buttons" + RouteNameGetHomeFeedStats = "home_feed.stats" + RouteNameSearchQuestion = "home_feed.search_question" + + RouteNameGetMatch = "meet.get_match" + RouteNameRateMatch = "meet.rate_match" + RouteNameMatchMadeInHeaven = "meet.match_made_in_heaven" + RouteNameProfile = "profile" + RouteNameProfileCalendarHeatmap = "profile.calendar_heatmap" + RouteNameInstallApp = "install_app" + + RouteNameMarkNotificationsAsRead = "markNormalNotificationRead" + RouteNameMarkAllNotificationsAsRead = "normalNotificationsMarkAllAsRead" + + RouteNameRealtime = "realtime" + + RouteNameFinishOnboarding = "finish_onboarding" + RouteNameGetGeolocationComponent = "geolocation" + RouteNameUpdateGeolocation = "geolocation.post" + RouteNameGetBio = "profileBio.get" + RouteNameUpdateBio = "profileBio.post" + RouteNameUpdateSelfGender = "profileGender.post" + RouteNameUpdateInterestedInGenders = "profileInterestedGenders.post" + RouteNameUpdateMinAgeInterestedIn = "profileMinAgeInterestedIn.post" + RouteNameUpdateMaxAgeInterestedIn = "profileMaxAgeInterestedIn.post" + + RouteNameGetPushSubscriptions = "push_subscriptions.get" + RouteNameRegisterSubscription = "notification_subscriptions.register" + RouteNameDeleteSubscription = "notification_subscriptions.delete" + RouteNameDeleteEmailSubscriptionWithToken = "email_subscriptions.delete_with_token" + + RouteNamePaymentProcessorGetPublicKey = "payment_processor.get_public_key" + RouteNameCreateCheckoutSession = "stripe.create_checkout_session" + RouteNameCreatePortalSession = "stripe.create_portal_session" + RouteNamePaymentProcessorWebhook = "stripe.webhook" + RouteNamePricingPage = "pricing_page" + RouteNamePaymentProcessorSuccess = "stripe.success" + + RouteNameDocs = "docs" + RouteNameDocsGettingStarted = "docs.getting_started" + RouteNameDocsGuidedTour = "docs.guided_tour" + RouteNameDocsArchitecture = "docs.architecture" +) diff --git a/pkg/routing/router/routenames.go b/pkg/routing/router/routenames.go deleted file mode 100644 index 7ef135b..0000000 --- a/pkg/routing/router/routenames.go +++ /dev/null @@ -1 +0,0 @@ -package router diff --git a/pkg/routing/routes/about_test.go b/pkg/routing/routes/about_test.go index ec41743..5b2e529 100644 --- a/pkg/routing/routes/about_test.go +++ b/pkg/routing/routes/about_test.go @@ -4,6 +4,7 @@ import ( "net/http" "testing" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/stretchr/testify/assert" ) @@ -13,7 +14,7 @@ func TestAbout_Get(t *testing.T) { t.Skip("Skipping TestAbout_Get for now") doc := request(t). - setRoute(routeNameAboutUs). + setRoute(routeNames.RouteNameAboutUs). get(). assertStatusCode(http.StatusOK). toDoc() diff --git a/pkg/routing/routes/delete_account.go b/pkg/routing/routes/delete_account.go index 21c5079..8e8e2d7 100644 --- a/pkg/routing/routes/delete_account.go +++ b/pkg/routing/routes/delete_account.go @@ -7,6 +7,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" "github.com/mikestefanello/pagoda/pkg/repos/subscriptions" @@ -78,5 +79,5 @@ func (c *deleteAccount) DeleteAccountRequest(ctx echo.Context) error { } else { msg.Danger(ctx, "An error occurred. Please try again.") } - return c.ctr.Redirect(ctx, routeNameLandingPage) + return c.ctr.Redirect(ctx, routeNames.RouteNameLandingPage) } diff --git a/pkg/routing/routes/forgot_password.go b/pkg/routing/routes/forgot_password.go index f5647ad..0d1ab6a 100644 --- a/pkg/routing/routes/forgot_password.go +++ b/pkg/routing/routes/forgot_password.go @@ -9,6 +9,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/context" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates" @@ -94,7 +95,7 @@ func (c *forgotPassword) Post(ctx echo.Context) error { ctx.Logger().Infof("generated password reset token for user %d", u.ID) // Email the user - url := ctx.Echo().Reverse(routeNameResetPassword, u.ID, pt.ID, token) + url := ctx.Echo().Reverse(routeNames.RouteNameResetPassword, u.ID, pt.ID, token) err = c.sendPasswordResetEmail(ctx, u.Name, u.Email, url) if err != nil { diff --git a/pkg/routing/routes/login.go b/pkg/routing/routes/login.go index 6cb500d..f0d6949 100644 --- a/pkg/routing/routes/login.go +++ b/pkg/routing/routes/login.go @@ -9,6 +9,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/context" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" "github.com/mikestefanello/pagoda/pkg/types" @@ -118,10 +119,10 @@ func (c *login) Post(ctx echo.Context) error { profile := usr.QueryProfile().FirstX(ctx.Request().Context()) if !profilerepo.IsProfileFullyOnboarded(profile) { - return c.ctr.Redirect(ctx, routeNamePreferences) + return c.ctr.Redirect(ctx, routeNames.RouteNamePreferences) } - return c.ctr.Redirect(ctx, routeNameHomeFeed) + return c.ctr.Redirect(ctx, routeNames.RouteNameHomeFeed) } // redirectAfterLogin redirects a now logged-in user to a previously requested page. diff --git a/pkg/routing/routes/logout.go b/pkg/routing/routes/logout.go index 6d2e23d..c31e11d 100644 --- a/pkg/routing/routes/logout.go +++ b/pkg/routing/routes/logout.go @@ -3,19 +3,24 @@ package routes import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/labstack/echo/v4" ) type logout struct { - controller.Controller + ctr controller.Controller +} + +func NewLogoutRoute(ctr controller.Controller) *logout { + return &logout{ctr: ctr} } func (l *logout) Get(c echo.Context) error { - if err := l.Container.Auth.Logout(c); err == nil { + if err := l.ctr.Container.Auth.Logout(c); err == nil { } else { msg.Danger(c, "An error occurred. Please try again.") } - return l.Redirect(c, routeNameLandingPage) + return l.ctr.Redirect(c, routeNames.RouteNameLandingPage) } diff --git a/pkg/routing/routes/notifications.go b/pkg/routing/routes/notifications.go index c6125bd..9e90715 100644 --- a/pkg/routing/routes/notifications.go +++ b/pkg/routing/routes/notifications.go @@ -24,35 +24,25 @@ import ( const NOTIFICATION_QUERY_PARAM = "notif" type ( - convosNotificationsCount struct { - controller.Controller - profileRepo profilerepo.ProfileRepo - } - normalNotificationsCount struct { - controller.Controller + ctr controller.Controller profileRepo profilerepo.ProfileRepo } normalNotifications struct { - controller.Controller + ctr controller.Controller notifierRepo *notifierrepo.NotifierRepo } ) -func (c *convosNotificationsCount) Get(ctx echo.Context) error { - // usr := ctx.Get(context.AuthenticatedUserKey).(*ent.User) - // profile := usr.QueryProfile().FirstX(ctx.Request().Context()) - - // num, err := c.profileRepo.GetCountOfUnseenConvosItemsOfFriends(ctx.Request().Context(), profile.ID, nil) - // if err != nil { - // return err - // } - num := 1 // Determine a function that will derive this number - - htmlResponse := fmt.Sprintf("%d", num) - - return ctx.String(http.StatusOK, htmlResponse) +func NewNormalNotificationsCountRoute( + ctr controller.Controller, + profileRepo profilerepo.ProfileRepo, +) *normalNotificationsCount { + return &normalNotificationsCount{ + ctr: ctr, + profileRepo: profileRepo, + } } func (c *normalNotificationsCount) Get(ctx echo.Context) error { @@ -74,6 +64,16 @@ func (c *normalNotificationsCount) Get(ctx echo.Context) error { return ctx.String(http.StatusOK, htmlResponse) } +func NewNormalNotificationsRoute( + ctr controller.Controller, + notifierRepo *notifierrepo.NotifierRepo, +) *normalNotifications { + return &normalNotifications{ + ctr: ctr, + notifierRepo: notifierRepo, + } +} + func (n *normalNotifications) Get(ctx echo.Context) error { timestampParam := ctx.QueryParam("timestamp") var timestamp *time.Time @@ -98,7 +98,7 @@ func (n *normalNotifications) Get(ctx echo.Context) error { usr := ctx.Get(context.AuthenticatedUserKey).(*ent.User) profile := usr.QueryProfile().FirstX(ctx.Request().Context()) - notifications, err := n.notifierRepo.GetNotifications(ctx.Request().Context(), profile.ID, false, timestamp, &n.Container.Config.App.PageSize) + notifications, err := n.notifierRepo.GetNotifications(ctx.Request().Context(), profile.ID, false, timestamp, &n.ctr.Container.Config.App.PageSize) if err != nil { return err } @@ -130,7 +130,7 @@ func (n *normalNotifications) Get(ctx echo.Context) error { NextPageURL: nextPageURL, } - return n.RenderPage(ctx, page) + return n.ctr.RenderPage(ctx, page) } func (n *normalNotifications) MarkAllAsRead(ctx echo.Context) error { @@ -165,10 +165,19 @@ func (n *normalNotifications) Delete(ctx echo.Context) error { } type markNormalNotificationRead struct { - controller.Controller + ctr controller.Controller notifierRepo *notifierrepo.NotifierRepo } +func NewMarkNormalNotificationReadRoute( + ctr controller.Controller, notifierRepo *notifierrepo.NotifierRepo, +) *markNormalNotificationRead { + return &markNormalNotificationRead{ + ctr: ctr, + notifierRepo: notifierRepo, + } +} + func (c *markNormalNotificationRead) Post(ctx echo.Context) error { notifIDStr := ctx.Param("notification_id") @@ -190,10 +199,19 @@ func (c *markNormalNotificationRead) Post(ctx echo.Context) error { } type markNormalNotificationUnread struct { - controller.Controller + ctr controller.Controller notifierRepo *notifierrepo.NotifierRepo } +func NewMarkNormalNotificationUnreadRoute( + ctr controller.Controller, notifierRepo *notifierrepo.NotifierRepo, +) *markNormalNotificationUnread { + return &markNormalNotificationUnread{ + ctr: ctr, + notifierRepo: notifierRepo, + } +} + type SeenEventRequest struct { ID int `form:"id" validate:"required"` } @@ -215,5 +233,5 @@ func (c *markNormalNotificationUnread) Post(ctx echo.Context) error { return err } - return c.Redirect(ctx, "normalNotifications") + return c.ctr.Redirect(ctx, "normalNotifications") } diff --git a/pkg/routing/routes/payments.go b/pkg/routing/routes/payments.go index 11afb46..b3e6b48 100644 --- a/pkg/routing/routes/payments.go +++ b/pkg/routing/routes/payments.go @@ -13,6 +13,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" "github.com/mikestefanello/pagoda/pkg/repos/subscriptions" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates" "github.com/mikestefanello/pagoda/templates/layouts" @@ -65,9 +66,9 @@ func (p *paymentsRoute) CreateCheckoutSession(ctx echo.Context) error { if form.Submission.HasErrors() { return p.PricingPage(ctx) } - successURL := ctx.Echo().Reverse(routeNamePaymentProcessorSuccess) + successURL := ctx.Echo().Reverse(routeNames.RouteNamePaymentProcessorSuccess) fullSuccessUrl := fmt.Sprintf("%s%s", p.ctr.Container.Config.HTTP.Domain, successURL) - cancelURL := ctx.Echo().Reverse(routeNamePreferences) + cancelURL := ctx.Echo().Reverse(routeNames.RouteNamePreferences) fullCancelUrl := fmt.Sprintf("%s%s", p.ctr.Container.Config.HTTP.Domain, cancelURL) usr := ctx.Get(internalContext.AuthenticatedUserKey).(*ent.User) @@ -115,7 +116,7 @@ func (p *paymentsRoute) CreatePortalSession(ctx echo.Context) error { usr := ctx.Get(internalContext.AuthenticatedUserKey).(*ent.User) profile := usr.QueryProfile().FirstX(ctx.Request().Context()) - returnURL := ctx.Echo().Reverse(routeNamePreferences) + returnURL := ctx.Echo().Reverse(routeNames.RouteNamePreferences) fullReturnsUrl := fmt.Sprintf("%s%s", p.ctr.Container.Config.HTTP.Domain, returnURL) // Authenticate your user. @@ -237,7 +238,7 @@ func (p *paymentsRoute) HandleWebhook(c echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError) } - fullURL := c.Echo().Reverse(routeNamePreferences) + fullURL := c.Echo().Reverse(routeNames.RouteNamePreferences) err = p.ctr.Container.Notifier.PublishNotification( c.Request().Context(), domain.Notification{ diff --git a/pkg/routing/routes/preferences.go b/pkg/routing/routes/preferences.go index d0887e6..40c4d27 100644 --- a/pkg/routing/routes/preferences.go +++ b/pkg/routing/routes/preferences.go @@ -11,6 +11,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/repos/notifierrepo" "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" @@ -141,31 +142,31 @@ func (g *preferences) Get(ctx echo.Context) error { addPushSubscriptionEndpoint := fmt.Sprintf("%s%s", g.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameRegisterSubscription, domain.NotificationPlatformPush.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameRegisterSubscription, domain.NotificationPlatformPush.Value)) + "?csrf=" + page.CSRF deletePushSubscriptionEndpoint := fmt.Sprintf("%s%s", g.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameDeleteSubscription, domain.NotificationPlatformPush.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameDeleteSubscription, domain.NotificationPlatformPush.Value)) + "?csrf=" + page.CSRF addFCMPushSubscriptionEndpoint := fmt.Sprintf("%s%s", g.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameRegisterSubscription, domain.NotificationPlatformFCMPush.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameRegisterSubscription, domain.NotificationPlatformFCMPush.Value)) + "?csrf=" + page.CSRF deleteFCMPushSubscriptionEndpoint := fmt.Sprintf("%s%s", g.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameDeleteSubscription, domain.NotificationPlatformFCMPush.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameDeleteSubscription, domain.NotificationPlatformFCMPush.Value)) + "?csrf=" + page.CSRF addEmailSubscriptionEndpoint := fmt.Sprintf("%s%s", g.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameRegisterSubscription, domain.NotificationPlatformEmail.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameRegisterSubscription, domain.NotificationPlatformEmail.Value)) + "?csrf=" + page.CSRF deleteEmailSubscriptionEndpoint := fmt.Sprintf("%s%s", g.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameDeleteSubscription, domain.NotificationPlatformEmail.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameDeleteSubscription, domain.NotificationPlatformEmail.Value)) + "?csrf=" + page.CSRF addSmsSubscriptionEndpoint := fmt.Sprintf("%s%s", g.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameRegisterSubscription, domain.NotificationPlatformSMS.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameRegisterSubscription, domain.NotificationPlatformSMS.Value)) + "?csrf=" + page.CSRF deleteSmsSubscriptionEndpoint := fmt.Sprintf("%s%s", g.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameDeleteSubscription, domain.NotificationPlatformSMS.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameDeleteSubscription, domain.NotificationPlatformSMS.Value)) + "?csrf=" + page.CSRF permissions, err := g.notificationSendPermissionRepo.GetPermissions(ctx.Request().Context(), profile.ID) if err != nil { diff --git a/pkg/routing/routes/push_notifs.go b/pkg/routing/routes/push_notifs.go index 2a3bfbe..4b5ceef 100644 --- a/pkg/routing/routes/push_notifs.go +++ b/pkg/routing/routes/push_notifs.go @@ -10,6 +10,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/repos/notifierrepo" "github.com/mikestefanello/pagoda/pkg/types" @@ -338,24 +339,24 @@ func (c *outgoingNotifications) createNotificationsPage(ctx echo.Context, profil } addPushSubscriptionEndpoint := fmt.Sprintf("%s%s", c.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameRegisterSubscription, domain.NotificationPlatformPush.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameRegisterSubscription, domain.NotificationPlatformPush.Value)) + "?csrf=" + page.CSRF deletePushSubscriptionEndpoint := fmt.Sprintf("%s%s", c.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameDeleteSubscription, domain.NotificationPlatformPush.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameDeleteSubscription, domain.NotificationPlatformPush.Value)) + "?csrf=" + page.CSRF addEmailSubscriptionEndpoint := fmt.Sprintf("%s%s", c.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameRegisterSubscription, domain.NotificationPlatformEmail.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameRegisterSubscription, domain.NotificationPlatformEmail.Value)) + "?csrf=" + page.CSRF deleteEmailSubscriptionEndpoint := fmt.Sprintf("%s%s", c.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameDeleteSubscription, domain.NotificationPlatformEmail.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameDeleteSubscription, domain.NotificationPlatformEmail.Value)) + "?csrf=" + page.CSRF addSmsSubscriptionEndpoint := fmt.Sprintf("%s%s", c.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameRegisterSubscription, domain.NotificationPlatformSMS.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameRegisterSubscription, domain.NotificationPlatformSMS.Value)) + "?csrf=" + page.CSRF deleteSmsSubscriptionEndpoint := fmt.Sprintf("%s%s", c.ctr.Container.Config.HTTP.Domain, ctx.Echo().Reverse( - routeNameDeleteSubscription, domain.NotificationPlatformSMS.Value)) + "?csrf=" + page.CSRF + routeNames.RouteNameDeleteSubscription, domain.NotificationPlatformSMS.Value)) + "?csrf=" + page.CSRF notificationPermissions := types.NotificationPermissionsData{ VapidPublicKey: c.ctr.Container.Config.App.VapidPublicKey, diff --git a/pkg/routing/routes/realtime.go b/pkg/routing/routes/realtime.go index a562d77..60b9ba4 100644 --- a/pkg/routing/routes/realtime.go +++ b/pkg/routing/routes/realtime.go @@ -17,10 +17,20 @@ import ( ) type realtime struct { - controller.Controller + ctr controller.Controller notifier notifierrepo.NotifierRepo } +func NewRealtimeRoute( + ctr controller.Controller, + notifier notifierrepo.NotifierRepo, +) *realtime { + return &realtime{ + ctr: ctr, + notifier: notifier, + } +} + // realtime handles SSE connections to any client desiring real-time data. func (c *realtime) Get(ctx echo.Context) error { usr := ctx.Get(customContext.AuthenticatedUserKey).(*ent.User) @@ -52,7 +62,7 @@ func (c *realtime) Get(ctx echo.Context) error { } // Send periodic comments to keep the connection alive - ticker := time.NewTicker(c.Container.Config.HTTP.SseKeepAlive) + ticker := time.NewTicker(c.ctr.Container.Config.HTTP.SseKeepAlive) defer ticker.Stop() for { diff --git a/pkg/routing/routes/register.go b/pkg/routing/routes/register.go index 022eaee..70ce002 100644 --- a/pkg/routing/routes/register.go +++ b/pkg/routing/routes/register.go @@ -10,6 +10,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/repos/notifierrepo" "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" @@ -135,7 +136,7 @@ func (c *register) Post(ctx echo.Context) error { switch err.(type) { case *ent.ConstraintError: msg.Warning(ctx, "A user with this email address already exists. Please log in.") - return c.ctr.Redirect(ctx, routeNameLogin) + return c.ctr.Redirect(ctx, routeNames.RouteNameLogin) default: return c.ctr.Fail(err, "unable to create user") } @@ -183,7 +184,7 @@ func (c *register) Post(ctx echo.Context) error { if err != nil { ctx.Logger().Errorf("unable to log in: %v", err) msg.Info(ctx, "Your account has been created.") - return c.ctr.Redirect(ctx, routeNameLogin) + return c.ctr.Redirect(ctx, routeNames.RouteNameLogin) } msg.Success(ctx, "Your account has been created. You are now logged in. πŸ‘Œ") @@ -199,7 +200,7 @@ func (c *register) Post(ctx echo.Context) error { return nil } - return c.ctr.Redirect(ctx, routeNamePreferences) + return c.ctr.Redirect(ctx, routeNames.RouteNamePreferences) } func (c *register) sendVerificationEmail(ctx echo.Context, usr *ent.User) { @@ -210,16 +211,9 @@ func (c *register) sendVerificationEmail(ctx echo.Context, usr *ent.User) { return } - url := ctx.Echo().Reverse(routeNameVerifyEmail, token) + url := ctx.Echo().Reverse(routeNames.RouteNameVerifyEmail, token) fullUrl := fmt.Sprintf("%s%s", c.ctr.Container.Config.HTTP.Domain, url) - type EmailData struct { - AppName string - ConfirmationLink string - SupportEmail string - Domain string - } - page := controller.NewPage(ctx) page.Layout = layouts.Main page.Data = types.EmailDefaultData{ diff --git a/pkg/routing/routes/reset_password.go b/pkg/routing/routes/reset_password.go index 2eef40a..1c439ce 100644 --- a/pkg/routing/routes/reset_password.go +++ b/pkg/routing/routes/reset_password.go @@ -5,6 +5,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/context" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates" @@ -84,5 +85,5 @@ func (c *resetPassword) Post(ctx echo.Context) error { } msg.Success(ctx, "Your password has been updated.") - return c.ctr.Redirect(ctx, routeNameLogin) + return c.ctr.Redirect(ctx, routeNames.RouteNameLogin) } diff --git a/pkg/routing/routes/router.go b/pkg/routing/routes/router.go index a3b1456..0d2f6f4 100644 --- a/pkg/routing/routes/router.go +++ b/pkg/routing/routes/router.go @@ -17,6 +17,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/repos/pubsub" storagerepo "github.com/mikestefanello/pagoda/pkg/repos/storage" "github.com/mikestefanello/pagoda/pkg/repos/subscriptions" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/services" "github.com/ziflex/lecho/v3" @@ -28,83 +29,6 @@ import ( slogecho "github.com/samber/slog-echo" ) -// TODO: I would like to move these route names to a new package so we can use vars -// in place of where we use the string literals due to circular imports (for example -// in middleware and in pages). -// TODO: I actually ran into a bug where I was using a stale string literal for a route name in a route template. I -// seemed to have carelessly renamed a route without checking if it appeared in a template, breaking prod... -const ( - routeNameForgotPassword = "forgot_password" - routeNameForgotPasswordSubmit = "forgot_password.submit" - routeNameLogin = "login" - routeNameLoginSubmit = "login.submit" - routeNameLogout = "logout" - routeNameRegister = "register" - routeNameRegisterSubmit = "register.post" // TODO: rename to "register.submit" as was done in pagoda - routeNameResetPassword = "reset_password" - routeNameResetPasswordSubmit = "reset_password.post" // TODO: rename to "register.submit" as was done in pagoda - routeNameVerifyEmail = "verify_email" - routeNameContact = "contact" - routeNameContactSubmit = "contact.submit" - routeNameAboutUs = "about" - routeNameLandingPage = "landing_page" - routeNameSearch = "search" - routeNamePreferences = "preferences" - routeNameGetPhone = "phone.get" - routeNameUpdatePhoneNum = "phone.save" - routeNameGetDisplayName = "display_name.get" - routeNameUpdateDisplayName = "display_name.save" - routeNameGetPhoneVerification = "phone.verification" - routeNameSubmitPhoneVerification = "phone.verification.submit" - routeNameDeleteAccountPage = "delete_account.page" - routeNameDeleteAccountRequest = "delete_account.request" - routeNamePrivacyPolicy = "privacy_policy" - - routeNameHomeFeed = "home_feed" - routeNameGetHomeFeedButtons = "home_feed.buttons" - routeNameGetHomeFeedStats = "home_feed.stats" - routeNameSearchQuestion = "home_feed.search_question" - - routeNameGetMatch = "meet.get_match" - routeNameRateMatch = "meet.rate_match" - routeNameMatchMadeInHeaven = "meet.match_made_in_heaven" - routeNameProfile = "profile" - routeNameProfileCalendarHeatmap = "profile.calendar_heatmap" - routeNameInstallApp = "install_app" - - routeMarkNotificationsAsRead = "markNormalNotificationRead" - routeMarkAllNotificationsAsRead = "normalNotificationsMarkAllAsRead" - - routeNameRealtime = "realtime" - - routeNameFinishOnboarding = "finish_onboarding" - routeNameGetGeolocationComponent = "geolocation" - routeNameUpdateGeolocation = "geolocation.post" - routeNameGetBio = "profileBio.get" - routeNameUpdateBio = "profileBio.post" - routeNameUpdateSelfGender = "profileGender.post" - routeNameUpdateInterestedInGenders = "profileInterestedGenders.post" - routeNameUpdateMinAgeInterestedIn = "profileMinAgeInterestedIn.post" - routeNameUpdateMaxAgeInterestedIn = "profileMaxAgeInterestedIn.post" - - routeNameGetPushSubscriptions = "push_subscriptions.get" - routeNameRegisterSubscription = "notification_subscriptions.register" - routeNameDeleteSubscription = "notification_subscriptions.delete" - routeNameDeleteEmailSubscriptionWithToken = "email_subscriptions.delete_with_token" - - routeNamePaymentProcessorGetPublicKey = "payment_processor.get_public_key" - routeNameCreateCheckoutSession = "stripe.create_checkout_session" - routeNameCreatePortalSession = "stripe.create_portal_session" - routeNamePaymentProcessorWebhook = "stripe.webhook" - routeNamePricingPage = "pricing_page" - routeNamePaymentProcessorSuccess = "stripe.success" - - routeNameDocs = "docs" - routeNameDocsGettingStarted = "docs.getting_started" - routeNameDocsGuidedTour = "docs.guided_tour" - routeNameDocsArchitecture = "docs.architecture" -) - func sseSkipper(c echo.Context) bool { // Skip timeout middleware for SSE endpoint return c.Path() == "/auth/realtime" // Replace with your SSE endpoint pathstripe @@ -273,10 +197,10 @@ func BuildRouter(c *services.Container) { func documentationRoutes(c *services.Container, g *echo.Group, ctr controller.Controller) { docsRoute := NewDocsRoute(ctr) - g.GET("/docs", docsRoute.GetDocsHome).Name = routeNameDocs - g.GET("/docs/gettingStarted", docsRoute.GetDocsGettingStarted).Name = routeNameDocsGettingStarted - g.GET("/docs/guidedTour", docsRoute.GetDocsGuidedTour).Name = routeNameDocsGuidedTour - g.GET("/docs/architecture", docsRoute.GetDocsArchitecture).Name = routeNameDocsArchitecture + g.GET("/docs", docsRoute.GetDocsHome).Name = routeNames.RouteNameDocs + g.GET("/docs/gettingStarted", docsRoute.GetDocsGettingStarted).Name = routeNames.RouteNameDocsGettingStarted + g.GET("/docs/guidedTour", docsRoute.GetDocsGuidedTour).Name = routeNames.RouteNameDocsGuidedTour + g.GET("/docs/architecture", docsRoute.GetDocsArchitecture).Name = routeNames.RouteNameDocsArchitecture } func externalRoutes(c *services.Container, g *echo.Group, ctr controller.Controller) { @@ -289,7 +213,7 @@ func externalRoutes(c *services.Container, g *echo.Group, ctr controller.Control payments := NewPaymentsRoute(ctr, c.ORM, subscriptionsRepo) // Using obfuscation to not get trolls at my payment webhooks. Note, we do check integrity of stripe requests. // TODO: make the first string an env var - g.POST("/Q2HBfAY7iid59J1SUN8h1Y3WxJcPWA/payments/webhooks", payments.HandleWebhook).Name = routeNamePaymentProcessorWebhook + g.POST("/Q2HBfAY7iid59J1SUN8h1Y3WxJcPWA/payments/webhooks", payments.HandleWebhook).Name = routeNames.RouteNamePaymentProcessorWebhook } func generalRoutes(c *services.Container, g *echo.Group, ctr controller.Controller) { @@ -304,7 +228,7 @@ func generalRoutes(c *services.Container, g *echo.Group, ctr controller.Controll notificationSendPermissionRepo := notifierrepo.NewNotificationSendPermissionRepo(c.ORM) landingPage := NewLandingPageRoute(ctr) - g.GET("/", landingPage.Get).Name = routeNameLandingPage + g.GET("/", landingPage.Get).Name = routeNames.RouteNameLandingPage clearCookie := NewClearCookiesRoute(ctr) g.GET("/clear-cookie", clearCookie.Get).Name = "clearCookie" @@ -326,35 +250,35 @@ func generalRoutes(c *services.Container, g *echo.Group, ctr controller.Controll g.GET("/email/subscription/:token", verifyEmailSubscription.Get).Name = "verify_email_subscription" installApp := NewInstallAppRoute(ctr) - g.GET("/install-app", installApp.GetInstallPage).Name = routeNameInstallApp + g.GET("/install-app", installApp.GetInstallPage).Name = routeNames.RouteNameInstallApp about := NewAboutUsRoute(ctr) - g.GET("/about", about.Get).Name = routeNameAboutUs + g.GET("/about", about.Get).Name = routeNames.RouteNameAboutUs privacyPolicy := NewPrivacyPolicyRoute(ctr) - g.GET("/privacy-policy", privacyPolicy.Get).Name = routeNamePrivacyPolicy + g.GET("/privacy-policy", privacyPolicy.Get).Name = routeNames.RouteNamePrivacyPolicy userGroup := g.Group("/user", middleware.RequireNoAuthentication()) login := NewLoginRoute(ctr) - userGroup.GET("/login", login.Get).Name = routeNameLogin - userGroup.POST("/login", login.Post).Name = routeNameLoginSubmit + userGroup.GET("/login", login.Get).Name = routeNames.RouteNameLogin + userGroup.POST("/login", login.Post).Name = routeNames.RouteNameLoginSubmit register := NewRegisterRoute(ctr, profileRepo, *subscriptionsRepo, notificationSendPermissionRepo) - userGroup.GET("/register", register.Get).Name = routeNameRegister - userGroup.POST("/register", register.Post).Name = routeNameRegisterSubmit + userGroup.GET("/register", register.Get).Name = routeNames.RouteNameRegister + userGroup.POST("/register", register.Post).Name = routeNames.RouteNameRegisterSubmit forgot := NewForgotPasswordRoute(ctr) - userGroup.GET("/password", forgot.Get).Name = routeNameForgotPassword - userGroup.POST("/password", forgot.Post).Name = routeNameForgotPasswordSubmit + userGroup.GET("/password", forgot.Get).Name = routeNames.RouteNameForgotPassword + userGroup.POST("/password", forgot.Post).Name = routeNames.RouteNameForgotPasswordSubmit resetGroup := userGroup.Group("/password/reset", middleware.LoadUser(c.ORM), middleware.LoadValidPasswordToken(c.Auth), ) reset := NewResetPasswordRoute(ctr) - resetGroup.GET("/token/:user/:password_token/:token", reset.Get).Name = routeNameResetPassword - resetGroup.POST("/token/:user/:password_token/:token", reset.Post).Name = routeNameResetPasswordSubmit + resetGroup.GET("/token/:user/:password_token/:token", reset.Get).Name = routeNames.RouteNameResetPassword + resetGroup.POST("/token/:user/:password_token/:token", reset.Post).Name = routeNames.RouteNameResetPasswordSubmit if ctr.Container.Config.App.Environment != config.EnvProduction { // These facilitate triggering specific errors and seeing what they look like in the UI @@ -403,50 +327,50 @@ func coreAuthRoutes(c *services.Container, g *echo.Group, ctr controller.Control onboardingGroup := g.Group("/welcome", middleware.RequireAuthentication()) preferences := NewPreferencesRoute( ctr, &profileRepo, pwaPushNotificationsRepo, notificationSendPermissionRepo, subscriptionsRepo, smsSenderRepo) - onboardingGroup.GET("/preferences", preferences.Get).Name = routeNamePreferences - onboardingGroup.GET("/preferences/phone", preferences.GetPhoneComponent).Name = routeNameGetPhone - onboardingGroup.GET("/preferences/phone/verification", preferences.GetPhoneVerificationComponent).Name = routeNameGetPhoneVerification - onboardingGroup.POST("/preferences/phone/verification", preferences.SubmitPhoneVerificationCode).Name = routeNameSubmitPhoneVerification - onboardingGroup.POST("/preferences/phone/save", preferences.SavePhoneInfo).Name = routeNameUpdatePhoneNum - onboardingGroup.GET("/preferences/display-name/get", preferences.GetDisplayName).Name = routeNameGetDisplayName - onboardingGroup.POST("/preferences/display-name/save", preferences.SaveDisplayName).Name = routeNameUpdateDisplayName + onboardingGroup.GET("/preferences", preferences.Get).Name = routeNames.RouteNamePreferences + onboardingGroup.GET("/preferences/phone", preferences.GetPhoneComponent).Name = routeNames.RouteNameGetPhone + onboardingGroup.GET("/preferences/phone/verification", preferences.GetPhoneVerificationComponent).Name = routeNames.RouteNameGetPhoneVerification + onboardingGroup.POST("/preferences/phone/verification", preferences.SubmitPhoneVerificationCode).Name = routeNames.RouteNameSubmitPhoneVerification + onboardingGroup.POST("/preferences/phone/save", preferences.SavePhoneInfo).Name = routeNames.RouteNameUpdatePhoneNum + onboardingGroup.GET("/preferences/display-name/get", preferences.GetDisplayName).Name = routeNames.RouteNameGetDisplayName + onboardingGroup.POST("/preferences/display-name/save", preferences.SaveDisplayName).Name = routeNames.RouteNameUpdateDisplayName deleteAccountRoute := NewDeleteAccountRoute(ctr, &profileRepo, subscriptionsRepo) - onboardingGroup.GET("/preferences/delete-account", deleteAccountRoute.DeleteAccountPage).Name = routeNameDeleteAccountPage - onboardingGroup.GET("/preferences/delete-account/now", deleteAccountRoute.DeleteAccountRequest).Name = routeNameDeleteAccountRequest + onboardingGroup.GET("/preferences/delete-account", deleteAccountRoute.DeleteAccountPage).Name = routeNames.RouteNameDeleteAccountPage + onboardingGroup.GET("/preferences/delete-account/now", deleteAccountRoute.DeleteAccountRequest).Name = routeNames.RouteNameDeleteAccountRequest - // TODO: move all pref routes to the preferences route (and not have a gazillion different routes...) + // TODO: move all pref routes to the preferences route (and not have a gazillion different ..) finishOnboarding := NewOnboardingRoute(ctr, c.ORM, c.Tasks) - onboardingGroup.GET("/finish-onboarding", finishOnboarding.Get).Name = routeNameFinishOnboarding + onboardingGroup.GET("/finish-onboarding", finishOnboarding.Get).Name = routeNames.RouteNameFinishOnboarding profilePrefs := NewProfilePrefsRoute(ctr, c.ORM) - onboardingGroup.GET("/profileBio", profilePrefs.GetBio).Name = routeNameGetBio - onboardingGroup.POST("/profileBio/update", profilePrefs.UpdateBio).Name = routeNameUpdateBio + onboardingGroup.GET("/profileBio", profilePrefs.GetBio).Name = routeNames.RouteNameGetBio + onboardingGroup.POST("/profileBio/update", profilePrefs.UpdateBio).Name = routeNames.RouteNameUpdateBio outgoingNotifications := NewPushNotifsRoute(ctr, pwaPushNotificationsRepo, fcmPushNotificationsRepo, notificationSendPermissionRepo) - onboardingGroup.GET("/subscription/push", outgoingNotifications.GetPushSubscriptions).Name = routeNameGetPushSubscriptions - onboardingGroup.POST("/subscription/:platform", outgoingNotifications.RegisterSubscription).Name = routeNameRegisterSubscription - onboardingGroup.DELETE("/subscription/:platform", outgoingNotifications.DeleteSubscription).Name = routeNameDeleteSubscription - onboardingGroup.GET("/email-subscription/unsubscribe/:permission/:token", outgoingNotifications.DeleteEmailSubscription).Name = routeNameDeleteEmailSubscriptionWithToken + onboardingGroup.GET("/subscription/push", outgoingNotifications.GetPushSubscriptions).Name = routeNames.RouteNameGetPushSubscriptions + onboardingGroup.POST("/subscription/:platform", outgoingNotifications.RegisterSubscription).Name = routeNames.RouteNameRegisterSubscription + onboardingGroup.DELETE("/subscription/:platform", outgoingNotifications.DeleteSubscription).Name = routeNames.RouteNameDeleteSubscription + onboardingGroup.GET("/email-subscription/unsubscribe/:permission/:token", outgoingNotifications.DeleteEmailSubscription).Name = routeNames.RouteNameDeleteEmailSubscriptionWithToken // The "all group" is for routes that need to have an authenticated but do not need an onboarded profile allGroup := g.Group("/auth", middleware.RequireAuthentication()) - logout := logout{Controller: ctr} - allGroup.GET("/logout", logout.Get, middleware.RequireAuthentication()).Name = routeNameLogout + logout := NewLogoutRoute(ctr) + allGroup.GET("/logout", logout.Get, middleware.RequireAuthentication()).Name = routeNames.RouteNameLogout // Auth group is for all routes that are accessible to a fully logged in and onboarded user onboardedGroup := g.Group("/auth", middleware.RequireAuthentication(), middleware.RedirectToOnboardingIfNotComplete()) - verifyEmail := verifyEmail{Controller: ctr} - g.GET("/email/verify/:token", verifyEmail.Get).Name = routeNameVerifyEmail + verifyEmail := NewVerifyEmailRoute(ctr) + g.GET("/email/verify/:token", verifyEmail.Get).Name = routeNames.RouteNameVerifyEmail homeFeed := NewHomeFeedRoute(ctr, profileRepo, &c.Config.App.PageSize) - onboardedGroup.GET("/homeFeed", homeFeed.Get, middleware.SetLastSeenOnline(c.Auth)).Name = routeNameHomeFeed - onboardedGroup.GET("/homeFeed/buttons", homeFeed.GetHomeButtons).Name = routeNameGetHomeFeedButtons + onboardedGroup.GET("/homeFeed", homeFeed.Get, middleware.SetLastSeenOnline(c.Auth)).Name = routeNames.RouteNameHomeFeed + onboardedGroup.GET("/homeFeed/buttons", homeFeed.GetHomeButtons).Name = routeNames.RouteNameGetHomeFeedButtons singleProfile := NewProfileRoutes(ctr, &profileRepo) - onboardedGroup.GET("/profile", singleProfile.Get).Name = routeNameProfile - onboardedGroup.GET("/profile/calendar-heatmap", singleProfile.GetCalendarHeatmap).Name = routeNameProfileCalendarHeatmap + onboardedGroup.GET("/profile", singleProfile.Get).Name = routeNames.RouteNameProfile + onboardedGroup.GET("/profile/calendar-heatmap", singleProfile.GetCalendarHeatmap).Name = routeNames.RouteNameProfileCalendarHeatmap uploadPhoto := NewUploadPhotoRoutes(ctr, &profileRepo, storageRepo, c.Config.Storage.PhotosMaxFileSizeMB) onboardedGroup.GET("/uploadPhoto", uploadPhoto.Get).Name = "uploadPhoto" @@ -457,28 +381,28 @@ func coreAuthRoutes(c *services.Container, g *echo.Group, ctr controller.Control onboardedGroup.GET("/currProfilePhoto", currProfilePhoto.Get).Name = "currProfilePhoto" onboardedGroup.POST("/currProfilePhoto", currProfilePhoto.Post).Name = "currProfilePhoto.post" - // TODO: create functions to create these routes. Removfe notifierRepo as it's accessible on container. - markNormalNotificationRead := markNormalNotificationRead{Controller: ctr, notifierRepo: notifierRepo} - onboardedGroup.POST("/notificationSeenByEvent/:notification_id", markNormalNotificationRead.Post).Name = routeMarkNotificationsAsRead + // TODO: create functions to create these Removfe notifierRepo as it's accessible on container. + markNormalNotificationRead := NewMarkNormalNotificationReadRoute(ctr, notifierRepo) + onboardedGroup.POST("/notificationSeenByEvent/:notification_id", markNormalNotificationRead.Post).Name = routeNames.RouteNameMarkNotificationsAsRead - markNormalNotificationUnread := markNormalNotificationUnread{Controller: ctr, notifierRepo: notifierRepo} + markNormalNotificationUnread := NewMarkNormalNotificationUnreadRoute(ctr, notifierRepo) onboardedGroup.POST("/markNormalNotificationUnread", markNormalNotificationUnread.Post).Name = "markNormalNotificationUnread" - normalNotificationsCount := normalNotificationsCount{Controller: ctr, profileRepo: profileRepo} + normalNotificationsCount := NewNormalNotificationsCountRoute(ctr, profileRepo) onboardedGroup.GET("/notifications/normalNotificationsCount", normalNotificationsCount.Get).Name = "normalNotificationsCount" - normalNotifications := normalNotifications{Controller: ctr, notifierRepo: notifierRepo} + normalNotifications := NewNormalNotificationsRoute(ctr, notifierRepo) onboardedGroup.GET("/notifications", normalNotifications.Get, middleware.SetLastSeenOnline(c.Auth)).Name = "normalNotifications" - onboardedGroup.GET("/notifications/markAllAsRead", normalNotifications.MarkAllAsRead, middleware.SetLastSeenOnline(c.Auth)).Name = routeMarkAllNotificationsAsRead + onboardedGroup.GET("/notifications/markAllAsRead", normalNotifications.MarkAllAsRead, middleware.SetLastSeenOnline(c.Auth)).Name = routeNames.RouteNameMarkAllNotificationsAsRead onboardedGroup.DELETE("/notifications/normalNotifications/:notification_id", normalNotifications.Delete).Name = "normalNotifications.delete" payments := NewPaymentsRoute(ctr, c.ORM, subscriptionsRepo) - onboardedGroup.GET("/payments/get-public-key", payments.GetPaymentProcessorPublickey).Name = routeNamePaymentProcessorGetPublicKey - onboardedGroup.POST("/payments/create-checkout-session", payments.CreateCheckoutSession).Name = routeNameCreateCheckoutSession - onboardedGroup.POST("/payments/create-portal-session", payments.CreatePortalSession).Name = routeNameCreatePortalSession - onboardedGroup.GET("/payments/pricing", payments.PricingPage).Name = routeNamePricingPage - onboardedGroup.GET("/payments/success", payments.SuccessfullySubscribed).Name = routeNamePaymentProcessorSuccess + onboardedGroup.GET("/payments/get-public-key", payments.GetPaymentProcessorPublickey).Name = routeNames.RouteNamePaymentProcessorGetPublicKey + onboardedGroup.POST("/payments/create-checkout-session", payments.CreateCheckoutSession).Name = routeNames.RouteNameCreateCheckoutSession + onboardedGroup.POST("/payments/create-portal-session", payments.CreatePortalSession).Name = routeNames.RouteNameCreatePortalSession + onboardedGroup.GET("/payments/pricing", payments.PricingPage).Name = routeNames.RouteNamePricingPage + onboardedGroup.GET("/payments/success", payments.SuccessfullySubscribed).Name = routeNames.RouteNamePaymentProcessorSuccess } @@ -487,6 +411,6 @@ func sseRoutes(c *services.Container, g *echo.Group, ctr controller.Controller) onboardedGroup := g.Group("/auth", middleware.RequireAuthentication()) - realtime := realtime{Controller: ctr, notifier: *c.Notifier} - onboardedGroup.GET("/realtime", realtime.Get).Name = routeNameRealtime + realtime := NewRealtimeRoute(ctr, *c.Notifier) + onboardedGroup.GET("/realtime", realtime.Get).Name = routeNames.RouteNameRealtime } diff --git a/pkg/routing/routes/verify_email.go b/pkg/routing/routes/verify_email.go index 944544b..0f05b80 100644 --- a/pkg/routing/routes/verify_email.go +++ b/pkg/routing/routes/verify_email.go @@ -7,21 +7,25 @@ import ( "github.com/mikestefanello/pagoda/pkg/context" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/repos/msg" + routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" ) type verifyEmail struct { - controller.Controller + ctr controller.Controller } +func NewVerifyEmailRoute(ctr controller.Controller) *verifyEmail { + return &verifyEmail{ctr: ctr} +} func (c *verifyEmail) Get(ctx echo.Context) error { var usr *ent.User // Validate the token token := ctx.Param("token") - email, err := c.Container.Auth.ValidateEmailVerificationToken(token) + email, err := c.ctr.Container.Auth.ValidateEmailVerificationToken(token) if err != nil { msg.Warning(ctx, "The link is either invalid or has expired.") - return c.Redirect(ctx, routeNameLandingPage) + return c.ctr.Redirect(ctx, routeNames.RouteNameLandingPage) } // Check if it matches the authenticated user @@ -36,13 +40,13 @@ func (c *verifyEmail) Get(ctx echo.Context) error { // Query to find a matching user, if needed if usr == nil { - usr, err = c.Container.ORM.User. + usr, err = c.ctr.Container.ORM.User. Query(). Where(user.Email(email)). Only(ctx.Request().Context()) if err != nil { - return c.Fail(err, "query failed loading email verification token user") + return c.ctr.Fail(err, "query failed loading email verification token user") } } @@ -54,7 +58,7 @@ func (c *verifyEmail) Get(ctx echo.Context) error { Save(ctx.Request().Context()) if err != nil { - return c.Fail(err, "failed to set user as verified") + return c.ctr.Fail(err, "failed to set user as verified") } } @@ -62,8 +66,8 @@ func (c *verifyEmail) Get(ctx echo.Context) error { // If we have a user, they are already logged in and just redirect them to their home feed if u != nil { - return c.Redirect(ctx, routeNamePreferences) + return c.ctr.Redirect(ctx, routeNames.RouteNamePreferences) } - return c.Redirect(ctx, routeNameLogin) + return c.ctr.Redirect(ctx, routeNames.RouteNameLogin) } From 6bdcbdd831f860cf343ed6347b8c37bad278ac68 Mon Sep 17 00:00:00 2001 From: Leo Audibert Date: Sun, 29 Sep 2024 12:05:09 -0700 Subject: [PATCH 3/3] Large refactor to use routenames package --- pkg/middleware/auth.go | 5 ++- pkg/middleware/onboarding.go | 3 +- pkg/repos/emailsmanager/update_email.go | 5 ++- pkg/routing/routenames/routenames.go | 29 ++++-------- pkg/routing/routes/clear_site_cookie.go | 3 +- pkg/routing/routes/home_feed.go | 3 +- pkg/routing/routes/landing.go | 3 +- pkg/routing/routes/preferences.go | 3 +- pkg/routing/routes/profile.go | 53 ---------------------- pkg/routing/routes/register.go | 3 +- pkg/routing/routes/register_test.go | 3 +- pkg/routing/routes/router.go | 1 - pkg/routing/routes/upload_photo.go | 3 +- pkg/tasks/notifications.go | 3 +- templates/components/auth.templ | 11 +++-- templates/components/auth_templ.go | 17 ++++--- templates/components/bottom_nav.templ | 9 ++-- templates/components/bottom_nav_templ.go | 23 +++++----- templates/components/core.templ | 5 ++- templates/components/core_templ.go | 33 +++++++------- templates/components/drawer.templ | 15 ++++--- templates/components/drawer_templ.go | 39 ++++++++-------- templates/components/navbar.templ | 31 +++++++------ templates/components/navbar_templ.go | 55 ++++++++++++----------- templates/components/payments.templ | 5 ++- templates/components/payments_templ.go | 7 +-- templates/components/profile.templ | 27 ++--------- templates/components/profile_templ.go | 54 +++------------------- templates/components/pwa_install.templ | 3 +- templates/components/pwa_install_templ.go | 5 ++- templates/layouts/auth.templ | 3 +- templates/layouts/auth_templ.go | 7 +-- templates/pages/delete_account.templ | 3 +- templates/pages/delete_account_templ.go | 3 +- templates/pages/error.templ | 5 ++- templates/pages/error_templ.go | 23 +++++----- templates/pages/forgot_password.templ | 3 +- templates/pages/forgot_password_templ.go | 5 ++- templates/pages/home_feed.templ | 9 ++-- templates/pages/home_feed_templ.go | 55 ++++++++++++----------- templates/pages/landing_page.templ | 3 +- templates/pages/landing_page_templ.go | 19 ++++---- templates/pages/login.templ | 3 +- templates/pages/login_templ.go | 7 +-- templates/pages/notifications.templ | 9 ++-- templates/pages/notifications_templ.go | 35 ++++++++------- templates/pages/payments.templ | 5 ++- templates/pages/payments_templ.go | 23 +++++----- templates/pages/phone.templ | 11 ++--- templates/pages/phone_templ.go | 23 +++++----- templates/pages/preferences.templ | 19 ++++---- templates/pages/preferences_templ.go | 47 +++++++++---------- templates/pages/register.templ | 5 ++- templates/pages/register_templ.go | 17 +++---- templates/templates.go | 1 - 55 files changed, 367 insertions(+), 435 deletions(-) diff --git a/pkg/middleware/auth.go b/pkg/middleware/auth.go index 3c80e79..64b1851 100644 --- a/pkg/middleware/auth.go +++ b/pkg/middleware/auth.go @@ -12,6 +12,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/repos/msg" "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" "github.com/mikestefanello/pagoda/pkg/repos/subscriptions" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/services" "github.com/rs/zerolog/log" ) @@ -92,7 +93,7 @@ func LoadValidPasswordToken(authClient *services.AuthClient) echo.MiddlewareFunc case services.InvalidPasswordTokenError: msg.Warning(c, "The link is either invalid or has expired. Please request a new one.") // TODO use the const for route name - return c.Redirect(http.StatusFound, c.Echo().Reverse("forgot_password")) + return c.Redirect(http.StatusFound, c.Echo().Reverse(routenames.RouteNameForgotPassword)) default: return echo.NewHTTPError( http.StatusInternalServerError, @@ -121,7 +122,7 @@ func RequireAuthentication() echo.MiddlewareFunc { } // Redirect to login page - url := c.Echo().Reverse("login") + url := c.Echo().Reverse(routenames.RouteNameLogin) return c.Redirect(http.StatusSeeOther, url) // Note: leaving original code commented out in case there are unforeseen consequences...so I remember this change which may have caused it... // return echo.NewHTTPError(http.StatusUnauthorized) diff --git a/pkg/middleware/onboarding.go b/pkg/middleware/onboarding.go index 8f3346e..ef70654 100644 --- a/pkg/middleware/onboarding.go +++ b/pkg/middleware/onboarding.go @@ -5,6 +5,7 @@ import ( "github.com/labstack/echo/v4" "github.com/mikestefanello/pagoda/pkg/context" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" ) func RedirectToOnboardingIfNotComplete() echo.MiddlewareFunc { @@ -15,7 +16,7 @@ func RedirectToOnboardingIfNotComplete() echo.MiddlewareFunc { } isFullyOnboarded := c.Get(context.ProfileFullyOnboarded).(bool) if !isFullyOnboarded { - url := c.Echo().Reverse("preferences") + url := c.Echo().Reverse(routenames.RouteNamePreferences) return c.Redirect(303, url) } return next(c) diff --git a/pkg/repos/emailsmanager/update_email.go b/pkg/repos/emailsmanager/update_email.go index c34cfb3..b54877e 100644 --- a/pkg/repos/emailsmanager/update_email.go +++ b/pkg/repos/emailsmanager/update_email.go @@ -17,6 +17,7 @@ import ( "github.com/mikestefanello/pagoda/ent/sentemail" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/services" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/emails" @@ -218,11 +219,11 @@ func (e *UpdateEmailSender) SendUpdateEmail( // Create a new Echo context echoCtx := ech.NewContext(req, rec) - url := e.container.Web.Reverse("email_subscriptions.delete_with_token", + url := e.container.Web.Reverse(routenames.RouteNameDeleteEmailSubscriptionWithToken, domain.NotificationPermissionDailyReminder.Value, dailyUpdatePermissionToken) unsubscribeDailyUpdatesLink := fmt.Sprintf("%s%s", e.container.Config.HTTP.Domain, url) - url = e.container.Web.Reverse("email_subscriptions.delete_with_token", + url = e.container.Web.Reverse(routenames.RouteNameDeleteEmailSubscriptionWithToken, domain.NotificationPermissionNewFriendActivity.Value, partnerUpdatePermissionToken) unsubscribePartnerActivityLink := fmt.Sprintf("%s%s", e.container.Config.HTTP.Domain, url) diff --git a/pkg/routing/routenames/routenames.go b/pkg/routing/routenames/routenames.go index 5150afb..109dca9 100644 --- a/pkg/routing/routenames/routenames.go +++ b/pkg/routing/routenames/routenames.go @@ -1,4 +1,4 @@ -package routeNames +package routenames const ( RouteNameForgotPassword = "forgot_password" @@ -7,15 +7,14 @@ const ( RouteNameLoginSubmit = "login.submit" RouteNameLogout = "logout" RouteNameRegister = "register" - RouteNameRegisterSubmit = "register.post" // TODO: rename to "register.submit" as was done in pagoda + RouteNameRegisterSubmit = "register.submit" RouteNameResetPassword = "reset_password" - RouteNameResetPasswordSubmit = "reset_password.post" // TODO: rename to "register.submit" as was done in pagoda + RouteNameResetPasswordSubmit = "reset_password.submit" RouteNameVerifyEmail = "verify_email" RouteNameContact = "contact" RouteNameContactSubmit = "contact.submit" RouteNameAboutUs = "about" RouteNameLandingPage = "landing_page" - RouteNameSearch = "search" RouteNamePreferences = "preferences" RouteNameGetPhone = "phone.get" RouteNameUpdatePhoneNum = "phone.save" @@ -30,29 +29,18 @@ const ( RouteNameHomeFeed = "home_feed" RouteNameGetHomeFeedButtons = "home_feed.buttons" RouteNameGetHomeFeedStats = "home_feed.stats" - RouteNameSearchQuestion = "home_feed.search_question" - RouteNameGetMatch = "meet.get_match" - RouteNameRateMatch = "meet.rate_match" - RouteNameMatchMadeInHeaven = "meet.match_made_in_heaven" - RouteNameProfile = "profile" - RouteNameProfileCalendarHeatmap = "profile.calendar_heatmap" - RouteNameInstallApp = "install_app" + RouteNameProfile = "profile" + RouteNameInstallApp = "install_app" RouteNameMarkNotificationsAsRead = "markNormalNotificationRead" RouteNameMarkAllNotificationsAsRead = "normalNotificationsMarkAllAsRead" RouteNameRealtime = "realtime" - RouteNameFinishOnboarding = "finish_onboarding" - RouteNameGetGeolocationComponent = "geolocation" - RouteNameUpdateGeolocation = "geolocation.post" - RouteNameGetBio = "profileBio.get" - RouteNameUpdateBio = "profileBio.post" - RouteNameUpdateSelfGender = "profileGender.post" - RouteNameUpdateInterestedInGenders = "profileInterestedGenders.post" - RouteNameUpdateMinAgeInterestedIn = "profileMinAgeInterestedIn.post" - RouteNameUpdateMaxAgeInterestedIn = "profileMaxAgeInterestedIn.post" + RouteNameFinishOnboarding = "finish_onboarding" + RouteNameGetBio = "profileBio.get" + RouteNameUpdateBio = "profileBio.post" RouteNameGetPushSubscriptions = "push_subscriptions.get" RouteNameRegisterSubscription = "notification_subscriptions.register" @@ -66,6 +54,7 @@ const ( RouteNamePricingPage = "pricing_page" RouteNamePaymentProcessorSuccess = "stripe.success" + // NOTE: docs route is being actively worked on. Refer to Readme for up to date documentation. RouteNameDocs = "docs" RouteNameDocsGettingStarted = "docs.getting_started" RouteNameDocsGuidedTour = "docs.guided_tour" diff --git a/pkg/routing/routes/clear_site_cookie.go b/pkg/routing/routes/clear_site_cookie.go index 7c8ce4e..a3ec452 100644 --- a/pkg/routing/routes/clear_site_cookie.go +++ b/pkg/routing/routes/clear_site_cookie.go @@ -6,6 +6,7 @@ import ( "github.com/labstack/echo/v4" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/repos/msg" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" ) type ( @@ -33,5 +34,5 @@ func (ck *clearCookie) Get(ctx echo.Context) error { cookie.MaxAge = -1 ctx.SetCookie(cookie) } - return ck.ctr.Redirect(ctx, "login") + return ck.ctr.Redirect(ctx, routenames.RouteNameLogin) } diff --git a/pkg/routing/routes/home_feed.go b/pkg/routing/routes/home_feed.go index da8359e..62b636f 100644 --- a/pkg/routing/routes/home_feed.go +++ b/pkg/routing/routes/home_feed.go @@ -9,6 +9,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates" "github.com/mikestefanello/pagoda/templates/layouts" @@ -81,7 +82,7 @@ func (c *homeFeed) Get(ctx echo.Context) error { } // NOTE: we're obviosuly not querying any home feed items with the timestamp, but feel free to create the appropriate repo method for it. - nextPageURL := ctx.Echo().Reverse("home_feed") + "?timestamp=" + oldestAnswerTimestamp.Format(time.RFC3339Nano) + nextPageURL := ctx.Echo().Reverse(routenames.RouteNameHomeFeed) + "?timestamp=" + oldestAnswerTimestamp.Format(time.RFC3339Nano) data := types.HomeFeedData{ NextPageURL: nextPageURL, diff --git a/pkg/routing/routes/landing.go b/pkg/routing/routes/landing.go index 10c2050..d28b607 100644 --- a/pkg/routing/routes/landing.go +++ b/pkg/routing/routes/landing.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates" "github.com/mikestefanello/pagoda/templates/layouts" @@ -29,7 +30,7 @@ func (c *landingPage) Get(ctx echo.Context) error { page.Layout = layouts.LandingPage if page.AuthUser != nil { - return c.ctr.Redirect(ctx, "home_feed") + return c.ctr.Redirect(ctx, routenames.RouteNameHomeFeed) } diff --git a/pkg/routing/routes/preferences.go b/pkg/routing/routes/preferences.go index 40c4d27..3329a74 100644 --- a/pkg/routing/routes/preferences.go +++ b/pkg/routing/routes/preferences.go @@ -11,6 +11,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" "github.com/mikestefanello/pagoda/pkg/repos/msg" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/repos/notifierrepo" @@ -449,5 +450,5 @@ func (p *onboarding) Get(ctx echo.Context) error { return err } - return p.ctr.RedirectWithDetails(ctx, "home_feed", "?just_finished_onboarding=true", http.StatusFound) + return p.ctr.RedirectWithDetails(ctx, routenames.RouteNameHomeFeed, "?just_finished_onboarding=true", http.StatusFound) } diff --git a/pkg/routing/routes/profile.go b/pkg/routing/routes/profile.go index 64b84bc..eecc9a4 100644 --- a/pkg/routing/routes/profile.go +++ b/pkg/routing/routes/profile.go @@ -3,7 +3,6 @@ package routes import ( "fmt" "strconv" - "time" "github.com/mikestefanello/pagoda/ent" "github.com/mikestefanello/pagoda/pkg/context" @@ -12,7 +11,6 @@ import ( "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates" - "github.com/mikestefanello/pagoda/templates/components" "github.com/mikestefanello/pagoda/templates/layouts" "github.com/mikestefanello/pagoda/templates/pages" "github.com/nyaruka/phonenumbers" @@ -119,54 +117,3 @@ func GetFullSecureUrlForRoute(ctx echo.Context, domain, routeName, csrf string) url := ctx.Echo().Reverse(routeName) return fmt.Sprintf("%s%s?csrf=%s", domain, url, csrf) } - -func (c *singleProfile) GetCalendarHeatmap(ctx echo.Context) error { - // var otherProfileID int - // var selfProfileID int - // var err error - - // usr := ctx.Get(context.AuthenticatedUserKey).(*ent.User) - - // selfProfileID = usr.QueryProfile(). - // FirstX(ctx.Request().Context()).ID - - // var wantedProfileID int - // otherProfileIdStr := ctx.QueryParam(PROFILE_ID_QUERY_PARAM) - // if otherProfileIdStr != "" { - // otherProfileID, err = strconv.Atoi(otherProfileIdStr) - // if err != nil { - // return err - // } - // wantedProfileID = otherProfileID - // } else { - // wantedProfileID = selfProfileID - // } - - // TODO: make your own func to get countByDay using wantedProfileID - countByDay := make(map[time.Time]int) - - page := controller.NewPage(ctx) - - page.Layout = layouts.Main - page.Name = templates.PageProfile - - data := types.ProfileCalendarHeatmap{ - Counts: ConvertCountsToCountByDay(countByDay), - } - - page.Data = data - page.Component = components.Heatmap(&page) - - return c.ctr.RenderPage(ctx, page) -} - -func ConvertCountsToCountByDay(counts map[time.Time]int) []types.CountByDay { - var data []types.CountByDay - for date, value := range counts { - data = append(data, types.CountByDay{ - Date: date.UTC().Format(time.RFC3339Nano), - Value: value, - }) - } - return data -} diff --git a/pkg/routing/routes/register.go b/pkg/routing/routes/register.go index 70ce002..b40913c 100644 --- a/pkg/routing/routes/register.go +++ b/pkg/routing/routes/register.go @@ -10,6 +10,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" "github.com/mikestefanello/pagoda/pkg/repos/msg" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" routeNames "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/repos/notifierrepo" @@ -154,7 +155,7 @@ func (c *register) Post(ctx echo.Context) error { tx.Rollback() ctx.Logger().Errorf("failed to create profile: %v", err) msg.Info(ctx, "unable to create user") - return c.ctr.Redirect(ctx, "login") + return c.ctr.Redirect(ctx, routenames.RouteNameLogin) } err = c.subscriptionsRepo.CreateSubscription(ctx.Request().Context(), tx, profile.ID) diff --git a/pkg/routing/routes/register_test.go b/pkg/routing/routes/register_test.go index 0afb92a..d7fb139 100644 --- a/pkg/routing/routes/register_test.go +++ b/pkg/routing/routes/register_test.go @@ -5,6 +5,7 @@ import ( "net/url" "testing" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/stretchr/testify/assert" ) @@ -63,7 +64,7 @@ func TestRegisterUserFieldValidation(t *testing.T) { formData.Del(tc.omitField) // Perform the HTTP POST request - postReq := request(t).setRoute("register").setBody(formData) + postReq := request(t).setRoute(routenames.RouteNameRegister).setBody(formData) response := postReq.post() // Ensure the page reloads with a 200 status, indicating form errors diff --git a/pkg/routing/routes/router.go b/pkg/routing/routes/router.go index 0d2f6f4..18ff167 100644 --- a/pkg/routing/routes/router.go +++ b/pkg/routing/routes/router.go @@ -370,7 +370,6 @@ func coreAuthRoutes(c *services.Container, g *echo.Group, ctr controller.Control singleProfile := NewProfileRoutes(ctr, &profileRepo) onboardedGroup.GET("/profile", singleProfile.Get).Name = routeNames.RouteNameProfile - onboardedGroup.GET("/profile/calendar-heatmap", singleProfile.GetCalendarHeatmap).Name = routeNames.RouteNameProfileCalendarHeatmap uploadPhoto := NewUploadPhotoRoutes(ctr, &profileRepo, storageRepo, c.Config.Storage.PhotosMaxFileSizeMB) onboardedGroup.GET("/uploadPhoto", uploadPhoto.Get).Name = "uploadPhoto" diff --git a/pkg/routing/routes/upload_photo.go b/pkg/routing/routes/upload_photo.go index e7b9886..033453b 100644 --- a/pkg/routing/routes/upload_photo.go +++ b/pkg/routing/routes/upload_photo.go @@ -11,6 +11,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" storagerepo "github.com/mikestefanello/pagoda/pkg/repos/storage" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/templates/layouts" "github.com/labstack/echo/v4" @@ -127,5 +128,5 @@ func (p *uploadPhoto) Delete(ctx echo.Context) error { return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) } - return p.ctr.RedirectWithDetails(ctx, "profile", "", http.StatusSeeOther) + return p.ctr.RedirectWithDetails(ctx, routenames.RouteNameProfile, "", http.StatusSeeOther) } diff --git a/pkg/tasks/notifications.go b/pkg/tasks/notifications.go index 53d08c2..795befc 100644 --- a/pkg/tasks/notifications.go +++ b/pkg/tasks/notifications.go @@ -15,6 +15,7 @@ import ( "github.com/mikestefanello/pagoda/pkg/repos/notifierrepo" "github.com/mikestefanello/pagoda/pkg/repos/profilerepo" "github.com/mikestefanello/pagoda/pkg/repos/subscriptions" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/services" "github.com/rs/zerolog/log" ) @@ -167,7 +168,7 @@ func (d *DailyConvoNotificationsProcessor) ProcessTask( title = "🌀 Today's question!" } - url := d.echoServer.Reverse("home_feed") + url := d.echoServer.Reverse(routenames.RouteNameHomeFeed) err = d.notifierRepo.PublishNotification(ctx, domain.Notification{ Type: domain.NotificationTypeDailyConversationReminder, ProfileID: profileID, diff --git a/templates/components/auth.templ b/templates/components/auth.templ index 563a2dc..20cb956 100644 --- a/templates/components/auth.templ +++ b/templates/components/auth.templ @@ -1,6 +1,9 @@ package components -import "github.com/mikestefanello/pagoda/pkg/controller" +import ( + "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" +) templ AuthButtons(page *controller.Page, showLoginBtn, showRegisterBtn, showResetPasswordBtn bool) {
@@ -17,7 +20,7 @@ templ AuthButtons(page *controller.Page, showLoginBtn, showRegisterBtn, showRese > if showLoginBtn {
- @initCalendarHeatmap("cal-heatmap", data.Counts) - } -} - -script initCalendarHeatmap(elementID string, countsByDay []types.CountByDay) { - - createCalHeatmap(countsByDay, elementID) -} diff --git a/templates/components/profile_templ.go b/templates/components/profile_templ.go index aa944ec..d348894 100644 --- a/templates/components/profile_templ.go +++ b/templates/components/profile_templ.go @@ -12,7 +12,7 @@ import ( "fmt" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" - "github.com/mikestefanello/pagoda/pkg/types" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" ) func Profile(page *controller.Page, profile domain.Profile, isSelf, isPotentialMatch bool, uploadGalleryPicUrl, uploadProfilePicUrl string, galleryPicsMaxCount int) templ.Component { @@ -271,9 +271,9 @@ func ProfileHeader(page *controller.Page, profile *domain.Profile, isSelf, isPot return templ_7745c5c3_Err } var templ_7745c5c3_Var9 string - templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("profile", profile.ID)) + templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameProfile, profile.ID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/components/profile.templ`, Line: 157, Col: 50} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/components/profile.templ`, Line: 157, Col: 68} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -359,9 +359,9 @@ func ProfileHeader(page *controller.Page, profile *domain.Profile, isSelf, isPot return templ_7745c5c3_Err } var templ_7745c5c3_Var13 string - templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("profile", profile.ID)) + templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameProfile, profile.ID)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/components/profile.templ`, Line: 184, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/components/profile.templ`, Line: 184, Col: 67} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -426,7 +426,7 @@ func ProfileHeader(page *controller.Page, profile *domain.Profile, isSelf, isPot if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var16 templ.SafeURL = templ.URL(page.ToURL("logout")) + var templ_7745c5c3_Var16 templ.SafeURL = templ.URL(page.ToURL(routenames.RouteNameLogout)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var16))) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err @@ -689,46 +689,4 @@ func InitPhoneNumberPicker(elementID, phoneE164, countryCode, saveEventName, for } } -func Heatmap(page *controller.Page) 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 - 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_Var31 := templ.GetChildren(ctx) - if templ_7745c5c3_Var31 == nil { - templ_7745c5c3_Var31 = templ.NopComponent - } - ctx = templ.ClearChildren(ctx) - if data, ok := page.Data.(types.ProfileCalendarHeatmap); ok { - _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString("
") - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - templ_7745c5c3_Err = initCalendarHeatmap("cal-heatmap", data.Counts).Render(ctx, templ_7745c5c3_Buffer) - if templ_7745c5c3_Err != nil { - return templ_7745c5c3_Err - } - } - return templ_7745c5c3_Err - }) -} - -func initCalendarHeatmap(elementID string, countsByDay []types.CountByDay) templ.ComponentScript { - return templ.ComponentScript{ - Name: `__templ_initCalendarHeatmap_46e0`, - Function: `function __templ_initCalendarHeatmap_46e0(elementID, countsByDay){createCalHeatmap(countsByDay, elementID) -}`, - Call: templ.SafeScript(`__templ_initCalendarHeatmap_46e0`, elementID, countsByDay), - CallInline: templ.SafeScriptInline(`__templ_initCalendarHeatmap_46e0`, elementID, countsByDay), - } -} - var _ = templruntime.GeneratedTemplate diff --git a/templates/components/pwa_install.templ b/templates/components/pwa_install.templ index 2a99de5..3ff2ced 100644 --- a/templates/components/pwa_install.templ +++ b/templates/components/pwa_install.templ @@ -1,11 +1,12 @@ package components import "github.com/mikestefanello/pagoda/pkg/controller" +import "github.com/mikestefanello/pagoda/pkg/routing/routenames" templ InstallButtonRedirectsToInstallPage(page *controller.Page, classes string) { Cancel diff --git a/templates/pages/forgot_password_templ.go b/templates/pages/forgot_password_templ.go index a1836e4..6ee35a8 100644 --- a/templates/pages/forgot_password_templ.go +++ b/templates/pages/forgot_password_templ.go @@ -10,6 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" ) @@ -71,7 +72,7 @@ func ForgotPassword(page *controller.Page) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(form.Email) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/forgot_password.templ`, Line: 30, Col: 23} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/forgot_password.templ`, Line: 31, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -89,7 +90,7 @@ func ForgotPassword(page *controller.Page) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var6 templ.SafeURL = templ.URL(page.ToURL("landing_page")) + var templ_7745c5c3_Var6 templ.SafeURL = templ.URL(page.ToURL(routenames.RouteNameLandingPage)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var6))) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err diff --git a/templates/pages/home_feed.templ b/templates/pages/home_feed.templ index 17c3691..cf5caae 100644 --- a/templates/pages/home_feed.templ +++ b/templates/pages/home_feed.templ @@ -3,6 +3,7 @@ package pages import ( "fmt" "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" "strconv" @@ -12,12 +13,12 @@ templ HomeFeed(page *controller.Page) {
if data, ok := page.Data.(types.HomeFeedData); ok { @hello(page, data.JustFinishedOnboarded)
diff --git a/templates/pages/login_templ.go b/templates/pages/login_templ.go index 9569bbf..11d332f 100644 --- a/templates/pages/login_templ.go +++ b/templates/pages/login_templ.go @@ -10,6 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" ) @@ -98,7 +99,7 @@ func login(page *controller.Page, form *types.LoginForm) templ.Component { var templ_7745c5c3_Var6 string templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(form.Email) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/login.templ`, Line: 29, Col: 23} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/login.templ`, Line: 30, Col: 23} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -119,7 +120,7 @@ func login(page *controller.Page, form *types.LoginForm) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(form.Password) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/login.templ`, Line: 44, Col: 26} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/login.templ`, Line: 45, Col: 26} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -129,7 +130,7 @@ func login(page *controller.Page, form *types.LoginForm) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var8 templ.SafeURL = templ.URL(page.ToURL("landing_page")) + var templ_7745c5c3_Var8 templ.SafeURL = templ.URL(page.ToURL(routenames.RouteNameLandingPage)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var8))) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err diff --git a/templates/pages/notifications.templ b/templates/pages/notifications.templ index ed41ed0..b8c5357 100644 --- a/templates/pages/notifications.templ +++ b/templates/pages/notifications.templ @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" ) @@ -12,7 +13,7 @@ templ NotificationsPage(page *controller.Page) { if data, ok := page.Data.(types.NormalNotificationsPageData); ok {
@@ -62,7 +63,7 @@ templ PhoneVerificationField(page *controller.Page) { if form, ok := page.Form.(*types.PhoneNumberVerification); ok { Submit } diff --git a/templates/pages/phone_templ.go b/templates/pages/phone_templ.go index 82e6b9b..736f3e1 100644 --- a/templates/pages/phone_templ.go +++ b/templates/pages/phone_templ.go @@ -11,6 +11,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "fmt" "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" ) @@ -35,7 +36,7 @@ func EditPhonePage(page *controller.Page) templ.Component { templ_7745c5c3_Var1 = templ.NopComponent } ctx = templ.ClearChildren(ctx) - templ_7745c5c3_Err = components.PrevNavBarWithTitle(page.ToURL("preferences"), "", "Edit Phone").Render(ctx, templ_7745c5c3_Buffer) + templ_7745c5c3_Err = components.PrevNavBarWithTitle(page.ToURL(routenames.RouteNamePreferences), "", "Edit Phone").Render(ctx, templ_7745c5c3_Buffer) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } @@ -49,9 +50,9 @@ func EditPhonePage(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var2 string - templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("phone.save") + "?csrf=" + page.CSRF) + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameUpdatePhoneNum) + "?csrf=" + page.CSRF) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 23, Col: 62} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 24, Col: 84} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -70,9 +71,9 @@ func EditPhonePage(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var3 string - templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("phone.verification")) + templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameGetPhoneVerification)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 42, Col: 47} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 43, Col: 67} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3)) if templ_7745c5c3_Err != nil { @@ -141,9 +142,9 @@ func PhoneVerificationField(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var6 string - templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("phone.save") + "?csrf=" + page.CSRF) + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameUpdatePhoneNum) + "?csrf=" + page.CSRF) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 65, Col: 61} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 66, Col: 83} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -161,7 +162,7 @@ func PhoneVerificationField(page *controller.Page) templ.Component { var templ_7745c5c3_Var7 string templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("A verification code was sent to you, please input it below to confirm your phone number. It expires in %d minutes.", data.ExpirationInMinutes)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 71, Col: 168} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 72, Col: 168} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { @@ -201,7 +202,7 @@ func PhoneVerificationField(page *controller.Page) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(form.VerificationCode) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 87, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 88, Col: 36} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -228,9 +229,9 @@ func PhoneVerificationField(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var11 string - templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("phone.verification.submit")) + templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameSubmitPhoneVerification)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 101, Col: 54} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/phone.templ`, Line: 102, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { diff --git a/templates/pages/preferences.templ b/templates/pages/preferences.templ index c5778cc..1bc65f1 100644 --- a/templates/pages/preferences.templ +++ b/templates/pages/preferences.templ @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" "time" @@ -16,7 +17,7 @@ templ Settings(page *controller.Page) { @firstWelcome() }
} @@ -471,7 +470,7 @@ templ finishOnboarding(page *controller.Page) {
diff --git a/templates/pages/preferences_templ.go b/templates/pages/preferences_templ.go index d302da5..a4f2753 100644 --- a/templates/pages/preferences_templ.go +++ b/templates/pages/preferences_templ.go @@ -12,6 +12,7 @@ import ( "fmt" "github.com/mikestefanello/pagoda/pkg/controller" "github.com/mikestefanello/pagoda/pkg/domain" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" "time" @@ -51,9 +52,9 @@ func Settings(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var2 string - templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("display_name.get")) + templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameGetDisplayName)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 19, Col: 43} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 20, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2)) if templ_7745c5c3_Err != nil { @@ -170,9 +171,9 @@ func DisplayName(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var6 string - templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("display_name.save") + "?csrf=" + page.CSRF) + templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameUpdateDisplayName) + "?csrf=" + page.CSRF) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 66, Col: 69} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 67, Col: 87} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6)) if templ_7745c5c3_Err != nil { @@ -198,7 +199,7 @@ func DisplayName(page *controller.Page) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(form.DisplayName) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 73, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 74, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -263,7 +264,7 @@ func NotificationPermissions(page *controller.Page, data types.NotificationPermi var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs("What we'll notify you about") if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 106, Col: 34} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 107, Col: 34} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -341,7 +342,7 @@ func subscription(page *controller.Page, fullyOnboarded bool, plan domain.Produc var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(plan.Value) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 171, Col: 15} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 172, Col: 15} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -359,7 +360,7 @@ func subscription(page *controller.Page, fullyOnboarded bool, plan domain.Produc var templ_7745c5c3_Var13 string templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs("Expiring on ") if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 181, Col: 20} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 182, Col: 20} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13)) if templ_7745c5c3_Err != nil { @@ -507,9 +508,9 @@ func deleteAccountAndData(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var16 string - templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("delete_account.page")) + templ_7745c5c3_Var16, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameDeleteAccountPage)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 373, Col: 45} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 374, Col: 61} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var16)) if templ_7745c5c3_Err != nil { @@ -551,9 +552,9 @@ func AboutMe(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var18 string - templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("profileBio.post") + "?csrf=" + page.CSRF) + templ_7745c5c3_Var18, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameUpdateBio) + "?csrf=" + page.CSRF) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 404, Col: 68} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 405, Col: 80} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var18)) if templ_7745c5c3_Err != nil { @@ -566,7 +567,7 @@ func AboutMe(page *controller.Page) templ.Component { var templ_7745c5c3_Var19 string templ_7745c5c3_Var19, templ_7745c5c3_Err = templ.JoinStringErrs(form.Bio) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 406, Col: 16} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 407, Col: 16} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var19)) if templ_7745c5c3_Err != nil { @@ -624,7 +625,7 @@ func birthdate(page *controller.Page) templ.Component { var templ_7745c5c3_Var21 string templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(data.SelfBirthdate) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 440, Col: 30} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 441, Col: 30} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { @@ -637,7 +638,7 @@ func birthdate(page *controller.Page) templ.Component { var templ_7745c5c3_Var22 string templ_7745c5c3_Var22, templ_7745c5c3_Err = templ.JoinStringErrs(data.SelfBirthdate) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 444, Col: 66} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 445, Col: 66} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var22)) if templ_7745c5c3_Err != nil { @@ -675,9 +676,9 @@ func saveAndReloadPrefsPage(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var24 string - templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("preferences")) + templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNamePreferences)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 460, Col: 37} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 459, Col: 55} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var24)) if templ_7745c5c3_Err != nil { @@ -743,7 +744,7 @@ func finishOnboarding(page *controller.Page) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var27 templ.SafeURL = templ.URL(page.ToURL("finish_onboarding")) + var templ_7745c5c3_Var27 templ.SafeURL = templ.URL(page.ToURL(routenames.RouteNameFinishOnboarding)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var27))) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err @@ -779,9 +780,9 @@ func savePrefs(page *controller.Page) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var29 string - templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("profile")) + templ_7745c5c3_Var29, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameProfile)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 502, Col: 33} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 501, Col: 51} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var29)) if templ_7745c5c3_Err != nil { @@ -820,7 +821,7 @@ func phoneNumber(page *controller.Page, phone string) templ.Component { var templ_7745c5c3_Var31 string templ_7745c5c3_Var31, templ_7745c5c3_Err = templ.JoinStringErrs(phone) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 526, Col: 18} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 525, Col: 18} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var31)) if templ_7745c5c3_Err != nil { @@ -831,9 +832,9 @@ func phoneNumber(page *controller.Page, phone string) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var32 string - templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL("phone.get")) + templ_7745c5c3_Var32, templ_7745c5c3_Err = templ.JoinStringErrs(page.ToURL(routenames.RouteNameGetPhone)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 540, Col: 36} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/preferences.templ`, Line: 539, Col: 53} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var32)) if templ_7745c5c3_Err != nil { diff --git a/templates/pages/register.templ b/templates/pages/register.templ index a8447ad..aa24dbb 100644 --- a/templates/pages/register.templ +++ b/templates/pages/register.templ @@ -2,6 +2,7 @@ package pages import ( "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" ) @@ -11,7 +12,7 @@ templ Register(page *controller.Page) { if data, ok := page.Data.(types.RegisterData);ok {
@@ -116,7 +117,7 @@ templ Register(page *controller.Page) {
diff --git a/templates/pages/register_templ.go b/templates/pages/register_templ.go index 5e4b5c3..b265f12 100644 --- a/templates/pages/register_templ.go +++ b/templates/pages/register_templ.go @@ -10,6 +10,7 @@ import templruntime "github.com/a-h/templ/runtime" import ( "github.com/mikestefanello/pagoda/pkg/controller" + "github.com/mikestefanello/pagoda/pkg/routing/routenames" "github.com/mikestefanello/pagoda/pkg/types" "github.com/mikestefanello/pagoda/templates/components" ) @@ -38,7 +39,7 @@ func Register(page *controller.Page) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var2 templ.SafeURL = templ.URL(page.ToURL("register.post")) + var templ_7745c5c3_Var2 templ.SafeURL = templ.URL(page.ToURL(routenames.RouteNameRegisterSubmit)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var2))) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err @@ -80,7 +81,7 @@ func Register(page *controller.Page) templ.Component { var templ_7745c5c3_Var5 string templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(form.Name) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 33, Col: 24} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 34, Col: 24} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil { @@ -123,7 +124,7 @@ func Register(page *controller.Page) templ.Component { var templ_7745c5c3_Var8 string templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(form.Email) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 51, Col: 25} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 52, Col: 25} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8)) if templ_7745c5c3_Err != nil { @@ -144,7 +145,7 @@ func Register(page *controller.Page) templ.Component { var templ_7745c5c3_Var9 string templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(form.Password) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 67, Col: 28} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 68, Col: 28} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9)) if templ_7745c5c3_Err != nil { @@ -165,7 +166,7 @@ func Register(page *controller.Page) templ.Component { var templ_7745c5c3_Var10 string templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs("Birthdate (you need to be 18+ 🍭πŸ₯)") if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 89, Col: 49} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 90, Col: 49} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10)) if templ_7745c5c3_Err != nil { @@ -178,7 +179,7 @@ func Register(page *controller.Page) templ.Component { var templ_7745c5c3_Var11 string templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(data.MinDate) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 99, Col: 25} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 100, Col: 25} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11)) if templ_7745c5c3_Err != nil { @@ -191,7 +192,7 @@ func Register(page *controller.Page) templ.Component { var templ_7745c5c3_Var12 string templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(form.Birthdate) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 101, Col: 29} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/pages/register.templ`, Line: 102, Col: 29} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12)) if templ_7745c5c3_Err != nil { @@ -209,7 +210,7 @@ func Register(page *controller.Page) templ.Component { if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } - var templ_7745c5c3_Var13 templ.SafeURL = templ.URL(page.ToURL("landing_page")) + var templ_7745c5c3_Var13 templ.SafeURL = templ.URL(page.ToURL(routenames.RouteNameLandingPage)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var13))) if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err diff --git a/templates/templates.go b/templates/templates.go index 07e55d1..be953da 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -14,7 +14,6 @@ const ( PageLogin Page = "login" PageRegister Page = "register" PageResetPassword Page = "reset-password" - PageSearch Page = "search" PageEmailSubscribe Page = "email-subscribe" PagePreferences Page = "preferences" PagePhoneNumber Page = "preferences.phone"