From 1c1ffea237435b697b256a0e442d004314ed3486 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Fri, 14 Oct 2022 00:30:29 +0800 Subject: [PATCH] demo --- modules/context/context.go | 3 +++ templates/base/head_script.tmpl | 9 +++++++++ templates/home.tmpl | 3 +++ 3 files changed, 15 insertions(+) diff --git a/modules/context/context.go b/modules/context/context.go index 4b6a21b217c3b..759dd1d389e0c 100644 --- a/modules/context/context.go +++ b/modules/context/context.go @@ -698,6 +698,9 @@ func Contexter(ctx context.Context) func(next http.Handler) http.Handler { ctx.Req = WithContext(req, &ctx) ctx.csrf = PrepareCSRFProtector(csrfOpts, &ctx) + browserSyncJson := ctx.GetCookie("_gitea_bsj") + ctx.PageData["browserSyncJson"] = browserSyncJson + // Get flash. flashCookie := ctx.GetCookie("macaron_flash") vals, _ := url.ParseQuery(flashCookie) diff --git a/templates/base/head_script.tmpl b/templates/base/head_script.tmpl index 8369b63b35701..abd0c36b4c209 100644 --- a/templates/base/head_script.tmpl +++ b/templates/base/head_script.tmpl @@ -47,3 +47,12 @@ If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly. {{/* in case some pages don't render the pageData, we make sure it is an object to prevent null access */}} window.config.pageData = window.config.pageData || {}; + + diff --git a/templates/home.tmpl b/templates/home.tmpl index 7667db27a1128..40afa58d87f4b 100644 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -1,4 +1,7 @@ {{template "base/head" .}} +
+ Backend has the user browser's locale and timezone offset now: {{.PageData.browserSyncJson}} +