forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
1{{ define "title" }}commits &middot; {{ .RepoInfo.FullName }}{{ end }} 2 3{{ define "extrameta" }} 4 {{ $title := printf "commits &middot; %s" .RepoInfo.FullName }} 5 {{ $url := printf "https://tangled.sh/%s/commits" .RepoInfo.FullName }} 6 7 {{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }} 8{{ end }} 9 10{{ define "repoContent" }} 11<section id="commit-table" class="overflow-x-auto"> 12 <h2 class="font-bold text-sm mb-4 uppercase dark:text-white"> 13 commits 14 </h2> 15 16 <!-- desktop view (hidden on small screens) --> 17 <div class="hidden md:flex md:flex-col divide-y divide-gray-200 dark:divide-gray-700"> 18 {{ $grid := "grid grid-cols-14 gap-4" }} 19 <div class="{{ $grid }}"> 20 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold col-span-2">Author</div> 21 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold col-span-3">Commit</div> 22 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold col-span-6">Message</div> 23 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold col-span-1"></div> 24 <div class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold col-span-2 justify-self-end">Date</div> 25 </div> 26 {{ range $index, $commit := .Commits }} 27 {{ $messageParts := splitN $commit.Message "\n\n" 2 }} 28 <div class="{{ $grid }} py-3"> 29 <div class="align-top truncate col-span-2"> 30 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 31 {{ if $didOrHandle }} 32 {{ template "user/fragments/picHandleLink" $didOrHandle }} 33 {{ else }} 34 <a href="mailto:{{ $commit.Author.Email }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $commit.Author.Name }}</a> 35 {{ end }} 36 </div> 37 <div class="align-top font-mono flex items-start col-span-3"> 38 {{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }} 39 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }} 40 {{ if $verified }} 41 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }} 42 {{ end }} 43 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="no-underline hover:underline {{ $hashStyle }} px-2 py-1/2 rounded flex items-center gap-2"> 44 {{ slice $commit.Hash.String 0 8 }} 45 {{ if $verified }} 46 {{ i "shield-check" "w-4 h-4" }} 47 {{ end }} 48 </a> 49 <div class="{{ if not $verified }} ml-6 {{ end }}inline-flex"> 50 <button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 51 title="Copy SHA" 52 onclick="navigator.clipboard.writeText('{{ $commit.Hash.String }}'); this.innerHTML=`{{ i "copy-check" "w-4 h-4" }}`; setTimeout(() => this.innerHTML=`{{ i "copy" "w-4 h-4" }}`, 1500)"> 53 {{ i "copy" "w-4 h-4" }} 54 </button> 55 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}" class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" title="Browse repository at this commit"> 56 {{ i "folder-code" "w-4 h-4" }} 57 </a> 58 </div> 59 60 </div> 61 <div class="align-top col-span-6"> 62 <div> 63 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a> 64 {{ if gt (len $messageParts) 1 }} 65 <button class="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> 66 {{ end }} 67 68 {{ if index $.TagMap $commit.Hash.String }} 69 {{ range $tag := index $.TagMap $commit.Hash.String }} 70 <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"> 71 {{ $tag }} 72 </span> 73 {{ end }} 74 {{ end }} 75 </div> 76 77 {{ if gt (len $messageParts) 1 }} 78 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p> 79 {{ end }} 80 </div> 81 <div class="align-top col-span-1"> 82 <!-- ci status --> 83 {{ $pipeline := index $.Pipelines .Hash.String }} 84 {{ if and $pipeline (gt (len $pipeline.Statuses) 0) }} 85 {{ template "repo/pipelines/fragments/pipelineSymbolLong" (dict "Pipeline" $pipeline "RepoInfo" $.RepoInfo) }} 86 {{ end }} 87 </div> 88 <div class="align-top justify-self-end text-gray-500 dark:text-gray-400 col-span-2">{{ template "repo/fragments/shortTimeAgo" $commit.Committer.When }}</div> 89 </div> 90 {{ end }} 91 </div> 92 93 <!-- mobile view (visible only on small screens) --> 94 <div class="md:hidden"> 95 {{ range $index, $commit := .Commits }} 96 <div class="relative p-2 mb-2 {{ if ne $index (sub (len $.Commits) 1) }}border-b border-gray-200 dark:border-gray-700{{ end }}"> 97 <div id="commit-message"> 98 {{ $messageParts := splitN $commit.Message "\n\n" 2 }} 99 <div class="text-base cursor-pointer"> 100 <div class="flex items-center justify-between"> 101 <div class="flex-1"> 102 <div> 103 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 104 class="inline no-underline hover:underline dark:text-white"> 105 {{ index $messageParts 0 }} 106 </a> 107 {{ if gt (len $messageParts) 1 }} 108 <button 109 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600" 110 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"> 111 {{ i "ellipsis" "w-3 h-3" }} 112 </button> 113 {{ end }} 114 115 {{ if index $.TagMap $commit.Hash.String }} 116 {{ range $tag := index $.TagMap $commit.Hash.String }} 117 <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"> 118 {{ $tag }} 119 </span> 120 {{ end }} 121 {{ end }} 122 </div> 123 124 {{ if gt (len $messageParts) 1 }} 125 <p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"> 126 {{ nl2br (index $messageParts 1) }} 127 </p> 128 {{ end }} 129 </div> 130 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}" 131 class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 132 title="Browse repository at this commit"> 133 {{ i "folder-code" "w-4 h-4" }} 134 </a> 135 </div> 136 </div> 137 </div> 138 139 <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center"> 140 {{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }} 141 {{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }} 142 {{ if $verified }} 143 {{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }} 144 {{ end }} 145 <span class="font-mono"> 146 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 147 class="no-underline hover:underline {{ $hashStyle }} px-2 py-1 rounded flex items-center gap-2"> 148 {{ slice $commit.Hash.String 0 8 }} 149 {{ if $verified }} 150 {{ i "shield-check" "w-3 h-3" }} 151 {{ end }} 152 </a> 153 </span> 154 <span class="mx-2 before:content-['·'] before:select-none"></span> 155 <span> 156 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 157 <a href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}" 158 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"> 159 {{ if $didOrHandle }}{{ template "user/fragments/picHandleLink" $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }} 160 </a> 161 </span> 162 <div class="inline-block px-1 select-none after:content-['·']"></div> 163 <span>{{ template "repo/fragments/shortTime" $commit.Committer.When }}</span> 164 165 <!-- ci status --> 166 {{ $pipeline := index $.Pipelines .Hash.String }} 167 {{ if and $pipeline (gt (len $pipeline.Statuses) 0) }} 168 <div class="inline-block px-1 select-none after:content-['·']"></div> 169 <span class="text-sm"> 170 {{ template "repo/pipelines/fragments/pipelineSymbolLong" (dict "Pipeline" $pipeline "RepoInfo" $.RepoInfo) }} 171 </span> 172 {{ end }} 173 </div> 174 </div> 175 {{ end }} 176 </div> 177</section> 178 179{{ end }} 180 181{{ define "repoAfter" }} 182 {{ $commits_len := len .Commits }} 183 <div class="flex justify-end mt-4 gap-2"> 184 {{ if gt .Page 1 }}<a class="btn flex items-center gap-2 no-underline hover:no-underline dark:text-white dark:hover:bg-gray-700" hx-boost="true" onclick="window.location.href = window.location.pathname + '?page={{ sub .Page 1 }}'">{{ i "chevron-left" "w-4 h-4" }} previous</a>{{ else }}<div></div>{{ end }} 185 {{ if eq $commits_len 60 }}<a class="btn flex items-center gap-2 no-underline hover:no-underline dark:text-white dark:hover:bg-gray-700" hx-boost="true" onclick="window.location.href = window.location.pathname + '?page={{ add .Page 1 }}'">next {{ i "chevron-right" "w-4 h-4" }}</a>{{ end }} 186 </div> 187{{ end }}