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 ------------- cmd/web/controller/htmx/article-action.go | 105 --------------------- cmd/web/controller/htmx/article.go | 64 ------------- cmd/web/controller/htmx/project-action.go | 105 +++++++++++++++++++++ cmd/web/controller/htmx/project.go | 64 +++++++++++++ cmd/web/controller/project.go | 63 +++++++++++++ cmd/web/model/article.go | 52 ---------- cmd/web/model/project.go | 52 ++++++++++ cmd/web/templates/articles/htmx-article-page.tmpl | 3 - cmd/web/templates/articles/htmx-post-comments.tmpl | 2 - cmd/web/templates/articles/htmx-show.tmpl | 3 - .../templates/articles/partials/comments-card.tmpl | 25 ----- .../templates/articles/partials/comments-form.tmpl | 18 ---- .../articles/partials/comments-wrapper.tmpl | 26 ----- .../articles/partials/detail-post-meta.tmpl | 42 --------- .../articles/partials/favorite-button.tmpl | 15 --- .../templates/articles/partials/follow-button.tmpl | 17 ---- cmd/web/templates/articles/show.tmpl | 38 -------- .../home/partials/article-favorite-button.tmpl | 6 -- .../home/partials/project-favorite-button.tmpl | 6 ++ cmd/web/templates/projects/htmx-post-comments.tmpl | 2 + cmd/web/templates/projects/htmx-project-page.tmpl | 3 + cmd/web/templates/projects/htmx-show.tmpl | 3 + .../templates/projects/partials/comments-card.tmpl | 25 +++++ .../templates/projects/partials/comments-form.tmpl | 18 ++++ .../projects/partials/comments-wrapper.tmpl | 26 +++++ .../projects/partials/detail-post-meta.tmpl | 42 +++++++++ .../projects/partials/favorite-button.tmpl | 15 +++ .../templates/projects/partials/follow-button.tmpl | 17 ++++ cmd/web/templates/projects/show.tmpl | 38 ++++++++ cmd/web/templates/users/htmx-users-articles.tmpl | 2 - cmd/web/templates/users/htmx-users-projects.tmpl | 2 + .../users/partials/article-favorite-button.tmpl | 12 --- .../users/partials/project-favorite-button.tmpl | 12 +++ 34 files changed, 493 insertions(+), 493 deletions(-) delete mode 100644 cmd/web/controller/article.go delete mode 100644 cmd/web/controller/htmx/article-action.go delete mode 100644 cmd/web/controller/htmx/article.go create mode 100644 cmd/web/controller/htmx/project-action.go create mode 100644 cmd/web/controller/htmx/project.go create mode 100644 cmd/web/controller/project.go delete mode 100644 cmd/web/model/article.go create mode 100644 cmd/web/model/project.go delete mode 100644 cmd/web/templates/articles/htmx-article-page.tmpl delete mode 100644 cmd/web/templates/articles/htmx-post-comments.tmpl delete mode 100644 cmd/web/templates/articles/htmx-show.tmpl delete mode 100644 cmd/web/templates/articles/partials/comments-card.tmpl delete mode 100644 cmd/web/templates/articles/partials/comments-form.tmpl delete mode 100644 cmd/web/templates/articles/partials/comments-wrapper.tmpl delete mode 100644 cmd/web/templates/articles/partials/detail-post-meta.tmpl delete mode 100644 cmd/web/templates/articles/partials/favorite-button.tmpl delete mode 100644 cmd/web/templates/articles/partials/follow-button.tmpl delete mode 100644 cmd/web/templates/articles/show.tmpl delete mode 100644 cmd/web/templates/home/partials/article-favorite-button.tmpl create mode 100644 cmd/web/templates/home/partials/project-favorite-button.tmpl create mode 100644 cmd/web/templates/projects/htmx-post-comments.tmpl create mode 100644 cmd/web/templates/projects/htmx-project-page.tmpl create mode 100644 cmd/web/templates/projects/htmx-show.tmpl create mode 100644 cmd/web/templates/projects/partials/comments-card.tmpl create mode 100644 cmd/web/templates/projects/partials/comments-form.tmpl create mode 100644 cmd/web/templates/projects/partials/comments-wrapper.tmpl create mode 100644 cmd/web/templates/projects/partials/detail-post-meta.tmpl create mode 100644 cmd/web/templates/projects/partials/favorite-button.tmpl create mode 100644 cmd/web/templates/projects/partials/follow-button.tmpl create mode 100644 cmd/web/templates/projects/show.tmpl delete mode 100644 cmd/web/templates/users/htmx-users-articles.tmpl create mode 100644 cmd/web/templates/users/htmx-users-projects.tmpl delete mode 100644 cmd/web/templates/users/partials/article-favorite-button.tmpl create mode 100644 cmd/web/templates/users/partials/project-favorite-button.tmpl 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") -} diff --git a/cmd/web/controller/htmx/article-action.go b/cmd/web/controller/htmx/article-action.go deleted file mode 100644 index a7b1f23..0000000 --- a/cmd/web/controller/htmx/article-action.go +++ /dev/null @@ -1,105 +0,0 @@ -package HTMXController - -import ( - "errors" - "projecty/cmd/web/model" - "projecty/internal/authentication" - "projecty/internal/database" - "projecty/internal/helper" - - "github.com/gofiber/fiber/v2" - "gorm.io/gorm" -) - -func ArticleFavoriteAction(c *fiber.Ctx) error { - - var article model.Article - var authenticatedUser model.User - - isArticleFavorited := false - - isAuthenticated, userID := authentication.AuthGet(c) - if !isAuthenticated { - return helper.HTMXRedirectTo("/sign-in", "/htmx/sign-in", c) - - } - - db := database.Get() - - err := db.Model(&article). - Where("slug = ?", c.Params("slug")). - Preload("Favorites"). - Find(&article).Error - - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return helper.HTMXRedirectTo("/sign-in", "/htmx/sign-in", c) - } - } - - authenticatedUser.ID = userID - - if article.FavoritedBy(userID) { - db.Model(&article).Association("Favorites").Delete(&authenticatedUser) - } else { - db.Model(&article).Association("Favorites").Append(&authenticatedUser) - isArticleFavorited = true - } - - return c.Render("articles/partials/favorite-button", fiber.Map{ - "Article": article, - "Slug": article.Slug, - "IsArticleFavorited": isArticleFavorited, - "IsOob": true, - }, "layouts/app-htmx") -} - -func ArticleFollowAction(c *fiber.Ctx) error { - - var article model.Article - var authenticatedUser model.User - - isFollowed := false - - isAuthenticated, userID := authentication.AuthGet(c) - if !isAuthenticated { - return helper.HTMXRedirectTo("/sign-in", "/htmx/sign-in", c) - } - - db := database.Get() - - err := db.Model(&article). - Where("slug = ?", c.Params("slug")). - Preload("Favorites"). - Preload("User.Followers"). - Find(&article).Error - - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return helper.HTMXRedirectTo("/sign-in", "/htmx/sign-in", c) - } - } - - authenticatedUser.ID = userID - - if article.User.FollowedBy(userID) { - - f := model.Follow{ - FollowerID: article.UserID, - FollowingID: userID, - } - - db.Model(&article.User).Association("Followers").Find(&f) - db.Delete(&f) - - } else { - db.Model(&article.User).Association("Followers").Append(&model.Follow{FollowerID: article.UserID, FollowingID: userID}) - isFollowed = true - } - - return c.Render("articles/partials/follow-button", fiber.Map{ - "Article": article, - "IsFollowed": isFollowed, - "IsOob": true, - }, "layouts/app-htmx") -} diff --git a/cmd/web/controller/htmx/article.go b/cmd/web/controller/htmx/article.go deleted file mode 100644 index c8dd8f4..0000000 --- a/cmd/web/controller/htmx/article.go +++ /dev/null @@ -1,64 +0,0 @@ -package HTMXController - -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 - isSelf := false - isFollowed := false - var authenticatedUser model.User - - isAuthenticated, userID := authentication.AuthGet(c) - - db := database.Get() - - if isAuthenticated { - db.Model(&authenticatedUser). - Where("id = ?", userID). - First(&authenticatedUser) - } - - 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"). - Find(&article).Error - - if err != nil { - if errors.Is(err, gorm.ErrRecordNotFound) { - return c.Redirect("/") - } - } - - if isAuthenticated && article.User.FollowedBy(userID) { - isFollowed = true - } - - if isAuthenticated && article.User.ID == userID { - isSelf = true - } - - return c.Render("articles/htmx-article-page", fiber.Map{ - "PageTitle": article.Title, - "NavBarActive": "none", - "Article": article, - "IsOob": false, - "IsSelf": isSelf, - "IsFollowed": isFollowed, - "IsArticleFavorited": article.FavoritedBy(userID), - "AuthenticatedUser": authenticatedUser, - "FiberCtx": c, - }, "layouts/app-htmx") -} diff --git a/cmd/web/controller/htmx/project-action.go b/cmd/web/controller/htmx/project-action.go new file mode 100644 index 0000000..a7b1f23 --- /dev/null +++ b/cmd/web/controller/htmx/project-action.go @@ -0,0 +1,105 @@ +package HTMXController + +import ( + "errors" + "projecty/cmd/web/model" + "projecty/internal/authentication" + "projecty/internal/database" + "projecty/internal/helper" + + "github.com/gofiber/fiber/v2" + "gorm.io/gorm" +) + +func ArticleFavoriteAction(c *fiber.Ctx) error { + + var article model.Article + var authenticatedUser model.User + + isArticleFavorited := false + + isAuthenticated, userID := authentication.AuthGet(c) + if !isAuthenticated { + return helper.HTMXRedirectTo("/sign-in", "/htmx/sign-in", c) + + } + + db := database.Get() + + err := db.Model(&article). + Where("slug = ?", c.Params("slug")). + Preload("Favorites"). + Find(&article).Error + + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return helper.HTMXRedirectTo("/sign-in", "/htmx/sign-in", c) + } + } + + authenticatedUser.ID = userID + + if article.FavoritedBy(userID) { + db.Model(&article).Association("Favorites").Delete(&authenticatedUser) + } else { + db.Model(&article).Association("Favorites").Append(&authenticatedUser) + isArticleFavorited = true + } + + return c.Render("articles/partials/favorite-button", fiber.Map{ + "Article": article, + "Slug": article.Slug, + "IsArticleFavorited": isArticleFavorited, + "IsOob": true, + }, "layouts/app-htmx") +} + +func ArticleFollowAction(c *fiber.Ctx) error { + + var article model.Article + var authenticatedUser model.User + + isFollowed := false + + isAuthenticated, userID := authentication.AuthGet(c) + if !isAuthenticated { + return helper.HTMXRedirectTo("/sign-in", "/htmx/sign-in", c) + } + + db := database.Get() + + err := db.Model(&article). + Where("slug = ?", c.Params("slug")). + Preload("Favorites"). + Preload("User.Followers"). + Find(&article).Error + + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return helper.HTMXRedirectTo("/sign-in", "/htmx/sign-in", c) + } + } + + authenticatedUser.ID = userID + + if article.User.FollowedBy(userID) { + + f := model.Follow{ + FollowerID: article.UserID, + FollowingID: userID, + } + + db.Model(&article.User).Association("Followers").Find(&f) + db.Delete(&f) + + } else { + db.Model(&article.User).Association("Followers").Append(&model.Follow{FollowerID: article.UserID, FollowingID: userID}) + isFollowed = true + } + + return c.Render("articles/partials/follow-button", fiber.Map{ + "Article": article, + "IsFollowed": isFollowed, + "IsOob": true, + }, "layouts/app-htmx") +} diff --git a/cmd/web/controller/htmx/project.go b/cmd/web/controller/htmx/project.go new file mode 100644 index 0000000..c8dd8f4 --- /dev/null +++ b/cmd/web/controller/htmx/project.go @@ -0,0 +1,64 @@ +package HTMXController + +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 + isSelf := false + isFollowed := false + var authenticatedUser model.User + + isAuthenticated, userID := authentication.AuthGet(c) + + db := database.Get() + + if isAuthenticated { + db.Model(&authenticatedUser). + Where("id = ?", userID). + First(&authenticatedUser) + } + + 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"). + Find(&article).Error + + if err != nil { + if errors.Is(err, gorm.ErrRecordNotFound) { + return c.Redirect("/") + } + } + + if isAuthenticated && article.User.FollowedBy(userID) { + isFollowed = true + } + + if isAuthenticated && article.User.ID == userID { + isSelf = true + } + + return c.Render("articles/htmx-article-page", fiber.Map{ + "PageTitle": article.Title, + "NavBarActive": "none", + "Article": article, + "IsOob": false, + "IsSelf": isSelf, + "IsFollowed": isFollowed, + "IsArticleFavorited": article.FavoritedBy(userID), + "AuthenticatedUser": authenticatedUser, + "FiberCtx": c, + }, "layouts/app-htmx") +} diff --git a/cmd/web/controller/project.go b/cmd/web/controller/project.go new file mode 100644 index 0000000..94735f1 --- /dev/null +++ b/cmd/web/controller/project.go @@ -0,0 +1,63 @@ +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") +} diff --git a/cmd/web/model/article.go b/cmd/web/model/article.go deleted file mode 100644 index 1475a0c..0000000 --- a/cmd/web/model/article.go +++ /dev/null @@ -1,52 +0,0 @@ -package model - -import ( - "gorm.io/gorm" -) - -type Article struct { - gorm.Model - Slug string `gorm:"uniqueIndex;not null"` - Title string `gorm:"not null" validate:"required"` - Description string `validate:"required"` - Body string `validate:"required"` - User User `validate:"-"` - UserID uint - Comments []Comment - Favorites []User `gorm:"many2many:article_favorite;"` - Tags []Tag `gorm:"many2many:article_tag;"` - IsFavorited bool `gorm:"-"` -} - -func (Article Article) GetFormattedCreatedAt() string { - dateLayout := "Jan 02, 2006" - return Article.CreatedAt.Format(dateLayout) -} - -func (Article Article) GetFavoriteCount() int { - return len(Article.Favorites) -} - -func (Article Article) FavoritedBy(id uint) bool { - if Article.Favorites == nil { - return false - } - - for _, u := range Article.Favorites { - if u.ID == id { - return true - } - } - - return false -} - -func (Article Article) GetTagsAsCommaSeparated() string { - tagsText := "" - - for i := 0; i < len(Article.Tags); i++ { - tagsText += Article.Tags[i].Name + "," - } - - return tagsText -} diff --git a/cmd/web/model/project.go b/cmd/web/model/project.go new file mode 100644 index 0000000..1475a0c --- /dev/null +++ b/cmd/web/model/project.go @@ -0,0 +1,52 @@ +package model + +import ( + "gorm.io/gorm" +) + +type Article struct { + gorm.Model + Slug string `gorm:"uniqueIndex;not null"` + Title string `gorm:"not null" validate:"required"` + Description string `validate:"required"` + Body string `validate:"required"` + User User `validate:"-"` + UserID uint + Comments []Comment + Favorites []User `gorm:"many2many:article_favorite;"` + Tags []Tag `gorm:"many2many:article_tag;"` + IsFavorited bool `gorm:"-"` +} + +func (Article Article) GetFormattedCreatedAt() string { + dateLayout := "Jan 02, 2006" + return Article.CreatedAt.Format(dateLayout) +} + +func (Article Article) GetFavoriteCount() int { + return len(Article.Favorites) +} + +func (Article Article) FavoritedBy(id uint) bool { + if Article.Favorites == nil { + return false + } + + for _, u := range Article.Favorites { + if u.ID == id { + return true + } + } + + return false +} + +func (Article Article) GetTagsAsCommaSeparated() string { + tagsText := "" + + for i := 0; i < len(Article.Tags); i++ { + tagsText += Article.Tags[i].Name + "," + } + + return tagsText +} diff --git a/cmd/web/templates/articles/htmx-article-page.tmpl b/cmd/web/templates/articles/htmx-article-page.tmpl deleted file mode 100644 index c7a567c..0000000 --- a/cmd/web/templates/articles/htmx-article-page.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -{{ template "projects/show" . }} -{{ template "components/navbar" . }} -{{ template "components/head" . }} \ No newline at end of file diff --git a/cmd/web/templates/articles/htmx-post-comments.tmpl b/cmd/web/templates/articles/htmx-post-comments.tmpl deleted file mode 100644 index 7a1aba4..0000000 --- a/cmd/web/templates/articles/htmx-post-comments.tmpl +++ /dev/null @@ -1,2 +0,0 @@ -{{ template "projects/partials/comments-card" . }} -{{ template "projects/partials/comments-form" . }} \ No newline at end of file diff --git a/cmd/web/templates/articles/htmx-show.tmpl b/cmd/web/templates/articles/htmx-show.tmpl deleted file mode 100644 index e5f6875..0000000 --- a/cmd/web/templates/articles/htmx-show.tmpl +++ /dev/null @@ -1,3 +0,0 @@ -{{ template "projects/partials/detail-title" . }} -{{ template "projects/partials/detail-post-meta" . }} -{{ template "projects/partials/detail-post-content" . }} \ No newline at end of file diff --git a/cmd/web/templates/articles/partials/comments-card.tmpl b/cmd/web/templates/articles/partials/comments-card.tmpl deleted file mode 100644 index 1e6062a..0000000 --- a/cmd/web/templates/articles/partials/comments-card.tmpl +++ /dev/null @@ -1,25 +0,0 @@ -
-
-

