diff options
Diffstat (limited to 'cmd/web/templates/projects/partials')
6 files changed, 143 insertions, 0 deletions
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 @@ +<div class="card"> + <div class="card-block"> + <p class="card-text">{{ .Comment.Body }}</p> + </div> + <div class="card-footer"> + <a href="/users/{{ .Comment.User.Username }}" + hx-push-url="/users/{{ .Comment.User.Username }}" + hx-get="/htmx/users/{{ .Comment.User.Username }}" + hx-target="#app-body" + class="comment-author" + > + <img src="{{ .Comment.User.Image }}" class="comment-author-img" /> + </a> + + <a href="/users/{{ .Comment.User.Username }}" + hx-push-url="/users/{{ .Comment.User.Username }}" + hx-get="/htmx/users/{{ .Comment.User.Username }}" + hx-target="#app-body" + class="comment-author" + > + {{ .Comment.User.Name }} + </a> + <span class="date-posted">{{ .Comment.GetFormattedCreatedAt }}</span> + </div> +</div>
\ 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 @@ +<form id="project-comment-form" class="card comment-form" + hx-post="/htmx/projects/{{ .Project.Slug }}/comments" + hx-target="#project-comments-wrapper" hx-swap="afterbegin show:top" + + {{ if .IsOob }} + hx-swap-oob="true" + {{ end }} +> + <div class="card-block"> + <textarea class="form-control" placeholder="Write a comment..." rows="3" name="comment"></textarea> + </div> + <div class="card-footer"> + <img src="{{ .Project.User.Image }}" class="comment-author-img" /> + <button class="btn btn-sm btn-primary"> + Post Comment + </button> + </div> +</form>
\ 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 @@ +<div id="project-comments-wrapper"> + {{ range $comment := .Project.Comments }} + {{ template "projects/partials/comments-card" Dict "Comment" $comment }} + {{ end }} +</div> + +{{ if .IsAuthenticated }} + <div id="form-message"></div> + + {{ template "projects/partials/comments-form" . }} +{{ else }} + <div> + <a href="/htmx/sign-in" hx-get="/htmx/sign-in" hx-target="#app-body" + hx-push-url="/sign-in" + > + Sign in + </a> + or + <a href="/htmx/sign-up" hx-get="/htmx/sign-up" hx-target="#app-body" + hx-push-url="/sign-up" + > + sign up + </a> + to add comments on this project. + </div> +{{ 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 @@ +<div class="post-meta"> + <a href="#"><img src="{{ .Project.User.Image }}" /></a> + <div class="info"> + <a href="/users/{{ .Project.User.Username }}" + hx-push-url="/users/{{ .Project.User.Username }}" + hx-get="/htmx/users/{{ .Project.User.Username }}" + hx-target="#app-body" + class="author" + > + {{ .Project.User.Name }} + </a> + <span class="date">{{ .Project.GetFormattedCreatedAt }}</span> + </div> + + {{ if .IsSelf }} + + <button class="btn btn-outline-secondary btn-sm edit-button" + hx-get="/htmx/editor/{{ .Project.Slug }}" + hx-target="#app-body" + hx-push-url="/editor/{{ .Project.Slug }}" + > + <i class="ion-edit"></i> + Edit Project + </button> + + <button class="btn btn-outline-danger btn-sm delete-button" + hx-delete="/htmx/projects/{{ .Project.Slug }}" + hx-target="#app-body" + hx-confirm="Are you sure you wish to delete the project?" + > + <i class="ion-trash-a"></i> + Delete Project + </button> + + {{ else }} + + {{ template "projects/partials/follow-button" . }} + + {{ template "projects/partials/favorite-button" . }} + + {{ end }} +</div>
\ 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 @@ +<button class="btn btn-outline-primary btn-sm {{ if .IsProjectFavorited }} active {{ end }} favorite-button" + hx-post="/htmx/projects/{{ .Project.Slug }}/favorite" + + {{ if .IsOob }} + hx-swap-oob="outerHTML:.favorite-button" + {{ end }} +> + <i class="ion-heart"></i> + {{ if .IsProjectFavorited }} + Unfavorite Post + {{ else }} + Favorite Post + {{ end }} + ({{ .Project.GetFavoriteCount }}) +</button>
\ 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 @@ +<button class="btn btn-sm btn-outline-secondary follow-button" + hx-post="/htmx/projects/follow-user/{{ .Project.Slug }}" + + {{ if .IsOob }} + hx-swap-oob="outerHTML:.follow-button" + {{ end }} +> + {{ if .IsFollowed }} + <i class="ion-minus-round"></i> + Unfollow + {{ else }} + <i class="ion-plus-round"></i> + Follow + {{ end }} + {{ .Project.User.Name }} + <span class="counter">({{ .Project.User.FollowersCount }})</span> +</button>
\ No newline at end of file |