From 095e1f51556d940a07d9f8580d0d25acf6a39c63 Mon Sep 17 00:00:00 2001 From: Jonas Date: Sat, 1 Apr 2017 03:03:01 +0200 Subject: [PATCH] Support for custom html meta (#1423) * Support for custom html meta * Changed html meta description default --- conf/app.ini | 5 +++++ modules/setting/setting.go | 14 ++++++++++++++ modules/templates/helper.go | 9 +++++++++ templates/base/head.tmpl | 8 ++++---- 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/conf/app.ini b/conf/app.ini index 07c3a1d21c..47dcffc37e 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) is a painless self-hosted Git service written in Go +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 59cc755d03..5a0666ade2 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: "Gitea (Git with a cup of tea) is a painless self-hosted Git service written in Go", + Keywords: "go,git,self-hosted,gitea", + }, } // Markdown settings diff --git a/modules/templates/helper.go b/modules/templates/helper.go index dd8a0fdd35..2e756ce364 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 f4b883335e..a80075513d 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}}