diff options
author | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-11 21:17:04 +0530 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-11 21:17:04 +0530 |
commit | ce71721c6dc80db8af63f2098a1548308e2621b2 (patch) | |
tree | 80a4083382113b095de03f9c5d9032591f4ea439 /routes/template.go | |
parent | e0f34796a37666058dce61277bc546add707fb2e (diff) | |
download | legit-ce71721c6dc80db8af63f2098a1548308e2621b2.tar.gz legit-ce71721c6dc80db8af63f2098a1548308e2621b2.tar.bz2 legit-ce71721c6dc80db8af63f2098a1548308e2621b2.zip |
routes, templates: tree and log views
Diffstat (limited to '')
-rw-r--r-- | routes/template.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/routes/template.go b/routes/template.go index 5595f6e..55a0d17 100644 --- a/routes/template.go +++ b/routes/template.go @@ -24,31 +24,29 @@ func Write500(w http.ResponseWriter, c config.Config) { 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 data["meta"] = d.c.Meta if err := t.ExecuteTemplate(w, "repo", data); err != nil { - Write500(w, *d.c) log.Println(err) return } } -func (d *deps) showFile(content string, w http.ResponseWriter) { +func (d *deps) showFile(content string, 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{}) + // TODO: Process content here. + data["content"] = content data["meta"] = d.c.Meta if err := t.ExecuteTemplate(w, "file", data); err != nil { - Write500(w, *d.c) log.Println(err) return } |