forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
1{{ define "title" }}commits &middot; {{ .RepoInfo.FullName }}{{ end }} 2 3{{ define "repoContent" }} 4<section id="commit-table" class="overflow-x-auto"> 5 <h2 class="font-bold text-sm mb-4 uppercase dark:text-white"> 6 commits 7 </h2> 8 9 <!-- desktop view (hidden on small screens) --> 10 <table class="w-full border-collapse hidden md:table"> 11 <thead> 12 <tr> 13 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Author</th> 14 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Commit</th> 15 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Message</th> 16 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Date</th> 17 </tr> 18 </thead> 19 <tbody> 20 {{ range $index, $commit := .Commits }} 21 {{ $messageParts := splitN $commit.Message "\n\n" 2 }} 22 <tr class="{{ if ne $index (sub (len $.Commits) 1) }}border-b border-gray-200 dark:border-gray-700{{ end }}"> 23 <td class=" py-3 align-top"> 24 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 25 {{ if $didOrHandle }} 26 <a href="/{{ $didOrHandle }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $didOrHandle }}</a> 27 {{ else }} 28 <a href="mailto:{{ $commit.Author.Email }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $commit.Author.Name }}</a> 29 {{ end }} 30 </td> 31 <td class=" py-3 align-top font-mono flex items-end"> 32 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ slice $commit.Hash.String 0 8 }}</a> 33 <div class="inline-flex"> 34 <button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 35 title="Copy SHA" 36 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)"> 37 {{ i "copy" "w-4 h-4" }} 38 </button> 39 <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"> 40 {{ i "folder-code" "w-4 h-4" }} 41 </a> 42 </div> 43 </td> 44 <td class=" py-3 align-top"> 45 <div> 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 }} 64 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p> 65 {{ end }} 66 </td> 67 <td class=" py-3 align-top text-gray-500 dark:text-gray-400">{{ timeFmt $commit.Author.When }}</td> 68 </tr> 69 {{ end }} 70 </tbody> 71 </table> 72 73 <!-- mobile view (visible only on small screens) --> 74 <div class="md:hidden"> 75 {{ range $index, $commit := .Commits }} 76 <div class="relative p-2 {{ if ne $index (sub (len $.Commits) 1) }}border-b border-gray-200 dark:border-gray-700{{ end }}"> 77 <div id="commit-message"> 78 {{ $messageParts := splitN $commit.Message "\n\n" 2 }} 79 <div class="text-base cursor-pointer"> 80 <div> 81 <div class="flex items-center justify-between"> 82 <div class="flex-1"> 83 <div class="inline"> 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 105 {{ if gt (len $messageParts) 1 }} 106 <p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"> 107 {{ nl2br (index $messageParts 1) }} 108 </p> 109 {{ end }} 110 </div> 111 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}" 112 class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 113 title="Browse repository at this commit"> 114 {{ i "folder-code" "w-4 h-4" }} 115 </a> 116 </div> 117 </div> 118 </div> 119 </div> 120 121 <div class="text-xs text-gray-500 dark:text-gray-400"> 122 <span class="font-mono"> 123 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 124 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"> 125 {{ slice $commit.Hash.String 0 8 }} 126 </a> 127 </span> 128 <span class="mx-2 before:content-['·'] before:select-none"></span> 129 <span> 130 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 131 <a href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}" 132 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"> 133 {{ if $didOrHandle }}{{ $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }} 134 </a> 135 </span> 136 <div class="inline-block px-1 select-none after:content-['·']"></div> 137 <span>{{ shortTimeFmt $commit.Author.When }}</span> 138 </div> 139 </div> 140 {{ end }} 141 </div> 142</section> 143 144{{ end }} 145 146{{ define "repoAfter" }} 147 {{ $commits_len := len .Commits }} 148 <div class="flex justify-end mt-4 gap-2"> 149 {{ 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 }} 150 {{ 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 }} 151 </div> 152{{ end }}