From dd136858f1ea40ad3c94191d647487fa4f31926c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 18 Oct 2024 20:33:49 +0200 Subject: Adding upstream version 9.0.0. Signed-off-by: Daniel Baumann --- templates/base/alert.tmpl | 23 ++++ templates/base/alert_details.tmpl | 7 + templates/base/disable_form_autofill.tmpl | 31 +++++ templates/base/footer.tmpl | 20 +++ templates/base/footer_content.tmpl | 32 +++++ templates/base/head.tmpl | 50 ++++++++ templates/base/head_navbar.tmpl | 205 ++++++++++++++++++++++++++++++ templates/base/head_opengraph.tmpl | 53 ++++++++ templates/base/head_script.tmpl | 50 ++++++++ templates/base/head_style.tmpl | 2 + templates/base/modal_actions_confirm.tmpl | 35 +++++ templates/base/paginate.tmpl | 34 +++++ 12 files changed, 542 insertions(+) create mode 100644 templates/base/alert.tmpl create mode 100644 templates/base/alert_details.tmpl create mode 100644 templates/base/disable_form_autofill.tmpl create mode 100644 templates/base/footer.tmpl create mode 100644 templates/base/footer_content.tmpl create mode 100644 templates/base/head.tmpl create mode 100644 templates/base/head_navbar.tmpl create mode 100644 templates/base/head_opengraph.tmpl create mode 100644 templates/base/head_script.tmpl create mode 100644 templates/base/head_style.tmpl create mode 100644 templates/base/modal_actions_confirm.tmpl create mode 100644 templates/base/paginate.tmpl (limited to 'templates/base') diff --git a/templates/base/alert.tmpl b/templates/base/alert.tmpl new file mode 100644 index 0000000..e2853d3 --- /dev/null +++ b/templates/base/alert.tmpl @@ -0,0 +1,23 @@ +{{if .Flash.ErrorMsg}} +
+

{{.Flash.ErrorMsg | SanitizeHTML}}

+
+{{end}} +{{if .Flash.SuccessMsg}} +
+

{{.Flash.SuccessMsg | SanitizeHTML}}

+
+{{end}} +{{if .Flash.InfoMsg}} +
+

{{.Flash.InfoMsg | SanitizeHTML}}

+
+{{end}} +{{if .Flash.WarningMsg}} +
+

{{.Flash.WarningMsg | SanitizeHTML}}

