my-gitea-templates/templates/base/ head.tmpl
196 lines
8.0 KiB

  1. <!DOCTYPE html>
  2. <html lang="{{.Language}}">
  3. <head data-suburl="{{AppSubUrl}}">
  4. <meta charset="utf-8">
  5. <meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' data:;">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <meta http-equiv="x-ua-compatible" content="ie=edge">
  8. <title>{{if .Repository.Name}}{{.Repository.Name}}{{else}}{{if .Title}}{{.Title}} — {{end}}{{AppName}}{{end}}</title>
  9. {{if UseServiceWorker}}
  10. <script>
  11. if ('serviceWorker' in navigator) {
  12. navigator.serviceWorker.register('{{AppSubUrl}}/serviceworker.js').then(function(registration) {
  13. // Registration was successful
  14. console.info('ServiceWorker registration successful with scope: ', registration.scope);
  15. }, function(err) {
  16. // registration failed :(
  17. console.info('ServiceWorker registration failed: ', err);
  18. });
  19. }
  20. </script>
  21. {{else}}
  22. <script>
  23. if ('serviceWorker' in navigator) {
  24. navigator.serviceWorker.getRegistrations().then(function(registrations) {
  25. registrations.forEach(function(registration) {
  26. registration.unregister();
  27. console.info('ServiceWorker unregistered');
  28. });
  29. });
  30. }
  31. </script>
  32. {{end}}
  33. <meta name="theme-color" content="{{ThemeColorMetaTag}}">
  34. <meta name="author" content="{{if .Repository}}{{.Owner.Name}}{{else}}{{end}}" />
  35. <meta name="description" content="{{if .Repository}}{{.Repository.Name}}{{if .Repository.Description}} - {{.Repository.Description}}{{end}}{{else}}{{end}}" />
  36. <meta name="referrer" content="no-referrer" />
  37. <meta name="_csrf" content="{{.CsrfToken}}" />
  38. {{if .IsSigned}}
  39. <meta name="_uid" content="{{.SignedUser.ID}}" />
  40. {{end}}
  41. {{if .ContextUser}}
  42. <meta name="_context_uid" content="{{.ContextUser.ID}}" />
  43. {{end}}
  44. {{if .SearchLimit}}
  45. <meta name="_search_limit" content="{{.SearchLimit}}" />
  46. {{end}}
  47. {{if .GoGetImport}}
  48. <meta name="go-import" content="{{.GoGetImport}} git {{.CloneLink.HTTPS}}">
  49. <meta name="go-source" content="{{.GoGetImport}} _ {{.GoDocDirectory}} {{.GoDocFile}}">
  50. {{end}}
  51. <script>
  52. {{SafeJS `/*
  53. @licstart The following is the entire license notice for the
  54. JavaScript code in this page.
  55. Copyright (c) 2016 The Gitea Authors
  56. Copyright (c) 2015 The Gogs Authors
  57. Permission is hereby granted, free of charge, to any person obtaining a copy
  58. of this software and associated documentation files (the "Software"), to deal
  59. in the Software without restriction, including without limitation the rights
  60. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  61. copies of the Software, and to permit persons to whom the Software is
  62. furnished to do so, subject to the following conditions:
  63. The above copyright notice and this permission notice shall be included in
  64. all copies or substantial portions of the Software.
  65. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  66. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  67. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  68. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  69. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  70. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  71. THE SOFTWARE.
  72. ---
  73. Licensing information for additional javascript libraries can be found at:
  74. {{StaticUrlPrefix}}/vendor/librejs.html
  75. @licend The above is the entire license notice
  76. for the JavaScript code in this page.
  77. */`}}
  78. </script>
  79. <script>
  80. window.config = {
  81. AppSubUrl: '{{AppSubUrl}}',
  82. StaticUrlPrefix: '{{StaticUrlPrefix}}',
  83. csrf: '{{.CsrfToken}}',
  84. HighlightJS: {{if .RequireHighlightJS}}true{{else}}false{{end}},
  85. Minicolors: {{if .RequireMinicolors}}true{{else}}false{{end}},
  86. SimpleMDE: {{if .RequireSimpleMDE}}true{{else}}false{{end}},
  87. Tribute: {{if .RequireTribute}}true{{else}}false{{end}},
  88. U2F: {{if .RequireU2F}}true{{else}}false{{end}},
  89. Heatmap: {{if .EnableHeatmap}}true{{else}}false{{end}},
  90. heatmapUser: {{if .HeatmapUser}}'{{.HeatmapUser}}'{{else}}null{{end}},
  91. };
  92. </script>
  93. <link rel="shortcut icon" type="image/png" href="{{StaticUrlPrefix}}/img/favicon.png" />
  94. <link rel="shortcut icon" type="image/svg" href="{{StaticUrlPrefix}}/img/favicon.svg" />
  95. <link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/assets/font-awesome/css/font-awesome.min.css">
  96. <link rel="preload" as="font" href="{{StaticUrlPrefix}}/fomantic/themes/default/assets/fonts/icons.woff2" type="font/woff2" crossorigin="anonymous">
  97. <link rel="preload" as="font" href="{{StaticUrlPrefix}}/fomantic/themes/default/assets/fonts/outline-icons.woff2" type="font/woff2" crossorigin="anonymous">
  98. {{if .RequireSimpleMDE}}
  99. <link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/simplemde/simplemde.min.css">
  100. {{end}}
  101. {{if .RequireTribute}}
  102. <link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/plugins/tribute/tribute.css">
  103. {{end}}
  104. <link rel="stylesheet" href="{{StaticUrlPrefix}}/fomantic/semantic.min.css?v={{MD5 AppVer}}">
  105. <link rel="stylesheet" href="{{StaticUrlPrefix}}/css/index.css?v={{MD5 AppVer}}">
  106. <link rel="stylesheet" href="/custom-style.css">
  107. <noscript>
  108. <style>
  109. .dropdown:hover > .menu { display: block; }
  110. .ui.secondary.menu .dropdown.item > .menu { margin-top: 0; }
  111. </style>
  112. </noscript>
  113. {{if .RequireMinicolors}}
  114. <link rel="stylesheet" href="{{StaticUrlPrefix}}/vendor/plugins/jquery.minicolors/jquery.minicolors.css">
  115. {{end}}
  116. <style class="list-search-style"></style>
  117. {{if .PageIsUserProfile}}
  118. <meta property="og:title" content="{{.Owner.Name}}" />
  119. <meta property="og:type" content="profile" />
  120. <meta property="og:image" content="{{.Owner.AvatarLink}}" />
  121. <meta property="og:url" content="{{.Owner.HTMLURL}}" />
  122. {{if .Owner.Description}}
  123. <meta property="og:description" content="{{.Owner.Description}}">
  124. {{end}}
  125. {{else if .Repository}}
  126. {{if .Issue}}
  127. <meta property="og:title" content="{{.Issue.Title}}" />
  128. <meta property="og:url" content="{{.Issue.HTMLURL}}" />
  129. {{if .Issue.Content}}
  130. <meta property="og:description" content="{{.Issue.Content}}" />
  131. {{end}}
  132. {{else}}
  133. <meta property="og:title" content="{{.Repository.Name}}" />
  134. <meta property="og:url" content="{{.Repository.HTMLURL}}" />
  135. {{if .Repository.Description}}
  136. <meta property="og:description" content="{{.Repository.Description}}" />
  137. {{end}}
  138. {{end}}
  139. <meta property="og:type" content="object" />
  140. <meta property="og:image" content="{{.Repository.Owner.AvatarLink}}" />
  141. {{else}}
  142. <meta property="og:title" content="{{AppName}}">
  143. <meta property="og:type" content="website" />
  144. <meta property="og:image" content="{{StaticUrlPrefix}}/img/gitea-lg.png" />
  145. <meta property="og:url" content="{{AppUrl}}" />
  146. <meta property="og:description" content="{{MetaDescription}}">
  147. {{end}}
  148. <meta property="og:site_name" content="{{AppName}}" />
  149. {{if .IsSigned }}
  150. {{ if ne .SignedUser.Theme "gitea" }}
  151. <link rel="stylesheet" href="{{StaticUrlPrefix}}/css/theme-{{.SignedUser.Theme}}.css?v={{MD5 AppVer}}">
  152. {{end}}
  153. {{else if ne DefaultTheme "gitea"}}
  154. <link rel="stylesheet" href="{{StaticUrlPrefix}}/css/theme-{{DefaultTheme}}.css?v={{MD5 AppVer}}">
  155. {{end}}
  156. {{template "custom/header" .}}
  157. </head>
  158. <body>
  159. {{template "custom/body_outer_pre" .}}
  160. <div class="full height">
  161. {{template "custom/body_inner_pre" .}}
  162. {{if .IsSigned}}
  163. {{if gt .SignedUser.MaxRepoCreation 0}}
  164. {{/* a/the ‘first-class citizen’ gets the standard gitea navigation bar */}}
  165. <div class="ui top secondary stackable main menu following bar light">
  166. {{template "base/head_navbar" .}}
  167. </div><!-- end bar -->
  168. {{else}}
  169. <a class="ui primary right corner label link-action" href data-url="{{AppSubUrl}}/user/logout" data-redirect="{{AppSubUrl}}/"
  170. title="{{.i18n.Tr "signed_in_as"}} {{.SignedUser.Name}} — {{.i18n.Tr "sign_out"}}">
  171. <i class="icon">{{svg "octicon-sign-out" 16}}</i>
  172. </a>
  173. {{end}}
  174. {{else}}
  175. <a class="ui{{if .PageIsSignIn}} active{{end}} right corner label" rel="nofollow" href="{{AppSubUrl}}/user/login?redirect_to={{.Link}}"
  176. title="{{.i18n.Tr "sign_in"}}"
  177. >
  178. <i class="icon">{{svg "octicon-sign-in" 16}}</i>
  179. </a>
  180. {{end}}
  181. {{/*
  182. </div>
  183. </body>
  184. </html>
  185. */}}