add tag pills to commit log
my vision...
MODIFIED
appview/pages/pages.go
MODIFIED
appview/pages/pages.go
@@ -194,6 +194,7 @@ type RepoIndexParams struct {LoggedInUser *auth.UserRepoInfo RepoInfoActive string+ TagMap map[string][]stringtypes.RepoIndexResponse}
@@ -2,172 +2,191 @@ {{ define "title" }}{{ .RepoInfo.FullName }} at {{ .Ref }}{{ end }}{{ define "repoContent" }}<main>- <div class="flex justify-between pb-5">- <select- onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value"- class="p-1 border border-gray-200 bg-white"- >- <optgroup label="branches" class="bold text-sm">- {{ range .Branches }}- <option- value="{{ .Reference.Name }}"- class="py-1"- {{ if eq .Reference.Name $.Ref }}- selected- {{ end }}- >- {{ .Reference.Name }}- </option>- {{ end }}- </optgroup>- <optgroup label="tags" class="bold text-sm">- {{ range .Tags }}- <option- value="{{ .Reference.Name }}"- class="py-1"- {{ if eq .Reference.Name $.Ref }}- selected- {{ end }}- >- {{ .Reference.Name }}- </option>- {{ else }}- <option class="py-1" disabled>no tags found</option>- {{ end }}- </optgroup>- </select>- <a- href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref }}"- class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold"- >- <i class="w-4 h-4" data-lucide="logs"></i>- {{ .TotalCommits }}- {{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }}- </a>+ {{ block "branchSelector" . }} {{ end }}+ <div class="flex gap-2">+ {{ block "fileTree" . }} {{ end }}+ {{ block "commitLog" . }} {{ end }}</div>+ </main>+{{ end }}- <div class="flex gap-2">- <div id="file-tree" class="w-3/5 pr-2 border-r border-gray-200">- {{ $containerstyle := "py-1" }}- {{ $linkstyle := "no-underline hover:underline" }}+{{ define "branchSelector" }}+<div class="flex justify-between pb-5">+ <select+ onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value"+ class="p-1 border border-gray-200 bg-white"+ >+ <optgroup label="branches" class="bold text-sm">+ {{ range .Branches }}+ <option+ value="{{ .Reference.Name }}"+ class="py-1"+ {{ if eq .Reference.Name $.Ref }}+ selected+ {{ end }}+ >+ {{ .Reference.Name }}+ </option>+ {{ end }}+ </optgroup>+ <optgroup label="tags" class="bold text-sm">+ {{ range .Tags }}+ <option+ value="{{ .Reference.Name }}"+ class="py-1"+ {{ if eq .Reference.Name $.Ref }}+ selected+ {{ end }}+ >+ {{ .Reference.Name }}+ </option>+ {{ else }}+ <option class="py-1" disabled>no tags found</option>+ {{ end }}+ </optgroup>+ </select>+ <a+ href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref }}"+ class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold"+ >+ <i class="w-4 h-4" data-lucide="logs"></i>+ {{ .TotalCommits }}+ {{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }}+ </a>+</div>+{{ end }}- {{ range .Files }}- {{ if not .IsFile }}- <div class="{{ $containerstyle }}">- <div class="flex justify-between items-center">- <a- href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}"- class="{{ $linkstyle }}"- >- <div class="flex items-center gap-2">- <i- class="w-3 h-3 fill-current"- data-lucide="folder"- ></i- >{{ .Name }}- </div>- </a>+{{ define "fileTree" }}+<div id="file-tree" class="w-3/5 pr-2 border-r border-gray-200">+ {{ $containerstyle := "py-1" }}+ {{ $linkstyle := "no-underline hover:underline" }}- <time class="text-xs text-gray-500"- >{{ timeFmt .LastCommit.Author.When }}</time- >- </div>+ {{ range .Files }}+ {{ if not .IsFile }}+ <div class="{{ $containerstyle }}">+ <div class="flex justify-between items-center">+ <a+ href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}"+ class="{{ $linkstyle }}"+ >+ <div class="flex items-center gap-2">+ <i+ class="w-3 h-3 fill-current"+ data-lucide="folder"+ ></i+ >{{ .Name }}</div>- {{ end }}- {{ end }}+ </a>- {{ range .Files }}- {{ if .IsFile }}- <div class="{{ $containerstyle }}">- <div class="flex justify-between items-center">- <a- href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref }}/{{ .Name }}"- class="{{ $linkstyle }}"- >- <div class="flex items-center gap-2">- <i- class="w-3 h-3"- data-lucide="file"- ></i- >{{ .Name }}- </div>- </a>+ <time class="text-xs text-gray-500"+ >{{ timeFmt .LastCommit.Author.When }}</time+ >+ </div>+ </div>+ {{ end }}+ {{ end }}- <time class="text-xs text-gray-500"- >{{ timeFmt .LastCommit.Author.When }}</time- >- </div>+ {{ range .Files }}+ {{ if .IsFile }}+ <div class="{{ $containerstyle }}">+ <div class="flex justify-between items-center">+ <a+ href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref }}/{{ .Name }}"+ class="{{ $linkstyle }}"+ >+ <div class="flex items-center gap-2">+ <i+ class="w-3 h-3"+ data-lucide="file"+ ></i+ >{{ .Name }}</div>- {{ end }}- {{ end }}+ </a>++ <time class="text-xs text-gray-500"+ >{{ timeFmt .LastCommit.Author.When }}</time+ >+ </div></div>+ {{ end }}+ {{ end }}+</div>+{{ end }}- <div id="commit-log" class="flex-1">- {{ range .Commits }}- <div class="relative px-2 pb-8">- <div id="commit-message">- {{ $messageParts := splitN .Message "\n\n" 2 }}- <div class="text-base cursor-pointer">- <div>- <div>- <a- href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"- class="inline no-underline hover:underline"- >{{ index $messageParts 0 }}</a- >- {{ if gt (len $messageParts) 1 }}- <button- class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded"- hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"- >- <i- class="w-3 h-3"- data-lucide="ellipsis"- ></i>- </button>- {{ end }}- </div>- {{ if gt (len $messageParts) 1 }}- <p- class="hidden mt-1 text-sm cursor-text pb-2"- >- {{ nl2br (unwrapText (index $messageParts 1)) }}- </p>- {{ end }}- </div>- </div>- </div>+{{ define "commitLog" }}+<div id="commit-log" class="flex-1">+ {{ range .Commits }}+ <div class="relative px-2 pb-8">+ <div id="commit-message">+ {{ $messageParts := splitN .Message "\n\n" 2 }}+ <div class="text-base cursor-pointer">+ <div>+ <div>+ <a+ href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"+ class="inline no-underline hover:underline"+ >{{ index $messageParts 0 }}</a+ >+ {{ if gt (len $messageParts) 1 }}- <div class="text-xs text-gray-500">- <span class="font-mono">- <a- href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"- class="text-gray-500 no-underline hover:underline"- >{{ slice .Hash.String 0 8 }}</a- >- </span>- <span- class="mx-2 before:content-['·'] before:select-none"- ></span>- <span>- <a- href="mailto:{{ .Author.Email }}"- class="text-gray-500 no-underline hover:underline"- >{{ .Author.Name }}</a+ <button+ class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded"+ hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">- </span>- <div- class="inline-block px-1 select-none after:content-['·']"- ></div>- <span>{{ timeFmt .Author.When }}</span>+ <i+ class="w-3 h-3"+ data-lucide="ellipsis"+ ></i>+ </button>+ {{ end }}++ {{ $tagsForCommit := index $.TagMap .Hash.String }}+ {{ range $tagsForCommit }}+ <span class="text-xs rounded-full bg-black text-white px-2 mx-1 inline-flex items-center">+ {{ . }}+ </span>+ {{ end }}</div>+ {{ if gt (len $messageParts) 1 }}+ <p+ class="hidden mt-1 text-sm cursor-text pb-2"+ >+ {{ nl2br (unwrapText (index $messageParts 1)) }}+ </p>+ {{ end }}</div>- {{ end }}- </div>- </div>- </main>+ </div>+ </div>++ <div class="text-xs text-gray-500">+ <span class="font-mono">+ <a+ href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"+ class="text-gray-500 no-underline hover:underline"+ >{{ slice .Hash.String 0 8 }}</a+ >+ </span>+ <span+ class="mx-2 before:content-['·'] before:select-none"+ ></span>+ <span>+ <a+ href="mailto:{{ .Author.Email }}"+ class="text-gray-500 no-underline hover:underline"+ >{{ .Author.Name }}</a+ >+ </span>+ <div+ class="inline-block px-1 select-none after:content-['·']"+ ></div>+ <span>{{ timeFmt .Author.When }}</span>+ </div>+ </div>+ {{ end }}+</div>{{ end }}+{{ define "repoAfter" }}{{- if .Readme }}
MODIFIED
appview/state/repo.go
MODIFIED
appview/state/repo.go
@@ -61,6 +61,19 @@ log.Fatalf("Error unmarshalling response body: %v", err)return}+ tagMap := make(map[string][]string)+ for _, tag := range result.Tags {+ hash := tag.Hash+ tagMap[hash] = append(tagMap[hash], tag.Name)+ }++ for _, branch := range result.Branches {+ hash := branch.Hash+ tagMap[hash] = append(tagMap[hash], branch.Name)+ }++ log.Println(tagMap)+user := s.auth.GetUser(r)s.pages.RepoIndexPage(w, pages.RepoIndexParams{LoggedInUser: user,@@ -70,6 +83,7 @@ OwnerHandle: f.OwnerHandle(),Name: f.RepoName,SettingsAllowed: settingsAllowed(s, user, f),},+ TagMap: tagMap,RepoIndexResponse: result,})