From 9b20ef637095413a8e7bde6701b8ad2379b4e7aa Mon Sep 17 00:00:00 2001 From: Runxi Yu <me@runxiyu.org> Date: Thu, 13 Feb 2025 12:06:36 +0800 Subject: repo_*_{dir,file}: Add ref params if not head --- templates/repo_raw_dir.html.tmpl | 4 +++- templates/repo_tree_dir.html.tmpl | 4 +++- templates/repo_tree_file.html.tmpl | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'templates') diff --git a/templates/repo_raw_dir.html.tmpl b/templates/repo_raw_dir.html.tmpl index a264d24..dc1a5b6 100644 --- a/templates/repo_raw_dir.html.tmpl +++ b/templates/repo_raw_dir.html.tmpl @@ -18,10 +18,12 @@ </thead> <tbody> {{- $path_spec := .path_spec }} + {{- $ref := .ref }} + {{- $ref_type := .ref_type }} {{- range .files }} <tr> <td class="file-mode">{{ .Mode }}</td> - <td class="file-name"><a href="{{ .Name }}{{ if not .Is_file }}/{{ end }}">{{ .Name }}</a>{{ if not .Is_file }}/{{ end }}</td> + <td class="file-name"><a href="{{ .Name }}{{ if not .Is_file }}/{{ end }}{{ if $ref }}?{{ $ref_type }}={{ $ref }}{{ end }}">{{ .Name }}</a>{{ if not .Is_file }}/{{ end }}</td> <td class="file-size">{{ .Size }}</td> </tr> {{- end }} diff --git a/templates/repo_tree_dir.html.tmpl b/templates/repo_tree_dir.html.tmpl index d7fbb10..5e56dc9 100644 --- a/templates/repo_tree_dir.html.tmpl +++ b/templates/repo_tree_dir.html.tmpl @@ -18,10 +18,12 @@ </thead> <tbody> {{- $path_spec := .path_spec }} + {{- $ref := .ref }} + {{- $ref_type := .ref_type }} {{- range .files }} <tr> <td class="file-mode">{{ .Mode }}</td> - <td class="file-name"><a href="{{ .Name }}{{ if not .Is_file }}/{{ end }}">{{ .Name }}</a>{{ if not .Is_file }}/{{ end }}</td> + <td class="file-name"><a href="{{ .Name }}{{ if not .Is_file }}/{{ end }}{{ if $ref }}?{{ $ref_type }}={{ $ref }}{{ end }}">{{ .Name }}</a>{{ if not .Is_file }}/{{ end }}</td> <td class="file-size">{{ .Size }}</td> </tr> {{- end }} diff --git a/templates/repo_tree_file.html.tmpl b/templates/repo_tree_file.html.tmpl index 6931c4e..0bf9164 100644 --- a/templates/repo_tree_file.html.tmpl +++ b/templates/repo_tree_file.html.tmpl @@ -10,7 +10,7 @@ {{ template "header" . }} <div class="padding"> <p> - /{{ .path_spec }} (<a href="/{{ .group_name }}/:/repos/{{ .repo_name }}/raw/{{ .path_spec }}{{ if not (eq .ref_type "head") }}?{{ .ref_type }}={{ .ref }}{{ end }}">raw</a>) + /{{ .path_spec }} (<a href="/{{ .group_name }}/:/repos/{{ .repo_name }}/raw/{{ .path_spec }}{{ if .ref }}?{{ .ref_type }}={{ .ref }}{{ end }}">raw</a>) </p> {{ .file_contents }} </div> -- cgit v1.2.3