diff options
author | Runxi Yu <me@runxiyu.org> | 2025-03-06 15:17:57 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-03-06 20:07:48 +0800 |
commit | 8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0 (patch) | |
tree | a2f33fccac42b554b1176741d00c1d0cd2d0dceb /templates | |
parent | sql: Add purge and test scripts (diff) | |
download | forge-8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0.tar.gz forge-8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0.tar.zst forge-8ed0dbe4201a58b00d6f3743178f4cbe5328e2b0.zip |
*: Support subgroups via SQL recursion
Diffstat (limited to 'templates')
-rw-r--r-- | templates/_group_path.tmpl | 8 | ||||
-rw-r--r-- | templates/_group_view.tmpl | 48 | ||||
-rw-r--r-- | templates/group.tmpl | 24 | ||||
-rw-r--r-- | templates/group_repos.tmpl | 40 | ||||
-rw-r--r-- | templates/index.tmpl | 37 | ||||
-rw-r--r-- | templates/repo_commit.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_contrib_index.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_contrib_one.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_index.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_log.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_raw_dir.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_tree_dir.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_tree_file.tmpl | 4 |
13 files changed, 106 insertions, 69 deletions
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 <https://runxiyu.org> +*/}} +{{- 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 <https://runxiyu.org> +*/}} +{{- define "group_view" -}} +{{ if .subgroups }} + <table class="wide"> + <thead> + <tr> + <th colspan="2" class="title-row">Subgroups</th> + </tr> + </thead> + <tbody> + {{- range .subgroups }} + <tr> + <td> + <a href="{{ .Name }}/">{{ .Name }}</a> + </td> + <td> + {{ .Description }} + </td> + </tr> + {{- end }} + </tbody> + </table> +{{ end }} +{{ if .repos }} +<table class="wide"> + <thead> + <tr> + <th colspan="2" class="title-row">Repos</th> + </tr> + </thead> + <tbody> + {{- range .repos }} + <tr> + <td> + <a href=":/repos/{{ .Name }}/">{{ .Name }}</a> + </td> + <td> + {{ .Description }} + </td> + </tr> + {{- end }} + </tbody> +</table> +{{ 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 <https://runxiyu.org> +*/}} +{{- define "group" -}} +{{ $group_path := .group_path }} +<!DOCTYPE html> +<html lang="en"> + <head> + {{ template "head_common" . }} + <title>{{ range $i, $s := .group_path }}{{ $s }}{{ if ne $i (len $group_path) }} / {{ end }}{{ end }} – {{ .global.forge_title }}</title> + </head> + <body class="group"> + {{ template "header" . }} + <div class="padding-wrapper"> + <p>{{ range $i, $s := .group_path }}{{ $s }}{{ if ne $i (len $group_path) }} / {{ end }}{{ end }} + {{ template "group_view" . }} + </div> + <footer> + {{ template "footer" . }} + </footer> + </body> +</html> +{{- 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 <https://runxiyu.org> -*/}} -{{- define "group_repos" -}} -<!DOCTYPE html> -<html lang="en"> - <head> - {{ template "head_common" . }} - <title>Repos – {{ .group_name }} – {{ .global.forge_title }}</title> - </head> - <body class="group-repos"> - {{ template "header" . }} - <div class="padding-wrapper"> - <table class="wide"> - <thead> - <tr> - <th colspan="2" class="title-row">Repos in {{ .group_name }}</th> - </tr> - </thead> - <tbody> - {{- range .repos }} - <tr> - <td> - <a href="{{ .Name }}/">{{ .Name }}</a> - </td> - <td> - {{ .Description }} - </td> - </tr> - {{- end }} - </tbody> - </table> - </div> - <footer> - {{ template "footer" . }} - </footer> - </body> -</html> -{{- 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 @@ <body class="index"> {{ template "header" . }} <div class="padding-wrapper"> - <table class="wide"> - <thead> + <table class="wide"> + <thead> + <tr> + <th colspan="2" class="title-row">Groups</th> + </tr> + </thead> + <tbody> + {{- range .groups }} <tr> - <th colspan="2" class="title-row"> - Groups - </th> + <td> + <a href="{{ .Name }}/">{{ .Name }}</a> + </td> + <td> + {{ .Description }} + </td> </tr> - </thead> - <tbody> - {{- range .groups }} - <tr> - <td> - <a href="{{ .Name }}/:/repos/">{{ .Name }}</a> - </td> - <td> - {{ .Description }} - </td> - </tr> - {{- end }} - </tbody> - </table> - </div> + {{- end }} + </tbody> + </table> <div class="padding-wrapper"> <table class="wide"> <thead> 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>Commit {{ .commit_id }} – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + <title>Commit {{ .commit_id }} – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }}</title> </head> <body class="repo-commit"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>Merge requests – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + <title>Merge requests – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }}</title> </head> <body class="repo-contrib-index"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>Merge requests – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + <title>Merge requests – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }}</title> </head> <body class="repo-contrib-one"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>{{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + <title>{{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }}</title> </head> <body class="repo-index"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>Log – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + <title>Log – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }}</title> </head> <body class="repo-log"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + <title>/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }}</title> </head> <body class="repo-raw-dir"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + <title>/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }}</title> </head> <body class="repo-tree-dir"> {{ 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 @@ <head> {{ template "head_common" . }} <link rel="stylesheet" href="/:/static/chroma.css" /> - <title>/{{ .path_spec }} – {{ .repo_name }} – {{ .group_name }} – {{ .global.forge_title }}</title> + <title>/{{ .path_spec }} – {{ .repo_name }} – {{ template "group_path_plain" .group_path }} – {{ .global.forge_title }}</title> </head> <body class="repo-tree-file"> {{ template "header" . }} <div class="padding"> <p> - /{{ .path_spec }} (<a href="/{{ .group_name }}/:/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 }}{{ if .ref_type }}?{{ .ref_type }}={{ .ref_name }}{{ end }}">raw</a>) </p> {{ .file_contents }} </div> |