This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / appview / pages / templates / timeline / fragments / timeline.html
7.3 kB 168 lines
1{{ define "timeline/fragments/timeline" }} 2 <div id="timeline-feed" class="mt-4 py-4"> 3 <div class="flex items-center justify-between pl-4 pb-4"> 4 <h3 class="text-base dark:text-white flex items-center gap-2"> 5 {{ i "gallery-vertical" "size-4 flex-shrink-0" }} 6 Timeline 7 </h3> 8 {{ if .LoggedInUser }} 9 <div class="btn-group grid grid-cols-2"> 10 <a href="/timeline?following=false" 11 hx-get="/timeline?following=false" 12 hx-target="#timeline-feed" 13 hx-select="#timeline-feed" 14 hx-swap="outerHTML" 15 hx-push-url="true" 16 class="group btn-group-item inline-flex items-center justify-center {{ if not .FollowingOnly }}active{{ end }}"> 17 <span class="relative inline-flex items-center justify-center"> 18 <span class="group-[.htmx-request]:invisible">Global</span> 19 {{ i "loader-circle" "size-3.5 animate-spin absolute hidden group-[.htmx-request]:block" }} 20 </span> 21 </a> 22 <a href="/timeline?following=true" 23 hx-get="/timeline?following=true" 24 hx-target="#timeline-feed" 25 hx-select="#timeline-feed" 26 hx-swap="outerHTML" 27 hx-push-url="true" 28 class="group btn-group-item inline-flex items-center justify-center {{ if .FollowingOnly }}active{{ end }}"> 29 <span class="relative inline-flex items-center justify-center"> 30 <span class="group-[.htmx-request]:invisible">Following</span> 31 {{ i "loader-circle" "size-3.5 animate-spin absolute hidden group-[.htmx-request]:block" }} 32 </span> 33 </a> 34 </div> 35 {{ end }} 36 </div> 37 38 {{ if .Timeline }} 39 <div class="flex flex-col gap-4"> 40 {{ range $i, $g := .Timeline }} 41 <div class="relative"> 42 {{ if ne $i 0 }} 43 <div class="absolute left-8 -top-4 w-px h-4 bg-gray-300 dark:bg-gray-600"></div> 44 {{ end }} 45 {{ $primary := $g.Primary }} 46 <div class="flex flex-col divide-y divide-gray-200 dark:divide-gray-700 border border-gray-200 dark:border-gray-700 rounded-sm"> 47 {{ if $primary.Repo }} 48 {{ template "timeline/fragments/repoEvent" (list $ $g) }} 49 {{ else if $primary.RepoStar }} 50 {{ template "timeline/fragments/starEvent" (list $ $g) }} 51 {{ else if $primary.Follow }} 52 {{ template "timeline/fragments/followEvent" (list $ $g) }} 53 {{ end }} 54 </div> 55 </div> 56 {{ end }} 57 </div> 58 {{ else }} 59 <div class="px-4 py-8 text-sm text-center text-gray-400 dark:text-gray-500 border border-gray-200 dark:border-gray-700 rounded-sm "> 60 <div class="w-10 h-10 mx-auto mb-3 text-gray-300 dark:text-gray-600"> 61 {{ if .FollowingOnly }} 62 {{ i "user-round-x" "size-10" }} 63 {{ else }} 64 {{ i "radio" "size-10" }} 65 {{ end }} 66 </div> 67 <p class="text-sm text-gray-500 dark:text-gray-400"> 68 {{ if .FollowingOnly }} 69 Follow some users to see their activity here. 70 {{ else }} 71 Nothing here yet. 72 {{ end }} 73 </p> 74 </div> 75 {{ end }} 76 </div> 77{{ end }} 78 79{{ define "timeline/fragments/repoEvent" }} 80 {{ $root := index . 0 }} 81 {{ $group := index . 1 }} 82 {{ $event := $group.Primary }} 83 {{ $repo := $event.Repo }} 84 {{ $source := $event.Source }} 85 {{ $userHandle := resolve $repo.Did }} 86 <div class="pl-6 py-2 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 flex flex-wrap items-center gap-2 text-sm"> 87 {{ template "user/fragments/picHandleLink" $repo.Did }} 88 {{ with $source }} 89 {{ $sourceDid := resolve .Did }} 90 forked 91 <a href="/{{ $sourceDid }}/{{ .Slug }}"class="no-underline hover:underline"> 92 {{ $sourceDid }}/{{ .Name }} 93 </a> 94 to 95 <a href="/{{ $userHandle }}/{{ $repo.Slug }}" class="no-underline hover:underline">{{ $repo.Name }}</a> 96 {{ else }} 97 created 98 <a href="/{{ $userHandle }}/{{ $repo.Slug }}" class="no-underline hover:underline"> 99 {{ $repo.Name }} 100 </a> 101 {{ end }} 102 <span class="text-gray-700 dark:text-gray-400 text-xs">{{ template "repo/fragments/time" $repo.Created }}</span> 103 </div> 104 {{ with $repo }} 105 {{ template "user/fragments/repoCard" (list $root . true true (dict "IsStarred" $event.IsStarred "SubjectAt" .RepoAt "StarCount" $event.StarCount "RepoName" .Slug)) }} 106 {{ end }} 107{{ end }} 108 109{{ define "timeline/fragments/starEvent" }} 110 {{ $root := index . 0 }} 111 {{ $group := index . 1 }} 112 {{ $event := $group.Primary }} 113 {{ $star := $event.RepoStar }} 114 {{ with $star }} 115 {{ $repoOwnerHandle := resolve .Repo.Did }} 116 <div class="pl-6 py-2 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 flex flex-wrap items-center gap-2 text-sm"> 117 {{ template "user/fragments/picHandleLink" .Did }} 118 {{ if $group.IsCollapsed }} 119 <span class="inline-flex items-center gap-1.5"> 120 {{ template "timeline/fragments/othersBadge" $group }} 121 starred 122 </span> 123 {{ else }} 124 starred 125 {{ end }} 126 <a href="/{{ $repoOwnerHandle }}/{{ .Repo.Slug }}" class="no-underline hover:underline"> 127 {{ $repoOwnerHandle | truncateAt30 }}/{{ .Repo.Name }} 128 </a> 129 <span class="text-gray-700 dark:text-gray-400 text-xs">{{ template "repo/fragments/time" .Created }}</span> 130 </div> 131 {{ with .Repo }} 132 {{ template "user/fragments/repoCard" (list $root . true true (dict "IsStarred" $event.IsStarred "SubjectAt" .RepoAt "StarCount" $event.StarCount "RepoName" .Slug)) }} 133 {{ end }} 134 {{ end }} 135{{ end }} 136 137{{ define "timeline/fragments/followEvent" }} 138 {{ $root := index . 0 }} 139 {{ $group := index . 1 }} 140 {{ $event := $group.Primary }} 141 {{ $follow := $event.Follow }} 142 {{ $profile := $event.Profile }} 143 {{ $followStats := $event.FollowStats }} 144 {{ $followStatus := $event.FollowStatus }} 145 146 {{ $subjectHandle := resolve $follow.SubjectDid }} 147 <div class="pl-6 py-2 bg-white dark:bg-gray-800 text-gray-600 dark:text-gray-300 flex flex-wrap items-center gap-2 text-sm"> 148 {{ template "user/fragments/picHandleLink" $follow.UserDid }} 149 {{ if $group.IsCollapsed }} 150 <span class="inline-flex items-center gap-1.5"> 151 {{ template "timeline/fragments/othersBadge" $group }} 152 followed 153 </span> 154 {{ else }} 155 followed 156 {{ end }} 157 {{ template "user/fragments/picHandleLink" $subjectHandle }} 158 <span class="text-gray-700 dark:text-gray-400 text-xs">{{ template "repo/fragments/time" $follow.FollowedAt }}</span> 159 </div> 160 {{ template "user/fragments/followCard" 161 (dict 162 "LoggedInUser" $root.LoggedInUser 163 "UserDid" $follow.SubjectDid 164 "Profile" $profile 165 "FollowStatus" $followStatus 166 "FollowersCount" $followStats.Followers 167 "FollowingCount" $followStats.Following) }} 168{{ end }}