From 8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Thu, 6 Mar 2025 15:17:57 +0800 Subject: *: Support subgroups via SQL recursion --- templates/_group_path.tmpl | 8 +++++++ templates/_group_view.tmpl | 48 +++++++++++++++++++++++++++++++++++++++ templates/group.tmpl | 24 ++++++++++++++++++++ templates/group_repos.tmpl | 40 -------------------------------- templates/index.tmpl | 37 ++++++++++++++---------------- templates/repo_commit.tmpl | 2 +- templates/repo_contrib_index.tmpl | 2 +- templates/repo_contrib_one.tmpl | 2 +- templates/repo_index.tmpl | 2 +- templates/repo_log.tmpl | 2 +- templates/repo_raw_dir.tmpl | 2 +- templates/repo_tree_dir.tmpl | 2 +- templates/repo_tree_file.tmpl | 4 ++-- 13 files changed, 106 insertions(+), 69 deletions(-) create mode 100644 templates/_group_path.tmpl create mode 100644 templates/_group_view.tmpl create mode 100644 templates/group.tmpl delete mode 100644 templates/group_repos.tmpl (limited to 'templates') diff --git a/templates/_group_path.tmpl b/templates/_group_path.tmpl new file mode 100644 index 0000000..f8b5f47 --- /dev/null +++ b/templates/_group_path.tmpl @@ -0,0 +1,8 @@ +{{/* + SPDX-License-Identifier: AGPL-3.0-only + SPDX-FileContributor: Runxi Yu +*/}} +{{- define "group_path_plain" -}} +{{ $p := . }} +{{ range $i, $s := . }}{{ $s }}{{ if ne $i (len $p) }}/{{ end }}{{ end }} +{{ end }} diff --git a/templates/_group_view.tmpl b/templates/_group_view.tmpl new file mode 100644 index 0000000..4783162 --- /dev/null +++ b/templates/_group_view.tmpl @@ -0,0 +1,48 @@ +{{/* + SPDX-License-Identifier: AGPL-3.0-only + SPDX-FileContributor: Runxi Yu +*/}} +{{- define "group_view" -}} +{{ if .subgroups }} + + + + + + + + {{- range .subgroups }} + + + + + {{- end }} + +
Subgroups
+ {{ .Name }} + + {{ .Description }} +
+{{ end }} +{{ if .repos }} + + + + + + + + {{- range .repos }} + + + + + {{- end }} + +
Repos
+ {{ .Name }} + + {{ .Description }} +
+{{ end }} +{{- end -}} diff --git a/templates/group.tmpl b/templates/group.tmpl new file mode 100644 index 0000000..f881458 --- /dev/null +++ b/templates/group.tmpl @@ -0,0 +1,24 @@ +{{/* + SPDX-License-Identifier: AGPL-3.0-only + SPDX-FileContributor: Runxi Yu +*/}} +{{- define "group" -}} +{{ $group_path := .group_path }} + + + + {{ template "head_common" . }} + {{ range $i, $s := .group_path }}{{ $s }}{{ if ne $i (len $group_path) }} / {{ end }}{{ end }} – {{ .global.forge_title }} + + + {{ template "header" . }} +
+

{{ range $i, $s := .group_path }}{{ $s }}{{ if ne $i (len $group_path) }} / {{ end }}{{ end }} + {{ template "group_view" . }} +

+
+ {{ template "footer" . }} +
+ + +{{- end -}} diff --git a/templates/group_repos.tmpl b/templates/group_repos.tmpl deleted file mode 100644 index 3eae4f4..0000000 --- a/templates/group_repos.tmpl +++ /dev/null @@ -1,40 +0,0 @@ -{{/* - SPDX-License-Identifier: AGPL-3.0-only - SPDX-FileContributor: Runxi Yu -*/}} -{{- define "group_repos" -}} - - - - {{ template "head_common" . }} - Repos – {{ .group_name }} – {{ .global.forge_title }} - - - {{ template "header" . }} -
- - - - - - - - {{- range .repos }} - - - - - {{- end }} - -
Repos in {{ .group_name }}
- {{ .Name }} - - {{ .Description }} -
-
-
- {{ template "footer" . }} -
- - -{{- end -}} diff --git a/templates/index.tmpl b/templates/index.tmpl index c3b8bef..2e039a9 100644 --- a/templates/index.tmpl +++ b/templates/index.tmpl @@ -12,28 +12,25 @@ {{ template "header" . }}
- - +
+ + + + + + + {{- range .groups }} - + + - - - {{- range .groups }} - - - - - {{- end }} - -
Groups
- Groups - + {{ .Name }} + + {{ .Description }} +
- {{ .Name }} - - {{ .Description }} -
-
+ {{- end }} + +
diff --git a/templates/repo_commit.tmpl b/templates/repo_commit.tmpl index 1e34604..bdb8c24 100644 --- a/templates/repo_commit.tmpl +++ b/templates/repo_commit.tmpl @@ -7,7 +7,7 @@ {{ template "head_common" . }} - Commit {{ .commit_id }} – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }} + Commit {{ .commit_id }} – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_contrib_index.tmpl b/templates/repo_contrib_index.tmpl index da779f8..512e352 100644 --- a/templates/repo_contrib_index.tmpl +++ b/templates/repo_contrib_index.tmpl @@ -7,7 +7,7 @@ {{ template "head_common" . }} - Merge requests – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }} + Merge requests – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_contrib_one.tmpl b/templates/repo_contrib_one.tmpl index 1083e8c..88bc2fc 100644 --- a/templates/repo_contrib_one.tmpl +++ b/templates/repo_contrib_one.tmpl @@ -7,7 +7,7 @@ {{ template "head_common" . }} - Merge requests – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }} + Merge requests – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_index.tmpl b/templates/repo_index.tmpl index 9dec745..3ce6d33 100644 --- a/templates/repo_index.tmpl +++ b/templates/repo_index.tmpl @@ -7,7 +7,7 @@ {{ template "head_common" . }} - {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }} + {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_log.tmpl b/templates/repo_log.tmpl index 8e33bea..dbe764e 100644 --- a/templates/repo_log.tmpl +++ b/templates/repo_log.tmpl @@ -7,7 +7,7 @@ {{ template "head_common" . }} - Log – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }} + Log – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_raw_dir.tmpl b/templates/repo_raw_dir.tmpl index 47ef69f..07f577a 100644 --- a/templates/repo_raw_dir.tmpl +++ b/templates/repo_raw_dir.tmpl @@ -7,7 +7,7 @@ {{ template "head_common" . }} - /{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }} + /{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_tree_dir.tmpl b/templates/repo_tree_dir.tmpl index e520225..ab9788b 100644 --- a/templates/repo_tree_dir.tmpl +++ b/templates/repo_tree_dir.tmpl @@ -7,7 +7,7 @@ {{ template "head_common" . }} - /{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }} + /{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_tree_file.tmpl b/templates/repo_tree_file.tmpl index d6890b8..333e1dc 100644 --- a/templates/repo_tree_file.tmpl +++ b/templates/repo_tree_file.tmpl @@ -8,13 +8,13 @@ {{ template "head_common" . }} - /{{ .path_spec }} – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }} + /{{ .path_spec }} – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }} {{ template "header" . }}

- /{{ .path_spec }} (raw) + /{{ .path_spec }} (raw)

{{ .file_contents }}
-- cgit v1.2.3