UI config to toggle whether user email shows up in Explore Users (#336)

* UI config to toggle whether user email shows up in Explore Users

* Recommendation made by @tboerger
66a1c59fe7 (r94122732)

* fixed typo, rename ShowUserEmailInExplore to ShowUserEmail

* Fixed typo merged conflict

* Hide email in the user profile page

if you are active ShowUserEmail
ref https://github.com/go-gitea/gitea/pull/336#issuecomment-269843725

* Please replace MustBool() with MustBool(true)
This commit is contained in:
Thiago Avelino 2017-01-01 00:51:10 -02:00 committed by Lunny Xiao
parent a09a3dcabb
commit 787fda53ef
5 changed files with 8 additions and 2 deletions

2
conf/app.ini vendored
View file

@ -57,6 +57,8 @@ FEED_MAX_COMMIT_NUM = 5
THEME_COLOR_META_TAG = `#6cc644` THEME_COLOR_META_TAG = `#6cc644`
; Max size of files to be displayed (defaults is 8MiB) ; Max size of files to be displayed (defaults is 8MiB)
MAX_DISPLAY_FILE_SIZE = 8388608 MAX_DISPLAY_FILE_SIZE = 8388608
; Whether show the user email in the Explore Users page
SHOW_USER_EMAIL = true
[ui.admin] [ui.admin]
; Number of users that are showed in one page ; Number of users that are showed in one page

View file

@ -203,6 +203,7 @@ var (
FeedMaxCommitNum int FeedMaxCommitNum int
ThemeColorMetaTag string ThemeColorMetaTag string
MaxDisplayFileSize int64 MaxDisplayFileSize int64
ShowUserEmail bool
Admin struct { Admin struct {
UserPagingNum int UserPagingNum int
@ -820,6 +821,8 @@ please consider changing to GITEA_CUSTOM`)
ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true) ShowFooterVersion = Cfg.Section("other").Key("SHOW_FOOTER_VERSION").MustBool(true)
ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true) ShowFooterTemplateLoadTime = Cfg.Section("other").Key("SHOW_FOOTER_TEMPLATE_LOAD_TIME").MustBool(true)
UI.ShowUserEmail = Cfg.Section("ui").Key("SHOW_USER_EMAIL").MustBool(true)
HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt")) HasRobotsTxt = com.IsFile(path.Join(CustomPath, "robots.txt"))
} }

View file

@ -229,6 +229,7 @@ func RenderUserSearch(ctx *context.Context, opts *UserSearchOptions) {
ctx.Data["Total"] = count ctx.Data["Total"] = count
ctx.Data["Page"] = paginater.New(int(count), opts.PageSize, page, 5) ctx.Data["Page"] = paginater.New(int(count), opts.PageSize, page, 5)
ctx.Data["Users"] = users ctx.Data["Users"] = users
ctx.Data["ShowUserEmail"] = setting.UI.ShowUserEmail
ctx.HTML(200, opts.TplName) ctx.HTML(200, opts.TplName)
} }

View file

@ -16,7 +16,7 @@
{{if .Location}} {{if .Location}}
<i class="octicon octicon-location"></i> {{.Location}} <i class="octicon octicon-location"></i> {{.Location}}
{{end}} {{end}}
{{if and .Email $.IsSigned}} {{if and $.ShowUserEmail .Email $.IsSigned}}
<i class="octicon octicon-mail"></i> <i class="octicon octicon-mail"></i>
<a href="mailto:{{.Email}}" rel="nofollow">{{.Email}}</a> <a href="mailto:{{.Email}}" rel="nofollow">{{.Email}}</a>
{{end}} {{end}}

View file

@ -22,7 +22,7 @@
{{if .Owner.Location}} {{if .Owner.Location}}
<li><i class="octicon octicon-location"></i> {{.Owner.Location}}</li> <li><i class="octicon octicon-location"></i> {{.Owner.Location}}</li>
{{end}} {{end}}
{{if and .Owner.Email .IsSigned}} {{if and $.ShowUserEmail .Owner.Email .IsSigned}}
<li> <li>
<i class="octicon octicon-mail"></i> <i class="octicon octicon-mail"></i>
<a href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a> <a href="mailto:{{.Owner.Email}}" rel="nofollow">{{.Owner.Email}}</a>