improve repo-index
MODIFIED
appview/pages/pages.go
MODIFIED
appview/pages/pages.go
@@ -11,6 +11,7 @@ "net/http""path""strings"+ "github.com/dustin/go-humanize""github.com/sotangled/tangled/appview/auth""github.com/sotangled/tangled/appview/db""github.com/sotangled/tangled/types"@@ -48,6 +49,7 @@ pairs = append(pairs, []string{values[i], values[i+1]})}return pairs, nil},+ "timeFmt": humanize.Time,}}
@@ -1,14 +1,16 @@{{ 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">@@ -24,7 +26,7 @@ class="relative -mr-px group no-underline"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,6 +1,6 @@{{ 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"><ahref="/"hx-boost="true"
@@ -4,18 +4,62 @@ <main>{{- 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>+ · + <span>+ <a href="mailto:{{ .Author.Email }}" class="text-gray-500 no-underline hover:underline">{{ .Author.Name }}</a>+ </span>+ · + <span>{{ timeFmt .Author.When }}</span>+ </div>++ </div>+ {{ end }}</div>- <hr />- {{ end }}</div>{{- if .Readme }}<article class="readme">
MODIFIED
flake.nix
MODIFIED
flake.nix
@@ -106,7 +106,7 @@ air-watcher = name: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"'';
MODIFIED
go.mod
MODIFIED
go.mod
@@ -37,6 +37,7 @@ github.com/cespare/xxhash/v2 v2.3.0 // indirectgithub.com/cloudflare/circl v1.4.0 // indirectgithub.com/cyphar/filepath-securejoin v0.3.3 // indirectgithub.com/davecgh/go-spew v1.1.1 // indirect+ github.com/dustin/go-humanize v1.0.1 // indirectgithub.com/emirpasic/gods v1.18.1 // indirectgithub.com/felixge/httpsnoop v1.0.4 // indirectgithub.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
MODIFIED
go.sum
MODIFIED
go.sum
@@ -50,6 +50,8 @@ github.com/cyphar/filepath-securejoin v0.3.3/go.mod h1:8s/MCNJREmFK0H02MF6Ihv1nakJe4L/w3WZLHNkvlYM=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=
MODIFIED
input.css
MODIFIED
input.css
@@ -16,7 +16,7 @@ @apply py-4;}::selection {- @apply bg-green-400;+ @apply bg-yellow-400;@apply text-black;@apply bg-opacity-30;}
MODIFIED
knotserver/routes.go
MODIFIED
knotserver/routes.go
@@ -87,15 +87,20 @@ l.Error("finding main branch", "error", err.Error())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)
MODIFIED
types/repo.go
MODIFIED
types/repo.go
@@ -12,6 +12,7 @@ Ref string `json:"ref,omitempty"`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 {