{{ .Comment.Body }}

-
- -
\ No newline at end of file diff --git a/cmd/web/templates/articles/partials/comments-form.tmpl b/cmd/web/templates/articles/partials/comments-form.tmpl deleted file mode 100644 index c88cac6..0000000 --- a/cmd/web/templates/articles/partials/comments-form.tmpl +++ /dev/null @@ -1,18 +0,0 @@ -
-
- -
- -
\ No newline at end of file diff --git a/cmd/web/templates/articles/partials/comments-wrapper.tmpl b/cmd/web/templates/articles/partials/comments-wrapper.tmpl deleted file mode 100644 index 2f401de..0000000 --- a/cmd/web/templates/articles/partials/comments-wrapper.tmpl +++ /dev/null @@ -1,26 +0,0 @@ -
- {{ range $comment := .Project.Comments }} - {{ template "projects/partials/comments-card" Dict "Comment" $comment }} - {{ end }} -
- -{{ if .IsAuthenticated }} -
- - {{ template "projects/partials/comments-form" . }} -{{ else }} -
- - Sign in - - or - - sign up - - to add comments on this project. -
-{{ end }} \ No newline at end of file diff --git a/cmd/web/templates/articles/partials/detail-post-meta.tmpl b/cmd/web/templates/articles/partials/detail-post-meta.tmpl deleted file mode 100644 index eb957b4..0000000 --- a/cmd/web/templates/articles/partials/detail-post-meta.tmpl +++ /dev/null @@ -1,42 +0,0 @@ -
- -
- - {{ .Project.User.Name }} - - {{ .Project.GetFormattedCreatedAt }} -
- - {{ if .IsSelf }} - - - - - - {{ else }} - - {{ template "projects/partials/follow-button" . }} - - {{ template "projects/partials/favorite-button" . }} - - {{ end }} -
\ No newline at end of file diff --git a/cmd/web/templates/articles/partials/favorite-button.tmpl b/cmd/web/templates/articles/partials/favorite-button.tmpl deleted file mode 100644 index f72a320..0000000 --- a/cmd/web/templates/articles/partials/favorite-button.tmpl +++ /dev/null @@ -1,15 +0,0 @@ - \ No newline at end of file diff --git a/cmd/web/templates/articles/partials/follow-button.tmpl b/cmd/web/templates/articles/partials/follow-button.tmpl deleted file mode 100644 index 73cd023..0000000 --- a/cmd/web/templates/articles/partials/follow-button.tmpl +++ /dev/null @@ -1,17 +0,0 @@ - \ No newline at end of file diff --git a/cmd/web/templates/articles/show.tmpl b/cmd/web/templates/articles/show.tmpl deleted file mode 100644 index 2078016..0000000 --- a/cmd/web/templates/articles/show.tmpl +++ /dev/null @@ -1,38 +0,0 @@ -
- - - -
-
-
- {{ .Project.Body }} -
-
-
    - {{ range $tag := .Project.Tags }} -
  • {{ $tag.Name }}
  • - {{ end }} -
