all repos — elgit @ a87f88a57c68627a1f63f1551fcef2c1f1ec7036

fork of legit: web frontend for git, written in go

routes: add raw file view

commit

a87f88a57c68627a1f63f1551fcef2c1f1ec7036

parent

bdfc973207a67a3b217c130520d53373d088763c

1 file changed, 11 insertions(+), 1 deletion(-)

changed files
M routes/routes.goroutes/routes.go
@@ -8,6 +8,7 @@ "net/http"
"os" "path/filepath" "sort" + "strconv" "time" "git.icyphox.sh/legit/config"
@@ -199,6 +200,11 @@ return
} func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) { + var raw bool + if rawParam, err := strconv.ParseBool(r.URL.Query().Get("raw")); err == nil { + raw = rawParam + } + name := flow.Param(r.Context(), "name") if d.isIgnored(name) { d.Write404(w)
@@ -222,7 +228,11 @@ data["ref"] = ref
data["desc"] = getDescription(path) data["path"] = treePath - d.showFile(contents, data, w) + if raw { + d.showRaw(contents, w) + } else { + d.showFile(contents, data, w) + } return }