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

improve repo-index

Changed files
+81 -24
appview
pages
templates
knotserver
types
+2
appview/pages/pages.go
···
"path"
"strings"
+
"github.com/dustin/go-humanize"
"github.com/sotangled/tangled/appview/auth"
"github.com/sotangled/tangled/appview/db"
"github.com/sotangled/tangled/types"
···
}
return pairs, nil
},
+
"timeFmt": humanize.Time,
}
}
+11 -9
appview/pages/templates/layouts/repobase.html
···
{{ define "title" }}{{ .RepoInfo.FullName }}{{ end }}
{{ define "content" }}
-
-
<section id="repo-header">
-
<h1>{{ .RepoInfo.FullName }}</h1>
-
{{ if .RepoInfo.Description }}
-
<h3 class="desc">{{ .RepoInfo.Description }}</h3>
-
{{ else }}
-
<em>this repo has no description</em>
-
{{ end }}
+
<section id="repo-header" class="mb-4">
+
<span class="text-xl">{{ .RepoInfo.FullName }}</span>
+
<br/>
+
<span>
+
{{ if .RepoInfo.Description }}
+
{{ .RepoInfo.Description }}
+
{{ else }}
+
<span class="italic">this repo has no description</span>
+
{{ end }}
+
</span>
</section>
<section id="repo-links" class="min-h-screen flex flex-col">
<nav class="w-full mx-auto">
···
hx-boost="true"
>
<div
-
class="px-4 py-2 mr-1 text-black min-w-[80px] text-center text-sm relative group-hover:bg-gray-50
+
class="px-4 py-2 mr-1 text-black min-w-[80px] text-center relative group-hover:bg-gray-200
{{ if eq $.Active $key }}{{ $activeTabStyles }}{{ end }}"
>
{{ $key }}
+1 -1
appview/pages/templates/layouts/topbar.html
···
{{ define "layouts/topbar" }}
{{ with .LoggedInUser }}
-
<nav class="flex items-center justify-center space-x-4 py-10">
+
<nav class="flex items-center justify-center space-x-4 text-sm mb-4">
<a
href="/"
hx-boost="true"
+54 -10
appview/pages/templates/repo/index.html
···
{{- if .IsEmpty }}
this repo is empty
{{ else }}
-
<div class="log">
-
{{ range .Commits }}
-
<div>
-
<div><a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" class="commit-hash">{{ slice .Hash.String 0 8 }}</a></div>
-
<pre>{{ .Message }}</pre>
+
<div class="flex gap-4">
+
<div id="file-tree" class="w-2/3">
+
{{ $containerstyle := "py-1" }}
+
{{ $linkstyle := "no-underline hover:underline" }}
+
+
{{ range .Files }}
+
{{ if not .IsFile }}
+
<div class="{{ $containerstyle }}">
+
<a href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}" class="{{ $linkstyle }}">{{ .Name }}/</a>
+
</div>
+
{{ end }}
+
{{ end }}
+
+
{{ range .Files }}
+
{{ if .IsFile }}
+
<div class="{{ $containerstyle }}">
+
<a href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref }}/{{ .Name }}" class="{{ $linkstyle }}">{{ .Name }}</a>
+
</div>
+
{{ end }}
+
{{ end }}
</div>
-
<div class="commit-info">
-
{{ .Author.Name }} <a href="mailto:{{ .Author.Email }}" class="commit-email">{{ .Author.Email }}</a>
-
<div>{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
+
<div id="file-tree" class="flex-1">
+
{{ range .Commits }}
+
<div class=
+
"relative
+
px-4
+
py-4
+
border-l
+
border-black
+
before:content-['']
+
before:absolute
+
before:w-1
+
before:h-1
+
before:bg-black
+
before:rounded-full
+
before:left-[-2.2px]
+
before:top-1/2
+
before:-translate-y-1/2
+
">
+
<div class="text-base">{{ .Message }}</div>
+
+
<div class="text-xs text-gray-500">
+
<span class="font-mono">
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" class="text-gray-500 no-underline hover:underline">{{ slice .Hash.String 0 8 }}</a>
+
</span>
+
&nbsp;·&nbsp;
+
<span>
+
<a href="mailto:{{ .Author.Email }}" class="text-gray-500 no-underline hover:underline">{{ .Author.Name }}</a>
+
</span>
+
&nbsp;·&nbsp;
+
<span>{{ timeFmt .Author.When }}</span>
+
</div>
+
+
</div>
+
{{ end }}
</div>
-
<hr />
-
{{ end }}
</div>
{{- if .Readme }}
<article class="readme">
+1 -1
flake.nix
···
pkgs.writeShellScriptBin "run"
''
${pkgs.air}/bin/air -c /dev/null \
-
-build.cmd "cp -rf ${htmx-src} appview/pages/static/htmx.min.js && ${pkgs.tailwindcss}/bin/tailwindcss -i input.css -o ./appview/pages/static/tw.css && ${pkgs.go}/bin/go build -o ./out/${name}.out ./cmd/${name}/main.go" \
+
-build.cmd "${pkgs.tailwindcss}/bin/tailwindcss -i input.css -o ./appview/pages/static/tw.css && ${pkgs.go}/bin/go build -o ./out/${name}.out ./cmd/${name}/main.go" \
-build.bin "./out/${name}.out" \
-build.include_ext "go,html,css"
'';
+1
go.mod
···
github.com/cloudflare/circl v1.4.0 // indirect
github.com/cyphar/filepath-securejoin v0.3.3 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
+
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
github.com/felixge/httpsnoop v1.0.4 // indirect
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
+2
go.sum
···
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
+
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=
github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ=
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
+1 -1
input.css
···
}
::selection {
-
@apply bg-green-400;
+
@apply bg-yellow-400;
@apply text-black;
@apply bg-opacity-30;
}
+7 -2
knotserver/routes.go
···
return
}
-
if len(commits) >= 3 {
-
commits = commits[:3]
+
files, err := gr.FileTree("")
+
if err != nil {
+
writeError(w, err.Error(), http.StatusInternalServerError)
+
l.Error("file tree", "error", err.Error())
+
return
}
+
resp := types.RepoIndexResponse{
IsEmpty: false,
Ref: mainBranch,
Commits: commits,
Description: getDescription(path),
Readme: readmeContent,
+
Files: files,
}
writeJSON(w, resp)
+1
types/repo.go
···
Readme template.HTML `json:"readme,omitempty"`
Commits []*object.Commit `json:"commits,omitempty"`
Description string `json:"description,omitempty"`
+
Files []NiceTree `json:"files,omitempty"`
}
type RepoLogResponse struct {