gitea源码

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <nav id="navbar" aria-label="{{ctx.Locale.Tr "aria.navbar"}}">
  2. <div class="navbar-left">
  3. <!-- the logo -->
  4. <a class="item" id="navbar-logo" href="{{AppSubUrl}}/" aria-label="{{if .IsSigned}}{{ctx.Locale.Tr "dashboard"}}{{else}}{{ctx.Locale.Tr "home"}}{{end}}">
  5. <img width="30" height="30" src="{{AssetUrlPrefix}}/img/logo.svg" alt="{{ctx.Locale.Tr "logo"}}" aria-hidden="true">
  6. </a>
  7. <!-- mobile right menu, it must be here because in mobile view, each item is a flex column, the first item is a full row column -->
  8. <div class="ui secondary menu navbar-mobile-right only-mobile">
  9. {{template "base/head_navbar_icons" dict "PageGlobalData" .PageGlobalData}}
  10. <button class="item ui icon mini button tw-m-0" id="navbar-expand-toggle" aria-label="{{ctx.Locale.Tr "home.nav_menu"}}">{{svg "octicon-three-bars"}}</button>
  11. </div>
  12. <!-- navbar links non-mobile -->
  13. {{if and .IsSigned .MustChangePassword}}
  14. {{/* No links */}}
  15. {{else if .IsSigned}}
  16. {{if not ctx.Consts.RepoUnitTypeIssues.UnitGlobalDisabled}}
  17. <a class="item{{if .PageIsIssues}} active{{end}}" href="{{AppSubUrl}}/issues">{{ctx.Locale.Tr "issues"}}</a>
  18. {{end}}
  19. {{if not ctx.Consts.RepoUnitTypePullRequests.UnitGlobalDisabled}}
  20. <a class="item{{if .PageIsPulls}} active{{end}}" href="{{AppSubUrl}}/pulls">{{ctx.Locale.Tr "pull_requests"}}</a>
  21. {{end}}
  22. {{if not (and ctx.Consts.RepoUnitTypeIssues.UnitGlobalDisabled ctx.Consts.RepoUnitTypePullRequests.UnitGlobalDisabled)}}
  23. {{if .ShowMilestonesDashboardPage}}
  24. <a class="item{{if .PageIsMilestonesDashboard}} active{{end}}" href="{{AppSubUrl}}/milestones">{{ctx.Locale.Tr "milestones"}}</a>
  25. {{end}}
  26. {{end}}
  27. <a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/repos">{{ctx.Locale.Tr "explore"}}</a>
  28. {{else if .IsLandingPageOrganizations}}
  29. <a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/organizations">{{ctx.Locale.Tr "explore"}}</a>
  30. {{else}}
  31. <a class="item{{if .PageIsExplore}} active{{end}}" href="{{AppSubUrl}}/explore/repos">{{ctx.Locale.Tr "explore"}}</a>
  32. {{end}}
  33. {{template "custom/extra_links" .}}
  34. {{if not .IsSigned}}
  35. <a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com">{{ctx.Locale.Tr "help"}}</a>
  36. {{end}}
  37. </div>
  38. <!-- the full dropdown menus -->
  39. <div class="navbar-right">
  40. {{if and .IsSigned .MustChangePassword}}
  41. <div class="ui dropdown jump item" data-tooltip-content="{{ctx.Locale.Tr "user_profile_and_more"}}">
  42. <span class="text">
  43. {{ctx.AvatarUtils.Avatar .SignedUser 24 "tw-mr-1"}}
  44. <span class="only-mobile">{{.SignedUser.Name}}</span>
  45. <span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
  46. </span>
  47. <div class="menu user-menu">
  48. <div class="header">
  49. {{ctx.Locale.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
  50. </div>
  51. <div class="divider"></div>
  52. <a class="item link-action" href data-url="{{AppSubUrl}}/user/logout">
  53. {{svg "octicon-sign-out"}}
  54. {{ctx.Locale.Tr "sign_out"}}
  55. </a>
  56. </div><!-- end content avatar menu -->
  57. </div><!-- end dropdown avatar menu -->
  58. {{else if .IsSigned}}
  59. {{template "base/head_navbar_icons" dict "ItemExtraClass" "not-mobile" "PageGlobalData" .PageGlobalData}}
  60. <div class="ui dropdown jump item" data-tooltip-content="{{ctx.Locale.Tr "create_new"}}">
  61. <span class="text">
  62. {{svg "octicon-plus"}}
  63. <span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
  64. <span class="only-mobile">{{ctx.Locale.Tr "create_new"}}</span>
  65. </span>
  66. <div class="menu">
  67. <a class="item" href="{{AppSubUrl}}/repo/create">
  68. {{svg "octicon-plus"}} {{ctx.Locale.Tr "new_repo"}}
  69. </a>
  70. {{if not .DisableMigrations}}
  71. <a class="item" href="{{AppSubUrl}}/repo/migrate">
  72. {{svg "octicon-repo-push"}} {{ctx.Locale.Tr "new_migrate"}}
  73. </a>
  74. {{end}}
  75. {{if .SignedUser.CanCreateOrganization}}
  76. <a class="item" href="{{AppSubUrl}}/org/create">
  77. {{svg "octicon-organization"}} {{ctx.Locale.Tr "new_org"}}
  78. </a>
  79. {{end}}
  80. </div><!-- end content create new menu -->
  81. </div><!-- end dropdown menu create new -->
  82. <div class="ui dropdown jump item" data-tooltip-content="{{ctx.Locale.Tr "user_profile_and_more"}}">
  83. <span class="text">
  84. {{ctx.AvatarUtils.Avatar .SignedUser 24 "tw-mr-1"}}
  85. <span class="only-mobile">{{.SignedUser.Name}}</span>
  86. <span class="not-mobile">{{svg "octicon-triangle-down"}}</span>
  87. </span>
  88. <div class="menu user-menu">
  89. <div class="header">
  90. {{ctx.Locale.Tr "signed_in_as"}} <strong>{{.SignedUser.Name}}</strong>
  91. </div>
  92. <div class="divider"></div>
  93. <a class="item" href="{{.SignedUser.HomeLink}}">
  94. {{svg "octicon-person"}}
  95. {{ctx.Locale.Tr "your_profile"}}
  96. </a>
  97. {{if not .DisableStars}}
  98. <a class="item" href="{{.SignedUser.HomeLink}}?tab=stars">
  99. {{svg "octicon-star"}}
  100. {{ctx.Locale.Tr "your_starred"}}
  101. </a>
  102. {{end}}
  103. <a class="item" href="{{AppSubUrl}}/notifications/subscriptions">
  104. {{svg "octicon-bell"}}
  105. {{ctx.Locale.Tr "notification.subscriptions"}}
  106. </a>
  107. <a class="{{if .PageIsUserSettings}}active {{end}}item" href="{{AppSubUrl}}/user/settings">
  108. {{svg "octicon-tools"}}
  109. {{ctx.Locale.Tr "your_settings"}}
  110. </a>
  111. <a class="item" target="_blank" rel="noopener noreferrer" href="https://docs.gitea.com">
  112. {{svg "octicon-question"}}
  113. {{ctx.Locale.Tr "help"}}
  114. </a>
  115. <div class="divider"></div>
  116. <a class="item link-action" href data-url="{{AppSubUrl}}/user/logout">
  117. {{svg "octicon-sign-out"}}
  118. {{ctx.Locale.Tr "sign_out"}}
  119. </a>
  120. </div><!-- end content avatar menu -->
  121. </div><!-- end dropdown avatar menu -->
  122. {{else}}
  123. {{if .ShowRegistrationButton}}
  124. <a class="item{{if .PageIsSignUp}} active{{end}}" href="{{AppSubUrl}}/user/sign_up">
  125. {{svg "octicon-person"}}
  126. <span class="tw-ml-1">{{ctx.Locale.Tr "register"}}</span>
  127. </a>
  128. {{end}}
  129. <a class="item{{if .PageIsSignIn}} active{{end}}" rel="nofollow" href="{{AppSubUrl}}/user/login{{if not .PageIsSignIn}}?redirect_to={{.CurrentURL}}{{end}}">
  130. {{svg "octicon-sign-in"}}
  131. <span class="tw-ml-1">{{ctx.Locale.Tr "sign_in"}}</span>
  132. </a>
  133. {{end}}
  134. </div><!-- end full right menu -->
  135. {{$activeStopwatch := and .PageGlobalData (call .PageGlobalData.GetActiveStopwatch)}}
  136. {{if $activeStopwatch}}
  137. <div class="active-stopwatch-popup tippy-target">
  138. <div class="tw-flex tw-items-center tw-gap-2 tw-p-3">
  139. <a class="stopwatch-link tw-flex tw-items-center tw-gap-2 muted" href="{{$activeStopwatch.IssueLink}}">
  140. {{svg "octicon-issue-opened" 16}}
  141. <span class="stopwatch-issue">{{$activeStopwatch.RepoSlug}}#{{$activeStopwatch.IssueIndex}}</span>
  142. </a>
  143. <div class="tw-flex tw-gap-1">
  144. <form class="stopwatch-commit form-fetch-action" method="post" action="{{$activeStopwatch.IssueLink}}/times/stopwatch/stop">
  145. {{.CsrfTokenHtml}}
  146. <button
  147. type="submit"
  148. class="ui button mini compact basic icon tw-mr-0"
  149. data-tooltip-content="{{ctx.Locale.Tr "repo.issues.stop_tracking"}}"
  150. >{{svg "octicon-square-fill"}}</button>
  151. </form>
  152. <form class="stopwatch-cancel form-fetch-action" method="post" action="{{$activeStopwatch.IssueLink}}/times/stopwatch/cancel">
  153. {{.CsrfTokenHtml}}
  154. <button
  155. type="submit"
  156. class="ui button mini compact basic icon tw-mr-0"
  157. data-tooltip-content="{{ctx.Locale.Tr "repo.issues.cancel_tracking"}}"
  158. >{{svg "octicon-trash"}}</button>
  159. </form>
  160. </div>
  161. </div>
  162. </div>
  163. {{end}}
  164. </nav>