From 278727612554ed695cec9669129de76c1eade11a Mon Sep 17 00:00:00 2001 From: Richard Mahn Date: Wed, 23 Nov 2016 10:01:01 -0700 Subject: [PATCH] Adds Google Analytics to templates --- modules/setting/setting.go | 4 ++++ modules/template/template.go | 3 +++ 2 files changed, 7 insertions(+) diff --git a/modules/setting/setting.go b/modules/setting/setting.go index baaa3f50a8..ad5cff7882 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -261,6 +261,9 @@ var ( RunUser string IsWindows bool HasRobotsTxt bool + Google struct { + GATrackingID string + } ) // DateLang transforms standard language locale name to corresponding value in datetime plugin. @@ -592,6 +595,7 @@ please consider changing to GITEA_CUSTOM`) ShowFooterBranding = Cfg.Section("other").Key("SHOW_FOOTER_BRANDING").MustBool() ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool() ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool() + Google.GATrackingID = Cfg.Section("other").Key("GA_TRACKING_ID").String() HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt")) } diff --git a/modules/template/template.go b/modules/template/template.go index 03fa0f5217..8034faee09 100644 --- a/modules/template/template.go +++ b/modules/template/template.go @@ -116,6 +116,9 @@ func NewFuncMap() []template.FuncMap { } return "tab-size-8" }, + "GATrackingID": func() string { + return setting.Google.GATrackingID + }, }} }