diff --git a/internal/app/handlers/auth_handler.go b/internal/app/handlers/auth_handler.go index 1733250..6b28357 100644 --- a/internal/app/handlers/auth_handler.go +++ b/internal/app/handlers/auth_handler.go @@ -61,5 +61,5 @@ func GoogleCallback(ctx *gin.Context) { func Logout(ctx *gin.Context) { // TODO: Use same values as the GoogleCallback function ctx.SetCookie("jwt_token", "", -1, "/", "localhost", false, true) - ctx.Redirect(http.StatusSeeOther, "/v1/web/home") + ctx.Redirect(http.StatusSeeOther, domain.WEB_HOME) } diff --git a/internal/app/handlers/page_handler.go b/internal/app/handlers/page_handler.go index 7f3c12c..71368e0 100644 --- a/internal/app/handlers/page_handler.go +++ b/internal/app/handlers/page_handler.go @@ -40,7 +40,7 @@ func CreatePage(ctx *gin.Context) { func ProfilePage(ctx *gin.Context) { // If not logged in, direct to the login page if !domain.IsLoggedIn(ctx) { - ctx.Redirect(http.StatusSeeOther, "/v1/web/login") + ctx.Redirect(http.StatusSeeOther, domain.WEB_LOGIN) return } diff --git a/internal/app/server/server.go b/internal/app/server/server.go index 291bc4c..c891e49 100644 --- a/internal/app/server/server.go +++ b/internal/app/server/server.go @@ -124,14 +124,14 @@ func (s *Server) Setup() *Server { s.Router.Use(JwtAuthMiddleWare(jwtSecret)) // Redirect index to home page: Update this as needed - s.Router.GET("/", func(ctx *gin.Context) { ctx.Redirect(http.StatusSeeOther, "/v1/web/home") }) + s.Router.GET("/", func(ctx *gin.Context) { ctx.Redirect(http.StatusSeeOther, domain.WEB_HOME) }) // Wrap all routes with a version - router_v1 := s.Router.Group("/v1") + router_v1 := s.Router.Group(domain.VERSION) // Domain specific routers - router_web := router_v1.Group("/web") - router_api := router_v1.Group("/api") + router_web := router_v1.Group(domain.WEB) + router_api := router_v1.Group(domain.API) // Static routes router_web.Static("/static", "./web/static") @@ -151,8 +151,8 @@ func (s *Server) Setup() *Server { }) // WEB router endpoints + router_web.GET("/", func(ctx *gin.Context) { ctx.Redirect(http.StatusSeeOther, domain.WEB_HOME) }) router_web.GET("/login", handlers.LoginPage) - router_web.GET("/", func(ctx *gin.Context) { ctx.Redirect(http.StatusSeeOther, "/v1/web/home") }) router_web.GET("/home", handlers.HomePage) router_web.GET("/favorites", handlers.FavoritesPage) router_web.GET("/create", handlers.CreatePage) diff --git a/internal/domain/recipe/recipe.go b/internal/domain/recipe/recipe.go deleted file mode 100644 index e69de29..0000000 diff --git a/internal/domain/recipe/repository.go b/internal/domain/recipe/repository.go deleted file mode 100644 index e69de29..0000000 diff --git a/internal/domain/recipe/service.go b/internal/domain/recipe/service.go deleted file mode 100644 index e69de29..0000000 diff --git a/internal/domain/server/routes.go b/internal/domain/server/routes.go new file mode 100644 index 0000000..2e7d279 --- /dev/null +++ b/internal/domain/server/routes.go @@ -0,0 +1,20 @@ +package domain + +// Sub-routes +const VERSION = "/v1" +const WEB = VERSION + "/web" +const API = VERSION + "/api" + +// Web prefixed routes +const WEB_LOGIN = WEB + "/login" +const WEB_INDEX = WEB +const WEB_HOME = WEB + "/home" +const WEB_FAVORITES = WEB + "/favorites" +const WEB_CREATE = WEB + "/create" +const WEB_PROFIlE = WEB + "/profile" +const WEB_LIST = WEB + "/list" + +// API prefixed routes +const API_AUTH_LOGIN = API + "/auth/login" +const API_AUTH_CALLBACK = API + "/auth/callback" +const API_AUTH_LOGOUT = API + "/auth/logout" diff --git a/internal/templates/components/navbar.templ b/internal/templates/components/navbar.templ index b1560a5..ac23cc1 100644 --- a/internal/templates/components/navbar.templ +++ b/internal/templates/components/navbar.templ @@ -1,6 +1,7 @@ package components import "strings" +import "github.com/haydenhargreaves/Potion/internal/domain/server" templ hamburgerMenu() { } @@ -67,11 +68,11 @@ templ Navbar(current string) {

Potion

+ } templ searchSection() { -
- @components.BannerText("Craving Something Specific?") -
- @searchBar() - @components.FilterDropdown() -
-
+
+ @components.BannerText("Craving Something Specific?") +
+ @searchBar() + @components.FilterDropdown() +
+
} templ highlightSection(liked bool) { -
- @components.BannerText("Recipe of the Week!") -

- Our 'Recipe of the Week' is the cream of the crop! We handpick it by looking at what recipes - our community loves most. This isn't just about how many people view a recipe; it's also about - how many times it's been made, liked, reviewed, and its average rating, all combined to find - the true fan favorite of the week. It's our way of highlighting the best recipes that truly - resonate with our users! -

-
- @components.RecipeCardLarge(false) -
-
+
+ @components.BannerText("Recipe of the Week!") +

+ Our 'Recipe of the Week' is the cream of the crop! We handpick it by looking at what recipes + our community loves most. This isn't just about how many people view a recipe; it's also about + how many times it's been made, liked, reviewed, and its average rating, all combined to find + the true fan favorite of the week. It's our way of highlighting the best recipes that truly + resonate with our users! +

+
+ @components.RecipeCardLarge(false) +
+
} templ listsSection() { -
- @components.BannerText("Take Another Look.") -
-

Recently viewed

-
- @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true) - @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false) - @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false) - @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true) - @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false) - @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false) -
-

