forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
at packages 10 kB view raw
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 <table class="w-full border-collapse hidden md:table"> 18 <thead> 19 <tr> 20 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Author</th> 21 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Commit</th> 22 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Message</th> 23 <th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Date</th> 24 </tr> 25 </thead> 26 <tbody> 27 {{ range $index, $commit := .Commits }} 28 {{ $messageParts := splitN $commit.Message "\n\n" 2 }} 29 <tr class="{{ if ne $index (sub (len $.Commits) 1) }}border-b border-gray-200 dark:border-gray-700{{ end }}"> 30 <td class=" py-3 align-top"> 31 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 32 {{ if $didOrHandle }} 33 <a href="/{{ $didOrHandle }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $didOrHandle }}</a> 34 {{ else }} 35 <a href="mailto:{{ $commit.Author.Email }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $commit.Author.Name }}</a> 36 {{ end }} 37 </td> 38 <td class=" py-3 align-top font-mono flex items-end"> 39 <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> 40 <div class="inline-flex"> 41 <button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 42 title="Copy SHA" 43 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)"> 44 {{ i "copy" "w-4 h-4" }} 45 </button> 46 <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"> 47 {{ i "folder-code" "w-4 h-4" }} 48 </a> 49 </div> 50 </td> 51 <td class=" py-3 align-top"> 52 <div> 53 <div class="flex items-center justify-start"> 54 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a> 55 {{ if gt (len $messageParts) 1 }} 56 <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> 57 {{ end }} 58 59 60 {{ if index $.TagMap $commit.Hash.String }} 61 {{ range $tag := index $.TagMap $commit.Hash.String }} 62 <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"> 63 {{ $tag }} 64 </span> 65 {{ end }} 66 {{ end }} 67 68 </div> 69 70 {{ if gt (len $messageParts) 1 }} 71 <p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p> 72 {{ end }} 73 </td> 74 <td class=" py-3 align-top text-gray-500 dark:text-gray-400">{{ timeFmt $commit.Committer.When }}</td> 75 </tr> 76 {{ end }} 77 </tbody> 78 </table> 79 80 <!-- mobile view (visible only on small screens) --> 81 <div class="md:hidden"> 82 {{ range $index, $commit := .Commits }} 83 <div class="relative p-2 {{ if ne $index (sub (len $.Commits) 1) }}border-b border-gray-200 dark:border-gray-700{{ end }}"> 84 <div id="commit-message"> 85 {{ $messageParts := splitN $commit.Message "\n\n" 2 }} 86 <div class="text-base cursor-pointer"> 87 <div> 88 <div class="flex items-center justify-between"> 89 <div class="flex-1"> 90 <div class="inline"> 91 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 92 class="inline no-underline hover:underline dark:text-white"> 93 {{ index $messageParts 0 }} 94 </a> 95 {{ if gt (len $messageParts) 1 }} 96 <button 97 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" 98 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"> 99 {{ i "ellipsis" "w-3 h-3" }} 100 </button> 101 {{ end }} 102 103 {{ if index $.TagMap $commit.Hash.String }} 104 {{ range $tag := index $.TagMap $commit.Hash.String }} 105 <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"> 106 {{ $tag }} 107 </span> 108 {{ end }} 109 {{ end }} 110 </div> 111 112 {{ if gt (len $messageParts) 1 }} 113 <p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"> 114 {{ nl2br (index $messageParts 1) }} 115 </p> 116 {{ end }} 117 </div> 118 <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}" 119 class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded" 120 title="Browse repository at this commit"> 121 {{ i "folder-code" "w-4 h-4" }} 122 </a> 123 </div> 124 </div> 125 </div> 126 </div> 127 128 <div class="text-xs text-gray-500 dark:text-gray-400"> 129 <span class="font-mono"> 130 <a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" 131 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"> 132 {{ slice $commit.Hash.String 0 8 }} 133 </a> 134 </span> 135 <span class="mx-2 before:content-['·'] before:select-none"></span> 136 <span> 137 {{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }} 138 <a href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}" 139 class="text-gray-500 dark:text-gray-400 no-underline hover:underline"> 140 {{ if $didOrHandle }}{{ $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }} 141 </a> 142 </span> 143 <div class="inline-block px-1 select-none after:content-['·']"></div> 144 <span>{{ shortTimeFmt $commit.Committer.When }}</span> 145 </div> 146 </div> 147 {{ end }} 148 </div> 149</section> 150 151{{ end }} 152 153{{ define "repoAfter" }} 154 {{ $commits_len := len .Commits }} 155 <div class="flex justify-end mt-4 gap-2"> 156 {{ 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 }} 157 {{ 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 }} 158 </div> 159{{ end }}