From 1bfd3a36e5720eb38cbf447812f5fcbe6b57463c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=96stanb=C3=A4ck?= Date: Fri, 31 Mar 2017 14:02:26 +0200 Subject: [PATCH 1/2] Support for custom html meta --- conf/app.ini | 5 +++++ modules/setting/setting.go | 15 +++++++++++++++ modules/templates/helper.go | 9 +++++++++ templates/base/head.tmpl | 8 ++++---- 4 files changed, 33 insertions(+), 4 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index 07c3a1d21c508..b14e74550b6e9 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -74,6 +74,11 @@ ORG_PAGING_NUM = 50 ; Number of repos that are showed in one page REPO_PAGING_NUM = 15 +[ui.meta] +AUTHOR = Gitea - Git with a cup of tea +DESCRIPTION = Gitea: Git with a cup of tea +KEYWORDS = go,git,self-hosted,gitea + [markdown] ; Enable hard line break extension ENABLE_HARD_LINE_BREAK = false diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 59cc755d03f46..0247031424fb4 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -226,6 +226,11 @@ var ( User struct { RepoPagingNum int } `ini:"ui.user"` + Meta struct { + Author string + Description string + Keywords string + } `ini:"ui.meta"` }{ ExplorePagingNum: 20, IssuePagingNum: 10, @@ -248,6 +253,15 @@ var ( }{ RepoPagingNum: 15, }, + Meta: struct { + Author string + Description string + Keywords string + }{ + Author: "Gitea - Git with a cup of tea", + Description: "", + Keywords: "go,git,self-hosted,gitea", + }, } // Markdown settings @@ -897,6 +911,7 @@ please consider changing to GITEA_CUSTOM`) ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true) UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true) + UI.Meta.Description = Cfg.Section("ui.meta").Key("DESCRIPTION").MustString(AppName) HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt")) } diff --git a/modules/templates/helper.go b/modules/templates/helper.go index dd8a0fdd35368..2e756ce364816 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -110,6 +110,15 @@ func NewFuncMap() []template.FuncMap { "ThemeColorMetaTag": func() string { return setting.UI.ThemeColorMetaTag }, + "MetaAuthor": func() string { + return setting.UI.Meta.Author + }, + "MetaDescription": func() string { + return setting.UI.Meta.Description + }, + "MetaKeywords": func() string { + return setting.UI.Meta.Keywords + }, "FilenameIsImage": func(filename string) bool { mimeType := mime.TypeByExtension(filepath.Ext(filename)) return strings.HasPrefix(mimeType, "image/") diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl index f4b883335ec20..a80075513d277 100644 --- a/templates/base/head.tmpl +++ b/templates/base/head.tmpl @@ -5,9 +5,9 @@ {{if .Title}}{{.Title}} - {{end}}{{AppName}} - - - + + + @@ -68,7 +68,7 @@ - + {{end}} From 57af3b66d070ae9a593647bd0ec00f71b1f2f324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=96stanb=C3=A4ck?= Date: Fri, 31 Mar 2017 14:34:12 +0200 Subject: [PATCH 2/2] Changed html meta description default --- conf/app.ini | 2 +- modules/setting/setting.go | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index b14e74550b6e9..47dcffc37eda2 100644 --- a/conf/app.ini +++ b/conf/app.ini @@ -76,7 +76,7 @@ REPO_PAGING_NUM = 15 [ui.meta] AUTHOR = Gitea - Git with a cup of tea -DESCRIPTION = Gitea: Git with a cup of tea +DESCRIPTION = Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go KEYWORDS = go,git,self-hosted,gitea [markdown] diff --git a/modules/setting/setting.go b/modules/setting/setting.go index 0247031424fb4..5a0666ade2347 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -259,7 +259,7 @@ var ( Keywords string }{ Author: "Gitea - Git with a cup of tea", - Description: "", + Description: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go", Keywords: "go,git,self-hosted,gitea", }, } @@ -911,7 +911,6 @@ please consider changing to GITEA_CUSTOM`) ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true) UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true) - UI.Meta.Description = Cfg.Section("ui.meta").Key("DESCRIPTION").MustString(AppName) HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt")) }