Make again

-
- @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true) - @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false) - @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false) - @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true) - @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false) - @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false) -
-
-
+
+ @components.BannerText("Take Another Look.") +
+

Recently viewed

+
+ @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true) + @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false) + @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false) + @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true) + @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false) + @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false) +
+

Make again

+
+ @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true) + @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false) + @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false) + @components.RecipeCardSmall("Avocado Toast", "Breakfast - 15 min", "Hayden Hargreaves", true) + @components.RecipeCardSmall("Fried Chicken", "Dinner - 120 min", "Hayden Hargreaves", false) + @components.RecipeCardSmall("Classic Butter Chicken", "Dinner - 60 min", "Hayden Hargreaves", false) +
+
+
} templ ctaSection() { -
-

- Unleash Your Inner Chef! -

-

- Have a unique recipe idea? Want to share your culinary masterpiece with the world? - It's time to bring your creations to life! -

- +

+ Unleash Your Inner Chef! +

+

+ Have a unique recipe idea? Want to share your culinary masterpiece with the world? + It's time to bring your creations to life! +

+
- Create Your Recipe! - -
+ text-lg md:text-2xl font-bold uppercase tracking-wide" + > + Create Your Recipe! + + } templ HomePage() { -@components.Navbar("home") -
-
- @introSection() - @searchSection() - @highlightSection(false) - @listsSection() - @ctaSection() -
-
+ @components.Navbar("home") +
+
+ @introSection() + @searchSection() + @highlightSection(false) + @listsSection() + @ctaSection() +
+
} diff --git a/internal/templates/pages/login.templ b/internal/templates/pages/login.templ index 45b028a..dd9cb45 100644 --- a/internal/templates/pages/login.templ +++ b/internal/templates/pages/login.templ @@ -1,5 +1,7 @@ package templates +import "github.com/haydenhargreaves/Potion/internal/domain/server" + templ LoginPage() {
@@ -15,7 +17,7 @@ templ LoginPage() {