+
+{{end}} +{{if and (not .Flash.ErrorMsg) (not .Flash.SuccessMsg) (not .Flash.InfoMsg) (not .Flash.WarningMsg) (not .IsHTMX)}} +
+{{end}} diff --git a/templates/base/alert_details.tmpl b/templates/base/alert_details.tmpl new file mode 100644 index 0000000..6801c82 --- /dev/null +++ b/templates/base/alert_details.tmpl @@ -0,0 +1,7 @@ +{{.Message}} +
+ {{.Summary}} + + {{.Details | SanitizeHTML}} + +
diff --git a/templates/base/disable_form_autofill.tmpl b/templates/base/disable_form_autofill.tmpl new file mode 100644 index 0000000..6f06395 --- /dev/null +++ b/templates/base/disable_form_autofill.tmpl @@ -0,0 +1,31 @@ +{{/* +Why we need to disable form autofill: +1. Many pages contain different password inputs for different usages, eg: repo setting, autofill will make a mess. +2. We have `areYouSure` confirm dialog if a user leaves a pages without submit. +Autofill will make the form changed even if the user didn't input anything. Then the user keeps seeing annoying confirm dialog. + +In history, Gitea put `` in forms to bypass the autofill, +but there were still many forms suffered the autofill problem. + +Now we improve it. + +Solutions which do NOT work: +1. Adding `autocomplete=off` doesn't help. New Chrome completely ignores it. +2. Use a JavaScript to run in a few seconds later after the page is loaded to process the autofilled inputs, it doesn't work. +Because for security reason, the inputs won't be filled before the user makes an interaction in the page. +So we can not predict the correct time to run the JavaScript code. + +Solutions which work: +1. Some hacky methods like: https://github.com/matteobad/detect-autofill +2. This solution: use invisible inputs. Be aware of: +(a) The inputs must be at the beginning of the form, and can not be hidden. +(b) The input for username must have a valid name. +(c) There should be no negative word (eg: fake) in the `name` attribute. +(d) Chrome seems to use a weighted algorithm to choose an input to fill text, so the using "username" as input name is better than using "user". +We make the names of these dummy inputs begin with an underline to indicate it is for special usage, +and these dummy form values won't be used by backend code. +*/}} + diff --git a/templates/base/footer.tmpl b/templates/base/footer.tmpl new file mode 100644 index 0000000..fed426a --- /dev/null +++ b/templates/base/footer.tmpl @@ -0,0 +1,20 @@ +{{if false}} + {{/* to make html structure "likely" complete to prevent IDE warnings */}} + + +
+{{end}} + + {{template "custom/body_inner_post" .}} + +
+ + {{template "custom/body_outer_post" .}} + + {{template "base/footer_content" .}} + + + + {{template "custom/footer" .}} + + diff --git a/templates/base/footer_content.tmpl b/templates/base/footer_content.tmpl new file mode 100644 index 0000000..5db7464 --- /dev/null +++ b/templates/base/footer_content.tmpl @@ -0,0 +1,32 @@ +
+ + +
diff --git a/templates/base/head.tmpl b/templates/base/head.tmpl new file mode 100644 index 0000000..7753f49 --- /dev/null +++ b/templates/base/head.tmpl @@ -0,0 +1,50 @@ + + + + + {{/* Display `- .Repository.FullName` only if `.Title` does not already start with that. */}} + {{if .Title}}{{.Title}} - {{end}}{{if and (.Repository.Name) (not (StringUtils.HasPrefix .Title .Repository.FullName))}}{{.Repository.FullName}} - {{end}}{{AppDisplayName}} + {{if .ManifestData}}{{end}} + + + + +{{if .GoGetImport}} + + +{{end}} +{{if and .EnableFeed .FeedURL}} + + +{{end}} + + + {{template "base/head_script" .}} + + {{template "base/head_opengraph" .}} + {{template "base/head_style" .}} + {{template "custom/header" .}} + + + {{template "custom/body_outer_pre" .}} + +
+ + + {{template "custom/body_inner_pre" .}} + + {{if not .PageIsInstall}} + {{template "base/head_navbar" .}} + {{end}} + +{{if false}} + {{/* to make html structure "likely" complete to prevent IDE warnings */}} +
+ + +{{end}} diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl new file mode 100644 index 0000000..ba17222 --- /dev/null +++ b/templates/base/head_navbar.tmpl @@ -0,0 +1,205 @@ +{{$notificationUnreadCount := 0}} +{{if and .IsSigned .NotificationUnreadCount}} + {{$notificationUnreadCount = call .NotificationUnreadCount}} +{{end}} + + diff --git a/templates/base/head_opengraph.tmpl b/templates/base/head_opengraph.tmpl new file mode 100644 index 0000000..292c3bd --- /dev/null +++ b/templates/base/head_opengraph.tmpl @@ -0,0 +1,53 @@ +{{- /* og:description - a one to two sentence description of your object, maybe it only needs at most 300 bytes */ -}} +{{if .PageIsUserProfile}} + + + + + {{if .ContextUser.Description}} + + {{end}} +{{else if .Repository}} + {{if .Issue}} + + + {{if .Issue.Content}} + + {{end}} + {{else if or .PageIsDiff .IsViewFile}} + + + {{if and .PageIsDiff .Commit}} + {{- $commitMessageParts := StringUtils.Cut .Commit.Message "\n" -}} + {{- $commitMessageBody := index $commitMessageParts 1 -}} + {{- if $commitMessageBody -}} + + {{- end -}} + {{end}} + {{else if .Pages}} + + + {{if .Repository.Description}} + + {{end}} + {{else}} + + + {{if .Repository.Description}} + + {{end}} + {{end}} + + {{if (.Repository.AvatarLink ctx)}} + + {{else}} + + {{end}} +{{else}} + + + + + +{{end}} + diff --git a/templates/base/head_script.tmpl b/templates/base/head_script.tmpl new file mode 100644 index 0000000..22e08e9 --- /dev/null +++ b/templates/base/head_script.tmpl @@ -0,0 +1,50 @@ +{{/* +==== 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. +*/}} + + diff --git a/templates/base/head_style.tmpl b/templates/base/head_style.tmpl new file mode 100644 index 0000000..0793eac --- /dev/null +++ b/templates/base/head_style.tmpl @@ -0,0 +1,2 @@ + + diff --git a/templates/base/modal_actions_confirm.tmpl b/templates/base/modal_actions_confirm.tmpl new file mode 100644 index 0000000..c44320d --- /dev/null +++ b/templates/base/modal_actions_confirm.tmpl @@ -0,0 +1,35 @@ +{{/* +Two buttons (negative, positive): +* ModalButtonTypes: "yes" (default) or "confirm" +* ModalButtonColors: "primary" (default) / "blue" / "yellow" +* ModalButtonCancelText +* ModalButtonOkText + +Single danger button (GitHub-like): +* ModalButtonDangerText "This action will destroy your data" + +The ".ok.button" and ".cancel.button" selectors are also used by Fomantic Modal internally +*/}} +
+ {{if .ModalButtonDangerText}} + + {{else}} + {{$textNegitive := ctx.Locale.Tr "modal.no"}} + {{$textPositive := ctx.Locale.Tr "modal.yes"}} + {{if eq .ModalButtonTypes "confirm"}} + {{$textNegitive = ctx.Locale.Tr "modal.cancel"}} + {{$textPositive = ctx.Locale.Tr "modal.confirm"}} + {{end}} + {{if .ModalButtonCancelText}}{{$textNegitive = .ModalButtonCancelText}}{{end}} + {{if .ModalButtonOkText}}{{$textPositive = .ModalButtonOkText}}{{end}} + + {{$stylePositive := "primary"}} + {{if eq .ModalButtonColors "blue"}} + {{$stylePositive = "blue"}} + {{else if eq .ModalButtonColors "yellow"}} + {{$stylePositive = "yellow"}} + {{end}} + + + {{end}} +
diff --git a/templates/base/paginate.tmpl b/templates/base/paginate.tmpl new file mode 100644 index 0000000..2ca72f6 --- /dev/null +++ b/templates/base/paginate.tmpl @@ -0,0 +1,34 @@ +{{$paginationParams := .Page.GetParams}} +{{$paginationLink := $.Link}} +{{if eq $paginationLink AppSubUrl}}{{$paginationLink = print $paginationLink "/"}}{{end}} +{{with .Page.Paginater}} + {{if gt .TotalPages 1}} + + {{end}} +{{end}} -- cgit v1.2.3