From c916e1854f36c22209987dcf7cb32c9feb811b22 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Fri, 14 Feb 2025 11:56:21 +0800 Subject: *: 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 +- 13 files changed, 29 insertions(+), 19 deletions(-) diff --git a/config.go b/config.go index 525581a..d427aee 100644 --- a/config.go +++ b/config.go @@ -26,6 +26,9 @@ var config struct { 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"` @@ -56,5 +59,7 @@ func load_config(path string) (err error) { return err } + global_data["forge_title"] = config.General.Title + return nil } diff --git a/forge.scfg b/forge.scfg index 11facba..ba61a30 100644 --- a/forge.scfg +++ b/forge.scfg @@ -11,6 +11,10 @@ ssh { 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 e7ee580..b1e5585 100644 --- a/http_global.go +++ b/http_global.go @@ -3,4 +3,5 @@ package main 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 7aebfbc..6d0a3a2 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 2d0b7d9..8c95c91 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 c725948..5f30f0c 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 99ee6b9..3b0e74a 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 @@ - Password Authentication + Password authentication diff --git a/templates/repo_commit.html.tmpl b/templates/repo_commit.html.tmpl index bd87f87..658ed57 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 @@ - + @@ -24,7 +24,7 @@ - + @@ -32,7 +32,7 @@ - + @@ -41,7 +41,7 @@ - +
Commit InfoCommit info
{{ .commit_object.Author.Name }} <{{ .commit_object.Author.Email }}>
Author DateAuthor date {{ .commit_object.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
{{ .commit_object.Committer.Name }} <{{ .commit_object.Committer.Email }}>
Committer DateCommitter date {{ .commit_object.Committer.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}
Actions
Get as Patch
Get patch
diff --git a/templates/repo_index.html.tmpl b/templates/repo_index.html.tmpl index 14d2a5d..806ceda 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 fa29fa5..6b89cdd 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 d306bbf..d38731b 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 34559da..5e0fdcc 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 8eacd28..7d5069c 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" . }} -- cgit v1.2.3