-
-
- -
- -
- {{ template "projects/partials/detail-post-meta" . }} -
- -
-
-
- -
-
\ No newline at end of file diff --git a/cmd/web/templates/home/partials/article-favorite-button.tmpl b/cmd/web/templates/home/partials/article-favorite-button.tmpl deleted file mode 100644 index 341f458..0000000 --- a/cmd/web/templates/home/partials/article-favorite-button.tmpl +++ /dev/null @@ -1,6 +0,0 @@ - \ No newline at end of file diff --git a/cmd/web/templates/home/partials/project-favorite-button.tmpl b/cmd/web/templates/home/partials/project-favorite-button.tmpl new file mode 100644 index 0000000..341f458 --- /dev/null +++ b/cmd/web/templates/home/partials/project-favorite-button.tmpl @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/cmd/web/templates/projects/htmx-post-comments.tmpl b/cmd/web/templates/projects/htmx-post-comments.tmpl new file mode 100644 index 0000000..7a1aba4 --- /dev/null +++ b/cmd/web/templates/projects/htmx-post-comments.tmpl @@ -0,0 +1,2 @@ +{{ template "projects/partials/comments-card" . }} +{{ template "projects/partials/comments-form" . }} \ No newline at end of file diff --git a/cmd/web/templates/projects/htmx-project-page.tmpl b/cmd/web/templates/projects/htmx-project-page.tmpl new file mode 100644 index 0000000..c7a567c --- /dev/null +++ b/cmd/web/templates/projects/htmx-project-page.tmpl @@ -0,0 +1,3 @@ +{{ template "projects/show" . }} +{{ template "components/navbar" . }} +{{ template "components/head" . }} \ No newline at end of file diff --git a/cmd/web/templates/projects/htmx-show.tmpl b/cmd/web/templates/projects/htmx-show.tmpl new file mode 100644 index 0000000..e5f6875 --- /dev/null +++ b/cmd/web/templates/projects/htmx-show.tmpl @@ -0,0 +1,3 @@ +{{ template "projects/partials/detail-title" . }} +{{ template "projects/partials/detail-post-meta" . }} +{{ template "projects/partials/detail-post-content" . }} \ No newline at end of file diff --git a/cmd/web/templates/projects/partials/comments-card.tmpl b/cmd/web/templates/projects/partials/comments-card.tmpl new file mode 100644 index 0000000..1e6062a --- /dev/null +++ b/cmd/web/templates/projects/partials/comments-card.tmpl @@ -0,0 +1,25 @@ +
+
+

