From 1f7d760e41016aa9ab6a9cfa78aabc877c88962d Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Thu, 9 Feb 2023 23:30:07 -0700 Subject: [PATCH 1/2] fix title tag and tree .. link --- routes/routes.go | 3 ++- templates/file.html | 2 -- templates/head.html | 20 ++++++++++++++++++++ templates/index.html | 6 ------ templates/log.html | 5 ----- templates/refs.html | 4 ---- templates/repo.html | 5 ----- templates/tree.html | 5 ----- 8 files changed, 22 insertions(+), 28 deletions(-) diff --git a/routes/routes.go b/routes/routes.go index 3c82bdb..f1b1286 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -187,6 +187,7 @@ func (d *deps) RepoTree(w http.ResponseWriter, r *http.Request) { data["ref"] = ref data["parent"] = treePath data["desc"] = getDescription(path) + data["dotdot"] = filepath.Dir(treePath) d.listFiles(files, data, w) return @@ -249,7 +250,7 @@ func (d *deps) Log(w http.ResponseWriter, r *http.Request) { data["name"] = name data["ref"] = ref data["desc"] = getDescription(path) - data["dotdot"] = filepath.Dir(path) + data["log"] = true if err := d.t.ExecuteTemplate(w, "log", data); err != nil { log.Println(err) diff --git a/templates/file.html b/templates/file.html index 208f653..f015974 100644 --- a/templates/file.html +++ b/templates/file.html @@ -1,8 +1,6 @@ {{ define "file" }} {{ template "head" . }} - {{.name }} — {{ .path }} - {{ template "repoheader" . }} {{ template "nav" . }} diff --git a/templates/head.html b/templates/head.html index 53487eb..6fc1761 100644 --- a/templates/head.html +++ b/templates/head.html @@ -5,6 +5,26 @@ + {{ if .parent }} + {{ .meta.Title }} — {{ .name }} ({{ .ref }}): {{ .parent }}/ + + {{ else if .path }} + {{ .meta.Title }} — {{ .name }} ({{ .ref }}): {{ .path }} + {{ else if .files }} + {{ .meta.Title }} — {{ .name }} ({{ .ref }}) + {{ else if .commit }} + {{ .meta.Title }} — {{ .name }}: {{ .commit.This }} + {{ else if .branches }} + {{ .meta.Title }} — {{ .name }}: refs + {{ else if .commits }} + {{ if .log }} + {{ .meta.Title }} — {{ .name }}: log + {{ else }} + {{ .meta.Title }} — {{ .name }} + {{ end }} + {{ else }} + {{ .meta.Title }} + {{ end }} {{ if and .servername .gomod }} {{ end }} diff --git a/templates/index.html b/templates/index.html index ae1109c..163d6a4 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,12 +1,6 @@ {{ define "index" }} {{ template "head" . }} - - - {{ .meta.Title }} - - -

{{ .meta.Title }}

diff --git a/templates/log.html b/templates/log.html index 372518a..9c783aa 100644 --- a/templates/log.html +++ b/templates/log.html @@ -1,11 +1,6 @@ {{ define "log" }} {{ template "head" . }} - - - {{ .name }} — log - - {{ template "repoheader" . }} {{ template "nav" . }} diff --git a/templates/refs.html b/templates/refs.html index 541ef4c..a7f6a9c 100644 --- a/templates/refs.html +++ b/templates/refs.html @@ -2,10 +2,6 @@ {{ template "head" . }} - - {{ .name }} — refs - - {{ template "repoheader" . }} {{ template "nav" . }} diff --git a/templates/repo.html b/templates/repo.html index 99b718f..7401ca4 100644 --- a/templates/repo.html +++ b/templates/repo.html @@ -1,10 +1,5 @@ {{ define "repo" }} - {{ .name }} - {{ if .parent }} - — {{ .parent }} - {{ end }} - {{ template "head" . }} {{ template "repoheader" . }} diff --git a/templates/tree.html b/templates/tree.html index be285c0..c5fb38f 100644 --- a/templates/tree.html +++ b/templates/tree.html @@ -1,10 +1,5 @@ {{ define "tree" }} - {{ .name }} - {{ if .parent }} - — {{ .parent }} - {{ end }} - {{ template "head" . }} {{ template "repoheader" . }} From 94d07ef8b2581e83aa92193d26ea201291fa62c9 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Tue, 21 Feb 2023 21:33:11 -0700 Subject: [PATCH 2/2] fix raw file link in file view --- routes/routes.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/routes.go b/routes/routes.go index f1b1286..b309054 100644 --- a/routes/routes.go +++ b/routes/routes.go @@ -216,7 +216,7 @@ func (d *deps) FileContent(w http.ResponseWriter, r *http.Request) { data["ref"] = ref data["desc"] = getDescription(path) data["path"] = treePath - data["raw"] = fmt.Sprintf("/%s/blob/raw/%s/%s", name, ref, treePath) + data["raw"] = fmt.Sprintf("/%s/raw/%s/%s", name, ref, treePath) d.showFile(contents, data, w) return