forked from tangled.org/core
this repo has no description

appview: pages: show tags against commits

anirudh.fi f5f258b2 2f49ac9b

verified
Changed files
+73 -22
appview
pages
templates
state
+1
appview/pages/pages.go
··· 499 499 type RepoLogParams struct { 500 500 LoggedInUser *auth.User 501 501 RepoInfo RepoInfo 502 + TagMap map[string][]string 502 503 types.RepoLogResponse 503 504 Active string 504 505 EmailToDidOrHandle map[string]string
+5 -6
appview/pages/templates/repo/index.html
··· 151 151 <div id="commit-log" class="md:col-span-1 px-2 pb-4"> 152 152 <div class="flex justify-between items-center"> 153 153 <a href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group"> 154 - <div class="flex gap-2 items-center"> 155 - {{ i "git-commit-horizontal" "w-4 h-4" }} commits 154 + <div class="flex gap-2 items-center font-bold"> 155 + {{ i "logs" "w-4 h-4" }} commits 156 156 </div> 157 157 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 "> 158 158 view {{ .TotalCommits }} commits {{ i "chevron-right" "w-4 h-4" }} ··· 248 248 {{ if gt (len .BranchesTrunc) 0 }} 249 249 <div id="branches" class="md:col-span-1 px-2 py-4 border-t border-gray-200 dark:border-gray-700"> 250 250 <a href="/{{ .RepoInfo.FullName }}/branches" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group"> 251 - <div class="flex gap-2 items-center"> 252 - <!-- git-branch icon is seemingly bigger than others at 4x4 --> 253 - {{ i "git-branch" "w-3 h-3" }} branches 251 + <div class="flex gap-2 items-center font-bold"> 252 + {{ i "git-branch" "w-4 h-4" }} branches 254 253 </div> 255 254 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 "> 256 255 view {{ len .Branches }} branches {{ i "chevron-right" "w-4 h-4" }} ··· 283 282 <div id="tags" class="md:col-span-1 px-2 py-4 border-t border-gray-200 dark:border-gray-700"> 284 283 <div class="flex justify-between items-center"> 285 284 <a href="/{{ .RepoInfo.FullName }}/tags" class="flex text-black dark:text-white items-center gap-4 pb-2 no-underline hover:no-underline group"> 286 - <div class="flex gap-2 items-center"> 285 + <div class="flex gap-2 items-center font-bold"> 287 286 {{ i "tags" "w-4 h-4" }} tags 288 287 </div> 289 288 <span class="hidden group-hover:flex gap-2 items-center text-sm text-gray-500 dark:text-gray-400 ">
+41 -16
appview/pages/templates/repo/log.html
··· 43 43 </td> 44 44 <td class=" py-3 align-top"> 45 45 <div> 46 - <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a> 47 - {{ if gt (len $messageParts) 1 }} 48 - <button class="ml-2 py-1/2 px-1 bg-gray-200 hover:bg-gray-400 dark:bg-gray-700 dark:hover:bg-gray-600 rounded" hx-on:click="this.nextElementSibling.classList.toggle('hidden')">{{ i "ellipsis" "w-3 h-3" }}</button> 46 + <div class="flex items-center justify-start"> 47 + <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a> 48 + {{ if gt (len $messageParts) 1 }} 49 + <button class="ml-2 py-1/2 px-1 bg-gray-200 hover:bg-gray-400 dark:bg-gray-700 dark:hover:bg-gray-600 rounded" hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">{{ i "ellipsis" "w-3 h-3" }}</button> 50 + {{ end }} 51 + 52 + 53 + {{ if index $.TagMap $commit.Hash.String }} 54 + {{ range $tag := index $.TagMap $commit.Hash.String }} 55 + <span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center"> 56 + {{ $tag }} 57 + </span> 58 + {{ end }} 59 + {{ end }} 60 + 61 + </div> 62 + 63 + {{ if gt (len $messageParts) 1 }} 49 64 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p> 50 65 {{ end }} 51 - </div> 52 66 </td> 53 67 <td class=" py-3 align-top text-gray-500 dark:text-gray-400">{{ timeFmt $commit.Author.When }}</td> 54 68 </tr> 55 - {{ end }} 69 + {{ end }} 56 70 </tbody> 57 71 </table> 58 72 ··· 66 80 <div> 67 81 <div class="flex items-center justify-between"> 68 82 <div class="flex-1"> 69 - <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 70 - class="inline no-underline hover:underline dark:text-white"> 71 - {{ index $messageParts 0 }} 72 - </a> 73 - {{ if gt (len $messageParts) 1 }} 74 - <button 75 - class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600" 76 - hx-on:click="this.nextElementSibling.classList.toggle('hidden')"> 77 - {{ i "ellipsis" "w-3 h-3" }} 78 - </button> 79 - {{ end }} 83 + <div class="flex items-center"> 84 + <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 85 + class="inline no-underline hover:underline dark:text-white"> 86 + {{ index $messageParts 0 }} 87 + </a> 88 + {{ if gt (len $messageParts) 1 }} 89 + <button 90 + class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600 ml-2" 91 + hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"> 92 + {{ i "ellipsis" "w-3 h-3" }} 93 + </button> 94 + {{ end }} 95 + 96 + {{ if index $.TagMap $commit.Hash.String }} 97 + {{ range $tag := index $.TagMap $commit.Hash.String }} 98 + <span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center"> 99 + {{ $tag }} 100 + </span> 101 + {{ end }} 102 + {{ end }} 103 + </div> 104 + 80 105 {{ if gt (len $messageParts) 1 }} 81 106 <p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"> 82 107 {{ nl2br (index $messageParts 1) }}
+26
appview/state/repo.go
··· 167 167 return 168 168 } 169 169 170 + resp, err = us.Tags(f.OwnerDid(), f.RepoName) 171 + if err != nil { 172 + log.Println("failed to reach knotserver", err) 173 + return 174 + } 175 + 176 + body, err = io.ReadAll(resp.Body) 177 + if err != nil { 178 + log.Printf("error reading response body: %v", err) 179 + return 180 + } 181 + 182 + var result types.RepoTagsResponse 183 + err = json.Unmarshal(body, &result) 184 + if err != nil { 185 + log.Printf("Error unmarshalling response body: %v", err) 186 + return 187 + } 188 + 189 + tagMap := make(map[string][]string) 190 + for _, tag := range result.Tags { 191 + hash := tag.Hash 192 + tagMap[hash] = append(tagMap[hash], tag.Name) 193 + } 194 + 170 195 user := s.auth.GetUser(r) 171 196 s.pages.RepoLog(w, pages.RepoLogParams{ 172 197 LoggedInUser: user, 198 + TagMap: tagMap, 173 199 RepoInfo: f.RepoInfo(s, user), 174 200 RepoLogResponse: repolog, 175 201 EmailToDidOrHandle: EmailToDidOrHandle(s, uniqueEmails(repolog.Commits)),