Monorepo for Tangled

appview/pages: extract lastCommit panel into fragment

Signed-off-by: oppiliappan <me@oppi.li>

+34 -48
+5 -48
appview/pages/templates/repo/blob.html
··· 13 13 {{ define "repoContent" }} 14 14 {{ $linkstyle := "no-underline hover:underline" }} 15 15 16 - {{ if .LastCommitInfo }} 17 - <div class="pb-3 mb-3 border-b border-gray-200 dark:border-gray-700"> 18 - <div id="commit-message"> 19 - {{ $messageParts := splitN .LastCommitInfo.Message "\n\n" 2 }} 20 - <div class="text-base"> 21 - <a href="/{{ .RepoInfo.FullName }}/commit/{{ .LastCommitInfo.Hash }}" 22 - class="inline no-underline hover:underline dark:text-white"> 23 - {{ index $messageParts 0 }} 24 - </a> 25 - {{ if gt (len $messageParts) 1 }} 26 - <button 27 - class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600" 28 - hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"> 29 - {{ i "ellipsis" "w-3 h-3" }} 30 - </button> 31 - {{ end }} 32 - </div> 33 - {{ if gt (len $messageParts) 1 }} 34 - <p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"> 35 - {{ nl2br (index $messageParts 1) }} 36 - </p> 37 - {{ end }} 38 - </div> 39 - <div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center flex-wrap"> 40 - {{ if .LastCommit.Author }} 41 - {{ $authorDid := index .EmailToDid .LastCommit.Author.Email }} 42 - <span class="flex items-center gap-1"> 43 - {{ if $authorDid }} 44 - {{ template "user/fragments/picHandleLink" $authorDid }} 45 - {{ else }} 46 - {{ placeholderAvatar "tiny" }} 47 - <a href="mailto:{{ .LastCommit.Author.Email }}" class="no-underline hover:underline">{{ .LastCommit.Author.Name }}</a> 48 - {{ end }} 49 - </span> 50 - <span class="px-1 select-none before:content-['\00B7']"></span> 51 - {{ end }} 52 - {{ template "repo/fragments/time" .LastCommitInfo.When }} 53 - <span class="px-1 select-none before:content-['\00B7']"></span> 54 - <span class="font-mono"> 55 - <a href="/{{ .RepoInfo.FullName }}/commit/{{ .LastCommitInfo.Hash.String }}" 56 - class="no-underline hover:underline text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900 px-2 py-1 rounded"> 57 - {{ slice .LastCommitInfo.Hash.String 0 8 }} 58 - </a> 59 - </span> 60 - </div> 61 - </div> 62 - {{ end }} 63 - 64 16 <div class="pb-2 mb-3 text-base border-b border-gray-200 dark:border-gray-700"> 65 17 <div class="flex flex-col md:flex-row md:justify-between gap-2"> 66 18 <div id="breadcrumbs" class="overflow-x-auto whitespace-nowrap text-gray-400 dark:text-gray-500"> ··· 106 58 </div> 107 59 </div> 108 60 </div> 61 + 62 + {{ if .LastCommitInfo }} 63 + {{ template "repo/fragments/lastCommitPanel" $ }} 64 + {{ end }} 65 + 109 66 {{ if .BlobView.IsUnsupported }} 110 67 <p class="text-center text-gray-400 dark:text-gray-500"> 111 68 Previews are not supported for this file type.
+29
appview/pages/templates/repo/fragments/lastCommitPanel.html
··· 1 + {{ define "repo/fragments/lastCommitPanel" }} 2 + {{ $messageParts := splitN .LastCommitInfo.Message "\n\n" 2 }} 3 + <div class="pb-2 mb-3 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between text-sm"> 4 + <div class="flex items-center gap-1"> 5 + {{ if .LastCommitInfo.Author }} 6 + {{ $authorDid := index .EmailToDid .LastCommitInfo.Author.Email }} 7 + <span class="flex items-center gap-1"> 8 + {{ if $authorDid }} 9 + {{ template "user/fragments/picHandleLink" $authorDid }} 10 + {{ else }} 11 + {{ placeholderAvatar "tiny" }} 12 + <a href="mailto:{{ .LastCommitInfo.Author.Email }}" class="no-underline hover:underline">{{ .LastCommitInfo.Author.Name }}</a> 13 + {{ end }} 14 + </span> 15 + <span class="px-1 select-none before:content-['\00B7']"></span> 16 + {{ end }} 17 + <a href="/{{ .RepoInfo.FullName }}/commit/{{ .LastCommitInfo.Hash }}" 18 + class="inline no-underline hover:underline dark:text-white"> 19 + {{ index $messageParts 0 }} 20 + </a> 21 + <span class="px-1 select-none before:content-['\00B7']"></span> 22 + <span class="text-gray-400 dark:text-gray-500">{{ template "repo/fragments/time" .LastCommitInfo.When }}</span> 23 + </div> 24 + <a href="/{{ .RepoInfo.FullName }}/commit/{{ .LastCommitInfo.Hash.String }}" 25 + class="no-underline hover:underline text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900 px-2 py-1 rounded font-mono text-xs"> 26 + {{ slice .LastCommitInfo.Hash.String 0 8 }} 27 + </a> 28 + </div> 29 + {{ end }}