From c916e1854f36c22209987dcf7cb32c9feb811b22 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 14 Feb 2025 11:56:21 +0800 Subject: [PATCH] *: Make the forge title configurable --- config.go | 5 +++++ forge.scfg | 4 ++++ http_global.go | 1 + templates/_header.html.tmpl | 2 +- templates/group_repos.html.tmpl | 2 +- templates/index.html.tmpl | 6 +++--- templates/login.html.tmpl | 4 ++-- templates/repo_commit.html.tmpl | 10 +++++----- templates/repo_index.html.tmpl | 6 +++--- templates/repo_log.html.tmpl | 2 +- templates/repo_raw_dir.html.tmpl | 2 +- templates/repo_tree_dir.html.tmpl | 2 +- templates/repo_tree_file.html.tmpl | 2 +- diff --git a/config.go b/config.go index 525581a37f18b8d85ad4d9ffcf14eb34b8fb209b..d427aeef47b4170ec919570e0b10e8f97bac16bc 100644 --- a/config.go +++ b/config.go @@ -26,6 +26,9 @@ Addr string `scfg:"addr"` Key string `scfg:"key"` Root string `scfg:"root"` } `scfg:"ssh"` + General struct { + Title string `scfg:"title"` + } `scfg:"general"` Git struct { Root string `scfg:"root"` } `scfg:"git"` @@ -55,6 +58,8 @@ database, err = pgxpool.New(context.Background(), config.DB.Conn) if err != nil { return err } + + global_data["forge_title"] = config.General.Title return nil } diff --git a/forge.scfg b/forge.scfg index 11facbab8dda830492ade2fdd47087d959716c63..ba61a30d41e11396d88cbc51e4634625cc902077 100644 --- a/forge.scfg +++ b/forge.scfg @@ -11,6 +11,10 @@ key /etc/ssh/ssh_host_ed25519_key root ssh://forge.example.org } +general { + title "Test Forge" +} + db { type postgres conn postgresql:///lindenii-forge?host=/var/run/postgresql diff --git a/http_global.go b/http_global.go index e7ee580091ef9b078589ec07d7c197505b4e25d2..b1e55853a3892375f72621d12e5827f5885ae815 100644 --- a/http_global.go +++ b/http_global.go @@ -3,4 +3,5 @@ var global_data = map[string]any{ "server_public_key_string": &server_public_key_string, "server_public_key_fingerprint": &server_public_key_fingerprint, + // Some other ones are populated after config parsing } diff --git a/templates/_header.html.tmpl b/templates/_header.html.tmpl index 7aebfbccd8ed5592394aeb49d320b6aba80515c0..6d0a3a2b74dc24a8036f3348998f353931bda52b 100644 --- a/templates/_header.html.tmpl +++ b/templates/_header.html.tmpl @@ -1,7 +1,7 @@ {{- define "header" -}}
{{ if ne .user_id "" }} diff --git a/templates/group_repos.html.tmpl b/templates/group_repos.html.tmpl index 2d0b7d9468d4fb9a62f60e5bdcfaf837a9cdaaad..8c95c916c8e67328d60b2955e9a3df7e19939efb 100644 --- a/templates/group_repos.html.tmpl +++ b/templates/group_repos.html.tmpl @@ -3,7 +3,7 @@ {{ template "head_common" . }} - Repos in {{ .group_name }} – Lindenii Forge + Repos in {{ .group_name }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/index.html.tmpl b/templates/index.html.tmpl index c7259487f2810f4582f0599e2c801e731677a5d5..5f30f0ce530a9057ddd2007b19b4e065360818ac 100644 --- a/templates/index.html.tmpl +++ b/templates/index.html.tmpl @@ -3,7 +3,7 @@ {{ template "head_common" . }} - Index – Lindenii Forge + Index – {{ .global.forge_title }} {{ template "header" . }} @@ -41,11 +41,11 @@ - SSH Public Key + SSH public key {{ .global.server_public_key_string }} - SSH Fingerprint + SSH fingerprint {{ .global.server_public_key_fingerprint }} diff --git a/templates/login.html.tmpl b/templates/login.html.tmpl index 99ee6b95adb6c5c2aec3af4c638f784081374f25..3b0e74a54a033fdb337edabb19f3e911d250da89 100644 --- a/templates/login.html.tmpl +++ b/templates/login.html.tmpl @@ -3,7 +3,7 @@ {{ template "head_common" . }} - Login – Lindenii Forge + Login – {{ .global.forge_title }} {{ .login_error }} @@ -13,7 +13,7 @@ diff --git a/templates/repo_commit.html.tmpl b/templates/repo_commit.html.tmpl index bd87f87873ac479f5e7780c1e87b1de43c1f057e..658ed572049127a0381e662d0e741204697baa9f 100644 --- a/templates/repo_commit.html.tmpl +++ b/templates/repo_commit.html.tmpl @@ -3,7 +3,7 @@ {{ template "head_common" . }} - {{ .group_name }}/repos/{{ .repo_name }} – Lindenii Forge + {{ .group_name }}/repos/{{ .repo_name }} – {{ .global.forge_title }} {{ template "header" . }} @@ -11,7 +11,7 @@
- Password Authentication + Password authentication
- + @@ -24,7 +24,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -41,7 +41,7 @@ - +
Commit InfoCommit info
Author {{ .commit_object.Author.Name }} <{{ .commit_object.Author.Email }}>
Author DateAuthor date {{ .commit_object.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
Committer {{ .commit_object.Committer.Name }} <{{ .commit_object.Committer.Email }}>
Committer DateCommitter date {{ .commit_object.Committer.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
{{ .commit_object.Message }}
Actions
Get as Patch
Get patch
diff --git a/templates/repo_index.html.tmpl b/templates/repo_index.html.tmpl index 14d2a5d7b1ffc0de3e66bed7a2f9be7353c363ca..806ceda07730f75bf282d9d31f0b601a89565a9a 100644 --- a/templates/repo_index.html.tmpl +++ b/templates/repo_index.html.tmpl @@ -3,7 +3,7 @@ {{ template "head_common" . }} - {{ .group_name }}/repos/{{ .repo_name }} – Lindenii Forge + {{ .group_name }}/repos/{{ .repo_name }} – {{ .global.forge_title }} {{ template "header" . }} @@ -11,7 +11,7 @@
- + @@ -37,7 +37,7 @@
Repo InfoRepo info
- + diff --git a/templates/repo_log.html.tmpl b/templates/repo_log.html.tmpl index fa29fa503f15e3f139b673abd741be183ce93054..6b89cdd58cb882731ff1f7c533c798460b57dc8e 100644 --- a/templates/repo_log.html.tmpl +++ b/templates/repo_log.html.tmpl @@ -3,7 +3,7 @@ {{ template "head_common" . }} - Log of {{ .group_name }}/repos/{{ .repo_name }} – Lindenii Forge + Log of {{ .group_name }}/repos/{{ .repo_name }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_raw_dir.html.tmpl b/templates/repo_raw_dir.html.tmpl index d306bbf315b935cdb7b8ecdcd7a704d9ff9ba205..d38731b310602f6287ed6d194e4954582d84fa98 100644 --- a/templates/repo_raw_dir.html.tmpl +++ b/templates/repo_raw_dir.html.tmpl @@ -3,7 +3,7 @@ {{ template "head_common" . }} - {{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – Lindenii Forge + {{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_tree_dir.html.tmpl b/templates/repo_tree_dir.html.tmpl index 34559da26b8802402aa72cc76f8e810297ba186e..5e0fdcc679baaf170308ed8ca1511d8bee5d935d 100644 --- a/templates/repo_tree_dir.html.tmpl +++ b/templates/repo_tree_dir.html.tmpl @@ -3,7 +3,7 @@ {{ template "head_common" . }} - {{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – Lindenii Forge + {{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .global.forge_title }} {{ template "header" . }} diff --git a/templates/repo_tree_file.html.tmpl b/templates/repo_tree_file.html.tmpl index 8eacd288c21565f9d4273d170d381ea1a9f6d535..7d5069c5bf0dcc304bec3d4c42472185f6600d65 100644 --- a/templates/repo_tree_file.html.tmpl +++ b/templates/repo_tree_file.html.tmpl @@ -4,7 +4,7 @@ {{ template "head_common" . }} - {{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }} – Lindenii Forge + {{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }} – {{ .global.forge_title }} {{ template "header" . }} -- 2.48.1