diff options
Diffstat (limited to 'templates/base/head_script.tmpl')
-rw-r--r-- | templates/base/head_script.tmpl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/templates/base/head_script.tmpl b/templates/base/head_script.tmpl new file mode 100644 index 0000000000..e6a8060a16 --- /dev/null +++ b/templates/base/head_script.tmpl @@ -0,0 +1,49 @@ +{{/* +==== DO NOT EDIT ==== +If you are customizing Gitea, please do not change this file. +If you introduce mistakes in it, Gitea JavaScript code wouldn't run correctly. +*/}} +<script> + <!-- /* eslint-disable */ --> + window.addEventListener('error', function(e) {window._globalHandlerErrors=window._globalHandlerErrors||[]; window._globalHandlerErrors.push(e);}); + window.config = { + appVer: '{{AppVer}}', + appUrl: '{{AppUrl}}', + appSubUrl: '{{AppSubUrl}}', + assetUrlPrefix: '{{AssetUrlPrefix}}', + runModeIsProd: {{.RunModeIsProd}}, + customEmojis: {{CustomEmojis}}, + useServiceWorker: {{UseServiceWorker}}, + csrfToken: '{{.CsrfToken}}', + pageData: {{.PageData}}, + requireTribute: {{.RequireTribute}}, + notificationSettings: {{NotificationSettings}}, {{/*a map provided by NewFuncMap in helper.go*/}} + enableTimeTracking: {{EnableTimetracking}}, + {{if .RequireTribute}} + tributeValues: Array.from(new Map([ + {{ range .Participants }} + ['{{.Name}}', {key: '{{.Name}} {{.FullName}}', value: '{{.Name}}', + name: '{{.Name}}', fullname: '{{.FullName}}', avatar: '{{.AvatarLink}}'}], + {{ end }} + {{ range .Assignees }} + ['{{.Name}}', {key: '{{.Name}} {{.FullName}}', value: '{{.Name}}', + name: '{{.Name}}', fullname: '{{.FullName}}', avatar: '{{.AvatarLink}}'}], + {{ end }} + {{ range .MentionableTeams }} + ['{{$.MentionableTeamsOrg}}/{{.Name}}', {key: '{{$.MentionableTeamsOrg}}/{{.Name}}', value: '{{$.MentionableTeamsOrg}}/{{.Name}}', + name: '{{$.MentionableTeamsOrg}}/{{.Name}}', avatar: '{{$.MentionableTeamsOrgAvatar}}'}], + {{ end }} + ]).values()), + {{end}} + mermaidMaxSourceCharacters: {{MermaidMaxSourceCharacters}}, + {{/* this global i18n object should only contain general texts. for specialized texts, it should be provided inside the related modules by: (1) API response (2) HTML data-attribute (3) PageData */}} + i18n: { + copy_success: '{{.i18n.Tr "copy_success"}}', + copy_error: '{{.i18n.Tr "copy_error"}}', + error_occurred: '{{.i18n.Tr "error.occurred"}}', + network_error: '{{.i18n.Tr "error.network_error"}}', + }, + }; + {{/* in case some pages don't render the pageData, we make sure it is an object to prevent null access */}} + window.config.pageData = window.config.pageData || {}; +</script> |