Monorepo for Tangled tangled.org

improve repo-index

Changed files
+81 -24
appview
pages
templates
knotserver
types
+2
appview/pages/pages.go
··· 11 11 "path" 12 12 "strings" 13 13 14 + "github.com/dustin/go-humanize" 14 15 "github.com/sotangled/tangled/appview/auth" 15 16 "github.com/sotangled/tangled/appview/db" 16 17 "github.com/sotangled/tangled/types" ··· 48 49 } 49 50 return pairs, nil 50 51 }, 52 + "timeFmt": humanize.Time, 51 53 } 52 54 } 53 55
+11 -9
appview/pages/templates/layouts/repobase.html
··· 1 1 {{ define "title" }}{{ .RepoInfo.FullName }}{{ end }} 2 2 3 3 {{ define "content" }} 4 - 5 - <section id="repo-header"> 6 - <h1>{{ .RepoInfo.FullName }}</h1> 7 - {{ if .RepoInfo.Description }} 8 - <h3 class="desc">{{ .RepoInfo.Description }}</h3> 9 - {{ else }} 10 - <em>this repo has no description</em> 11 - {{ end }} 4 + <section id="repo-header" class="mb-4"> 5 + <span class="text-xl">{{ .RepoInfo.FullName }}</span> 6 + <br/> 7 + <span> 8 + {{ if .RepoInfo.Description }} 9 + {{ .RepoInfo.Description }} 10 + {{ else }} 11 + <span class="italic">this repo has no description</span> 12 + {{ end }} 13 + </span> 12 14 </section> 13 15 <section id="repo-links" class="min-h-screen flex flex-col"> 14 16 <nav class="w-full mx-auto"> ··· 24 26 hx-boost="true" 25 27 > 26 28 <div 27 - class="px-4 py-2 mr-1 text-black min-w-[80px] text-center text-sm relative group-hover:bg-gray-50 29 + class="px-4 py-2 mr-1 text-black min-w-[80px] text-center relative group-hover:bg-gray-200 28 30 {{ if eq $.Active $key }}{{ $activeTabStyles }}{{ end }}" 29 31 > 30 32 {{ $key }}
+1 -1
appview/pages/templates/layouts/topbar.html
··· 1 1 {{ define "layouts/topbar" }} 2 2 {{ with .LoggedInUser }} 3 - <nav class="flex items-center justify-center space-x-4 py-10"> 3 + <nav class="flex items-center justify-center space-x-4 text-sm mb-4"> 4 4 <a 5 5 href="/" 6 6 hx-boost="true"
+54 -10
appview/pages/templates/repo/index.html
··· 4 4 {{- if .IsEmpty }} 5 5 this repo is empty 6 6 {{ else }} 7 - <div class="log"> 8 - {{ range .Commits }} 9 - <div> 10 - <div><a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" class="commit-hash">{{ slice .Hash.String 0 8 }}</a></div> 11 - <pre>{{ .Message }}</pre> 7 + <div class="flex gap-4"> 8 + <div id="file-tree" class="w-2/3"> 9 + {{ $containerstyle := "py-1" }} 10 + {{ $linkstyle := "no-underline hover:underline" }} 11 + 12 + {{ range .Files }} 13 + {{ if not .IsFile }} 14 + <div class="{{ $containerstyle }}"> 15 + <a href="/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}/{{ .Name }}" class="{{ $linkstyle }}">{{ .Name }}/</a> 16 + </div> 17 + {{ end }} 18 + {{ end }} 19 + 20 + {{ range .Files }} 21 + {{ if .IsFile }} 22 + <div class="{{ $containerstyle }}"> 23 + <a href="/{{ $.RepoInfo.FullName }}/blob/{{ $.Ref }}/{{ .Name }}" class="{{ $linkstyle }}">{{ .Name }}</a> 24 + </div> 25 + {{ end }} 26 + {{ end }} 12 27 </div> 13 - <div class="commit-info"> 14 - {{ .Author.Name }} <a href="mailto:{{ .Author.Email }}" class="commit-email">{{ .Author.Email }}</a> 15 - <div>{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div> 28 + <div id="file-tree" class="flex-1"> 29 + {{ range .Commits }} 30 + <div class= 31 + "relative 32 + px-4 33 + py-4 34 + border-l 35 + border-black 36 + before:content-[''] 37 + before:absolute 38 + before:w-1 39 + before:h-1 40 + before:bg-black 41 + before:rounded-full 42 + before:left-[-2.2px] 43 + before:top-1/2 44 + before:-translate-y-1/2 45 + "> 46 + <div class="text-base">{{ .Message }}</div> 47 + 48 + <div class="text-xs text-gray-500"> 49 + <span class="font-mono"> 50 + <a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" class="text-gray-500 no-underline hover:underline">{{ slice .Hash.String 0 8 }}</a> 51 + </span> 52 + &nbsp;·&nbsp; 53 + <span> 54 + <a href="mailto:{{ .Author.Email }}" class="text-gray-500 no-underline hover:underline">{{ .Author.Name }}</a> 55 + </span> 56 + &nbsp;·&nbsp; 57 + <span>{{ timeFmt .Author.When }}</span> 58 + </div> 59 + 60 + </div> 61 + {{ end }} 16 62 </div> 17 - <hr /> 18 - {{ end }} 19 63 </div> 20 64 {{- if .Readme }} 21 65 <article class="readme">
+1 -1
flake.nix
··· 106 106 pkgs.writeShellScriptBin "run" 107 107 '' 108 108 ${pkgs.air}/bin/air -c /dev/null \ 109 - -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" \ 109 + -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" \ 110 110 -build.bin "./out/${name}.out" \ 111 111 -build.include_ext "go,html,css" 112 112 '';
+1
go.mod
··· 37 37 github.com/cloudflare/circl v1.4.0 // indirect 38 38 github.com/cyphar/filepath-securejoin v0.3.3 // indirect 39 39 github.com/davecgh/go-spew v1.1.1 // indirect 40 + github.com/dustin/go-humanize v1.0.1 // indirect 40 41 github.com/emirpasic/gods v1.18.1 // indirect 41 42 github.com/felixge/httpsnoop v1.0.4 // indirect 42 43 github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
+2
go.sum
··· 50 50 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 51 51 github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 52 52 github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 53 + github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= 54 + github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= 53 55 github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= 54 56 github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= 55 57 github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
+1 -1
input.css
··· 16 16 } 17 17 18 18 ::selection { 19 - @apply bg-green-400; 19 + @apply bg-yellow-400; 20 20 @apply text-black; 21 21 @apply bg-opacity-30; 22 22 }
+7 -2
knotserver/routes.go
··· 87 87 return 88 88 } 89 89 90 - if len(commits) >= 3 { 91 - commits = commits[:3] 90 + files, err := gr.FileTree("") 91 + if err != nil { 92 + writeError(w, err.Error(), http.StatusInternalServerError) 93 + l.Error("file tree", "error", err.Error()) 94 + return 92 95 } 96 + 93 97 resp := types.RepoIndexResponse{ 94 98 IsEmpty: false, 95 99 Ref: mainBranch, 96 100 Commits: commits, 97 101 Description: getDescription(path), 98 102 Readme: readmeContent, 103 + Files: files, 99 104 } 100 105 101 106 writeJSON(w, resp)
+1
types/repo.go
··· 12 12 Readme template.HTML `json:"readme,omitempty"` 13 13 Commits []*object.Commit `json:"commits,omitempty"` 14 14 Description string `json:"description,omitempty"` 15 + Files []NiceTree `json:"files,omitempty"` 15 16 } 16 17 17 18 type RepoLogResponse struct {