forked from tangled.org/core
Monorepo for Tangled — https://tangled.org
1{{ define "title" }}{{ .RepoInfo.FullName }} at {{ .Ref }}{{ end }} 2 3{{ define "repoContent" }} 4 <main> 5 {{ block "branchSelector" . }} {{ end }} 6 <div class="grid grid-cols-1 md:grid-cols-2 gap-2"> 7 {{ block "fileTree" . }} {{ end }} 8 {{ block "commitLog" . }} {{ end }} 9 </div> 10 </main> 11{{ end }} 12 13{{ define "branchSelector" }} 14<div class="flex justify-between pb-5"> 15 <select 16 onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + this.value" 17 class="p-1 border border-gray-200 bg-white" 18 > 19 <optgroup label="branches" class="bold text-sm"> 20 {{ range .Branches }} 21 <option 22 value="{{ .Reference.Name }}" 23 class="py-1" 24 {{ if eq .Reference.Name $.Ref }} 25 selected 26 {{ end }} 27 > 28 {{ .Reference.Name }} 29 </option> 30 {{ end }} 31 </optgroup> 32 <optgroup label="tags" class="bold text-sm"> 33 {{ range .Tags }} 34 <option 35 value="{{ .Reference.Name }}" 36 class="py-1" 37 {{ if eq .Reference.Name $.Ref }} 38 selected 39 {{ end }} 40 > 41 {{ .Reference.Name }} 42 </option> 43 {{ else }} 44 <option class="py-1" disabled>no tags found</option> 45 {{ end }} 46 </optgroup> 47 </select> 48 <a 49 href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref }}" 50 class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold" 51 > 52 <i class="w-4 h-4" data-lucide="logs"></i> 53 {{ .TotalCommits }} 54 {{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }} 55 </a> 56</div> 57{{ end }} 58 59{{ define "fileTree" }} 60<div id="file-tree" class="col-span-1 pr-2 md:border-r md:border-gray-200"> 61 {{ $containerstyle := "py-1" }} 62 {{ $linkstyle := "no-underline hover:underline" }} 63 64 {{ range .Files }} 65 {{ if not .IsFile }} 66 <div class="{{ $containerstyle }}"> 67 <div class="flex justify-between items-center"> 68 <a 69 href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}" 70 class="{{ $linkstyle }}" 71 > 72 <div class="flex items-center gap-2"> 73 <i 74 class="w-3 h-3 fill-current" 75 data-lucide="folder" 76 ></i 77 >{{ .Name }} 78 </div> 79 </a> 80 81 <time class="text-xs text-gray-500" 82 >{{ timeFmt .LastCommit.When }}</time 83 > 84 </div> 85 </div> 86 {{ end }} 87 {{ end }} 88 89 {{ range .Files }} 90 {{ if .IsFile }} 91 <div class="{{ $containerstyle }}"> 92 <div class="flex justify-between items-center"> 93 <a 94 href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref }}/{{ .Name }}" 95 class="{{ $linkstyle }}" 96 > 97 <div class="flex items-center gap-2"> 98 <i 99 class="w-3 h-3" 100 data-lucide="file" 101 ></i 102 >{{ .Name }} 103 </div> 104 </a> 105 106 <time class="text-xs text-gray-500" 107 >{{ timeFmt .LastCommit.When }}</time 108 > 109 </div> 110 </div> 111 {{ end }} 112 {{ end }} 113</div> 114{{ end }} 115 116 117{{ define "commitLog" }} 118<div id="commit-log" class="hidden md:block md:col-span-1"> 119 {{ range .Commits }} 120 <div class="relative px-2 pb-8"> 121 <div id="commit-message"> 122 {{ $messageParts := splitN .Message "\n\n" 2 }} 123 <div class="text-base cursor-pointer"> 124 <div> 125 <div> 126 <a 127 href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 128 class="inline no-underline hover:underline" 129 >{{ index $messageParts 0 }}</a 130 > 131 {{ if gt (len $messageParts) 1 }} 132 133 <button 134 class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded" 135 hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')" 136 > 137 <i 138 class="w-3 h-3" 139 data-lucide="ellipsis" 140 ></i> 141 </button> 142 {{ end }} 143 </div> 144 {{ if gt (len $messageParts) 1 }} 145 <p 146 class="hidden mt-1 text-sm cursor-text pb-2" 147 > 148 {{ nl2br (unwrapText (index $messageParts 1)) }} 149 </p> 150 {{ end }} 151 </div> 152 </div> 153 </div> 154 155 <div class="text-xs text-gray-500"> 156 <span class="font-mono"> 157 <a 158 href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 159 class="text-gray-500 no-underline hover:underline" 160 >{{ slice .Hash.String 0 8 }}</a 161 > 162 </span> 163 <span 164 class="mx-2 before:content-['·'] before:select-none" 165 ></span> 166 <span> 167 <a 168 href="mailto:{{ .Author.Email }}" 169 class="text-gray-500 no-underline hover:underline" 170 >{{ .Author.Name }}</a 171 > 172 </span> 173 <div 174 class="inline-block px-1 select-none after:content-['·']" 175 ></div> 176 <span>{{ timeFmt .Author.When }}</span> 177 {{ $tagsForCommit := index $.TagMap .Hash.String }} 178 {{ range $tagsForCommit }} 179 <div 180 class="inline-block px-1 select-none after:content-['·']" 181 ></div> 182 <span class="text-xs rounded bg-gray-100 font-mono px-2 mx-1/2 inline-flex items-center"> 183 {{ . }} 184 </span> 185 {{ end }} 186 </div> 187 </div> 188 {{ end }} 189</div> 190{{ end }} 191 192 193{{ define "repoAfter" }} 194 {{- if .HTMLReadme }} 195 <section class="mt-4 p-6 rounded bg-white w-full mx-auto overflow-auto {{ if not .Raw }} prose {{ end }}"> 196 <article class="{{ if .Raw }}whitespace-pre{{end}}"> 197 {{ if .Raw }} 198 <pre>{{ .HTMLReadme }}</pre> 199 {{ else }} 200 {{ .HTMLReadme }} 201 {{ end }} 202 </article> 203 </section> 204 {{- end -}} 205 206 207 <section class="mt-4 p-6 rounded bg-white w-full mx-auto overflow-auto"> 208 <strong>push</strong> 209 <div class="py-2"> 210 <code>git remote add origin git@{{.RepoInfo.Knot}}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code> 211 </div> 212 <strong>clone</strong> 213 214 215 <div class="flex flex-col gap-2"> 216 <div class="pt-2 flex flex-row gap-2"> 217 <span class="bg-gray-100 p-1 mr-1 font-mono text-sm rounded select-none">HTTP</span> 218 <code>git clone https://tangled.sh/{{ .RepoInfo.OwnerWithAt }}/{{ .RepoInfo.Name }}</code> 219 </div> 220 <div class="pt-2 flex flex-row gap-2"> 221 <span class="bg-gray-100 p-1 mr-1 font-mono text-sm rounded select-none">SSH</span><code>git clone git@{{.RepoInfo.Knot}}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code> 222 </div> 223 </div> 224 <p class="py-2 text-gray-500">Note that for self-hosted knots, clone URLs may be different based on your setup.</p> 225 </section> 226{{ end }}