From efd51762781d4ba57c459190846a26636aef6564 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sun, 24 Sep 2023 21:07:57 +0800 Subject: [PATCH 001/238] Fix Fomantic UI dropdown icon bug when there is a search input in menu (#27225) Fix #27224 And add the case to the devtest page. --- templates/devtest/gitea-ui.tmpl | 1 + web_src/js/modules/fomantic.js | 3 +++ 2 files changed, 4 insertions(+) diff --git a/templates/devtest/gitea-ui.tmpl b/templates/devtest/gitea-ui.tmpl index 258b72f8cd..e15ed0b8df 100644 --- a/templates/devtest/gitea-ui.tmpl +++ b/templates/devtest/gitea-ui.tmpl @@ -171,6 +171,7 @@ simple {{svg "octicon-triangle-down" 14 "dropdown icon"}} diff --git a/web_src/js/modules/fomantic.js b/web_src/js/modules/fomantic.js index ab5f842bc6..3d4a66c1ea 100644 --- a/web_src/js/modules/fomantic.js +++ b/web_src/js/modules/fomantic.js @@ -16,6 +16,9 @@ export function initGiteaFomantic() { $.fn.dropdown.settings.fullTextSearch = 'exact'; // Do not use "cursor: pointer" for dropdown labels $.fn.dropdown.settings.className.label += ' gt-cursor-default'; + // The default selector has a bug: if there is a "search input" in the "menu", Fomantic will only "focus the input" but not "toggle the menu" when the "dropdown icon" is clicked. + // Actually, the "search input in menu" shouldn't be considered as the dropdown's input + $.fn.dropdown.settings.selector.search = '> input.search, :not(.menu) > .search > input, :not(.menu) input.search'; // Always use Gitea's SVG icons $.fn.dropdown.settings.templates.label = function(_value, text, preserveHTML, className) { const escape = $.fn.dropdown.settings.templates.escape; From 63b25e816db6862bad9ad14ab272901b5570f48b Mon Sep 17 00:00:00 2001 From: Denys Konovalov Date: Sun, 24 Sep 2023 20:12:21 +0200 Subject: [PATCH 002/238] fix issues on action runners page (#27226) - switch from some weird status badge to label - translate untranslated `Reset registration token` string - change documentation link from act_runner README to Gitea Docs site - fix "No runners available" message width - use `ctx.Locale.Tr` where possible ![grafik](https://github.com/go-gitea/gitea/assets/47871822/65547228-f9ed-4f80-9cfd-df5e55513a44) --- options/locale/locale_en-US.ini | 1 + templates/shared/actions/runner_edit.tmpl | 2 +- templates/shared/actions/runner_list.tmpl | 37 +++++++++++------------ web_src/css/actions.css | 6 ---- 4 files changed, 20 insertions(+), 26 deletions(-) diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 74b8931de8..035dc9b9e3 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -3507,6 +3507,7 @@ runners.status.idle = Idle runners.status.active = Active runners.status.offline = Offline runners.version = Version +runners.reset_registration_token = Reset registration token runners.reset_registration_token_success = Runner registration token reset successfully runs.all_workflows = All Workflows diff --git a/templates/shared/actions/runner_edit.tmpl b/templates/shared/actions/runner_edit.tmpl index ec3c25ab87..46bd981999 100644 --- a/templates/shared/actions/runner_edit.tmpl +++ b/templates/shared/actions/runner_edit.tmpl @@ -9,7 +9,7 @@
- {{.Runner.StatusLocaleName $.locale}} + {{.Runner.StatusLocaleName $.locale}}
diff --git a/templates/shared/actions/runner_list.tmpl b/templates/shared/actions/runner_list.tmpl index ead260f128..8c01766edd 100644 --- a/templates/shared/actions/runner_list.tmpl +++ b/templates/shared/actions/runner_list.tmpl @@ -1,17 +1,16 @@

- {{.locale.Tr "actions.runners.runner_manage_panel"}} ({{.locale.Tr "admin.total" .Total}}) + {{ctx.Locale.Tr "actions.runners.runner_manage_panel"}} ({{ctx.Locale.Tr "admin.total" .Total}})
@@ -37,7 +36,7 @@
{{template "shared/searchinput" dict "locale" .locale "Value" .Keyword "AutoFocus" true}} - +
@@ -46,22 +45,22 @@ - {{.locale.Tr "actions.runners.status"}} + {{ctx.Locale.Tr "actions.runners.status"}} {{SortArrow "online" "offline" .SortType false}} - {{.locale.Tr "actions.runners.id"}} + {{ctx.Locale.Tr "actions.runners.id"}} {{SortArrow "oldest" "newest" .SortType false}} - {{.locale.Tr "actions.runners.name"}} + {{ctx.Locale.Tr "actions.runners.name"}} {{SortArrow "alphabetically" "reversealphabetically" .SortType false}} - {{.locale.Tr "actions.runners.version"}} - {{.locale.Tr "actions.runners.owner_type"}} - {{.locale.Tr "actions.runners.labels"}} - {{.locale.Tr "actions.runners.last_online"}} - {{.locale.Tr "edit"}} + {{ctx.Locale.Tr "actions.runners.version"}} + {{ctx.Locale.Tr "actions.runners.owner_type"}} + {{ctx.Locale.Tr "actions.runners.labels"}} + {{ctx.Locale.Tr "actions.runners.last_online"}} + {{ctx.Locale.Tr "edit"}} @@ -69,16 +68,16 @@ {{range .Runners}} - {{.StatusLocaleName $.locale}} + {{.StatusLocaleName $.locale}} {{.ID}}

{{.Name}}

- {{if .Version}}{{.Version}}{{else}}{{$.locale.Tr "unknown"}}{{end}} + {{if .Version}}{{.Version}}{{else}}{{ctx.Locale.Tr "unknown"}}{{end}} {{.BelongsToOwnerType.LocaleString $.locale}} {{range .AgentLabels}}{{.}}{{end}} - {{if .LastOnline}}{{TimeSinceUnix .LastOnline $.locale}}{{else}}{{$.locale.Tr "never"}}{{end}} + {{if .LastOnline}}{{TimeSinceUnix .LastOnline $.locale}}{{else}}{{ctx.Locale.Tr "never"}}{{end}} {{if .Editable $.RunnerOwnerID $.RunnerRepoID}} {{svg "octicon-pencil"}} @@ -88,7 +87,7 @@ {{end}} {{else}} - {{.locale.Tr "actions.runners.none"}} + {{ctx.Locale.Tr "actions.runners.none"}} {{end}} diff --git a/web_src/css/actions.css b/web_src/css/actions.css index f081698c66..e353a013a7 100644 --- a/web_src/css/actions.css +++ b/web_src/css/actions.css @@ -18,12 +18,6 @@ margin-right: 1em; } -.runner-container .runner-status-online { - padding: 0.3em 0.5em; - background-color: var(--color-green); - color: var(--color-white); -} - .runner-container .runner-new-text { color: var(--color-white); } From 8e23524b18f4075e7db3dc1a7270abc0d9793dcb Mon Sep 17 00:00:00 2001 From: Nabapadma-sarker Date: Mon, 25 Sep 2023 04:02:47 +0900 Subject: [PATCH 003/238] Fix PushEvent NullPointerException jenkinsci/github-plugin (#27203) Fixes #27202 --- modules/structs/repo.go | 1 + services/convert/repository.go | 1 + templates/swagger/v1_json.tmpl | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 6a2ba4836b..3974c4db3a 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -63,6 +63,7 @@ type Repository struct { Language string `json:"language"` LanguagesURL string `json:"languages_url"` HTMLURL string `json:"html_url"` + URL string `json:"url"` Link string `json:"link"` SSHURL string `json:"ssh_url"` CloneURL string `json:"clone_url"` diff --git a/services/convert/repository.go b/services/convert/repository.go index 6f77b4932e..71038cd062 100644 --- a/services/convert/repository.go +++ b/services/convert/repository.go @@ -181,6 +181,7 @@ func innerToRepo(ctx context.Context, repo *repo_model.Repository, permissionInR Parent: parent, Mirror: repo.IsMirror, HTMLURL: repo.HTMLURL(), + URL: repoAPIURL, SSHURL: cloneLink.SSH, CloneURL: cloneLink.HTTPS, OriginalURL: repo.SanitizedOriginalURL(), diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index a9a69bc82a..abe579ac82 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -22114,6 +22114,10 @@ "format": "date-time", "x-go-name": "Updated" }, + "url": { + "type": "string", + "x-go-name": "URL" + }, "watchers_count": { "type": "integer", "format": "int64", From 3a187eace5643a3dc681f87bdd8d0edbb742aa8f Mon Sep 17 00:00:00 2001 From: silverwind Date: Sun, 24 Sep 2023 21:51:02 +0200 Subject: [PATCH 004/238] Fix EOL handling in web editor (#27141) Fixes https://github.com/go-gitea/gitea/issues/27136. This does the following for Monaco's EOL setting: 1. Use editorconfig setting if present 2. Use the file's dominant line ending as detected by monaco, which uses LF for empty file --- routers/web/repo/editor.go | 2 +- templates/repo/editor/edit.tmpl | 7 ++++--- web_src/js/features/codeeditor.js | 19 +++++++++++++++++-- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/routers/web/repo/editor.go b/routers/web/repo/editor.go index 0a606582e5..9d9fee3a77 100644 --- a/routers/web/repo/editor.go +++ b/routers/web/repo/editor.go @@ -287,7 +287,7 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b Operation: operation, FromTreePath: ctx.Repo.TreePath, TreePath: form.TreePath, - ContentReader: strings.NewReader(strings.ReplaceAll(form.Content, "\r", "")), + ContentReader: strings.NewReader(form.Content), }, }, Signoff: form.Signoff, diff --git a/templates/repo/editor/edit.tmpl b/templates/repo/editor/edit.tmpl index 2b303be97c..abe2e345fc 100644 --- a/templates/repo/editor/edit.tmpl +++ b/templates/repo/editor/edit.tmpl @@ -34,12 +34,13 @@ {{end}}

- + data-line-wrap-extensions="{{.LineWrapExtensions}}" + data-initial-value="{{JsonUtils.EncodeToString .FileContent}}">
diff --git a/web_src/js/features/codeeditor.js b/web_src/js/features/codeeditor.js index 7dbbcd3dd6..5f924fd086 100644 --- a/web_src/js/features/codeeditor.js +++ b/web_src/js/features/codeeditor.js @@ -62,7 +62,7 @@ export async function createMonaco(textarea, filename, editorOpts) { const monaco = await import(/* webpackChunkName: "monaco" */'monaco-editor'); initLanguages(monaco); - let {language, ...other} = editorOpts; + let {language, eol, ...other} = editorOpts; if (!language) language = getLanguage(filename); const container = document.createElement('div'); @@ -105,14 +105,28 @@ export async function createMonaco(textarea, filename, editorOpts) { monaco.languages.register({id: 'vs.editor.nullLanguage'}); monaco.languages.setLanguageConfiguration('vs.editor.nullLanguage', {}); + // We encode the initial value in JSON on the backend to prevent browsers from + // discarding the \r during HTML parsing: + // https://html.spec.whatwg.org/multipage/parsing.html#preprocessing-the-input-stream + const value = JSON.parse(textarea.getAttribute('data-initial-value') || '""'); + textarea.value = value; + textarea.removeAttribute('data-initial-value'); + const editor = monaco.editor.create(container, { - value: textarea.value, + value, theme: 'gitea', language, ...other, }); const model = editor.getModel(); + + // Monaco performs auto-detection of dominant EOL in the file, biased towards LF for + // empty files. If there is an editorconfig value, override this detected value. + if (eol in monaco.editor.EndOfLineSequence) { + model.setEOL(monaco.editor.EndOfLineSequence[eol]); + } + model.onDidChangeContent(() => { textarea.value = editor.getValue(); textarea.dispatchEvent(new Event('change')); // seems to be needed for jquery-are-you-sure @@ -187,5 +201,6 @@ function getEditorConfigOptions(ec) { opts.trimAutoWhitespace = ec.trim_trailing_whitespace === true; opts.insertSpaces = ec.indent_style === 'space'; opts.useTabStops = ec.indent_style === 'tab'; + opts.eol = ec.end_of_line?.toUpperCase(); return opts; } From 2325fe777dcb8c8bbaea84718dcfbdc298d33304 Mon Sep 17 00:00:00 2001 From: Denys Konovalov Date: Sun, 24 Sep 2023 22:31:58 +0200 Subject: [PATCH 005/238] cleanup locale function usage (#27227) --- templates/admin/base/search.tmpl | 2 +- templates/admin/emails/list.tmpl | 2 +- templates/admin/packages/list.tmpl | 2 +- templates/admin/repo/search.tmpl | 2 +- templates/admin/repo/unadopted.tmpl | 4 +-- templates/admin/user/list.tmpl | 2 +- templates/base/modal_actions_confirm.tmpl | 11 +++---- templates/code/searchform.tmpl | 2 +- templates/devtest/fomantic-modal.tmpl | 16 ++++----- templates/explore/repo_search.tmpl | 2 +- templates/explore/search.tmpl | 2 +- templates/package/shared/list.tmpl | 2 +- templates/package/shared/versionlist.tmpl | 2 +- templates/projects/list.tmpl | 2 +- templates/projects/view.tmpl | 4 +-- templates/repo/actions/runs_list.tmpl | 2 +- templates/repo/actions/status.tmpl | 2 +- templates/repo/blame.tmpl | 2 +- templates/repo/branch/list.tmpl | 4 +-- templates/repo/commit_statuses.tmpl | 2 +- templates/repo/diff/blob_excerpt.tmpl | 14 ++++---- templates/repo/diff/box.tmpl | 1 - templates/repo/diff/comment_form.tmpl | 13 ++++---- templates/repo/diff/comments.tmpl | 18 +++++----- templates/repo/diff/escape_title.tmpl | 4 +-- templates/repo/diff/new_review.tmpl | 1 - templates/repo/diff/section_split.tmpl | 28 ++++++++-------- templates/repo/diff/section_unified.tmpl | 8 ++--- templates/repo/issue/comment_tab.tmpl | 1 - templates/repo/issue/fields/textarea.tmpl | 1 - templates/repo/issue/milestones.tmpl | 2 +- templates/repo/issue/search.tmpl | 2 +- templates/repo/issue/view_content.tmpl | 1 - .../view_content/comments_delete_time.tmpl | 2 +- templates/repo/issue/view_content/pull.tmpl | 2 +- .../view_content/pull_merge_instruction.tmpl | 20 +++++------ templates/repo/release/new.tmpl | 1 - templates/repo/settings/lfs.tmpl | 2 +- templates/repo/shabox_badge.tmpl | 6 ++-- templates/repo/unicode_escape_prompt.tmpl | 10 +++--- templates/repo/wiki/new.tmpl | 1 - templates/shared/actions/runner_list.tmpl | 2 +- templates/shared/combomarkdowneditor.tmpl | 33 +++++++++---------- templates/shared/searchinput.tmpl | 2 +- templates/shared/secrets/add_list.tmpl | 2 +- templates/shared/variables/variable_list.tmpl | 2 +- templates/user/dashboard/issues.tmpl | 2 +- templates/user/dashboard/milestones.tmpl | 2 +- templates/user/settings/applications.tmpl | 2 +- 49 files changed, 121 insertions(+), 133 deletions(-) diff --git a/templates/admin/base/search.tmpl b/templates/admin/base/search.tmpl index 865cc8830f..22f839bf05 100644 --- a/templates/admin/base/search.tmpl +++ b/templates/admin/base/search.tmpl @@ -1,7 +1,7 @@ @@ -36,7 +36,7 @@
- {{template "base/modal_actions_confirm" (dict "locale" $.locale "ModalButtonTypes" "confirm")}} + {{template "base/modal_actions_confirm" (dict "ModalButtonTypes" "confirm")}}
@@ -45,25 +45,25 @@
very long aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
- {{template "base/modal_actions_confirm" (dict "locale" $.locale)}} + {{template "base/modal_actions_confirm"}}
@@ -258,7 +258,7 @@ - {{template "base/modal_actions_confirm" (dict "locale" $.locale "ModalButtonTypes" "confirm")}} + {{template "base/modal_actions_confirm" (dict "ModalButtonTypes" "confirm")}} {{template "base/footer" .}} diff --git a/templates/repo/commit_statuses.tmpl b/templates/repo/commit_statuses.tmpl index 20a59bf0d7..0006dcb4a7 100644 --- a/templates/repo/commit_statuses.tmpl +++ b/templates/repo/commit_statuses.tmpl @@ -14,7 +14,7 @@ {{template "repo/commit_status" .}} {{.Context}} {{.Description}} {{if .TargetURL}} - {{$.root.locale.Tr "repo.pulls.status_checks_details"}} + {{ctx.Locale.Tr "repo.pulls.status_checks_details"}} {{end}} {{end}} diff --git a/templates/repo/diff/blob_excerpt.tmpl b/templates/repo/diff/blob_excerpt.tmpl index 23149f611a..feb2aa5738 100644 --- a/templates/repo/diff/blob_excerpt.tmpl +++ b/templates/repo/diff/blob_excerpt.tmpl @@ -22,22 +22,22 @@ {{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}}{{/* - */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}} + */}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}} {{else}} {{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}} - {{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}{{end}} + {{if and $line.LeftIdx $inlineDiff.EscapeStatus.Escaped}}{{end}} {{if $line.LeftIdx}}{{end}} {{/* - */}}{{if $line.LeftIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}}{{else}}{{/* + */}}{{if $line.LeftIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{else}}{{/* */}}{{/* */}}{{end}}{{/* */}} - {{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}{{end}} + {{if and $line.RightIdx $inlineDiff.EscapeStatus.Escaped}}{{end}} {{if $line.RightIdx}}{{end}} {{/* - */}}{{if $line.RightIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff "locale" $.locale}}{{else}}{{/* + */}}{{if $line.RightIdx}}{{template "repo/diff/section_code" dict "diff" $inlineDiff}}{{else}}{{/* */}}{{/* */}}{{end}}{{/* */}} @@ -72,9 +72,9 @@ {{end}} {{$inlineDiff := $.section.GetComputedInlineDiffFor $line $.locale}} - {{if $inlineDiff.EscapeStatus.Escaped}}{{end}} + {{if $inlineDiff.EscapeStatus.Escaped}}{{end}} - {{$inlineDiff.Content}} + {{$inlineDiff.Content}} {{end}} {{end}} diff --git a/templates/repo/diff/box.tmpl b/templates/repo/diff/box.tmpl index 2e1461226a..ff3fc7aef7 100644 --- a/templates/repo/diff/box.tmpl +++ b/templates/repo/diff/box.tmpl @@ -225,7 +225,6 @@