This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / appview / pages / templates / repo / fragments / cloneDropdown.html
4.7 kB 143 lines
1{{ define "repo/fragments/cloneDropdown" }} 2 {{ $knot := .RepoInfo.Knot }} 3 {{ if eq $knot "knot1.tangled.sh" }} 4 {{ $knot = "tangled.org" }} 5 {{ end }} 6 7 <style> 8 #clone-dropdown-btn { 9 anchor-name: --clone-dropdown-btn; 10 } 11 #clone-dropdown { 12 position-anchor: --clone-dropdown-btn; 13 position-area: bottom span-left; 14 } 15 </style> 16 17 <button 18 id="clone-dropdown-btn" 19 popovertarget="clone-dropdown" 20 popovertargetaction="toggle" 21 class="btn-create cursor-pointer list-none flex items-center gap-2 px-4"> 22 {{ i "download" "w-4 h-4" }} 23 <span class="hidden md:inline">Code</span> 24 </button> 25 <div 26 popover 27 id="clone-dropdown" 28 class=" 29 bg-white dark:bg-gray-800 border border-gray-200 dark:border-gray-700 30 dark:text-white shadow-lg 31 w-96 md:w-[440px] p-4 rounded drop-shadow overflow-visible"> 32 33 <input 34 type="checkbox" 35 id="permalink-toggle" 36 class="peer hidden m-0"> 37 38 <div class="flex items-center justify-between"> 39 <h3 class="text-sm font-semibold text-gray-900 dark:text-white">Clone this repository</h3> 40 <label for="permalink-toggle" class="flex items-center gap-1 text-xs text-gray-700 dark:text-gray-300 cursor-pointer normal-case font-normal"> 41 {{ i "square-check-big" "checkbox-checked size-4" }} 42 {{ i "square" "checkbox-unchecked size-4" }} 43 <span>Use permalink</span> 44 </label> 45 </div> 46 47 {{ $repoOwnerHandle := resolve .RepoInfo.OwnerDid }} 48 49 {{ template "cloneUrlItem" ( 50 dict 51 "Label" "HTTPS" 52 "HandleUrl" (printf "https://tangled.org/%s/%s" $repoOwnerHandle .RepoInfo.Slug) 53 "PermaUrl" (printf "https://tangled.org/%s" .RepoInfo.RepoDid) 54 ) }} 55 56 {{ template "cloneUrlItem" ( 57 dict 58 "Label" "SSH" 59 "HandleUrl" (printf "git@%s:%s/%s" (stripPort $knot) $repoOwnerHandle .RepoInfo.Slug) 60 "PermaUrl" (printf "git@%s:%s" (stripPort $knot) .RepoInfo.RepoDid) 61 ) }} 62 63 <p class="text-xs text-gray-500 dark:text-gray-400 mt-2"> 64 For self-hosted knots, clone URLs may differ based on your setup. 65 </p> 66 67 <br/> 68 69 <div class="flex gap-2 mt-4"> 70 <a 71 href="/{{ .RepoInfo.FullName }}/archive/{{ .Ref | urlquery }}?format=tar.gz" 72 class="btn flex-1" 73 > 74 {{ i "download" "w-4 h-4" }} 75 Download tar.gz 76 </a> 77 <a 78 href="/{{ .RepoInfo.FullName }}/archive/{{ .Ref | urlquery }}?format=zip" 79 class="btn flex-1" 80 > 81 {{ i "download" "w-4 h-4" }} 82 Download .zip 83 </a> 84 </div> 85 </div> 86 87 <style> 88 .clone-url-did { 89 display: none; 90 } 91 .checkbox-checked { 92 display: none; 93 } 94 #permalink-toggle:checked ~ * .clone-url-handle { 95 display: none; 96 } 97 #permalink-toggle:checked ~ * .clone-url-did { 98 display: block; 99 } 100 #permalink-toggle:checked ~ * .checkbox-checked { 101 display: block; 102 } 103 #permalink-toggle:checked ~ * .checkbox-unchecked { 104 display: none; 105 } 106 </style> 107 108 <script> 109 function copyToClipboard(button, text) { 110 navigator.clipboard.writeText(text).then(() => { 111 const originalContent = button.innerHTML; 112 button.innerHTML = `{{ i "check" "w-4 h-4" }}`; 113 setTimeout(() => { 114 button.innerHTML = originalContent; 115 }, 2000); 116 }); 117 } 118 </script> 119{{ end }} 120 121{{ define "cloneUrlItem" }} 122 <div class="mt-4"> 123 <label class="block text-xs font-medium text-gray-700 dark:text-gray-300 mb-1 normal-case">{{ .Label }}</label> 124 <div class="flex items-stretch border border-gray-300 dark:border-gray-600 divide-x divide-gray-300 dark:divide-gray-600 rounded"> 125 <span 126 class="clone-url-handle flex-1 px-3 py-2 text-sm text-gray-900 dark:text-gray-100 select-all cursor-pointer whitespace-nowrap overflow-x-auto font-mono bg-gray-200 dark:bg-gray-700" 127 onclick="window.getSelection().selectAllChildren(this)" 128 >{{ .HandleUrl }}</span> 129 <span 130 class="clone-url-did flex-1 px-3 py-2 text-sm text-gray-900 dark:text-gray-100 select-all cursor-pointer whitespace-nowrap overflow-x-auto font-mono bg-gray-200 dark:bg-gray-700" 131 onclick="window.getSelection().selectAllChildren(this)" 132 >{{ .PermaUrl }}</span> 133 <button 134 onclick="copyToClipboard(this, Array.from(this.parentElement.querySelectorAll('span')).find(s => getComputedStyle(s).display !== 'none').textContent)" 135 class="px-3 py-2 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200" 136 title="Copy to clipboard" 137 > 138 {{ i "copy" "w-4 h-4" }} 139 </button> 140 </div> 141 </div> 142{{ end }} 143