Skip to content

Commit cbeb8d0

Browse files
lunnywxiaoguangsilverwind
authored and
Stelios Malathouras
committed
Display template path of current page in dev mode (go-gitea#18717)
* Display template path of current page in dev mode * improve code * Update templates/base/footer_content.tmpl Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
1 parent 389ce8e commit cbeb8d0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

modules/context/context.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ func (ctx *Context) RedirectToFirst(location ...string) {
197197
func (ctx *Context) HTML(status int, name base.TplName) {
198198
log.Debug("Template: %s", name)
199199
tmplStartTime := time.Now()
200-
ctx.Data["TmplLoadTimes"] = func() string {
200+
if !setting.IsProd {
201+
ctx.Data["TemplateName"] = name
202+
}
203+
ctx.Data["TemplateLoadTimes"] = func() string {
201204
return strconv.FormatInt(time.Since(tmplStartTime).Nanoseconds()/1e6, 10) + "ms"
202205
}
203206
if err := ctx.Render.HTML(ctx.Resp, status, string(name), ctx.Data); err != nil {

templates/base/footer_content.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<footer>
22
<div class="ui container">
33
<div class="ui left">
4-
{{.i18n.Tr "powered_by" "Gitea"}} {{if (or .ShowFooterVersion .PageIsAdmin)}}{{.i18n.Tr "version"}}: {{AppVer}}{{end}} {{if ShowFooterTemplateLoadTime}}{{.i18n.Tr "page"}}: <strong>{{LoadTimes .PageStartTime}}</strong> {{.i18n.Tr "template"}}: <strong>{{call .TmplLoadTimes}}</strong>{{end}}
4+
{{.i18n.Tr "powered_by" "Gitea"}} {{if (or .ShowFooterVersion .PageIsAdmin)}}{{.i18n.Tr "version"}}: {{AppVer}}{{end}} {{if ShowFooterTemplateLoadTime}}{{.i18n.Tr "page"}}: <strong>{{LoadTimes .PageStartTime}}</strong> {{.i18n.Tr "template"}}{{if .TemplateName}} {{.TemplateName}}{{end}}: <strong>{{call .TemplateLoadTimes}}</strong>{{end}}
55
</div>
66
<div class="ui right links">
77
{{if .ShowFooterBranding}}

0 commit comments

Comments
 (0)