feat: added following system using cookies
This commit is contained in:
@@ -100,3 +100,15 @@ proc getTabClass*(query: Query; tab: QueryKind): string =
|
||||
proc getAvatarClass*(prefs: Prefs): string =
|
||||
if prefs.squareAvatars: "avatar"
|
||||
else: "avatar round"
|
||||
|
||||
proc renderFollowButton*(user: User; prefs: Prefs; path: string): VNode =
|
||||
let
|
||||
isFollowing = user.username in prefs.following
|
||||
action = if isFollowing: "/unfollow" else: "/follow"
|
||||
text = if isFollowing: "Unfollow" else: "Follow"
|
||||
class = if isFollowing: "follow-button unfollow" else: "follow-button"
|
||||
|
||||
buildHtml(form(action=action, `method`="post", class="follow-form")):
|
||||
refererField path
|
||||
hiddenField("user", user.username)
|
||||
button(class=class, `type`="submit"): text text
|
||||
|
||||
Reference in New Issue
Block a user