Skip to content

Commit f125330

Browse files
mrsdizzietechknowlogick
authored andcommitted
Include more variables on admin/config page (#6378)
Include the current CustomPath location in the admin section and also display GITEA_WORK_DIR and/or GITEA_CUSTOM env var if they are set. Right now there is no easy way to see this information, and if you try and help most users they won't be able to tell you anything about these values -- just that their custom template isn't working, files aren't in the right place, etc... Now you can see all paths and if they were set by ENV or not.
1 parent 5c82ef0 commit f125330

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,7 @@ config.app_name = Site Title
16291629
config.app_ver = Gitea Version
16301630
config.app_url = Gitea Base URL
16311631
config.custom_conf = Configuration File Path
1632+
config.custom_file_root_path = "Custom File Root Path"
16321633
config.domain = SSH Server Domain
16331634
config.offline_mode = Local Mode
16341635
config.disable_router_log = Disable Router Log

routers/admin/admin.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package admin
66

77
import (
88
"fmt"
9+
"os"
910
"runtime"
1011
"strings"
1112
"time"
@@ -211,6 +212,7 @@ func Config(ctx *context.Context) {
211212
ctx.Data["RunMode"] = strings.Title(macaron.Env)
212213
ctx.Data["GitVersion"] = setting.Git.Version
213214
ctx.Data["RepoRootPath"] = setting.RepoRootPath
215+
ctx.Data["CustomRootPath"] = setting.CustomPath
214216
ctx.Data["StaticRootPath"] = setting.StaticRootPath
215217
ctx.Data["LogRootPath"] = setting.LogRootPath
216218
ctx.Data["ScriptType"] = setting.ScriptType
@@ -240,6 +242,20 @@ func Config(ctx *context.Context) {
240242

241243
ctx.Data["Git"] = setting.Git
242244

245+
type envVar struct {
246+
Name, Value string
247+
}
248+
249+
envVars := map[string]*envVar{}
250+
if len(os.Getenv("GITEA_WORK_DIR")) > 0 {
251+
envVars["GITEA_WORK_DIR"] = &envVar{"GITEA_WORK_DIR", os.Getenv("GITEA_WORK_DIR")}
252+
}
253+
if len(os.Getenv("GITEA_CUSTOM")) > 0 {
254+
envVars["GITEA_CUSTOM"] = &envVar{"GITEA_CUSTOM", os.Getenv("GITEA_CUSTOM")}
255+
}
256+
257+
ctx.Data["EnvVars"] = envVars
258+
243259
type logger struct {
244260
Mode, Config string
245261
}

templates/admin/config.tmpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,23 @@
4141
<dd>{{.RepoRootPath}}</dd>
4242
<dt>{{.i18n.Tr "admin.config.static_file_root_path"}}</dt>
4343
<dd>{{.StaticRootPath}}</dd>
44+
<dt>{{.i18n.Tr "admin.config.custom_file_root_path"}}</dt>
45+
<dd>{{.CustomRootPath}}</dd>
4446
<dt>{{.i18n.Tr "admin.config.log_file_root_path"}}</dt>
4547
<dd>{{.LogRootPath}}</dd>
4648
<dt>{{.i18n.Tr "admin.config.script_type"}}</dt>
4749
<dd>{{.ScriptType}}</dd>
4850
<dt>{{.i18n.Tr "admin.config.reverse_auth_user"}}</dt>
4951
<dd>{{.ReverseProxyAuthUser}}</dd>
52+
53+
{{if .EnvVars }}
54+
<div class="ui divider"></div>
55+
{{range .EnvVars}}
56+
<dt>{{.Name}}</dt>
57+
<dd>{{.Value}}</dd>
58+
{{end}}
59+
{{end}}
60+
5061
</dl>
5162
</div>
5263

0 commit comments

Comments
 (0)