web frontend for git (tangled's grandpa)
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

routes: add raw file view

+19 -2
+11 -1
routes/routes.go
··· 8 8 "os" 9 9 "path/filepath" 10 10 "sort" 11 + "strconv" 11 12 "time" 12 13 13 14 "git.icyphox.sh/legit/config" ··· 199 200 } 200 201 201 202 func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) { 203 + var raw bool 204 + if rawParam, err := strconv.ParseBool(r.URL.Query().Get("raw")); err == nil { 205 + raw = rawParam 206 + } 207 + 202 208 name := flow.Param(r.Context(), "name") 203 209 if d.isIgnored(name) { 204 210 d.Write404(w) ··· 222 228 data["desc"] = getDescription(path) 223 229 data["path"] = treePath 224 230 225 - d.showFile(contents, data, w) 231 + if raw { 232 + d.showRaw(contents, w) 233 + } else { 234 + d.showFile(contents, data, w) 235 + } 226 236 return 227 237 } 228 238
+7
routes/template.go
··· 95 95 return 96 96 } 97 97 } 98 + 99 + func (d *deps) showRaw(content string, w http.ResponseWriter) { 100 + w.WriteHeader(http.StatusOK) 101 + w.Header().Set("Content-Type", "text/plain") 102 + w.Write([]byte(content)) 103 + return 104 + }
+1 -1
templates/file.html
··· 5 5 <body> 6 6 {{ template "nav" . }} 7 7 <main> 8 - <p>{{ .path }}</p> 8 + <p>{{ .path }} (<a style="color: gray" href="?raw=true">view raw</a>)</p> 9 9 <div class="file-wrapper"> 10 10 <table > 11 11 <tbody><tr>