[关闭]
@zoand 2019-08-23T04:36:08.000000Z 字数 1858 阅读 1913

gitea 模板修改

gitea


探索页面导航不显示全局用户列表

gitea 默认安装完之后,游客访问 探索 页面时,子导航中显示 仓库用户组织 三个标签页,现在不想让普通用户查看全局用户列表,修改以下模板文件:

templates\explorer\navbar.tmpl

  1. <div class="ui secondary pointing tabular top attached borderless stackable menu navbar">
  2. <a class="{{if .PageIsExploreRepositories}}active{{end}} item" href="{{AppSubUrl}}/explore/repos">
  3. <span class="octicon octicon-repo"></span> {{.i18n.Tr "explore.repos"}}
  4. </a>
  5. {{if .IsAdmin}}
  6. <a class="{{if .PageIsExploreUsers}}active{{end}} item" href="{{AppSubUrl}}/explore/users">
  7. <span class="octicon octicon-person"></span> {{.i18n.Tr "explore.users"}}
  8. </a>
  9. {{end}}
  10. <a class="{{if .PageIsExploreOrganizations}}active{{end}} item" href="{{AppSubUrl}}/explore/organizations">
  11. <span class="octicon octicon-organization"></span> {{.i18n.Tr "explore.organizations"}}
  12. </a>
  13. {{if .IsRepoIndexerEnabled}}
  14. <a class="{{if .PageIsExploreCode}}active{{end}} item" href="{{AppSubUrl}}/explore/code">
  15. <span class="octicon octicon-code"></span> {{.i18n.Tr "explore.code"}}
  16. </a>
  17. {{end}}
  18. </div>

templates\explorer\users.tmpl

  1. {{template "base/head" .}}
  2. <div class="explore users">
  3. {{template "explore/navbar" .}}
  4. <div class="ui container">
  5. {{template "explore/search" .}}
  6. {{if .IsAdmin}}
  7. <div class="ui user list">
  8. {{range .Users}}
  9. <div class="item">
  10. <img class="ui avatar image" src="{{.RelAvatarLink}}">
  11. <div class="content">
  12. <span class="header"><a href="{{.HomeLink}}">{{.Name}}</a> {{.FullName}}</span>
  13. <div class="description">
  14. {{if .Location}}
  15. <i class="octicon octicon-location"></i> {{.Location}}
  16. {{end}}
  17. {{if and $.ShowUserEmail .Email $.IsSigned (not .KeepEmailPrivate)}}
  18. <i class="octicon octicon-mail"></i>
  19. <a href="mailto:{{.Email}}" rel="nofollow">{{.Email}}</a>
  20. {{end}}
  21. <i class="octicon octicon-clock"></i> {{$.i18n.Tr "user.join_on"}} {{.CreatedUnix.FormatShort}}
  22. </div>
  23. </div>
  24. </div>
  25. {{else}}
  26. <div>{{$.i18n.Tr "explore.user_no_results"}}</div>
  27. {{end}}
  28. </div>
  29. {{end}}
  30. {{template "base/paginate" .}}
  31. </div>
  32. </div>
  33. {{template "base/footer" .}}

说明

使用 {{if .IsAdmin}} {{end}} 将要隐藏的块包裹起来即可。

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注