aboutsummaryrefslogtreecommitdiff
path: root/cmd/web/templates/users/partials
diff options
context:
space:
mode:
authorVikas Kushwaha <dev@vikas.rocks>2025-02-11 16:31:08 +0530
committerVikas Kushwaha <dev@vikas.rocks>2025-02-11 16:31:08 +0530
commit57eb8f6712361a3bf75983ce153fac4846dc0273 (patch)
tree269a168d59c917c4e313c819e2b4c3ff8175f912 /cmd/web/templates/users/partials
Initial commit
Diffstat (limited to 'cmd/web/templates/users/partials')
-rw-r--r--cmd/web/templates/users/partials/article-favorite-button.tmpl12
-rw-r--r--cmd/web/templates/users/partials/feed-navigation.tmpl17
-rw-r--r--cmd/web/templates/users/partials/follow-button.tmpl14
-rw-r--r--cmd/web/templates/users/partials/post-preview.tmpl61
4 files changed, 104 insertions, 0 deletions
diff --git a/cmd/web/templates/users/partials/article-favorite-button.tmpl b/cmd/web/templates/users/partials/article-favorite-button.tmpl
new file mode 100644
index 0000000..c63182a
--- /dev/null
+++ b/cmd/web/templates/users/partials/article-favorite-button.tmpl
@@ -0,0 +1,12 @@
+<button class="btn btn-outline-primary btn-sm pull-xs-right {{ if .Article.IsFavorited }} active {{ end }}"
+ hx-post="/htmx/users/articles/{{ .Article.Slug }}/favorite"
+
+ {{ if .IsSelf }}
+ hx-swap="delete"
+ hx-target="closest .post-preview"
+ {{ else }}
+ hx-swap="outerHTML"
+ {{ end }}
+>
+ <i class="ion-heart"></i> {{ .Article.GetFavoriteCount }}
+</button> \ No newline at end of file
diff --git a/cmd/web/templates/users/partials/feed-navigation.tmpl b/cmd/web/templates/users/partials/feed-navigation.tmpl
new file mode 100644
index 0000000..00629d9
--- /dev/null
+++ b/cmd/web/templates/users/partials/feed-navigation.tmpl
@@ -0,0 +1,17 @@
+<ul id="user-feed-navigation" class="nav nav-pills outline-active" hx-swap-oob="true">
+ {{ range $item := .FeedNavbarItems }}
+ <li class="nav-item">
+ <a class="nav-link {{ if $item.IsActive }} active {{ end }}"
+ {{ if not $item.IsActive }}
+ href="{{ $item.HXPushURL }}"
+ hx-get="{{ $item.HXGetURL }}"
+ hx-trigger="click"
+ hx-target="#user-post-preview"
+ hx-push-url="{{ $item.HXPushURL }}"
+ {{ end }}
+ >
+ {{ $item.Title }}
+ </a>
+ </li>
+ {{ end }}
+</ul> \ No newline at end of file
diff --git a/cmd/web/templates/users/partials/follow-button.tmpl b/cmd/web/templates/users/partials/follow-button.tmpl
new file mode 100644
index 0000000..d893ea0
--- /dev/null
+++ b/cmd/web/templates/users/partials/follow-button.tmpl
@@ -0,0 +1,14 @@
+<button class="btn btn-sm btn-outline-secondary follow-button action-btn"
+ hx-post="/htmx/users/{{ .User.Username }}/follow"
+ hx-swap="outerHTML"
+>
+ {{ if .IsFollowed }}
+ <i class="ion-minus-round"></i>
+ Unfollow
+ {{ else }}
+ <i class="ion-plus-round"></i>
+ Follow
+ {{ end }}
+ {{ .User.Name }}
+ <span class="counter">({{ .User.FollowersCount }})</span>
+</button> \ No newline at end of file
diff --git a/cmd/web/templates/users/partials/post-preview.tmpl b/cmd/web/templates/users/partials/post-preview.tmpl
new file mode 100644
index 0000000..4e00357
--- /dev/null
+++ b/cmd/web/templates/users/partials/post-preview.tmpl
@@ -0,0 +1,61 @@
+<div id="user-post-preview">
+ {{ if .HasArticles }}
+ {{ $isSelf := .IsSelf }}
+ {{ range $article := .Articles }}
+
+ <div class="post-preview">
+ <div class="post-meta">
+ <a href="/users/{{ $article.User.Username }}"
+ hx-push-url="/users/{{ $article.User.Username }}"
+ hx-get="/htmx/users/{{ $article.User.Username }}"
+ hx-target="#app-body"
+ >
+ <img src="{{ $article.User.Image }}" />
+ </a>
+
+ <div class="info">
+ <a href="/users/{{ $article.User.Username }}"
+ hx-push-url="/users/{{ $article.User.Username }}"
+ hx-get="/htmx/users/{{ $article.User.Username }}"
+ hx-target="#app-body"
+ class="author"
+ >
+ {{ $article.User.Name }}
+ </a>
+ <span class="date">{{ $article.GetFormattedCreatedAt }}</span>
+ </div>
+
+ {{ template "users/partials/article-favorite-button" Dict "Article" $article "IsSelf" $isSelf }}
+
+ </div>
+ <a href="/articles/{{ $article.Slug }}"
+ hx-push-url="/articles/{{ $article.Slug }}"
+ hx-get="/htmx/articles/{{ $article.Slug }}"
+ hx-target="#app-body"
+ class="preview-link"
+ >
+ <h1>{{ $article.Title }}</h1>
+ <p>{{ $article.Description }}</p>
+
+ <div class="m-t-1">
+ <span>Read more...</span>
+
+ <ul class="tag-list">
+ {{ range $tag := $article.Tags }}
+ <li class="tag-default tag-pill tag-outline">{{ $tag.Name }}</li>
+ {{ end }}
+ </ul>
+ </div>
+ </a>
+ </div>
+ {{ end }}
+ {{ end }}
+
+ {{ if not .HasArticles }}
+ <div class="post-preview">
+ <div class="alert alert-warning" role="alert">
+ No articles are here... yet.
+ </div>
+ </div>
+ {{ end }}
+</div> \ No newline at end of file