Make the repo file browser page full-width
Repo view and single-file view no longer cap out at the usual 980px reading column — the file table and rendered README/LICENSE now use the full viewport width. Every other page (dashboard, settings, admin, etc.) keeps the narrower column, since forms and prose read worse stretched edge to edge.
2 files changed
+17 −5
M
cmd/gitfed-web/handlers_repo.go
+2 −2
M
cmd/gitfed-web/render.go
+15 −3
cmd/gitfed-web/handlers_repo.go
@@ -244,7 +244,7 @@ func (s *server) handleRepoView(w http.ResponseWriter, r *http.Request) {
if path != "" {
title = path + " — " + name
}
- s.render(w, r, title, "home", template.HTML(buf.String()))
+ s.renderWide(w, r, title, "home", template.HTML(buf.String()))
}
var blobTpl = template.Must(template.New("blob").Parse(`
@@ -306,7 +306,7 @@ func (s *server) handleRepoBlob(w http.ResponseWriter, r *http.Request) {
Flash template.HTML
}{name, breadcrumbs(path), rendered, flash(r)})
- s.render(w, r, path+" — "+name, "home", template.HTML(buf.String()))
+ s.renderWide(w, r, path+" — "+name, "home", template.HTML(buf.String()))
}
func renderFileContent(filename, content string) (template.HTML, error) {
cmd/gitfed-web/render.go
@@ -112,6 +112,7 @@ const shellSrc = `<!doctype html>
/* ---------- layout ---------- */
main { padding: 1.5rem 1rem; max-width: 980px; margin: 0 auto; }
+ main.wide { max-width: none; }
section { margin-bottom: 2rem; }
/* ---------- repo page ---------- */
@@ -306,7 +307,7 @@ const shellSrc = `<!doctype html>
</div>
</div>
</header>
-<main>
+<main{{if .Wide}} class="wide"{{end}}>
{{.Body}}
</main>
<footer>
@@ -368,13 +369,24 @@ const shellSrc = `<!doctype html>
var shellTpl = template.Must(template.New("shell").Parse(shellSrc))
func (s *server) render(w http.ResponseWriter, r *http.Request, title, active string, body template.HTML) {
+ s.renderOpt(w, r, title, active, body, false)
+}
+
+// renderWide is render, but the page body isn't capped at the usual
+// reading-width column — for pages like the repo file browser where a
+// narrow column just wastes space on file/README content.
+func (s *server) renderWide(w http.ResponseWriter, r *http.Request, title, active string, body template.HTML) {
+ s.renderOpt(w, r, title, active, body, true)
+}
+
+func (s *server) renderOpt(w http.ResponseWriter, r *http.Request, title, active string, body template.HTML, wide bool) {
sess, loggedIn := s.currentSession(r)
w.Header().Set("Content-Type", "text/html; charset=utf-8")
_ = shellTpl.Execute(w, struct {
Title, Domain, Active, Username, Version, Initials, SearchQuery string
- LoggedIn, IsAdmin bool
+ LoggedIn, IsAdmin, Wide bool
Body, BrandMark template.HTML
- }{title, s.domain, active, sess.Username, version.Version, initials(sess.Username), r.URL.Query().Get("q"), loggedIn, sess.IsAdmin, body, template.HTML(brandMark)})
+ }{title, s.domain, active, sess.Username, version.Version, initials(sess.Username), r.URL.Query().Get("q"), loggedIn, sess.IsAdmin, wide, body, template.HTML(brandMark)})
}
// initials turns a username into a one-or-two-letter avatar label: