Monorepo for Tangled tangled.org

appview/pages: add shortcut to convert blob link to permalink

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

authored by oppi.li and committed by tangled.org da1a4747 70b7627f

+28 -6
+1
appview/pages/templates/repo/blob.html
··· 152 152 showWrapContentToggleOnOverflow(); 153 153 })(); 154 154 </script> 155 + {{ template "repo/fragments/permalinkShortcut" . }} 155 156 {{ end }}
+6 -6
appview/pages/templates/repo/fragments/lastCommitPanel.html
··· 1 1 {{ define "repo/fragments/lastCommitPanel" }} 2 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 flex-col md:flex-row md:items-center md:justify-between text-sm gap-2"> 4 - <div class="flex flex-col md:flex-row md:items-center gap-1"> 3 + <div class="pb-2 mb-3 border-b border-gray-200 dark:border-gray-700 flex items-center justify-between flex-wrap text-sm gap-2"> 4 + <div class="flex flex-wrap items-center gap-1"> 5 5 {{ if .LastCommitInfo.Author }} 6 6 {{ $authorDid := index .EmailToDid .LastCommitInfo.Author.Email }} 7 7 <span class="flex items-center gap-1"> ··· 12 12 <a href="mailto:{{ .LastCommitInfo.Author.Email }}" class="no-underline hover:underline">{{ .LastCommitInfo.Author.Name }}</a> 13 13 {{ end }} 14 14 </span> 15 - <span class="hidden md:inline px-1 select-none before:content-['\00B7']"></span> 15 + <span class="px-1 select-none before:content-['\00B7'] text-gray-400 dark:text-gray-500"></span> 16 16 {{ end }} 17 17 <a href="/{{ .RepoInfo.FullName }}/commit/{{ .LastCommitInfo.Hash }}" 18 18 class="inline no-underline hover:underline dark:text-white"> 19 19 {{ index $messageParts 0 }} 20 20 </a> 21 - <span class="hidden md:inline 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> 21 + <span class="px-1 select-none before:content-['\00B7'] text-gray-400 dark:text-gray-500"></span> 22 + <span class="text-gray-400 dark:text-gray-500">{{ template "repo/fragments/shortTimeAgo" .LastCommitInfo.When }}</span> 23 23 </div> 24 24 <a href="/{{ .RepoInfo.FullName }}/commit/{{ .LastCommitInfo.Hash.String }}" 25 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 w-fit"> 26 26 {{ slice .LastCommitInfo.Hash.String 0 8 }} 27 27 </a> 28 28 </div> 29 - {{ end }} 29 + {{ end }}
+20
appview/pages/templates/repo/fragments/permalinkShortcut.html
··· 1 + {{ define "repo/fragments/permalinkShortcut" }} 2 + <script> 3 + (() => { 4 + {{ if .LastCommitInfo }} 5 + const abortController = new AbortController(); 6 + document.addEventListener('keydown', (e) => { 7 + if(e.key === 'y' && !e.ctrlKey && !e.metaKey && !e.altKey) { 8 + if(e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return; 9 + const permalinkUrl = '/{{ .RepoInfo.FullName }}/tree/{{ .LastCommitInfo.Hash }}/{{ .Path }}'; 10 + window.location.href = permalinkUrl; 11 + } 12 + }, {signal: abortController.signal}); 13 + 14 + document.body.addEventListener('htmx:beforeCleanupElement', (e) => { 15 + abortController.abort(); 16 + }, {signal: abortController.signal}); 17 + {{ end }} 18 + })(); 19 + </script> 20 + {{ end }}
+1
appview/pages/templates/repo/tree.html
··· 99 99 100 100 </div> 101 101 </main> 102 + {{ template "repo/fragments/permalinkShortcut" . }} 102 103 {{end}} 103 104 104 105 {{ define "repoAfter" }}