From e44397dcbb9454f89b8263738d5ccf1e20a12074 Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Tue, 11 Feb 2025 17:50:21 +0530 Subject: Substituted 'article' with 'project' in filenames --- cmd/web/controller/article.go | 63 ------------------------------------------- 1 file changed, 63 deletions(-) delete mode 100644 cmd/web/controller/article.go (limited to 'cmd/web/controller/article.go') diff --git a/cmd/web/controller/article.go b/cmd/web/controller/article.go deleted file mode 100644 index 94735f1..0000000 --- a/cmd/web/controller/article.go +++ /dev/null @@ -1,63 +0,0 @@ -package controller - -import ( - "errors" - "projecty/cmd/web/model" - "projecty/internal/authentication" - "projecty/internal/database" - - "github.com/gofiber/fiber/v2" - "gorm.io/gorm" -) - -func ArticleDetailPage(c *fiber.Ctx) error { - - var article model.Article - var authenticatedUser model.User - isSelf := false - isFollowed := false - - isAuthenticated, userID := authentication.AuthGet(c) - - db := database.Get() - - err := db.Model(&article). - Where("slug = ?", c.Params("slug")). - Preload("Favorites"). - Preload("Tags", func(db *gorm.DB) *gorm.DB { - return db.Order("tags.name asc") - }). - Preload("User.Followers"). - Find(&article).Error - - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return c.Redirect("/") - } - } - - if isAuthenticated { - db.Model(&authenticatedUser). - Where("id = ?", userID). - First(&authenticatedUser) - } - - if isAuthenticated && article.User.FollowedBy(userID) { - isFollowed = true - } - - if isAuthenticated && article.User.ID == userID { - isSelf = true - } - - return c.Render("articles/show", fiber.Map{ - "PageTitle": article.Title + " — Projecty", - "Article": article, - "FiberCtx": c, - "IsOob": false, - "IsSelf": isSelf, - "IsFollowed": isFollowed, - "IsArticleFavorited": article.FavoritedBy(userID), - "AuthenticatedUser": authenticatedUser, - }, "layouts/app") -} -- cgit v1.2.3