forked from tangled.org/core
Monorepo for Tangled

appview: pages/templates: move fragments closer to the call site

+54 -31
appview/pages/pages.go
··· 36 36 t map[string]*template.Template 37 37 } 38 38 39 + 40 + 39 41 func NewPages() *Pages { 40 42 templates := make(map[string]*template.Template) 43 + fragmentPaths := []string{} 41 44 42 - // Walk through embedded templates directory and parse all .html files 45 + // First, collect all fragment paths 43 46 err := fs.WalkDir(Files, "templates", func(path string, d fs.DirEntry, err error) error { 44 47 if err != nil { 45 48 return err 46 49 } 47 50 51 + if !d.IsDir() && strings.HasSuffix(path, ".html") && strings.Contains(path, "fragments/") { 52 + fragmentPaths = append(fragmentPaths, path) 53 + } 54 + return nil 55 + }) 56 + if err != nil { 57 + log.Fatalf("walking template dir for fragments: %v", err) 58 + } 59 + 60 + // Load all fragments first 61 + for _, path := range fragmentPaths { 62 + name := strings.TrimPrefix(path, "templates/") 63 + name = strings.TrimSuffix(name, ".html") 64 + 65 + tmpl, err := template.New(name). 66 + Funcs(funcMap()). 67 + ParseFS(Files, path) 68 + if err != nil { 69 + log.Fatalf("setting up fragment: %v", err) 70 + } 71 + 72 + templates[name] = tmpl 73 + log.Printf("loaded fragment: %s", name) 74 + } 75 + 76 + // Then walk through and setup the rest of the templates 77 + err = fs.WalkDir(Files, "templates", func(path string, d fs.DirEntry, err error) error { 78 + if err != nil { 79 + return err 80 + } 81 + 48 82 if !d.IsDir() && strings.HasSuffix(path, ".html") { 49 83 name := strings.TrimPrefix(path, "templates/") 50 84 name = strings.TrimSuffix(name, ".html") 51 85 52 - // add fragments as templates 53 - if strings.HasPrefix(path, "templates/fragments/") { 54 - tmpl, err := template.New(name). 55 - Funcs(funcMap()). 56 - ParseFS(Files, path) 57 - if err != nil { 58 - return fmt.Errorf("setting up fragment: %w", err) 59 - } 60 - 61 - templates[name] = tmpl 62 - log.Printf("loaded fragment: %s", name) 86 + // Skip fragments as they've already been loaded 87 + if strings.Contains(path, "fragments/") { 88 + return nil 63 89 } 64 90 65 - // layouts and fragments are applied first 66 - if !strings.HasPrefix(path, "templates/layouts/") && 67 - !strings.HasPrefix(path, "templates/fragments/") { 91 + // Load layouts and main templates 92 + if !strings.HasPrefix(path, "templates/layouts/") { 68 93 // Add the page template on top of the base 69 94 tmpl, err := template.New(name). 70 95 Funcs(funcMap()). 71 - ParseFS(Files, "templates/layouts/*.html", "templates/fragments/*.html", path) 96 + ParseFS(Files, "templates/layouts/*.html", "templates/**/fragments/*.html", path) 72 97 if err != nil { 73 98 return fmt.Errorf("setting up template: %w", err) 74 99 } ··· 76 101 templates[name] = tmpl 77 102 log.Printf("loaded template: %s", name) 78 103 } 79 - 80 - return nil 81 104 } 82 105 return nil 83 106 }) ··· 200 223 } 201 224 202 225 func (p *Pages) FollowFragment(w io.Writer, params FollowFragmentParams) error { 203 - return p.executePlain("fragments/follow", w, params) 226 + return p.executePlain("user/fragments/follow", w, params) 204 227 } 205 228 206 229 type RepoActionsFragmentParams struct { ··· 210 233 } 211 234 212 235 func (p *Pages) RepoActionsFragment(w io.Writer, params RepoActionsFragmentParams) error { 213 - return p.executePlain("fragments/repoActions", w, params) 236 + return p.executePlain("repo/fragments/repoActions", w, params) 214 237 } 215 238 216 239 type RepoDescriptionParams struct { ··· 218 241 } 219 242 220 243 func (p *Pages) EditRepoDescriptionFragment(w io.Writer, params RepoDescriptionParams) error { 221 - return p.executePlain("fragments/editRepoDescription", w, params) 244 + return p.executePlain("repo/fragments/editRepoDescription", w, params) 222 245 } 223 246 224 247 func (p *Pages) RepoDescriptionFragment(w io.Writer, params RepoDescriptionParams) error { 225 - return p.executePlain("fragments/repoDescription", w, params) 248 + return p.executePlain("repo/fragments/repoDescription", w, params) 226 249 } 227 250 228 251 type RepoInfo struct { ··· 580 603 } 581 604 582 605 func (p *Pages) EditIssueCommentFragment(w io.Writer, params EditIssueCommentParams) error { 583 - return p.executePlain("fragments/editIssueComment", w, params) 606 + return p.executePlain("repo/issues/fragments/editIssueComment", w, params) 584 607 } 585 608 586 609 type SingleIssueCommentParams struct { ··· 592 615 } 593 616 594 617 func (p *Pages) SingleIssueCommentFragment(w io.Writer, params SingleIssueCommentParams) error { 595 - return p.executePlain("fragments/issueComment", w, params) 618 + return p.executePlain("repo/issues/fragments/issueComment", w, params) 596 619 } 597 620 598 621 type RepoNewPullParams struct { ··· 675 698 } 676 699 677 700 func (p *Pages) PullPatchUploadFragment(w io.Writer, params PullPatchUploadParams) error { 678 - return p.executePlain("fragments/pullPatchUpload", w, params) 701 + return p.executePlain("repo/pulls/fragments/pullPatchUpload", w, params) 679 702 } 680 703 681 704 type PullCompareBranchesParams struct { ··· 684 707 } 685 708 686 709 func (p *Pages) PullCompareBranchesFragment(w io.Writer, params PullCompareBranchesParams) error { 687 - return p.executePlain("fragments/pullCompareBranches", w, params) 710 + return p.executePlain("repo/pulls/fragments/pullCompareBranches", w, params) 688 711 } 689 712 690 713 type PullCompareForkParams struct { ··· 693 716 } 694 717 695 718 func (p *Pages) PullCompareForkFragment(w io.Writer, params PullCompareForkParams) error { 696 - return p.executePlain("fragments/pullCompareForks", w, params) 719 + return p.executePlain("repo/pulls/fragments/pullCompareForks", w, params) 697 720 } 698 721 699 722 type PullCompareForkBranchesParams struct { ··· 703 726 } 704 727 705 728 func (p *Pages) PullCompareForkBranchesFragment(w io.Writer, params PullCompareForkBranchesParams) error { 706 - return p.executePlain("fragments/pullCompareForksBranches", w, params) 729 + return p.executePlain("repo/pulls/fragments/pullCompareForksBranches", w, params) 707 730 } 708 731 709 732 type PullResubmitParams struct { ··· 714 737 } 715 738 716 739 func (p *Pages) PullResubmitFragment(w io.Writer, params PullResubmitParams) error { 717 - return p.executePlain("fragments/pullResubmit", w, params) 740 + return p.executePlain("repo/pulls/fragments/pullResubmit", w, params) 718 741 } 719 742 720 743 type PullActionsParams struct { ··· 727 750 } 728 751 729 752 func (p *Pages) PullActionsFragment(w io.Writer, params PullActionsParams) error { 730 - return p.executePlain("fragments/pullActions", w, params) 753 + return p.executePlain("repo/pulls/fragments/pullActions", w, params) 731 754 } 732 755 733 756 type PullNewCommentParams struct { ··· 738 761 } 739 762 740 763 func (p *Pages) PullNewCommentFragment(w io.Writer, params PullNewCommentParams) error { 741 - return p.executePlain("fragments/pullNewComment", w, params) 764 + return p.executePlain("repo/pulls/fragments/pullNewComment", w, params) 742 765 } 743 766 744 767 func (p *Pages) Static() http.Handler {
-33
appview/pages/templates/fragments/cloneInstructions.html
··· 1 - {{ define "fragments/cloneInstructions" }} 2 - <section class="mt-4 p-6 rounded bg-white dark:bg-gray-800 dark:text-white w-full mx-auto overflow-auto flex flex-col gap-4"> 3 - <div class="flex flex-col gap-2"> 4 - <strong>push</strong> 5 - <div class="md:pl-4 overflow-x-auto whitespace-nowrap"> 6 - <code class="dark:text-gray-100">git remote add origin git@{{.RepoInfo.Knot}}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code> 7 - </div> 8 - </div> 9 - 10 - <div class="flex flex-col gap-2"> 11 - <strong>clone</strong> 12 - <div class="md:pl-4 flex flex-col gap-2"> 13 - 14 - <div class="flex items-center gap-3"> 15 - <span class="bg-gray-100 dark:bg-gray-700 p-1 mr-1 font-mono text-sm rounded select-none dark:text-white">HTTP</span> 16 - <div class="overflow-x-auto whitespace-nowrap flex-1"> 17 - <code class="dark:text-gray-100">git clone https://tangled.sh/{{ .RepoInfo.OwnerWithAt }}/{{ .RepoInfo.Name }}</code> 18 - </div> 19 - </div> 20 - 21 - <div class="flex items-center gap-3"> 22 - <span class="bg-gray-100 dark:bg-gray-700 p-1 mr-1 font-mono text-sm rounded select-none dark:text-white">SSH</span> 23 - <div class="overflow-x-auto whitespace-nowrap flex-1"> 24 - <code class="dark:text-gray-100">git clone git@{{.RepoInfo.Knot}}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code> 25 - </div> 26 - </div> 27 - </div> 28 - </div> 29 - 30 - 31 - <p class="py-2 text-gray-500 dark:text-gray-400">Note that for self-hosted knots, clone URLs may be different based on your setup.</p> 32 - </section> 33 - {{ end }}
+2 -2
appview/pages/templates/fragments/diff.html appview/pages/templates/repo/fragments/diff.html
··· 1 - {{ define "fragments/diff" }} 1 + {{ define "repo/fragments/diff" }} 2 2 {{ $repo := index . 0 }} 3 3 {{ $diff := index . 1 }} 4 4 {{ $commit := $diff.Commit }} ··· 172 172 <span class="rounded p-1 select-none bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400">-{{ .Deletions }}</span> 173 173 {{ end }} 174 174 </div> 175 - {{ end }} 175 + {{ end }}
+1 -1
appview/pages/templates/fragments/editIssueComment.html appview/pages/templates/repo/issues/fragments/editIssueComment.html
··· 1 - {{ define "fragments/editIssueComment" }} 1 + {{ define "repo/issues/fragments/editIssueComment" }} 2 2 {{ with .Comment }} 3 3 <div id="comment-container-{{.CommentId}}"> 4 4 <div class="flex items-center gap-2 mb-2 text-gray-500 text-sm">
+1 -1
appview/pages/templates/fragments/editRepoDescription.html appview/pages/templates/repo/fragments/editRepoDescription.html
··· 1 - {{ define "fragments/editRepoDescription" }} 1 + {{ define "repo/fragments/editRepoDescription" }} 2 2 <form hx-put="/{{ .RepoInfo.FullName }}/description" hx-target="this" hx-swap="outerHTML" class="flex flex-wrap gap-2"> 3 3 <input type="text" class="p-1" name="description" value="{{ .RepoInfo.Description }}"> 4 4 <button type="submit" class="btn p-1 flex items-center gap-2 no-underline text-sm">
+1 -1
appview/pages/templates/fragments/follow.html appview/pages/templates/user/fragments/follow.html
··· 1 - {{ define "fragments/follow" }} 1 + {{ define "user/fragments/follow" }} 2 2 <button id="followBtn" 3 3 class="btn mt-2 w-full" 4 4
+1 -1
appview/pages/templates/fragments/issueComment.html appview/pages/templates/repo/issues/fragments/issueComment.html
··· 1 - {{ define "fragments/issueComment" }} 1 + {{ define "repo/issues/fragments/issueComment" }} 2 2 {{ with .Comment }} 3 3 <div id="comment-container-{{.CommentId}}"> 4 4 <div class="flex items-center gap-2 mb-2 text-gray-500 text-sm">
+1 -1
appview/pages/templates/fragments/pullActions.html appview/pages/templates/repo/pulls/fragments/pullActions.html
··· 1 - {{ define "fragments/pullActions" }} 1 + {{ define "repo/pulls/fragments/pullActions" }} 2 2 {{ $lastIdx := sub (len .Pull.Submissions) 1 }} 3 3 {{ $roundNumber := .RoundNumber }} 4 4
+1 -1
appview/pages/templates/fragments/pullCompareBranches.html appview/pages/templates/repo/pulls/fragments/pullCompareBranches.html
··· 1 - {{ define "fragments/pullCompareBranches" }} 1 + {{ define "repo/pulls/fragments/pullCompareBranches" }} 2 2 <div id="patch-upload"> 3 3 <label for="targetBranch" class="dark:text-white" 4 4 >select a branch</label
+1 -1
appview/pages/templates/fragments/pullCompareForks.html appview/pages/templates/repo/pulls/fragments/pullCompareForks.html
··· 1 - {{ define "fragments/pullCompareForks" }} 1 + {{ define "repo/pulls/fragments/pullCompareForks" }} 2 2 <div id="patch-upload"> 3 3 <label for="forkSelect" class="dark:text-white" 4 4 >select a fork to compare</label
+1 -1
appview/pages/templates/fragments/pullCompareForksBranches.html appview/pages/templates/repo/pulls/fragments/pullCompareForksBranches.html
··· 1 - {{ define "fragments/pullCompareForksBranches" }} 1 + {{ define "repo/pulls/fragments/pullCompareForksBranches" }} 2 2 <div class="flex flex-wrap gap-2 items-center"> 3 3 <select 4 4 name="sourceBranch"
+1 -1
appview/pages/templates/fragments/pullNewComment.html appview/pages/templates/repo/pulls/fragments/pullNewComment.html
··· 1 - {{ define "fragments/pullNewComment" }} 1 + {{ define "repo/pulls/fragments/pullNewComment" }} 2 2 <div 3 3 id="pull-comment-card-{{ .RoundNumber }}" 4 4 class="bg-white dark:bg-gray-800 rounded drop-shadow-sm p-4 relative w-full flex flex-col gap-2">
+1 -1
appview/pages/templates/fragments/pullPatchUpload.html appview/pages/templates/repo/pulls/fragments/pullPatchUpload.html
··· 1 - {{ define "fragments/pullPatchUpload" }} 1 + {{ define "repo/pulls/fragments/pullPatchUpload" }} 2 2 <div id="patch-upload"> 3 3 <textarea 4 4 name="patch"
+1 -1
appview/pages/templates/fragments/pullResubmit.html appview/pages/templates/repo/pulls/fragments/pullResubmit.html
··· 1 - {{ define "fragments/pullResubmit" }} 1 + {{ define "repo/pulls/fragments/pullResubmit" }} 2 2 <div 3 3 id="resubmit-pull-card" 4 4 class="rounded relative border bg-amber-50 dark:bg-amber-900 border-amber-200 dark:border-amber-500 px-6 py-2">
-41
appview/pages/templates/fragments/repoActions.html
··· 1 - {{ define "fragments/repoActions" }} 2 - <div class="flex items-center gap-2 z-auto"> 3 - <button id="starBtn" 4 - class="btn disabled:opacity-50 disabled:cursor-not-allowed" 5 - 6 - {{ if .IsStarred }} 7 - hx-delete="/star?subject={{.RepoAt}}&countHint={{.Stats.StarCount}}" 8 - {{ else }} 9 - hx-post="/star?subject={{.RepoAt}}&countHint={{.Stats.StarCount}}" 10 - {{ end }} 11 - 12 - hx-trigger="click" 13 - hx-target="#starBtn" 14 - hx-swap="outerHTML" 15 - hx-disabled-elt="#starBtn" 16 - > 17 - <div class="flex gap-2 items-center"> 18 - {{ if .IsStarred }} 19 - {{ i "star" "w-4 h-4 fill-current" }} 20 - {{ else }} 21 - {{ i "star" "w-4 h-4" }} 22 - {{ end }} 23 - <span class="text-sm"> 24 - {{ .Stats.StarCount }} 25 - </span> 26 - </div> 27 - </button> 28 - {{ if .DisableFork }} 29 - <button class="btn text-sm no-underline hover:no-underline flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed" disabled title="Empty repositories cannot be forked"> 30 - {{ i "git-fork" "w-4 h-4"}} 31 - fork 32 - </button> 33 - {{ else }} 34 - <a class="btn text-sm no-underline hover:no-underline flex items-center gap-2" href="/{{ .FullName }}/fork"> 35 - {{ i "git-fork" "w-4 h-4"}} 36 - fork 37 - </a> 38 - {{ end }} 39 - </div> 40 - {{ end }} 41 -
+1 -1
appview/pages/templates/fragments/repoDescription.html appview/pages/templates/repo/fragments/repoDescription.html
··· 1 - {{ define "fragments/repoDescription" }} 1 + {{ define "repo/fragments/repoDescription" }} 2 2 <span id="repo-description" class="flex flex-wrap items-center gap-2 text-sm" hx-target="this" hx-swap="outerHTML"> 3 3 {{ if .RepoInfo.Description }} 4 4 {{ .RepoInfo.Description }}
+2 -2
appview/pages/templates/layouts/repobase.html
··· 19 19 <a href="/{{ .RepoInfo.FullName }}" class="font-bold">{{ .RepoInfo.Name }}</a> 20 20 </div> 21 21 22 - {{ template "fragments/repoActions" .RepoInfo }} 22 + {{ template "repo/fragments/repoActions" .RepoInfo }} 23 23 </div> 24 - {{ template "fragments/repoDescription" . }} 24 + {{ template "repo/fragments/repoDescription" . }} 25 25 </section> 26 26 <section class="min-h-screen flex flex-col drop-shadow-sm"> 27 27 <nav class="w-full pl-4 overflow-auto">
+1 -1
appview/pages/templates/repo/commit.html
··· 44 44 {{end}} 45 45 46 46 {{ define "repoAfter" }} 47 - {{ template "fragments/diff" (list .RepoInfo.FullName .Diff) }} 47 + {{ template "repo/fragments/diff" (list .RepoInfo.FullName .Diff) }} 48 48 {{end}}
+1 -1
appview/pages/templates/repo/empty.html
··· 9 9 {{ end }} 10 10 11 11 {{ define "repoAfter" }} 12 - {{ template "fragments/cloneInstructions" . }} 12 + {{ template "repo/fragments/cloneInstructions" . }} 13 13 {{ end }}
+51
appview/pages/templates/repo/fragments/cloneInstructions.html
··· 1 + {{ define "repo/fragments/cloneInstructions" }} 2 + <section 3 + class="mt-4 p-6 rounded bg-white dark:bg-gray-800 dark:text-white w-full mx-auto overflow-auto flex flex-col gap-4" 4 + > 5 + <div class="flex flex-col gap-2"> 6 + <strong>push</strong> 7 + <div class="md:pl-4 overflow-x-auto whitespace-nowrap"> 8 + <code class="dark:text-gray-100" 9 + >git remote add origin 10 + git@{{ .RepoInfo.Knot }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code 11 + > 12 + </div> 13 + </div> 14 + 15 + <div class="flex flex-col gap-2"> 16 + <strong>clone</strong> 17 + <div class="md:pl-4 flex flex-col gap-2"> 18 + <div class="flex items-center gap-3"> 19 + <span 20 + class="bg-gray-100 dark:bg-gray-700 p-1 mr-1 font-mono text-sm rounded select-none dark:text-white" 21 + >HTTP</span 22 + > 23 + <div class="overflow-x-auto whitespace-nowrap flex-1"> 24 + <code class="dark:text-gray-100" 25 + >git clone 26 + https://tangled.sh/{{ .RepoInfo.OwnerWithAt }}/{{ .RepoInfo.Name }}</code 27 + > 28 + </div> 29 + </div> 30 + 31 + <div class="flex items-center gap-3"> 32 + <span 33 + class="bg-gray-100 dark:bg-gray-700 p-1 mr-1 font-mono text-sm rounded select-none dark:text-white" 34 + >SSH</span 35 + > 36 + <div class="overflow-x-auto whitespace-nowrap flex-1"> 37 + <code class="dark:text-gray-100" 38 + >git clone 39 + git@{{ .RepoInfo.Knot }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code 40 + > 41 + </div> 42 + </div> 43 + </div> 44 + </div> 45 + 46 + <p class="py-2 text-gray-500 dark:text-gray-400"> 47 + Note that for self-hosted knots, clone URLs may be different based 48 + on your setup. 49 + </p> 50 + </section> 51 + {{ end }}
+47
appview/pages/templates/repo/fragments/repoActions.html
··· 1 + {{ define "repo/fragments/repoActions" }} 2 + <div class="flex items-center gap-2 z-auto"> 3 + <button 4 + id="starBtn" 5 + class="btn disabled:opacity-50 disabled:cursor-not-allowed" 6 + {{ if .IsStarred }} 7 + hx-delete="/star?subject={{ .RepoAt }}&countHint={{ .Stats.StarCount }}" 8 + {{ else }} 9 + hx-post="/star?subject={{ .RepoAt }}&countHint={{ .Stats.StarCount }}" 10 + {{ end }} 11 + 12 + hx-trigger="click" 13 + hx-target="#starBtn" 14 + hx-swap="outerHTML" 15 + hx-disabled-elt="#starBtn" 16 + > 17 + <div class="flex gap-2 items-center"> 18 + {{ if .IsStarred }} 19 + {{ i "star" "w-4 h-4 fill-current" }} 20 + {{ else }} 21 + {{ i "star" "w-4 h-4" }} 22 + {{ end }} 23 + <span class="text-sm"> 24 + {{ .Stats.StarCount }} 25 + </span> 26 + </div> 27 + </button> 28 + {{ if .DisableFork }} 29 + <button 30 + class="btn text-sm no-underline hover:no-underline flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed" 31 + disabled 32 + title="Empty repositories cannot be forked" 33 + > 34 + {{ i "git-fork" "w-4 h-4" }} 35 + fork 36 + </button> 37 + {{ else }} 38 + <a 39 + class="btn text-sm no-underline hover:no-underline flex items-center gap-2" 40 + href="/{{ .FullName }}/fork" 41 + > 42 + {{ i "git-fork" "w-4 h-4" }} 43 + fork 44 + </a> 45 + {{ end }} 46 + </div> 47 + {{ end }}
+209 -172
appview/pages/templates/repo/index.html
··· 1 1 {{ define "title" }}{{ .RepoInfo.FullName }} at {{ .Ref }}{{ end }} 2 2 3 - 4 3 {{ define "extrameta" }} 5 - <meta name="vcs:clone" content="https://tangled.sh/{{ .RepoInfo.FullName }}"/> 6 - <meta name="forge:summary" content="https://tangled.sh/{{ .RepoInfo.FullName }}"> 7 - <meta name="forge:dir" content="https://tangled.sh/{{ .RepoInfo.FullName }}/tree/{ref}/{path}"> 8 - <meta name="forge:file" content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}"> 9 - <meta name="forge:line" content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}#L{line}"> 10 - <meta name="go-import" content="tangled.sh/{{ .RepoInfo.FullNameWithoutAt }} git https://tangled.sh/{{ .RepoInfo.FullName }}"> 4 + <meta 5 + name="vcs:clone" 6 + content="https://tangled.sh/{{ .RepoInfo.FullName }}" 7 + /> 8 + <meta 9 + name="forge:summary" 10 + content="https://tangled.sh/{{ .RepoInfo.FullName }}" 11 + /> 12 + <meta 13 + name="forge:dir" 14 + content="https://tangled.sh/{{ .RepoInfo.FullName }}/tree/{ref}/{path}" 15 + /> 16 + <meta 17 + name="forge:file" 18 + content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}" 19 + /> 20 + <meta 21 + name="forge:line" 22 + content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}#L{line}" 23 + /> 24 + <meta 25 + name="go-import" 26 + content="tangled.sh/{{ .RepoInfo.FullNameWithoutAt }} git https://tangled.sh/{{ .RepoInfo.FullName }}" 27 + /> 11 28 {{ end }} 12 - 13 29 14 30 {{ define "repoContent" }} 15 31 <main> 16 - {{ block "branchSelector" . }} {{ end }} 32 + {{ block "branchSelector" . }}{{ end }} 17 33 <div class="grid grid-cols-1 md:grid-cols-2 gap-2"> 18 - {{ block "fileTree" . }} {{ end }} 19 - {{ block "commitLog" . }} {{ end }} 34 + {{ block "fileTree" . }}{{ end }} 35 + {{ block "commitLog" . }}{{ end }} 20 36 </div> 21 37 </main> 22 38 {{ end }} 23 39 24 40 {{ define "branchSelector" }} 25 - <div class="flex justify-between pb-5"> 26 - <select 27 - onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)" 28 - class="p-1 border border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700" 29 - > 30 - <optgroup label="branches" class="bold text-sm"> 31 - {{ range .Branches }} 32 - <option 33 - value="{{ .Reference.Name }}" 34 - class="py-1" 35 - {{ if eq .Reference.Name $.Ref }} 36 - selected 37 - {{ end }} 38 - > 39 - {{ .Reference.Name }} 40 - </option> 41 - {{ end }} 42 - </optgroup> 43 - <optgroup label="tags" class="bold text-sm"> 44 - {{ range .Tags }} 45 - <option 46 - value="{{ .Reference.Name }}" 47 - class="py-1" 48 - {{ if eq .Reference.Name $.Ref }} 49 - selected 50 - {{ end }} 51 - > 52 - {{ .Reference.Name }} 53 - </option> 54 - {{ else }} 55 - <option class="py-1" disabled>no tags found</option> 56 - {{ end }} 57 - </optgroup> 58 - </select> 59 - <a 60 - href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}" 61 - class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold dark:text-white" 62 - > 63 - {{ i "logs" "w-4 h-4" }} 64 - {{ .TotalCommits }} 65 - {{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }} 66 - </a> 67 - </div> 41 + <div class="flex justify-between pb-5"> 42 + <select 43 + onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)" 44 + class="p-1 border border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700" 45 + > 46 + <optgroup label="branches" class="bold text-sm"> 47 + {{ range .Branches }} 48 + <option 49 + value="{{ .Reference.Name }}" 50 + class="py-1" 51 + {{ if eq .Reference.Name $.Ref }} 52 + selected 53 + {{ end }} 54 + > 55 + {{ .Reference.Name }} 56 + </option> 57 + {{ end }} 58 + </optgroup> 59 + <optgroup label="tags" class="bold text-sm"> 60 + {{ range .Tags }} 61 + <option 62 + value="{{ .Reference.Name }}" 63 + class="py-1" 64 + {{ if eq .Reference.Name $.Ref }} 65 + selected 66 + {{ end }} 67 + > 68 + {{ .Reference.Name }} 69 + </option> 70 + {{ else }} 71 + <option class="py-1" disabled>no tags found</option> 72 + {{ end }} 73 + </optgroup> 74 + </select> 75 + <a 76 + href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}" 77 + class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold dark:text-white" 78 + > 79 + {{ i "logs" "w-4 h-4" }} 80 + {{ .TotalCommits }} 81 + {{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }} 82 + </a> 83 + </div> 68 84 {{ end }} 69 85 70 86 {{ define "fileTree" }} 71 - <div id="file-tree" class="col-span-1 pr-2 md:border-r md:border-gray-200 dark:md:border-gray-700"> 72 - {{ $containerstyle := "py-1" }} 73 - {{ $linkstyle := "no-underline hover:underline dark:text-white" }} 87 + <div 88 + id="file-tree" 89 + class="col-span-1 pr-2 md:border-r md:border-gray-200 dark:md:border-gray-700" 90 + > 91 + {{ $containerstyle := "py-1" }} 92 + {{ $linkstyle := "no-underline hover:underline dark:text-white" }} 74 93 75 - {{ range .Files }} 76 - {{ if not .IsFile }} 77 - <div class="{{ $containerstyle }}"> 78 - <div class="flex justify-between items-center"> 79 - <a 80 - href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref | urlquery }}/{{ .Name }}" 81 - class="{{ $linkstyle }}" 82 - > 83 - <div class="flex items-center gap-2"> 84 - {{ i "folder" "w-3 h-3 fill-current" }} 85 - {{ .Name }} 86 - </div> 87 - </a> 94 + {{ range .Files }} 95 + {{ if not .IsFile }} 96 + <div class="{{ $containerstyle }}"> 97 + <div class="flex justify-between items-center"> 98 + <a 99 + href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref | urlquery }}/{{ .Name }}" 100 + class="{{ $linkstyle }}" 101 + > 102 + <div class="flex items-center gap-2"> 103 + {{ i "folder" "w-3 h-3 fill-current" }} 104 + {{ .Name }} 105 + </div> 106 + </a> 88 107 89 - <time class="text-xs text-gray-500 dark:text-gray-400" 90 - >{{ timeFmt .LastCommit.When }}</time 91 - > 108 + <time class="text-xs text-gray-500 dark:text-gray-400" 109 + >{{ timeFmt .LastCommit.When }}</time 110 + > 111 + </div> 92 112 </div> 93 - </div> 113 + {{ end }} 94 114 {{ end }} 95 - {{ end }} 96 115 97 - {{ range .Files }} 98 - {{ if .IsFile }} 99 - <div class="{{ $containerstyle }}"> 100 - <div class="flex justify-between items-center"> 101 - <a 102 - href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref | urlquery }}/{{ .Name }}" 103 - class="{{ $linkstyle }}" 104 - > 105 - <div class="flex items-center gap-2"> 106 - {{ i "file" "w-3 h-3" }}{{ .Name }} 107 - </div> 108 - </a> 116 + {{ range .Files }} 117 + {{ if .IsFile }} 118 + <div class="{{ $containerstyle }}"> 119 + <div class="flex justify-between items-center"> 120 + <a 121 + href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref | urlquery }}/{{ .Name }}" 122 + class="{{ $linkstyle }}" 123 + > 124 + <div class="flex items-center gap-2"> 125 + {{ i "file" "w-3 h-3" }}{{ .Name }} 126 + </div> 127 + </a> 109 128 110 - <time class="text-xs text-gray-500 dark:text-gray-400" 111 - >{{ timeFmt .LastCommit.When }}</time 112 - > 129 + <time class="text-xs text-gray-500 dark:text-gray-400" 130 + >{{ timeFmt .LastCommit.When }}</time 131 + > 132 + </div> 113 133 </div> 114 - </div> 134 + {{ end }} 115 135 {{ end }} 116 - {{ end }} 117 - </div> 136 + </div> 118 137 {{ end }} 119 - 120 138 121 139 {{ define "commitLog" }} 122 - <div id="commit-log" class="hidden md:block md:col-span-1"> 123 - {{ range .Commits }} 124 - <div class="relative px-2 pb-8"> 125 - <div id="commit-message"> 126 - {{ $messageParts := splitN .Message "\n\n" 2 }} 127 - <div class="text-base cursor-pointer"> 128 - <div> 129 - <div> 130 - <a 131 - href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 132 - class="inline no-underline hover:underline dark:text-white" 133 - >{{ index $messageParts 0 }}</a 134 - > 135 - {{ if gt (len $messageParts) 1 }} 140 + <div id="commit-log" class="hidden md:block md:col-span-1"> 141 + {{ range .Commits }} 142 + <div class="relative px-2 pb-8"> 143 + <div id="commit-message"> 144 + {{ $messageParts := splitN .Message "\n\n" 2 }} 145 + <div class="text-base cursor-pointer"> 146 + <div> 147 + <div> 148 + <a 149 + href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 150 + class="inline no-underline hover:underline dark:text-white" 151 + >{{ index $messageParts 0 }}</a 152 + > 153 + {{ if gt (len $messageParts) 1 }} 136 154 137 - <button 138 - class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600" 139 - hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')" 140 - > 141 - {{ i "ellipsis" "w-3 h-3" }} 142 - </button> 143 - {{ end }} 144 - </div> 145 - {{ if gt (len $messageParts) 1 }} 146 - <p 147 - class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300" 148 - > 149 - {{ nl2br (index $messageParts 1) }} 150 - </p> 151 - {{ end }} 152 - </div> 153 - </div> 154 - </div> 155 + <button 156 + class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600" 157 + hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')" 158 + > 159 + {{ i "ellipsis" "w-3 h-3" }} 160 + </button> 161 + {{ end }} 162 + </div> 163 + {{ if gt (len $messageParts) 1 }} 164 + <p 165 + class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300" 166 + > 167 + {{ nl2br (index $messageParts 1) }} 168 + </p> 169 + {{ end }} 170 + </div> 171 + </div> 172 + </div> 155 173 156 - <div class="text-xs text-gray-500 dark:text-gray-400"> 157 - <span class="font-mono"> 158 - <a 159 - href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 160 - class="text-gray-500 dark:text-gray-400 no-underline hover:underline" 161 - >{{ slice .Hash.String 0 8 }}</a 162 - > 163 - </span> 164 - <span 165 - class="mx-2 before:content-['·'] before:select-none" 166 - ></span> 167 - <span> 168 - {{ $didOrHandle := index $.EmailToDidOrHandle .Author.Email }} 169 - <a 170 - href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ .Author.Email }}{{ end }}" 171 - class="text-gray-500 dark:text-gray-400 no-underline hover:underline" 172 - >{{ if $didOrHandle }}{{ $didOrHandle }}{{ else }}{{ .Author.Name }}{{ end }}</a 173 - > 174 - </span> 175 - <div 176 - class="inline-block px-1 select-none after:content-['·']" 177 - ></div> 178 - <span>{{ timeFmt .Author.When }}</span> 179 - {{ $tagsForCommit := index $.TagMap .Hash.String }} 180 - {{ if gt (len $tagsForCommit) 0 }} 174 + <div class="text-xs text-gray-500 dark:text-gray-400"> 175 + <span class="font-mono"> 176 + <a 177 + href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" 178 + class="text-gray-500 dark:text-gray-400 no-underline hover:underline" 179 + >{{ slice .Hash.String 0 8 }}</a 180 + > 181 + </span> 182 + <span 183 + class="mx-2 before:content-['·'] before:select-none" 184 + ></span> 185 + <span> 186 + {{ $didOrHandle := index $.EmailToDidOrHandle .Author.Email }} 187 + <a 188 + href="{{ if $didOrHandle }} 189 + /{{ $didOrHandle }} 190 + {{ else }} 191 + mailto:{{ .Author.Email }} 192 + {{ end }}" 193 + class="text-gray-500 dark:text-gray-400 no-underline hover:underline" 194 + >{{ if $didOrHandle }} 195 + {{ $didOrHandle }} 196 + {{ else }} 197 + {{ .Author.Name }} 198 + {{ end }}</a 199 + > 200 + </span> 181 201 <div 182 202 class="inline-block px-1 select-none after:content-['·']" 183 203 ></div> 184 - {{ end }} 185 - {{ range $tagsForCommit }} 186 - <span class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center"> 187 - {{ . }} 188 - </span> 189 - {{ end }} 190 - </div> 191 - </div> 192 - {{ end }} 193 - </div> 204 + <span>{{ timeFmt .Author.When }}</span> 205 + {{ $tagsForCommit := index $.TagMap .Hash.String }} 206 + {{ if gt (len $tagsForCommit) 0 }} 207 + <div 208 + class="inline-block px-1 select-none after:content-['·']" 209 + ></div> 210 + {{ end }} 211 + {{ range $tagsForCommit }} 212 + <span 213 + class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center" 214 + > 215 + {{ . }} 216 + </span> 217 + {{ end }} 218 + </div> 219 + </div> 220 + {{ end }} 221 + </div> 194 222 {{ end }} 195 - 196 223 197 224 {{ define "repoAfter" }} 198 225 {{- if .HTMLReadme }} 199 - <section class="mt-4 p-6 rounded bg-white dark:bg-gray-800 dark:text-white w-full mx-auto overflow-auto {{ if not .Raw }} prose dark:prose-invert dark:[&_pre]:bg-gray-900 dark:[&_code]:text-gray-300 dark:[&_pre_code]:bg-gray-900 dark:[&_pre]:border dark:[&_pre]:border-gray-700 {{ end }}"> 200 - <article class="{{ if .Raw }}whitespace-pre{{end}}"> 201 - {{ if .Raw }} 202 - <pre class="dark:bg-gray-900 dark:text-gray-200 dark:border dark:border-gray-700 dark:p-4 dark:rounded">{{ .HTMLReadme }}</pre> 203 - {{ else }} 204 - {{ .HTMLReadme }} 205 - {{ end }} 206 - </article> 207 - </section> 226 + <section 227 + class="mt-4 p-6 rounded bg-white dark:bg-gray-800 dark:text-white w-full mx-auto overflow-auto {{ if not .Raw }} 228 + prose dark:prose-invert dark:[&_pre]:bg-gray-900 229 + dark:[&_code]:text-gray-300 dark:[&_pre_code]:bg-gray-900 230 + dark:[&_pre]:border dark:[&_pre]:border-gray-700 231 + {{ end }}" 232 + > 233 + <article class="{{ if .Raw }}whitespace-pre{{ end }}"> 234 + {{ if .Raw }} 235 + <pre 236 + class="dark:bg-gray-900 dark:text-gray-200 dark:border dark:border-gray-700 dark:p-4 dark:rounded" 237 + > 238 + {{ .HTMLReadme }}</pre 239 + > 240 + {{ else }} 241 + {{ .HTMLReadme }} 242 + {{ end }} 243 + </article> 244 + </section> 208 245 {{- end -}} 209 246 210 - {{ template "fragments/cloneInstructions" . }} 247 + {{ template "repo/fragments/cloneInstructions" . }} 211 248 {{ end }}
+1 -1
appview/pages/templates/repo/issues/issue.html
··· 52 52 {{ if gt $index 0 }} 53 53 <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div> 54 54 {{ end }} 55 - {{ template "fragments/issueComment" (dict "RepoInfo" $.RepoInfo "LoggedInUser" $.LoggedInUser "DidHandleMap" $.DidHandleMap "Issue" $.Issue "Comment" .)}} 55 + {{ template "repo/issues/fragments/issueComment" (dict "RepoInfo" $.RepoInfo "LoggedInUser" $.LoggedInUser "DidHandleMap" $.DidHandleMap "Issue" $.Issue "Comment" .)}} 56 56 </div> 57 57 {{ end }} 58 58 </section>
+1 -1
appview/pages/templates/repo/pulls/new.html
··· 84 84 </nav> 85 85 86 86 <section id="patch-strategy"> 87 - {{ template "fragments/pullPatchUpload" . }} 87 + {{ template "repo/pulls/fragments/pullPatchUpload" . }} 88 88 </section> 89 89 90 90 <div class="flex justify-start items-center gap-2 mt-4">
+1 -1
appview/pages/templates/repo/pulls/patch.html
··· 72 72 </div> 73 73 74 74 <section> 75 - {{ template "fragments/diff" (list .RepoInfo.FullName .Diff) }} 75 + {{ template "repo/fragments/diff" (list .RepoInfo.FullName .Diff) }} 76 76 </section> 77 77 {{ end }}
+1 -1
appview/pages/templates/repo/pulls/pull.html
··· 147 147 {{ end }} 148 148 149 149 {{ if $.LoggedInUser }} 150 - {{ template "fragments/pullActions" (dict "LoggedInUser" $.LoggedInUser "Pull" $.Pull "RepoInfo" $.RepoInfo "RoundNumber" .RoundNumber "MergeCheck" $.MergeCheck "ResubmitCheck" $.ResubmitCheck) }} 150 + {{ template "repo/pulls/fragments/pullActions" (dict "LoggedInUser" $.LoggedInUser "Pull" $.Pull "RepoInfo" $.RepoInfo "RoundNumber" .RoundNumber "MergeCheck" $.MergeCheck "ResubmitCheck" $.ResubmitCheck) }} 151 151 {{ else }} 152 152 <div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm px-6 py-4 w-fit dark:text-white"> 153 153 <div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div>
+1 -1
appview/pages/templates/user/profile.html
··· 247 247 </div> 248 248 249 249 {{ if ne .FollowStatus.String "IsSelf" }} 250 - {{ template "fragments/follow" . }} 250 + {{ template "user/fragments/follow" . }} 251 251 {{ end }} 252 252 </div> 253 253 {{ end }}