aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-31 00:35:29 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-31 00:35:29 +0800
commit1d36ef43c2d6c2f9b106821ac04552d359f47116 (patch)
tree561ebf98fde70403ba8416aa9fc15a46b928fe9f
parentmandoc in Makefile and forge.5 (diff)
downloadforge-1d36ef43c2d6c2f9b106821ac04552d359f47116.tar.gz
forge-1d36ef43c2d6c2f9b106821ac04552d359f47116.tar.zst
forge-1d36ef43c2d6c2f9b106821ac04552d359f47116.zip
Use ref_query for ?branch=x, etc
-rw-r--r--templates/_ref_query.tmpl3
-rw-r--r--templates/repo_index.tmpl9
-rw-r--r--templates/repo_raw_dir.tmpl5
-rw-r--r--templates/repo_tree_dir.tmpl5
-rw-r--r--templates/repo_tree_file.tmpl3
5 files changed, 14 insertions, 11 deletions
diff --git a/templates/_ref_query.tmpl b/templates/_ref_query.tmpl
new file mode 100644
index 0000000..2f78955
--- /dev/null
+++ b/templates/_ref_query.tmpl
@@ -0,0 +1,3 @@
+{{- define "ref_query" -}}
+{{- if .ref_type -}}?{{- .ref_type -}}={{- .ref_name -}}{{- end -}}
+{{- end -}}
diff --git a/templates/repo_index.tmpl b/templates/repo_index.tmpl
index 767e0c8..6db5b05 100644
--- a/templates/repo_index.tmpl
+++ b/templates/repo_index.tmpl
@@ -3,6 +3,7 @@
SPDX-FileContributor: Runxi Yu <https://runxiyu.org>
*/}}
{{- define "repo_index" -}}
+{{- $root := . -}}
<!DOCTYPE html>
<html lang="en">
<head>
@@ -14,13 +15,13 @@
<div class="padding-wrapper">
<ul class="nav-tabs-standalone">
<li class="nav-item active">
- <a class="nav-link" href="./">Summary</a>
+ <a class="nav-link" href="./{{- template "ref_query" $root -}}">Summary</a>
</li>
<li class="nav-item">
- <a class="nav-link" href="tree/">Tree</a>
+ <a class="nav-link" href="tree/{{- template "ref_query" $root -}}">Tree</a>
</li>
<li class="nav-item">
- <a class="nav-link" href="log/">Log</a>
+ <a class="nav-link" href="log/{{- template "ref_query" $root -}}">Log</a>
</li>
<li class="nav-item">
<a class="nav-link" href="branches/">Branches</a>
@@ -84,7 +85,7 @@
<table id="recent-commits" class="wide">
<thead>
<tr class="title-row">
- <th colspan="3">Recent commits (<a href="log/{{- if .ref_type -}}?{{- .ref_type -}}={{- .ref_name -}}{{- end -}}">see all</a>)</th>
+ <th colspan="3">Recent commits (<a href="log/{{- template "ref_query" $root -}}">see all</a>)</th>
</tr>
<tr>
<th scope="col">Title</th>
diff --git a/templates/repo_raw_dir.tmpl b/templates/repo_raw_dir.tmpl
index eef5b7e..fdeb016 100644
--- a/templates/repo_raw_dir.tmpl
+++ b/templates/repo_raw_dir.tmpl
@@ -3,6 +3,7 @@
SPDX-FileContributor: Runxi Yu <https://runxiyu.org>
*/}}
{{- define "repo_raw_dir" -}}
+{{- $root := . -}}
<!DOCTYPE html>
<html lang="en">
<head>
@@ -27,12 +28,10 @@
</thead>
<tbody>
{{- $path_spec := .path_spec -}}
- {{- $ref := .ref_name -}}
- {{- $ref_type := .ref_type -}}
{{- range .files -}}
<tr>
<td class="file-mode">{{- .Mode -}}</td>
- <td class="file-name"><a href="{{- .Name -}}{{- if not .IsFile -}}/{{- end -}}{{- if $ref_type -}}?{{- $ref_type -}}={{- $ref -}}{{- end -}}">{{- .Name -}}</a>{{- if not .IsFile -}}/{{- end -}}</td>
+ <td class="file-name"><a href="{{- .Name -}}{{- if not .IsFile -}}/{{- end -}}{{- template "ref_query" $root -}}">{{- .Name -}}</a>{{- if not .IsFile -}}/{{- end -}}</td>
<td class="file-size">{{- .Size -}}</td>
</tr>
{{- end -}}
diff --git a/templates/repo_tree_dir.tmpl b/templates/repo_tree_dir.tmpl
index f3701d8..40bbf54 100644
--- a/templates/repo_tree_dir.tmpl
+++ b/templates/repo_tree_dir.tmpl
@@ -3,6 +3,7 @@
SPDX-FileContributor: Runxi Yu <https://runxiyu.org>
*/}}
{{- define "repo_tree_dir" -}}
+{{ $root := . }}
<!DOCTYPE html>
<html lang="en">
<head>
@@ -27,12 +28,10 @@
</thead>
<tbody>
{{- $path_spec := .path_spec -}}
- {{- $ref := .ref_name -}}
- {{- $ref_type := .ref_type -}}
{{- range .files -}}
<tr>
<td class="file-mode">{{- .Mode -}}</td>
- <td class="file-name"><a href="{{- .Name -}}{{- if not .IsFile -}}/{{- end -}}{{- if $ref_type -}}?{{- $ref_type -}}={{- $ref -}}{{- end -}}">{{- .Name -}}</a>{{- if not .IsFile -}}/{{- end -}}</td>
+ <td class="file-name"><a href="{{- .Name -}}{{- if not .IsFile -}}/{{- end -}}{{- template "ref_query" $root -}}">{{- .Name -}}</a>{{- if not .IsFile -}}/{{- end -}}</td>
<td class="file-size">{{- .Size -}}</td>
</tr>
{{- end -}}
diff --git a/templates/repo_tree_file.tmpl b/templates/repo_tree_file.tmpl
index b0ce0f1..037a5af 100644
--- a/templates/repo_tree_file.tmpl
+++ b/templates/repo_tree_file.tmpl
@@ -3,6 +3,7 @@
SPDX-FileContributor: Runxi Yu <https://runxiyu.org>
*/}}
{{- define "repo_tree_file" -}}
+{{- $root := . -}}
<!DOCTYPE html>
<html lang="en">
<head>
@@ -14,7 +15,7 @@
{{- template "header" . -}}
<div class="padding">
<p>
- /{{ .path_spec }} (<a href="/{{ template "group_path_plain" .group_path }}/:/repos/{{ .repo_name }}/raw/{{ .path_spec }}{{ if .ref_type }}?{{ .ref_type }}={{ .ref_name }}{{ end }}">raw</a>)
+ /{{ .path_spec }} (<a href="/{{ template "group_path_plain" .group_path }}/:/repos/{{ .repo_name }}/raw/{{ .path_spec }}{{- template "ref_query" $root -}}">raw</a>)
</p>
{{- .file_contents -}}
</div>