{{ .Comment.Body }}

+
+ +
\ No newline at end of file diff --git a/cmd/web/templates/projects/partials/comments-form.tmpl b/cmd/web/templates/projects/partials/comments-form.tmpl new file mode 100644 index 0000000..c88cac6 --- /dev/null +++ b/cmd/web/templates/projects/partials/comments-form.tmpl @@ -0,0 +1,18 @@ +
+
+ +
+ +
\ No newline at end of file diff --git a/cmd/web/templates/projects/partials/comments-wrapper.tmpl b/cmd/web/templates/projects/partials/comments-wrapper.tmpl new file mode 100644 index 0000000..2f401de --- /dev/null +++ b/cmd/web/templates/projects/partials/comments-wrapper.tmpl @@ -0,0 +1,26 @@ +
+ {{ range $comment := .Project.Comments }} + {{ template "projects/partials/comments-card" Dict "Comment" $comment }} + {{ end }} +
+ +{{ if .IsAuthenticated }} +
+ + {{ template "projects/partials/comments-form" . }} +{{ else }} +
+ + Sign in + + or + + sign up + + to add comments on this project. +
+{{ end }} \ No newline at end of file diff --git a/cmd/web/templates/projects/partials/detail-post-meta.tmpl b/cmd/web/templates/projects/partials/detail-post-meta.tmpl new file mode 100644 index 0000000..eb957b4 --- /dev/null +++ b/cmd/web/templates/projects/partials/detail-post-meta.tmpl @@ -0,0 +1,42 @@ +
+ +
+ + {{ .Project.User.Name }} + + {{ .Project.GetFormattedCreatedAt }} +
+ + {{ if .IsSelf }} + + + + + + {{ else }} + + {{ template "projects/partials/follow-button" . }} + + {{ template "projects/partials/favorite-button" . }} + + {{ end }} +
\ No newline at end of file diff --git a/cmd/web/templates/projects/partials/favorite-button.tmpl b/cmd/web/templates/projects/partials/favorite-button.tmpl new file mode 100644 index 0000000..f72a320 --- /dev/null +++ b/cmd/web/templates/projects/partials/favorite-button.tmpl @@ -0,0 +1,15 @@ + \ No newline at end of file diff --git a/cmd/web/templates/projects/partials/follow-button.tmpl b/cmd/web/templates/projects/partials/follow-button.tmpl new file mode 100644 index 0000000..73cd023 --- /dev/null +++ b/cmd/web/templates/projects/partials/follow-button.tmpl @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/cmd/web/templates/projects/show.tmpl b/cmd/web/templates/projects/show.tmpl new file mode 100644 index 0000000..2078016 --- /dev/null +++ b/cmd/web/templates/projects/show.tmpl @@ -0,0 +1,38 @@ +
+ + + +
+
+
+ {{ .Project.Body }} +
+
+
    + {{ range $tag := .Project.Tags }} +
  • {{ $tag.Name }}
  • + {{ end }} +
