diff options
author | Runxi Yu <me@runxiyu.org> | 2025-02-14 11:56:21 +0800 |
---|---|---|
committer | Runxi Yu <me@runxiyu.org> | 2025-02-14 11:56:21 +0800 |
commit | c916e1854f36c22209987dcf7cb32c9feb811b22 (patch) | |
tree | 163bc34b14f7839b58a24f445756b1dadcfdc9d4 | |
parent | README.md: Fix typo (diff) | |
download | forge-c916e1854f36c22209987dcf7cb32c9feb811b22.tar.gz forge-c916e1854f36c22209987dcf7cb32c9feb811b22.tar.zst forge-c916e1854f36c22209987dcf7cb32c9feb811b22.zip |
*: Make the forge title configurable
-rw-r--r-- | config.go | 5 | ||||
-rw-r--r-- | forge.scfg | 4 | ||||
-rw-r--r-- | http_global.go | 1 | ||||
-rw-r--r-- | templates/_header.html.tmpl | 2 | ||||
-rw-r--r-- | templates/group_repos.html.tmpl | 2 | ||||
-rw-r--r-- | templates/index.html.tmpl | 6 | ||||
-rw-r--r-- | templates/login.html.tmpl | 4 | ||||
-rw-r--r-- | templates/repo_commit.html.tmpl | 10 | ||||
-rw-r--r-- | templates/repo_index.html.tmpl | 6 | ||||
-rw-r--r-- | templates/repo_log.html.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_raw_dir.html.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_tree_dir.html.tmpl | 2 | ||||
-rw-r--r-- | templates/repo_tree_file.html.tmpl | 2 |
13 files changed, 29 insertions, 19 deletions
@@ -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 } @@ -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" -}} <header id="main-header"> <div id="main-header-forge-title"> - <a href="/">Lindenii Forge</a> + <a href="/">{{ .global.forge_title }}</a> </div> <div id="main-header-user"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>Repos in {{ .group_name }} – Lindenii Forge</title> + <title>Repos in {{ .group_name }} – {{ .global.forge_title }}</title> </head> <body class="group-repos"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>Index – Lindenii Forge</title> + <title>Index – {{ .global.forge_title }}</title> </head> <body class="index"> {{ template "header" . }} @@ -41,11 +41,11 @@ </thead> <tbody> <tr> - <th scope="row">SSH Public Key</th> + <th scope="row">SSH public key</th> <td><code>{{ .global.server_public_key_string }}</code></td> </tr> <tr> - <th scope="row">SSH Fingerprint</th> + <th scope="row">SSH fingerprint</th> <td><code>{{ .global.server_public_key_fingerprint }}</code></td> </tr> </tbody> 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>Login – Lindenii Forge</title> + <title>Login – {{ .global.forge_title }}</title> </head> <body class="index"> {{ .login_error }} @@ -13,7 +13,7 @@ <thead> <tr> <th class="title-row" colspan="2"> - Password Authentication + Password authentication </th> </tr> </thead> 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>{{ .group_name }}/repos/{{ .repo_name }} – Lindenii Forge</title> + <title>{{ .group_name }}/repos/{{ .repo_name }} – {{ .global.forge_title }}</title> </head> <body class="repo-commit"> {{ template "header" . }} @@ -11,7 +11,7 @@ <table id="commit-info-table"> <thead> <tr class="title-row"> - <th colspan="2">Commit Info</th> + <th colspan="2">Commit info</th> </tr> </thead> <tbody> @@ -24,7 +24,7 @@ <td>{{ .commit_object.Author.Name }} <<a href="mailto:{{ .commit_object.Author.Email }}">{{ .commit_object.Author.Email }}</a>></td> </tr> <tr> - <th scope="row">Author Date</th> + <th scope="row">Author date</th> <td>{{ .commit_object.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</td> </tr> <tr> @@ -32,7 +32,7 @@ <td>{{ .commit_object.Committer.Name }} <<a href="mailto:{{ .commit_object.Committer.Email }}">{{ .commit_object.Committer.Email }}</a>></td> </tr> <tr> - <th scope="row">Committer Date</th> + <th scope="row">Committer date</th> <td>{{ .commit_object.Committer.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</td> </tr> <tr> @@ -41,7 +41,7 @@ </tr> <tr> <th scope="row">Actions</th> - <td><pre><a href="{{ .commit_object.Hash }}.patch">Get as Patch</a></pre></td> + <td><pre><a href="{{ .commit_object.Hash }}.patch">Get patch</a></pre></td> </tr> </tbody> </table> 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>{{ .group_name }}/repos/{{ .repo_name }} – Lindenii Forge</title> + <title>{{ .group_name }}/repos/{{ .repo_name }} – {{ .global.forge_title }}</title> </head> <body class="repo-index"> {{ template "header" . }} @@ -11,7 +11,7 @@ <table id="repo-info-table"> <thead> <tr class="title-row"> - <th colspan="2">Repo Info</th> + <th colspan="2">Repo info</th> </tr> </thead> <tbody> @@ -37,7 +37,7 @@ <table id="recent-commits" class="wide"> <thead> <tr class="title-row"> - <th colspan="3"><label for="toggle-table-recent-commits">Recent Commits (<a href="log/{{ if .ref_type }}?{{ .ref_type }}={{ .ref_name }}{{ end }}">see all</a>)</label></th> + <th colspan="3"><label for="toggle-table-recent-commits">Recent commits (<a href="log/{{ if .ref_type }}?{{ .ref_type }}={{ .ref_name }}{{ end }}">see all</a>)</label></th> </tr> </thead> <tbody> 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>Log of {{ .group_name }}/repos/{{ .repo_name }} – Lindenii Forge</title> + <title>Log of {{ .group_name }}/repos/{{ .repo_name }} – {{ .global.forge_title }}</title> </head> <body class="repo-log"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>{{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – Lindenii Forge</title> + <title>{{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .global.forge_title }}</title> </head> <body class="repo-raw-dir"> {{ 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 @@ <html lang="en"> <head> {{ template "head_common" . }} - <title>{{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – Lindenii Forge</title> + <title>{{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }}{{ if ne .path_spec "" }}/{{ end }} – {{ .global.forge_title }}</title> </head> <body class="repo-tree-dir"> {{ 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 @@ <head> {{ template "head_common" . }} <link rel="stylesheet" href="/:/static/chroma.css" /> - <title>{{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }} – Lindenii Forge</title> + <title>{{ .group_name }}/repos/{{ .repo_name }}/{{ .path_spec }} – {{ .global.forge_title }}</title> </head> <body class="repo-tree-file"> {{ template "header" . }} |