git-preview @ main

static git web frontend but with images and html previews + code truncation

routes, templates: tree and log views
Sun, 11 Dec 2022
6 files changed, 110 insertions(+), 37 deletions(-)
M routes/handler.go

@@ -11,5 +11,6 @@ d := deps{c}

mux.HandleFunc("/:name", d.RepoIndex, "GET") mux.HandleFunc("/:name/tree/:ref/...", d.RepoTree, "GET") mux.HandleFunc("/:name/blob/:ref/...", d.FileContent, "GET") + mux.HandleFunc("/:name/log/:ref", d.Log, "GET") return mux }
M routes/routes.go

@@ -1,13 +1,12 @@

package routes import ( + "html/template" "log" "net/http" "path/filepath" "github.com/alexedwards/flow" - gogit "github.com/go-git/go-git/v5"

… preview truncated

M routes/template.go

@@ -24,31 +24,29 @@ t := template.Must(template.ParseFiles(tpath))

t.Execute(w, nil) } -func (d *deps) listFiles(files []git.NiceTree, w http.ResponseWriter) { +func (d *deps) listFiles(files []git.NiceTree, data map[string]any, w http.ResponseWriter) { tpath := filepath.Join(d.c.Template.Dir, "*") t := template.Must(template.ParseGlob(tpath)) - data := make(map[string]interface{}) data["files"] = files

… preview truncated

… and 3 more changed files not shown in this preview