forked from tangled.org/core
this repo has no description

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

+54 -31
appview/pages/pages.go
···
t map[string]*template.Template
}
+
+
func NewPages() *Pages {
templates := make(map[string]*template.Template)
+
fragmentPaths := []string{}
-
// Walk through embedded templates directory and parse all .html files
+
// First, collect all fragment paths
err := fs.WalkDir(Files, "templates", func(path string, d fs.DirEntry, err error) error {
if err != nil {
return err
}
+
if !d.IsDir() && strings.HasSuffix(path, ".html") && strings.Contains(path, "fragments/") {
+
fragmentPaths = append(fragmentPaths, path)
+
}
+
return nil
+
})
+
if err != nil {
+
log.Fatalf("walking template dir for fragments: %v", err)
+
}
+
+
// Load all fragments first
+
for _, path := range fragmentPaths {
+
name := strings.TrimPrefix(path, "templates/")
+
name = strings.TrimSuffix(name, ".html")
+
+
tmpl, err := template.New(name).
+
Funcs(funcMap()).
+
ParseFS(Files, path)
+
if err != nil {
+
log.Fatalf("setting up fragment: %v", err)
+
}
+
+
templates[name] = tmpl
+
log.Printf("loaded fragment: %s", name)
+
}
+
+
// Then walk through and setup the rest of the templates
+
err = fs.WalkDir(Files, "templates", func(path string, d fs.DirEntry, err error) error {
+
if err != nil {
+
return err
+
}
+
if !d.IsDir() && strings.HasSuffix(path, ".html") {
name := strings.TrimPrefix(path, "templates/")
name = strings.TrimSuffix(name, ".html")
-
// add fragments as templates
-
if strings.HasPrefix(path, "templates/fragments/") {
-
tmpl, err := template.New(name).
-
Funcs(funcMap()).
-
ParseFS(Files, path)
-
if err != nil {
-
return fmt.Errorf("setting up fragment: %w", err)
-
}
-
-
templates[name] = tmpl
-
log.Printf("loaded fragment: %s", name)
+
// Skip fragments as they've already been loaded
+
if strings.Contains(path, "fragments/") {
+
return nil
}
-
// layouts and fragments are applied first
-
if !strings.HasPrefix(path, "templates/layouts/") &&
-
!strings.HasPrefix(path, "templates/fragments/") {
+
// Load layouts and main templates
+
if !strings.HasPrefix(path, "templates/layouts/") {
// Add the page template on top of the base
tmpl, err := template.New(name).
Funcs(funcMap()).
-
ParseFS(Files, "templates/layouts/*.html", "templates/fragments/*.html", path)
+
ParseFS(Files, "templates/layouts/*.html", "templates/**/fragments/*.html", path)
if err != nil {
return fmt.Errorf("setting up template: %w", err)
}
···
templates[name] = tmpl
log.Printf("loaded template: %s", name)
}
-
-
return nil
}
return nil
})
···
}
func (p *Pages) FollowFragment(w io.Writer, params FollowFragmentParams) error {
-
return p.executePlain("fragments/follow", w, params)
+
return p.executePlain("user/fragments/follow", w, params)
}
type RepoActionsFragmentParams struct {
···
}
func (p *Pages) RepoActionsFragment(w io.Writer, params RepoActionsFragmentParams) error {
-
return p.executePlain("fragments/repoActions", w, params)
+
return p.executePlain("repo/fragments/repoActions", w, params)
}
type RepoDescriptionParams struct {
···
}
func (p *Pages) EditRepoDescriptionFragment(w io.Writer, params RepoDescriptionParams) error {
-
return p.executePlain("fragments/editRepoDescription", w, params)
+
return p.executePlain("repo/fragments/editRepoDescription", w, params)
}
func (p *Pages) RepoDescriptionFragment(w io.Writer, params RepoDescriptionParams) error {
-
return p.executePlain("fragments/repoDescription", w, params)
+
return p.executePlain("repo/fragments/repoDescription", w, params)
}
type RepoInfo struct {
···
}
func (p *Pages) EditIssueCommentFragment(w io.Writer, params EditIssueCommentParams) error {
-
return p.executePlain("fragments/editIssueComment", w, params)
+
return p.executePlain("repo/issues/fragments/editIssueComment", w, params)
}
type SingleIssueCommentParams struct {
···
}
func (p *Pages) SingleIssueCommentFragment(w io.Writer, params SingleIssueCommentParams) error {
-
return p.executePlain("fragments/issueComment", w, params)
+
return p.executePlain("repo/issues/fragments/issueComment", w, params)
}
type RepoNewPullParams struct {
···
}
func (p *Pages) PullPatchUploadFragment(w io.Writer, params PullPatchUploadParams) error {
-
return p.executePlain("fragments/pullPatchUpload", w, params)
+
return p.executePlain("repo/pulls/fragments/pullPatchUpload", w, params)
}
type PullCompareBranchesParams struct {
···
}
func (p *Pages) PullCompareBranchesFragment(w io.Writer, params PullCompareBranchesParams) error {
-
return p.executePlain("fragments/pullCompareBranches", w, params)
+
return p.executePlain("repo/pulls/fragments/pullCompareBranches", w, params)
}
type PullCompareForkParams struct {
···
}
func (p *Pages) PullCompareForkFragment(w io.Writer, params PullCompareForkParams) error {
-
return p.executePlain("fragments/pullCompareForks", w, params)
+
return p.executePlain("repo/pulls/fragments/pullCompareForks", w, params)
}
type PullCompareForkBranchesParams struct {
···
}
func (p *Pages) PullCompareForkBranchesFragment(w io.Writer, params PullCompareForkBranchesParams) error {
-
return p.executePlain("fragments/pullCompareForksBranches", w, params)
+
return p.executePlain("repo/pulls/fragments/pullCompareForksBranches", w, params)
}
type PullResubmitParams struct {
···
}
func (p *Pages) PullResubmitFragment(w io.Writer, params PullResubmitParams) error {
-
return p.executePlain("fragments/pullResubmit", w, params)
+
return p.executePlain("repo/pulls/fragments/pullResubmit", w, params)
}
type PullActionsParams struct {
···
}
func (p *Pages) PullActionsFragment(w io.Writer, params PullActionsParams) error {
-
return p.executePlain("fragments/pullActions", w, params)
+
return p.executePlain("repo/pulls/fragments/pullActions", w, params)
}
type PullNewCommentParams struct {
···
}
func (p *Pages) PullNewCommentFragment(w io.Writer, params PullNewCommentParams) error {
-
return p.executePlain("fragments/pullNewComment", w, params)
+
return p.executePlain("repo/pulls/fragments/pullNewComment", w, params)
}
func (p *Pages) Static() http.Handler {
-33
appview/pages/templates/fragments/cloneInstructions.html
···
-
{{ define "fragments/cloneInstructions" }}
-
<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">
-
<div class="flex flex-col gap-2">
-
<strong>push</strong>
-
<div class="md:pl-4 overflow-x-auto whitespace-nowrap">
-
<code class="dark:text-gray-100">git remote add origin git@{{.RepoInfo.Knot}}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code>
-
</div>
-
</div>
-
-
<div class="flex flex-col gap-2">
-
<strong>clone</strong>
-
<div class="md:pl-4 flex flex-col gap-2">
-
-
<div class="flex items-center gap-3">
-
<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>
-
<div class="overflow-x-auto whitespace-nowrap flex-1">
-
<code class="dark:text-gray-100">git clone https://tangled.sh/{{ .RepoInfo.OwnerWithAt }}/{{ .RepoInfo.Name }}</code>
-
</div>
-
</div>
-
-
<div class="flex items-center gap-3">
-
<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>
-
<div class="overflow-x-auto whitespace-nowrap flex-1">
-
<code class="dark:text-gray-100">git clone git@{{.RepoInfo.Knot}}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code>
-
</div>
-
</div>
-
</div>
-
</div>
-
-
-
<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>
-
</section>
-
{{ end }}
+2 -2
appview/pages/templates/fragments/diff.html appview/pages/templates/repo/fragments/diff.html
···
-
{{ define "fragments/diff" }}
+
{{ define "repo/fragments/diff" }}
{{ $repo := index . 0 }}
{{ $diff := index . 1 }}
{{ $commit := $diff.Commit }}
···
<span class="rounded p-1 select-none bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400">-{{ .Deletions }}</span>
{{ end }}
</div>
-
{{ end }}
+
{{ end }}
+1 -1
appview/pages/templates/fragments/editIssueComment.html appview/pages/templates/repo/issues/fragments/editIssueComment.html
···
-
{{ define "fragments/editIssueComment" }}
+
{{ define "repo/issues/fragments/editIssueComment" }}
{{ with .Comment }}
<div id="comment-container-{{.CommentId}}">
<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
···
-
{{ define "fragments/editRepoDescription" }}
+
{{ define "repo/fragments/editRepoDescription" }}
<form hx-put="/{{ .RepoInfo.FullName }}/description" hx-target="this" hx-swap="outerHTML" class="flex flex-wrap gap-2">
<input type="text" class="p-1" name="description" value="{{ .RepoInfo.Description }}">
<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
···
-
{{ define "fragments/follow" }}
+
{{ define "user/fragments/follow" }}
<button id="followBtn"
class="btn mt-2 w-full"
+1 -1
appview/pages/templates/fragments/issueComment.html appview/pages/templates/repo/issues/fragments/issueComment.html
···
-
{{ define "fragments/issueComment" }}
+
{{ define "repo/issues/fragments/issueComment" }}
{{ with .Comment }}
<div id="comment-container-{{.CommentId}}">
<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
···
-
{{ define "fragments/pullActions" }}
+
{{ define "repo/pulls/fragments/pullActions" }}
{{ $lastIdx := sub (len .Pull.Submissions) 1 }}
{{ $roundNumber := .RoundNumber }}
+1 -1
appview/pages/templates/fragments/pullCompareBranches.html appview/pages/templates/repo/pulls/fragments/pullCompareBranches.html
···
-
{{ define "fragments/pullCompareBranches" }}
+
{{ define "repo/pulls/fragments/pullCompareBranches" }}
<div id="patch-upload">
<label for="targetBranch" class="dark:text-white"
>select a branch</label
+1 -1
appview/pages/templates/fragments/pullCompareForks.html appview/pages/templates/repo/pulls/fragments/pullCompareForks.html
···
-
{{ define "fragments/pullCompareForks" }}
+
{{ define "repo/pulls/fragments/pullCompareForks" }}
<div id="patch-upload">
<label for="forkSelect" class="dark:text-white"
>select a fork to compare</label
+1 -1
appview/pages/templates/fragments/pullCompareForksBranches.html appview/pages/templates/repo/pulls/fragments/pullCompareForksBranches.html
···
-
{{ define "fragments/pullCompareForksBranches" }}
+
{{ define "repo/pulls/fragments/pullCompareForksBranches" }}
<div class="flex flex-wrap gap-2 items-center">
<select
name="sourceBranch"
+1 -1
appview/pages/templates/fragments/pullNewComment.html appview/pages/templates/repo/pulls/fragments/pullNewComment.html
···
-
{{ define "fragments/pullNewComment" }}
+
{{ define "repo/pulls/fragments/pullNewComment" }}
<div
id="pull-comment-card-{{ .RoundNumber }}"
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
···
-
{{ define "fragments/pullPatchUpload" }}
+
{{ define "repo/pulls/fragments/pullPatchUpload" }}
<div id="patch-upload">
<textarea
name="patch"
+1 -1
appview/pages/templates/fragments/pullResubmit.html appview/pages/templates/repo/pulls/fragments/pullResubmit.html
···
-
{{ define "fragments/pullResubmit" }}
+
{{ define "repo/pulls/fragments/pullResubmit" }}
<div
id="resubmit-pull-card"
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
···
-
{{ define "fragments/repoActions" }}
-
<div class="flex items-center gap-2 z-auto">
-
<button id="starBtn"
-
class="btn disabled:opacity-50 disabled:cursor-not-allowed"
-
-
{{ if .IsStarred }}
-
hx-delete="/star?subject={{.RepoAt}}&countHint={{.Stats.StarCount}}"
-
{{ else }}
-
hx-post="/star?subject={{.RepoAt}}&countHint={{.Stats.StarCount}}"
-
{{ end }}
-
-
hx-trigger="click"
-
hx-target="#starBtn"
-
hx-swap="outerHTML"
-
hx-disabled-elt="#starBtn"
-
>
-
<div class="flex gap-2 items-center">
-
{{ if .IsStarred }}
-
{{ i "star" "w-4 h-4 fill-current" }}
-
{{ else }}
-
{{ i "star" "w-4 h-4" }}
-
{{ end }}
-
<span class="text-sm">
-
{{ .Stats.StarCount }}
-
</span>
-
</div>
-
</button>
-
{{ if .DisableFork }}
-
<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">
-
{{ i "git-fork" "w-4 h-4"}}
-
fork
-
</button>
-
{{ else }}
-
<a class="btn text-sm no-underline hover:no-underline flex items-center gap-2" href="/{{ .FullName }}/fork">
-
{{ i "git-fork" "w-4 h-4"}}
-
fork
-
</a>
-
{{ end }}
-
</div>
-
{{ end }}
-
+1 -1
appview/pages/templates/fragments/repoDescription.html appview/pages/templates/repo/fragments/repoDescription.html
···
-
{{ define "fragments/repoDescription" }}
+
{{ define "repo/fragments/repoDescription" }}
<span id="repo-description" class="flex flex-wrap items-center gap-2 text-sm" hx-target="this" hx-swap="outerHTML">
{{ if .RepoInfo.Description }}
{{ .RepoInfo.Description }}
+2 -2
appview/pages/templates/layouts/repobase.html
···
<a href="/{{ .RepoInfo.FullName }}" class="font-bold">{{ .RepoInfo.Name }}</a>
</div>
-
{{ template "fragments/repoActions" .RepoInfo }}
+
{{ template "repo/fragments/repoActions" .RepoInfo }}
</div>
-
{{ template "fragments/repoDescription" . }}
+
{{ template "repo/fragments/repoDescription" . }}
</section>
<section class="min-h-screen flex flex-col drop-shadow-sm">
<nav class="w-full pl-4 overflow-auto">
+1 -1
appview/pages/templates/repo/commit.html
···
{{end}}
{{ define "repoAfter" }}
-
{{ template "fragments/diff" (list .RepoInfo.FullName .Diff) }}
+
{{ template "repo/fragments/diff" (list .RepoInfo.FullName .Diff) }}
{{end}}
+1 -1
appview/pages/templates/repo/empty.html
···
{{ end }}
{{ define "repoAfter" }}
-
{{ template "fragments/cloneInstructions" . }}
+
{{ template "repo/fragments/cloneInstructions" . }}
{{ end }}
+51
appview/pages/templates/repo/fragments/cloneInstructions.html
···
+
{{ define "repo/fragments/cloneInstructions" }}
+
<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"
+
>
+
<div class="flex flex-col gap-2">
+
<strong>push</strong>
+
<div class="md:pl-4 overflow-x-auto whitespace-nowrap">
+
<code class="dark:text-gray-100"
+
>git remote add origin
+
git@{{ .RepoInfo.Knot }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code
+
>
+
</div>
+
</div>
+
+
<div class="flex flex-col gap-2">
+
<strong>clone</strong>
+
<div class="md:pl-4 flex flex-col gap-2">
+
<div class="flex items-center gap-3">
+
<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
+
>
+
<div class="overflow-x-auto whitespace-nowrap flex-1">
+
<code class="dark:text-gray-100"
+
>git clone
+
https://tangled.sh/{{ .RepoInfo.OwnerWithAt }}/{{ .RepoInfo.Name }}</code
+
>
+
</div>
+
</div>
+
+
<div class="flex items-center gap-3">
+
<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
+
>
+
<div class="overflow-x-auto whitespace-nowrap flex-1">
+
<code class="dark:text-gray-100"
+
>git clone
+
git@{{ .RepoInfo.Knot }}:{{ .RepoInfo.OwnerHandle }}/{{ .RepoInfo.Name }}</code
+
>
+
</div>
+
</div>
+
</div>
+
</div>
+
+
<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>
+
</section>
+
{{ end }}
+47
appview/pages/templates/repo/fragments/repoActions.html
···
+
{{ define "repo/fragments/repoActions" }}
+
<div class="flex items-center gap-2 z-auto">
+
<button
+
id="starBtn"
+
class="btn disabled:opacity-50 disabled:cursor-not-allowed"
+
{{ if .IsStarred }}
+
hx-delete="/star?subject={{ .RepoAt }}&countHint={{ .Stats.StarCount }}"
+
{{ else }}
+
hx-post="/star?subject={{ .RepoAt }}&countHint={{ .Stats.StarCount }}"
+
{{ end }}
+
+
hx-trigger="click"
+
hx-target="#starBtn"
+
hx-swap="outerHTML"
+
hx-disabled-elt="#starBtn"
+
>
+
<div class="flex gap-2 items-center">
+
{{ if .IsStarred }}
+
{{ i "star" "w-4 h-4 fill-current" }}
+
{{ else }}
+
{{ i "star" "w-4 h-4" }}
+
{{ end }}
+
<span class="text-sm">
+
{{ .Stats.StarCount }}
+
</span>
+
</div>
+
</button>
+
{{ if .DisableFork }}
+
<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"
+
>
+
{{ i "git-fork" "w-4 h-4" }}
+
fork
+
</button>
+
{{ else }}
+
<a
+
class="btn text-sm no-underline hover:no-underline flex items-center gap-2"
+
href="/{{ .FullName }}/fork"
+
>
+
{{ i "git-fork" "w-4 h-4" }}
+
fork
+
</a>
+
{{ end }}
+
</div>
+
{{ end }}
+209 -172
appview/pages/templates/repo/index.html
···
{{ define "title" }}{{ .RepoInfo.FullName }} at {{ .Ref }}{{ end }}
-
{{ define "extrameta" }}
-
<meta name="vcs:clone" content="https://tangled.sh/{{ .RepoInfo.FullName }}"/>
-
<meta name="forge:summary" content="https://tangled.sh/{{ .RepoInfo.FullName }}">
-
<meta name="forge:dir" content="https://tangled.sh/{{ .RepoInfo.FullName }}/tree/{ref}/{path}">
-
<meta name="forge:file" content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}">
-
<meta name="forge:line" content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}#L{line}">
-
<meta name="go-import" content="tangled.sh/{{ .RepoInfo.FullNameWithoutAt }} git https://tangled.sh/{{ .RepoInfo.FullName }}">
+
<meta
+
name="vcs:clone"
+
content="https://tangled.sh/{{ .RepoInfo.FullName }}"
+
/>
+
<meta
+
name="forge:summary"
+
content="https://tangled.sh/{{ .RepoInfo.FullName }}"
+
/>
+
<meta
+
name="forge:dir"
+
content="https://tangled.sh/{{ .RepoInfo.FullName }}/tree/{ref}/{path}"
+
/>
+
<meta
+
name="forge:file"
+
content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}"
+
/>
+
<meta
+
name="forge:line"
+
content="https://tangled.sh/{{ .RepoInfo.FullName }}/blob/{ref}/{path}#L{line}"
+
/>
+
<meta
+
name="go-import"
+
content="tangled.sh/{{ .RepoInfo.FullNameWithoutAt }} git https://tangled.sh/{{ .RepoInfo.FullName }}"
+
/>
{{ end }}
-
{{ define "repoContent" }}
<main>
-
{{ block "branchSelector" . }} {{ end }}
+
{{ block "branchSelector" . }}{{ end }}
<div class="grid grid-cols-1 md:grid-cols-2 gap-2">
-
{{ block "fileTree" . }} {{ end }}
-
{{ block "commitLog" . }} {{ end }}
+
{{ block "fileTree" . }}{{ end }}
+
{{ block "commitLog" . }}{{ end }}
</div>
</main>
{{ end }}
{{ define "branchSelector" }}
-
<div class="flex justify-between pb-5">
-
<select
-
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)"
-
class="p-1 border border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700"
-
>
-
<optgroup label="branches" class="bold text-sm">
-
{{ range .Branches }}
-
<option
-
value="{{ .Reference.Name }}"
-
class="py-1"
-
{{ if eq .Reference.Name $.Ref }}
-
selected
-
{{ end }}
-
>
-
{{ .Reference.Name }}
-
</option>
-
{{ end }}
-
</optgroup>
-
<optgroup label="tags" class="bold text-sm">
-
{{ range .Tags }}
-
<option
-
value="{{ .Reference.Name }}"
-
class="py-1"
-
{{ if eq .Reference.Name $.Ref }}
-
selected
-
{{ end }}
-
>
-
{{ .Reference.Name }}
-
</option>
-
{{ else }}
-
<option class="py-1" disabled>no tags found</option>
-
{{ end }}
-
</optgroup>
-
</select>
-
<a
-
href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}"
-
class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold dark:text-white"
-
>
-
{{ i "logs" "w-4 h-4" }}
-
{{ .TotalCommits }}
-
{{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }}
-
</a>
-
</div>
+
<div class="flex justify-between pb-5">
+
<select
+
onchange="window.location.href = '/{{ .RepoInfo.FullName }}/tree/' + encodeURIComponent(this.value)"
+
class="p-1 border border-gray-200 bg-white dark:bg-gray-800 dark:text-white dark:border-gray-700"
+
>
+
<optgroup label="branches" class="bold text-sm">
+
{{ range .Branches }}
+
<option
+
value="{{ .Reference.Name }}"
+
class="py-1"
+
{{ if eq .Reference.Name $.Ref }}
+
selected
+
{{ end }}
+
>
+
{{ .Reference.Name }}
+
</option>
+
{{ end }}
+
</optgroup>
+
<optgroup label="tags" class="bold text-sm">
+
{{ range .Tags }}
+
<option
+
value="{{ .Reference.Name }}"
+
class="py-1"
+
{{ if eq .Reference.Name $.Ref }}
+
selected
+
{{ end }}
+
>
+
{{ .Reference.Name }}
+
</option>
+
{{ else }}
+
<option class="py-1" disabled>no tags found</option>
+
{{ end }}
+
</optgroup>
+
</select>
+
<a
+
href="/{{ .RepoInfo.FullName }}/commits/{{ .Ref | urlquery }}"
+
class="ml-2 no-underline flex items-center gap-2 text-sm uppercase font-bold dark:text-white"
+
>
+
{{ i "logs" "w-4 h-4" }}
+
{{ .TotalCommits }}
+
{{ if eq .TotalCommits 1 }}commit{{ else }}commits{{ end }}
+
</a>
+
</div>
{{ end }}
{{ define "fileTree" }}
-
<div id="file-tree" class="col-span-1 pr-2 md:border-r md:border-gray-200 dark:md:border-gray-700">
-
{{ $containerstyle := "py-1" }}
-
{{ $linkstyle := "no-underline hover:underline dark:text-white" }}
+
<div
+
id="file-tree"
+
class="col-span-1 pr-2 md:border-r md:border-gray-200 dark:md:border-gray-700"
+
>
+
{{ $containerstyle := "py-1" }}
+
{{ $linkstyle := "no-underline hover:underline dark:text-white" }}
-
{{ range .Files }}
-
{{ if not .IsFile }}
-
<div class="{{ $containerstyle }}">
-
<div class="flex justify-between items-center">
-
<a
-
href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref | urlquery }}/{{ .Name }}"
-
class="{{ $linkstyle }}"
-
>
-
<div class="flex items-center gap-2">
-
{{ i "folder" "w-3 h-3 fill-current" }}
-
{{ .Name }}
-
</div>
-
</a>
+
{{ range .Files }}
+
{{ if not .IsFile }}
+
<div class="{{ $containerstyle }}">
+
<div class="flex justify-between items-center">
+
<a
+
href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref | urlquery }}/{{ .Name }}"
+
class="{{ $linkstyle }}"
+
>
+
<div class="flex items-center gap-2">
+
{{ i "folder" "w-3 h-3 fill-current" }}
+
{{ .Name }}
+
</div>
+
</a>
-
<time class="text-xs text-gray-500 dark:text-gray-400"
-
>{{ timeFmt .LastCommit.When }}</time
-
>
+
<time class="text-xs text-gray-500 dark:text-gray-400"
+
>{{ timeFmt .LastCommit.When }}</time
+
>
+
</div>
</div>
-
</div>
+
{{ end }}
{{ end }}
-
{{ end }}
-
{{ range .Files }}
-
{{ if .IsFile }}
-
<div class="{{ $containerstyle }}">
-
<div class="flex justify-between items-center">
-
<a
-
href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref | urlquery }}/{{ .Name }}"
-
class="{{ $linkstyle }}"
-
>
-
<div class="flex items-center gap-2">
-
{{ i "file" "w-3 h-3" }}{{ .Name }}
-
</div>
-
</a>
+
{{ range .Files }}
+
{{ if .IsFile }}
+
<div class="{{ $containerstyle }}">
+
<div class="flex justify-between items-center">
+
<a
+
href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref | urlquery }}/{{ .Name }}"
+
class="{{ $linkstyle }}"
+
>
+
<div class="flex items-center gap-2">
+
{{ i "file" "w-3 h-3" }}{{ .Name }}
+
</div>
+
</a>
-
<time class="text-xs text-gray-500 dark:text-gray-400"
-
>{{ timeFmt .LastCommit.When }}</time
-
>
+
<time class="text-xs text-gray-500 dark:text-gray-400"
+
>{{ timeFmt .LastCommit.When }}</time
+
>
+
</div>
</div>
-
</div>
+
{{ end }}
{{ end }}
-
{{ end }}
-
</div>
+
</div>
{{ end }}
-
{{ define "commitLog" }}
-
<div id="commit-log" class="hidden md:block md:col-span-1">
-
{{ range .Commits }}
-
<div class="relative px-2 pb-8">
-
<div id="commit-message">
-
{{ $messageParts := splitN .Message "\n\n" 2 }}
-
<div class="text-base cursor-pointer">
-
<div>
-
<div>
-
<a
-
href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
-
class="inline no-underline hover:underline dark:text-white"
-
>{{ index $messageParts 0 }}</a
-
>
-
{{ if gt (len $messageParts) 1 }}
+
<div id="commit-log" class="hidden md:block md:col-span-1">
+
{{ range .Commits }}
+
<div class="relative px-2 pb-8">
+
<div id="commit-message">
+
{{ $messageParts := splitN .Message "\n\n" 2 }}
+
<div class="text-base cursor-pointer">
+
<div>
+
<div>
+
<a
+
href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
+
class="inline no-underline hover:underline dark:text-white"
+
>{{ index $messageParts 0 }}</a
+
>
+
{{ if gt (len $messageParts) 1 }}
-
<button
-
class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600"
-
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"
-
>
-
{{ i "ellipsis" "w-3 h-3" }}
-
</button>
-
{{ end }}
-
</div>
-
{{ if gt (len $messageParts) 1 }}
-
<p
-
class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"
-
>
-
{{ nl2br (index $messageParts 1) }}
-
</p>
-
{{ end }}
-
</div>
-
</div>
-
</div>
+
<button
+
class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600"
+
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')"
+
>
+
{{ i "ellipsis" "w-3 h-3" }}
+
</button>
+
{{ end }}
+
</div>
+
{{ if gt (len $messageParts) 1 }}
+
<p
+
class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300"
+
>
+
{{ nl2br (index $messageParts 1) }}
+
</p>
+
{{ end }}
+
</div>
+
</div>
+
</div>
-
<div class="text-xs text-gray-500 dark:text-gray-400">
-
<span class="font-mono">
-
<a
-
href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
-
class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
-
>{{ slice .Hash.String 0 8 }}</a
-
>
-
</span>
-
<span
-
class="mx-2 before:content-['·'] before:select-none"
-
></span>
-
<span>
-
{{ $didOrHandle := index $.EmailToDidOrHandle .Author.Email }}
-
<a
-
href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ .Author.Email }}{{ end }}"
-
class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
-
>{{ if $didOrHandle }}{{ $didOrHandle }}{{ else }}{{ .Author.Name }}{{ end }}</a
-
>
-
</span>
-
<div
-
class="inline-block px-1 select-none after:content-['·']"
-
></div>
-
<span>{{ timeFmt .Author.When }}</span>
-
{{ $tagsForCommit := index $.TagMap .Hash.String }}
-
{{ if gt (len $tagsForCommit) 0 }}
+
<div class="text-xs text-gray-500 dark:text-gray-400">
+
<span class="font-mono">
+
<a
+
href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}"
+
class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
+
>{{ slice .Hash.String 0 8 }}</a
+
>
+
</span>
+
<span
+
class="mx-2 before:content-['·'] before:select-none"
+
></span>
+
<span>
+
{{ $didOrHandle := index $.EmailToDidOrHandle .Author.Email }}
+
<a
+
href="{{ if $didOrHandle }}
+
/{{ $didOrHandle }}
+
{{ else }}
+
mailto:{{ .Author.Email }}
+
{{ end }}"
+
class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
+
>{{ if $didOrHandle }}
+
{{ $didOrHandle }}
+
{{ else }}
+
{{ .Author.Name }}
+
{{ end }}</a
+
>
+
</span>
<div
class="inline-block px-1 select-none after:content-['·']"
></div>
-
{{ end }}
-
{{ range $tagsForCommit }}
-
<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">
-
{{ . }}
-
</span>
-
{{ end }}
-
</div>
-
</div>
-
{{ end }}
-
</div>
+
<span>{{ timeFmt .Author.When }}</span>
+
{{ $tagsForCommit := index $.TagMap .Hash.String }}
+
{{ if gt (len $tagsForCommit) 0 }}
+
<div
+
class="inline-block px-1 select-none after:content-['·']"
+
></div>
+
{{ end }}
+
{{ range $tagsForCommit }}
+
<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"
+
>
+
{{ . }}
+
</span>
+
{{ end }}
+
</div>
+
</div>
+
{{ end }}
+
</div>
{{ end }}
-
{{ define "repoAfter" }}
{{- if .HTMLReadme }}
-
<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 }}">
-
<article class="{{ if .Raw }}whitespace-pre{{end}}">
-
{{ if .Raw }}
-
<pre class="dark:bg-gray-900 dark:text-gray-200 dark:border dark:border-gray-700 dark:p-4 dark:rounded">{{ .HTMLReadme }}</pre>
-
{{ else }}
-
{{ .HTMLReadme }}
-
{{ end }}
-
</article>
-
</section>
+
<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 }}"
+
>
+
<article class="{{ if .Raw }}whitespace-pre{{ end }}">
+
{{ if .Raw }}
+
<pre
+
class="dark:bg-gray-900 dark:text-gray-200 dark:border dark:border-gray-700 dark:p-4 dark:rounded"
+
>
+
{{ .HTMLReadme }}</pre
+
>
+
{{ else }}
+
{{ .HTMLReadme }}
+
{{ end }}
+
</article>
+
</section>
{{- end -}}
-
{{ template "fragments/cloneInstructions" . }}
+
{{ template "repo/fragments/cloneInstructions" . }}
{{ end }}
+1 -1
appview/pages/templates/repo/issues/issue.html
···
{{ if gt $index 0 }}
<div class="absolute left-8 -top-2 w-px h-2 bg-gray-300 dark:bg-gray-600"></div>
{{ end }}
-
{{ template "fragments/issueComment" (dict "RepoInfo" $.RepoInfo "LoggedInUser" $.LoggedInUser "DidHandleMap" $.DidHandleMap "Issue" $.Issue "Comment" .)}}
+
{{ template "repo/issues/fragments/issueComment" (dict "RepoInfo" $.RepoInfo "LoggedInUser" $.LoggedInUser "DidHandleMap" $.DidHandleMap "Issue" $.Issue "Comment" .)}}
</div>
{{ end }}
</section>
+1 -1
appview/pages/templates/repo/pulls/new.html
···
</nav>
<section id="patch-strategy">
-
{{ template "fragments/pullPatchUpload" . }}
+
{{ template "repo/pulls/fragments/pullPatchUpload" . }}
</section>
<div class="flex justify-start items-center gap-2 mt-4">
+1 -1
appview/pages/templates/repo/pulls/patch.html
···
</div>
<section>
-
{{ template "fragments/diff" (list .RepoInfo.FullName .Diff) }}
+
{{ template "repo/fragments/diff" (list .RepoInfo.FullName .Diff) }}
</section>
{{ end }}
+1 -1
appview/pages/templates/repo/pulls/pull.html
···
{{ end }}
{{ if $.LoggedInUser }}
-
{{ template "fragments/pullActions" (dict "LoggedInUser" $.LoggedInUser "Pull" $.Pull "RepoInfo" $.RepoInfo "RoundNumber" .RoundNumber "MergeCheck" $.MergeCheck "ResubmitCheck" $.ResubmitCheck) }}
+
{{ template "repo/pulls/fragments/pullActions" (dict "LoggedInUser" $.LoggedInUser "Pull" $.Pull "RepoInfo" $.RepoInfo "RoundNumber" .RoundNumber "MergeCheck" $.MergeCheck "ResubmitCheck" $.ResubmitCheck) }}
{{ else }}
<div class="bg-white dark:bg-gray-800 rounded drop-shadow-sm px-6 py-4 w-fit dark:text-white">
<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
···
</div>
{{ if ne .FollowStatus.String "IsSelf" }}
-
{{ template "fragments/follow" . }}
+
{{ template "user/fragments/follow" . }}
{{ end }}
</div>
{{ end }}