+
+
+ +
+ +
+ {{ template "projects/partials/detail-post-meta" . }} +
+ +
+
+
+ +
+
\ No newline at end of file diff --git a/cmd/web/templates/users/htmx-users-articles.tmpl b/cmd/web/templates/users/htmx-users-articles.tmpl deleted file mode 100644 index d002097..0000000 --- a/cmd/web/templates/users/htmx-users-articles.tmpl +++ /dev/null @@ -1,2 +0,0 @@ -{{ template "users/partials/post-preview" . }} -{{ template "users/partials/feed-navigation" . }} \ No newline at end of file diff --git a/cmd/web/templates/users/htmx-users-projects.tmpl b/cmd/web/templates/users/htmx-users-projects.tmpl new file mode 100644 index 0000000..d002097 --- /dev/null +++ b/cmd/web/templates/users/htmx-users-projects.tmpl @@ -0,0 +1,2 @@ +{{ template "users/partials/post-preview" . }} +{{ template "users/partials/feed-navigation" . }} \ No newline at end of file diff --git a/cmd/web/templates/users/partials/article-favorite-button.tmpl b/cmd/web/templates/users/partials/article-favorite-button.tmpl deleted file mode 100644 index 5a70718..0000000 --- a/cmd/web/templates/users/partials/article-favorite-button.tmpl +++ /dev/null @@ -1,12 +0,0 @@ - \ No newline at end of file diff --git a/cmd/web/templates/users/partials/project-favorite-button.tmpl b/cmd/web/templates/users/partials/project-favorite-button.tmpl new file mode 100644 index 0000000..5a70718 --- /dev/null +++ b/cmd/web/templates/users/partials/project-favorite-button.tmpl @@ -0,0 +1,12 @@ + \ No newline at end of file -- cgit v1.2.3