@zoand
2019-08-23T04:36:08.000000Z
字数 1858
阅读 2165
gitea
探索页面导航不显示全局用户列表gitea 默认安装完之后,游客访问 探索 页面时,子导航中显示 仓库、用户、组织 三个标签页,现在不想让普通用户查看全局用户列表,修改以下模板文件:
templates\explorer\navbar.tmpl
<div class="ui secondary pointing tabular top attached borderless stackable menu navbar"><a class="{{if .PageIsExploreRepositories}}active{{end}} item" href="{{AppSubUrl}}/explore/repos"><span class="octicon octicon-repo"></span> {{.i18n.Tr "explore.repos"}}</a>{{if .IsAdmin}}<a class="{{if .PageIsExploreUsers}}active{{end}} item" href="{{AppSubUrl}}/explore/users"><span class="octicon octicon-person"></span> {{.i18n.Tr "explore.users"}}</a>{{end}}<a class="{{if .PageIsExploreOrganizations}}active{{end}} item" href="{{AppSubUrl}}/explore/organizations"><span class="octicon octicon-organization"></span> {{.i18n.Tr "explore.organizations"}}</a>{{if .IsRepoIndexerEnabled}}<a class="{{if .PageIsExploreCode}}active{{end}} item" href="{{AppSubUrl}}/explore/code"><span class="octicon octicon-code"></span> {{.i18n.Tr "explore.code"}}</a>{{end}}</div>
templates\explorer\users.tmpl
{{template "base/head" .}}<div class="explore users">{{template "explore/navbar" .}}<div class="ui container">{{template "explore/search" .}}{{if .IsAdmin}}<div class="ui user list">{{range .Users}}<div class="item"><img class="ui avatar image" src="{{.RelAvatarLink}}"><div class="content"><span class="header"><a href="{{.HomeLink}}">{{.Name}}</a> {{.FullName}}</span><div class="description">{{if .Location}}<i class="octicon octicon-location"></i> {{.Location}}{{end}}{{if and $.ShowUserEmail .Email $.IsSigned (not .KeepEmailPrivate)}}<i class="octicon octicon-mail"></i><a href="mailto:{{.Email}}" rel="nofollow">{{.Email}}</a>{{end}}<i class="octicon octicon-clock"></i> {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}}</div></div></div>{{else}}<div>{{$.i18n.Tr "explore.user_no_results"}}</div>{{end}}</div>{{end}}{{template "base/paginate" .}}</div></div>{{template "base/footer" .}}
使用 {{if .IsAdmin}} {{end}} 将要隐藏的块包裹起来即可。