Monorepo for Tangled tangled.org
854
fork

Configure Feed

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

add tag pills to commit log

my vision...

Akshay 329cd001 e56dc938

+184 -150
+1
appview/pages/pages.go
··· 194 194 LoggedInUser *auth.User 195 195 RepoInfo RepoInfo 196 196 Active string 197 + TagMap map[string][]string 197 198 types.RepoIndexResponse 198 199 } 199 200
+169 -150
appview/pages/templates/repo/index.html
··· 2 2 3 3 {{ define "repoContent" }} 4 4 <main> 5 - <div class="flex justify-between pb-5"> 6 - <select 7 - onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value" 8 - class="p-1 border border-gray-200 bg-white" 9 - > 10 - <optgroup label="branches" class="bold text-sm"> 11 - {{ range .Branches }} 12 - <option 13 - value="{{ .Reference.Name }}" 14 - class="py-1" 15 - {{ if eq .Reference.Name $.Ref }} 16 - selected 17 - {{ end }} 18 - > 19 - {{ .Reference.Name }} 20 - </option> 21 - {{ end }} 22 - </optgroup> 23 - <optgroup label="tags" class="bold text-sm"> 24 - {{ range .Tags }} 25 - <option 26 - value="{{ .Reference.Name }}" 27 - class="py-1" 28 - {{ if eq .Reference.Name $.Ref }} 29 - selected 30 - {{ end }} 31 - > 32 - {{ .Reference.Name }} 33 - </option> 34 - {{ else }} 35 - <option class="py-1" disabled>no tags found</option> 36 - {{ end }} 37 - </optgroup> 38 - </select> 39 - <a 40 - href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref }}" 41 - class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold" 42 - > 43 - <i class="w-4 h-4" data-lucide="logs"></i> 44 - {{ .TotalCommits }} 45 - {{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }} 46 - </a> 5 + {{ block "branchSelector" . }} {{ end }} 6 + <div class="flex gap-2"> 7 + {{ block "fileTree" . }} {{ end }} 8 + {{ block "commitLog" . }} {{ end }} 47 9 </div> 10 + </main> 11 + {{ end }} 48 12 49 - <div class="flex gap-2"> 50 - <div id="file-tree" class="w-3/5 pr-2 border-r border-gray-200"> 51 - {{ $containerstyle := "py-1" }} 52 - {{ $linkstyle := "no-underline hover:underline" }} 13 + {{ define "branchSelector" }} 14 + <div class="flex justify-between pb-5"> 15 + <select 16 + onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value" 17 + class="p-1 border border-gray-200 bg-white" 18 + > 19 + <optgroup label="branches" class="bold text-sm"> 20 + {{ range .Branches }} 21 + <option 22 + value="{{ .Reference.Name }}" 23 + class="py-1" 24 + {{ if eq .Reference.Name $.Ref }} 25 + selected 26 + {{ end }} 27 + > 28 + {{ .Reference.Name }} 29 + </option> 30 + {{ end }} 31 + </optgroup> 32 + <optgroup label="tags" class="bold text-sm"> 33 + {{ range .Tags }} 34 + <option 35 + value="{{ .Reference.Name }}" 36 + class="py-1" 37 + {{ if eq .Reference.Name $.Ref }} 38 + selected 39 + {{ end }} 40 + > 41 + {{ .Reference.Name }} 42 + </option> 43 + {{ else }} 44 + <option class="py-1" disabled>no tags found</option> 45 + {{ end }} 46 + </optgroup> 47 + </select> 48 + <a 49 + href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref }}" 50 + class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold" 51 + > 52 + <i class="w-4 h-4" data-lucide="logs"></i> 53 + {{ .TotalCommits }} 54 + {{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }} 55 + </a> 56 + </div> 57 + {{ end }} 53 58 54 - {{ range .Files }} 55 - {{ if not .IsFile }} 56 - <div class="{{ $containerstyle }}"> 57 - <div class="flex justify-between items-center"> 58 - <a 59 - href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}" 60 - class="{{ $linkstyle }}" 61 - > 62 - <div class="flex items-center gap-2"> 63 - <i 64 - class="w-3 h-3 fill-current" 65 - data-lucide="folder" 66 - ></i 67 - >{{ .Name }} 68 - </div> 69 - </a> 59 + {{ define "fileTree" }} 60 + <div id="file-tree" class="w-3/5 pr-2 border-r border-gray-200"> 61 + {{ $containerstyle := "py-1" }} 62 + {{ $linkstyle := "no-underline hover:underline" }} 70 63 71 - <time class="text-xs text-gray-500" 72 - >{{ timeFmt .LastCommit.Author.When }}</time 73 - > 74 - </div> 64 + {{ range .Files }} 65 + {{ if not .IsFile }} 66 + <div class="{{ $containerstyle }}"> 67 + <div class="flex justify-between items-center"> 68 + <a 69 + href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}" 70 + class="{{ $linkstyle }}" 71 + > 72 + <div class="flex items-center gap-2"> 73 + <i 74 + class="w-3 h-3 fill-current" 75 + data-lucide="folder" 76 + ></i 77 + >{{ .Name }} 75 78 </div> 76 - {{ end }} 77 - {{ end }} 79 + </a> 78 80 79 - {{ range .Files }} 80 - {{ if .IsFile }} 81 - <div class="{{ $containerstyle }}"> 82 - <div class="flex justify-between items-center"> 83 - <a 84 - href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref }}/{{ .Name }}" 85 - class="{{ $linkstyle }}" 86 - > 87 - <div class="flex items-center gap-2"> 88 - <i 89 - class="w-3 h-3" 90 - data-lucide="file" 91 - ></i 92 - >{{ .Name }} 93 - </div> 94 - </a> 81 + <time class="text-xs text-gray-500" 82 + >{{ timeFmt .LastCommit.Author.When }}</time 83 + > 84 + </div> 85 + </div> 86 + {{ end }} 87 + {{ end }} 95 88 96 - <time class="text-xs text-gray-500" 97 - >{{ timeFmt .LastCommit.Author.When }}</time 98 - > 99 - </div> 89 + {{ range .Files }} 90 + {{ if .IsFile }} 91 + <div class="{{ $containerstyle }}"> 92 + <div class="flex justify-between items-center"> 93 + <a 94 + href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref }}/{{ .Name }}" 95 + class="{{ $linkstyle }}" 96 + > 97 + <div class="flex items-center gap-2"> 98 + <i 99 + class="w-3 h-3" 100 + data-lucide="file" 101 + ></i 102 + >{{ .Name }} 100 103 </div> 101 - {{ end }} 102 - {{ end }} 104 + </a> 105 + 106 + <time class="text-xs text-gray-500" 107 + >{{ timeFmt .LastCommit.Author.When }}</time 108 + > 109 + </div> 103 110 </div> 111 + {{ end }} 112 + {{ end }} 113 + </div> 114 + {{ end }} 104 115 105 - <div id="commit-log" class="flex-1"> 106 - {{ range .Commits }} 107 - <div class="relative px-2 pb-8"> 108 - <div id="commit-message"> 109 - {{ $messageParts := splitN .Message "\n\n" 2 }} 110 - <div class="text-base cursor-pointer"> 111 - <div> 112 - <div> 113 - <a 114 - href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 115 - class="inline no-underline hover:underline" 116 - >{{ index $messageParts 0 }}</a 117 - > 118 - {{ if gt (len $messageParts) 1 }} 119 116 120 - <button 121 - class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded" 122 - hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')" 123 - > 124 - <i 125 - class="w-3 h-3" 126 - data-lucide="ellipsis" 127 - ></i> 128 - </button> 129 - {{ end }} 130 - </div> 131 - {{ if gt (len $messageParts) 1 }} 132 - <p 133 - class="hidden mt-1 text-sm cursor-text pb-2" 134 - > 135 - {{ nl2br (unwrapText (index $messageParts 1)) }} 136 - </p> 137 - {{ end }} 138 - </div> 139 - </div> 140 - </div> 117 + {{ define "commitLog" }} 118 + <div id="commit-log" class="flex-1"> 119 + {{ range .Commits }} 120 + <div class="relative px-2 pb-8"> 121 + <div id="commit-message"> 122 + {{ $messageParts := splitN .Message "\n\n" 2 }} 123 + <div class="text-base cursor-pointer"> 124 + <div> 125 + <div> 126 + <a 127 + href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 128 + class="inline no-underline hover:underline" 129 + >{{ index $messageParts 0 }}</a 130 + > 131 + {{ if gt (len $messageParts) 1 }} 141 132 142 - <div class="text-xs text-gray-500"> 143 - <span class="font-mono"> 144 - <a 145 - href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 146 - class="text-gray-500 no-underline hover:underline" 147 - >{{ slice .Hash.String 0 8 }}</a 148 - > 149 - </span> 150 - <span 151 - class="mx-2 before:content-['·'] before:select-none" 152 - ></span> 153 - <span> 154 - <a 155 - href="mailto:{{ .Author.Email }}" 156 - class="text-gray-500 no-underline hover:underline" 157 - >{{ .Author.Name }}</a 133 + <button 134 + class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded" 135 + hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')" 158 136 > 159 - </span> 160 - <div 161 - class="inline-block px-1 select-none after:content-['·']" 162 - ></div> 163 - <span>{{ timeFmt .Author.When }}</span> 137 + <i 138 + class="w-3 h-3" 139 + data-lucide="ellipsis" 140 + ></i> 141 + </button> 142 + {{ end }} 143 + 144 + {{ $tagsForCommit := index $.TagMap .Hash.String }} 145 + {{ range $tagsForCommit }} 146 + <span class="text-xs rounded-full bg-black text-white px-2 mx-1 inline-flex items-center"> 147 + {{ . }} 148 + </span> 149 + {{ end }} 164 150 </div> 151 + {{ if gt (len $messageParts) 1 }} 152 + <p 153 + class="hidden mt-1 text-sm cursor-text pb-2" 154 + > 155 + {{ nl2br (unwrapText (index $messageParts 1)) }} 156 + </p> 157 + {{ end }} 165 158 </div> 166 - {{ end }} 167 - </div> 168 - </div> 169 - </main> 159 + </div> 160 + </div> 161 + 162 + <div class="text-xs text-gray-500"> 163 + <span class="font-mono"> 164 + <a 165 + href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 166 + class="text-gray-500 no-underline hover:underline" 167 + >{{ slice .Hash.String 0 8 }}</a 168 + > 169 + </span> 170 + <span 171 + class="mx-2 before:content-['·'] before:select-none" 172 + ></span> 173 + <span> 174 + <a 175 + href="mailto:{{ .Author.Email }}" 176 + class="text-gray-500 no-underline hover:underline" 177 + >{{ .Author.Name }}</a 178 + > 179 + </span> 180 + <div 181 + class="inline-block px-1 select-none after:content-['·']" 182 + ></div> 183 + <span>{{ timeFmt .Author.When }}</span> 184 + </div> 185 + </div> 186 + {{ end }} 187 + </div> 170 188 {{ end }} 189 + 171 190 172 191 {{ define "repoAfter" }} 173 192 {{- if .Readme }}
+14
appview/state/repo.go
··· 61 61 return 62 62 } 63 63 64 + tagMap := make(map[string][]string) 65 + for _, tag := range result.Tags { 66 + hash := tag.Hash 67 + tagMap[hash] = append(tagMap[hash], tag.Name) 68 + } 69 + 70 + for _, branch := range result.Branches { 71 + hash := branch.Hash 72 + tagMap[hash] = append(tagMap[hash], branch.Name) 73 + } 74 + 75 + log.Println(tagMap) 76 + 64 77 user := s.auth.GetUser(r) 65 78 s.pages.RepoIndexPage(w, pages.RepoIndexParams{ 66 79 LoggedInUser: user, ··· 70 83 Name: f.RepoName, 71 84 SettingsAllowed: settingsAllowed(s, user, f), 72 85 }, 86 + TagMap: tagMap, 73 87 RepoIndexResponse: result, 74 88 }) 75 89