diff options
author | silverwind <me@silverwind.io> | 2023-06-14 20:17:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-14 18:17:58 +0000 |
commit | e24f651c86a5168da8181f2c75f5f99b56561224 (patch) | |
tree | 1f604dc894e29a0c99adca856bd55ad1ca78d4be /templates/repo | |
parent | a0eaf0881235d41ca98f4718af815908d1237d2c (diff) | |
download | gitea-e24f651c86a5168da8181f2c75f5f99b56561224.tar.gz gitea-e24f651c86a5168da8181f2c75f5f99b56561224.zip |
Add template linting via djlint (#25212)
So I found this [linter](https://github.com/Riverside-Healthcare/djlint)
which features a mode for go templates, so I gave it a try and it did
find a number of valid issue, like unbalanced tags etc. It also has a
number of bugs, I had to disable/workaround many issues.
Given that this linter is written in python, this does add a dependency
on `python` >= 3.8 and `poetry` to the development environment to be
able to run this linter locally.
- `e.g.` prefixes on placeholders are removed because the linter had a
false-positive on `placeholder="e.g. cn=Search"` for the `attr=value`
syntax and it's not ideal anyways to write `e.g.` into a placeholder
because a placeholder is meant to hold a sample value.
- In `templates/repo/settings/options.tmpl` I simplified the logic to
not conditionally create opening tags without closing tags because this
stuff confuses the linter (and possibly the reader as well).
Diffstat (limited to 'templates/repo')
22 files changed, 71 insertions, 112 deletions
diff --git a/templates/repo/blame.tmpl b/templates/repo/blame.tmpl index c7116a5f59..b253c4d901 100644 --- a/templates/repo/blame.tmpl +++ b/templates/repo/blame.tmpl @@ -56,7 +56,7 @@ {{end}} </td> {{end}} - <td rel="L{{$row.RowNumber}}" rel="L{{$row.RowNumber}}" class="lines-code blame-code chroma"> + <td rel="L{{$row.RowNumber}}" class="lines-code blame-code chroma"> <code class="code-inner gt-pl-3">{{$row.Code}}</code> </td> </tr> diff --git a/templates/repo/commit_page.tmpl b/templates/repo/commit_page.tmpl index 5e26c04fd8..2e8732b40b 100644 --- a/templates/repo/commit_page.tmpl +++ b/templates/repo/commit_page.tmpl @@ -19,7 +19,7 @@ {{end}} <div class="ui top attached header clearing segment gt-relative commit-header {{$class}}"> <div class="gt-df gt-mb-4 gt-fw"> - <h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "root" $}}</h3> + <h3 class="gt-mb-0 gt-f1"><span class="commit-summary" title="{{.Commit.Summary}}">{{RenderCommitMessage $.Context .Commit.Message $.RepoLink $.Repository.ComposeMetas}}</span>{{template "repo/commit_statuses" dict "Status" .CommitStatus "Statuses" .CommitStatuses "root" $}}</h3> {{if not $.PageIsWiki}} <div> <a class="ui primary tiny button" href="{{.SourcePath}}"> @@ -70,7 +70,7 @@ "branchForm" "branch-dropdown-form" "branchURLPrefix" (printf "%s/_cherrypick/%s/" $.RepoLink .CommitID) "branchURLSuffix" "" "setAction" true "submitForm" true}} - <form method="GET" action="{{$.RepoLink}}/_cherrypick/{{.CommitID}}/{{if $.BranchName}}{{PathEscapeSegments $.BranchName}}{{else}}{{PathEscapeSegments $.Repository.DefaultBranch}}{{end}}" id="branch-dropdown-form"> + <form method="get" action="{{$.RepoLink}}/_cherrypick/{{.CommitID}}/{{if $.BranchName}}{{PathEscapeSegments $.BranchName}}{{else}}{{PathEscapeSegments $.Repository.DefaultBranch}}{{end}}" id="branch-dropdown-form"> <input type="hidden" name="ref" value="{{if $.BranchName}}{{$.BranchName}}{{else}}{{$.Repository.DefaultBranch}}{{end}}"> <input type="hidden" name="refType" value="branch"> <input type="hidden" id="cherry-pick-type" name="cherry-pick-type"><br> diff --git a/templates/repo/commits_list.tmpl b/templates/repo/commits_list.tmpl index 36333c5540..0073ee1562 100644 --- a/templates/repo/commits_list.tmpl +++ b/templates/repo/commits_list.tmpl @@ -52,7 +52,9 @@ {{if .Signature}} {{template "repo/shabox_badge" dict "root" $ "verification" .Verification}} {{end}} - {{if $.Reponame}} + {{if $.PageIsWiki}} + </a> + {{else if $.Reponame}} </a> {{else}} </span> diff --git a/templates/repo/diff/section_code.tmpl b/templates/repo/diff/section_code.tmpl index c95ce83fc4..3e8303eda6 100644 --- a/templates/repo/diff/section_code.tmpl +++ b/templates/repo/diff/section_code.tmpl @@ -1,6 +1 @@ -<code {{if .diff.EscapeStatus.Escaped}}{{/* - */}}class="code-inner has-escaped" {{/* - */}}title="{{template "repo/diff/escape_title" .}}"{{/* - */}}{{else}}{{/* - */}}class="code-inner"{{/* - */}}{{end}}>{{.diff.Content}}</code> +<code class="code-inner{{if .diff.EscapeStatus.Escaped}} has-escaped{{end}}"{{if .diff.EscapeStatus.Escaped}} title="{{template "repo/diff/escape_title" .}}"{{end}}>{{.diff.Content}}</code> diff --git a/templates/repo/diff/section_split.tmpl b/templates/repo/diff/section_split.tmpl index 1c9bfed04e..6a8a105e2b 100644 --- a/templates/repo/diff/section_split.tmpl +++ b/templates/repo/diff/section_split.tmpl @@ -43,7 +43,7 @@ {{- $leftDiff := ""}}{{if $line.LeftIdx}}{{$leftDiff = $section.GetComputedInlineDiffFor $line $.root.locale}}{{end}} {{- $rightDiff := ""}}{{if $match.RightIdx}}{{$rightDiff = $section.GetComputedInlineDiffFor $match $.root.locale}}{{end}} <td class="lines-num lines-num-old del-code" data-line-num="{{$line.LeftIdx}}"><span rel="diff-{{$file.NameHash}}L{{$line.LeftIdx}}"></span></td> - <td class="lines-escape del-code lines-escape-old">{{if $line.LeftIdx}}{{if $leftDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $leftDiff "locale" $.root.locale}}"></a>{{end}}{{end}}</td> + <td class="lines-escape del-code lines-escape-old">{{if $line.LeftIdx}}{{if $leftDiff.EscapeStatus.Escaped}}<button class="toggle-escape-button btn interact-bg" title="{{template "repo/diff/escape_title" dict "diff" $leftDiff "locale" $.root.locale}}"></button>{{end}}{{end}}</td> <td class="lines-type-marker lines-type-marker-old del-code"><span class="gt-mono" data-type-marker="{{$line.GetLineTypeMarker}}"></span></td> <td class="lines-code lines-code-old del-code">{{/* */}}{{if and $.root.SignedUserID $.root.PageIsPullFiles}}{{/* diff --git a/templates/repo/diff/whitespace_dropdown.tmpl b/templates/repo/diff/whitespace_dropdown.tmpl index 4d9b00cb55..2b27a56c04 100644 --- a/templates/repo/diff/whitespace_dropdown.tmpl +++ b/templates/repo/diff/whitespace_dropdown.tmpl @@ -12,7 +12,7 @@ <label class="gt-pointer-events-none"> <input class="gt-mr-3 gt-pointer-events-none" type="radio"{{if eq .WhitespaceBehavior "ignore-all"}} checked{{end}}> {{.locale.Tr "repo.diff.whitespace_ignore_all_whitespace"}} - <label> + </label> </a> <a class="item" href="?style={{if .IsSplitStyle}}split{{else}}unified{{end}}&whitespace=ignore-change"> <label class="gt-pointer-events-none"> diff --git a/templates/repo/editor/cherry_pick.tmpl b/templates/repo/editor/cherry_pick.tmpl index 4f1937b848..828addb75a 100644 --- a/templates/repo/editor/cherry_pick.tmpl +++ b/templates/repo/editor/cherry_pick.tmpl @@ -3,7 +3,7 @@ {{template "repo/header" .}} <div class="ui container"> {{template "base/alert" .}} - <form class="ui edit form" method="post" action="{{.RepoLink}}/_cherrypick/{{.SHA}}/{{.BranchName | PathEscapeSegments}}"> + <form class="ui edit form" method="post" action="{{.RepoLink}}/_cherrypick/{{.SHA}}/{{.BranchName | PathEscapeSegments}}"> {{.CsrfTokenHtml}} <input type="hidden" name="last_commit" value="{{.last_commit}}"> <input type="hidden" name="page_has_posted" value="true"> @@ -11,7 +11,7 @@ <div class="repo-editor-header"> <div class="ui breadcrumb field {{if .Err_TreePath}}error{{end}}"> {{$shaurl := printf "%s/commit/%s" $.RepoLink (PathEscape .SHA)}} - {{$shalink := printf "<a class=\"ui primary sha label\" href=\"%s\">%s</a>" (Escape $shaurl) (ShortSha .SHA)}} + {{$shalink := printf `<a class="ui primary sha label" href="%s">%s</a>` (Escape $shaurl) (ShortSha .SHA)}} {{if eq .CherryPickType "revert"}} {{.locale.Tr "repo.editor.revert" $shalink | Str2html}} {{else}} diff --git a/templates/repo/editor/patch.tmpl b/templates/repo/editor/patch.tmpl index 4f4032e81c..581a80e827 100644 --- a/templates/repo/editor/patch.tmpl +++ b/templates/repo/editor/patch.tmpl @@ -3,7 +3,7 @@ {{template "repo/header" .}} <div class="ui container"> {{template "base/alert" .}} - <form class="ui edit form" method="post" action="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}"> + <form class="ui edit form" method="post" action="{{.RepoLink}}/_diffpatch/{{.BranchName | PathEscapeSegments}}"> {{.CsrfTokenHtml}} <input type="hidden" name="last_commit" value="{{.last_commit}}"> <input type="hidden" name="page_has_posted" value="{{.PageHasPosted}}"> diff --git a/templates/repo/header.tmpl b/templates/repo/header.tmpl index 33791fd512..c1d4676d68 100644 --- a/templates/repo/header.tmpl +++ b/templates/repo/header.tmpl @@ -169,7 +169,7 @@ {{if .Permission.CanRead $.UnitTypeExternalTracker}} <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer"> - {{svg "octicon-link-external"}} {{.locale.Tr "repo.issues"}} </span> + {{svg "octicon-link-external"}} {{.locale.Tr "repo.issues"}} </a> {{end}} diff --git a/templates/repo/issue/branch_selector_field.tmpl b/templates/repo/issue/branch_selector_field.tmpl index 2577a0feb0..4669c9e8e5 100644 --- a/templates/repo/issue/branch_selector_field.tmpl +++ b/templates/repo/issue/branch_selector_field.tmpl @@ -1,7 +1,7 @@ {{if and (not .Issue.IsPull) (not .PageIsComparePull)}} <input id="ref_selector" name="ref" type="hidden" value="{{.Reference}}"> <input id="editing_mode" name="edit_mode" type="hidden" value="{{(or .IsIssueWriter .HasIssuesOrPullsWritePermission)}}"> -<form method="POST" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/ref" id="update_issueref_form"> +<form method="post" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/ref" id="update_issueref_form"> {{$.CsrfTokenHtml}} </form> diff --git a/templates/repo/issue/choose.tmpl b/templates/repo/issue/choose.tmpl index b5316454ba..ccfeb7b331 100644 --- a/templates/repo/issue/choose.tmpl +++ b/templates/repo/issue/choose.tmpl @@ -50,7 +50,7 @@ <div class="ui warning message"> <div class="text left"> <div>{{.locale.Tr "repo.issues.choose.invalid_config"}}</div> - <diy>{{.IssueConfigError}}</div> + <div>{{.IssueConfigError}}</div> </div> </div> {{end}} diff --git a/templates/repo/issue/labels.tmpl b/templates/repo/issue/labels.tmpl index a122333c89..f897590cc2 100644 --- a/templates/repo/issue/labels.tmpl +++ b/templates/repo/issue/labels.tmpl @@ -19,7 +19,6 @@ </div> {{if and (or .CanWriteIssues .CanWritePulls) (not .Repository.IsArchived)}} -{{template "repo/issue/labels/edit_delete_label" .}} + {{template "repo/issue/labels/edit_delete_label" .}} {{end}} -</div> {{template "base/footer" .}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 0652198adf..bfcd292f44 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -249,7 +249,7 @@ {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} - {{$.locale.Tr "repo.issues.start_tracking_history" $createdStr | Safe}} + {{$.locale.Tr "repo.issues.start_tracking_history" $createdStr | Safe}} </span> </div> {{else if eq .Type 13}} @@ -258,7 +258,7 @@ {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} - {{$.locale.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}} + {{$.locale.Tr "repo.issues.stop_tracking_history" $createdStr | Safe}} </span> {{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}} <div class="detail"> @@ -272,7 +272,7 @@ {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} - {{$.locale.Tr "repo.issues.add_time_history" $createdStr | Safe}} + {{$.locale.Tr "repo.issues.add_time_history" $createdStr | Safe}} </span> {{template "repo/issue/view_content/comments_delete_time" dict "ctxData" $ "comment" .}} <div class="detail"> @@ -286,7 +286,7 @@ {{template "shared/user/avatarlink" dict "Context" $.Context "user" .Poster}} <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} - {{$.locale.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}} + {{$.locale.Tr "repo.issues.cancel_tracking_history" $createdStr | Safe}} </span> </div> {{else if eq .Type 16}} @@ -672,7 +672,7 @@ <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} - {{$.locale.Tr "repo.issues.del_time_history" $createdStr | Safe}} + {{$.locale.Tr "repo.issues.del_time_history" $createdStr | Safe}} </span> <div class="detail"> {{svg "octicon-clock"}} @@ -719,7 +719,7 @@ <span class="text grey muted-links"> {{template "shared/user/authorlink" .Poster}} {{if .IsForcePush}} - {{$.locale.Tr "repo.issues.force_push_codes" ($.Issue.PullRequest.HeadBranch|Escape) (ShortSha .OldCommit) (($.Issue.Repo.CommitLink .OldCommit)|Escape) (ShortSha .NewCommit) (($.Issue.Repo.CommitLink .NewCommit)|Escape) $createdStr | Safe}} + {{$.locale.Tr "repo.issues.force_push_codes" ($.Issue.PullRequest.HeadBranch|Escape) (ShortSha .OldCommit) (($.Issue.Repo.CommitLink .OldCommit)|Escape) (ShortSha .NewCommit) (($.Issue.Repo.CommitLink .NewCommit)|Escape) $createdStr | Safe}} {{else}} {{$.locale.TrN (len .Commits) "repo.issues.push_commit_1" "repo.issues.push_commits_n" (len .Commits) $createdStr | Safe}} {{end}} diff --git a/templates/repo/issue/view_content/comments_delete_time.tmpl b/templates/repo/issue/view_content/comments_delete_time.tmpl index cbfb1144fd..b9072ca140 100644 --- a/templates/repo/issue/view_content/comments_delete_time.tmpl +++ b/templates/repo/issue/view_content/comments_delete_time.tmpl @@ -3,7 +3,7 @@ {{if (or .ctxData.IsAdmin (and .ctxData.IsSigned (eq .ctxData.SignedUserID .comment.PosterID)))}} <span class="ui float right"> <div class="ui mini modal issue-delete-time-modal" data-id="{{.comment.Time.ID}}"> - <form method="POST" class="delete-time-form" action="{{.ctxData.RepoLink}}/issues/{{.ctxData.Issue.Index}}/times/{{.comment.TimeID}}/delete"> + <form method="post" class="delete-time-form" action="{{.ctxData.RepoLink}}/issues/{{.ctxData.Issue.Index}}/times/{{.comment.TimeID}}/delete"> {{.ctxData.CsrfTokenHtml}} </form> <div class="header">{{.ctxData.locale.Tr "repo.issues.del_time"}}</div> diff --git a/templates/repo/issue/view_content/sidebar.tmpl b/templates/repo/issue/view_content/sidebar.tmpl index 901f714e32..c0f5a8d3d7 100644 --- a/templates/repo/issue/view_content/sidebar.tmpl +++ b/templates/repo/issue/view_content/sidebar.tmpl @@ -270,7 +270,7 @@ <div class="ui watching"> <span class="text"><strong>{{.locale.Tr "notification.notifications"}}</strong></span> <div class="gt-mt-3"> - <form method="POST" action="{{.Issue.Link}}/watch"> + <form method="post" action="{{.Issue.Link}}/watch"> <input type="hidden" name="watch" value="{{if $.IssueWatch.IsWatching}}0{{else}}1{{end}}"> {{$.CsrfTokenHtml}} <button class="fluid ui button"> @@ -292,13 +292,13 @@ <div class="ui timetrack"> <span class="text"><strong>{{.locale.Tr "repo.issues.tracker"}}</strong></span> <div class="gt-mt-3"> - <form method="POST" action="{{.Issue.Link}}/times/stopwatch/toggle" id="toggle_stopwatch_form"> + <form method="post" action="{{.Issue.Link}}/times/stopwatch/toggle" id="toggle_stopwatch_form"> {{$.CsrfTokenHtml}} </form> - <form method="POST" action="{{.Issue.Link}}/times/stopwatch/cancel" id="cancel_stopwatch_form"> + <form method="post" action="{{.Issue.Link}}/times/stopwatch/cancel" id="cancel_stopwatch_form"> {{$.CsrfTokenHtml}} </form> - {{if $.IsStopwatchRunning}} + {{if $.IsStopwatchRunning}} <button class="ui fluid button issue-stop-time">{{.locale.Tr "repo.issues.stop_tracking"}}</button> <button class="ui fluid negative button issue-cancel-time gt-mt-3">{{.locale.Tr "repo.issues.cancel_tracking"}}</button> {{else}} @@ -311,7 +311,7 @@ <div class="ui mini modal issue-start-time-modal"> <div class="header">{{.locale.Tr "repo.issues.add_time"}}</div> <div class="content"> - <form method="POST" id="add_time_manual_form" action="{{.Issue.Link}}/times/add" class="ui action input fluid"> + <form method="post" id="add_time_manual_form" action="{{.Issue.Link}}/times/add" class="ui action input fluid"> {{$.CsrfTokenHtml}} <input placeholder='{{.locale.Tr "repo.issues.add_time_hours"}}' type="number" name="hours"> <input placeholder='{{.locale.Tr "repo.issues.add_time_minutes"}}' type="number" name="minutes" class="ui compact"> @@ -330,7 +330,7 @@ {{if gt (len .WorkingUsers) 0}} <div class="ui divider"></div> <div class="ui comments"> - <span class="text"><strong>{{.locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}}</strong></span> + <span class="text"><strong>{{.locale.Tr "repo.issues.time_spent_from_all_authors" ($.Issue.TotalTrackedTime | Sec2Time) | Safe}}</strong></span> <div> {{range $user, $trackedtime := .WorkingUsers}} <div class="comment gt-mt-3"> @@ -498,7 +498,7 @@ {{if and .CanCreateIssueDependencies (not .Repository.IsArchived)}} <div> - <form method="POST" action="{{.Issue.Link}}/dependency/add" id="addDependencyForm"> + <form method="post" action="{{.Issue.Link}}/dependency/add" id="addDependencyForm"> {{$.CsrfTokenHtml}} <div class="ui fluid action input"> <div class="ui search selection dropdown" id="new-dependency-drop-list" data-issue-id="{{.Issue.ID}}"> @@ -525,7 +525,7 @@ {{.locale.Tr "repo.issues.dependency.remove_header"}} </div> <div class="content"> - <form method="POST" action="{{.Issue.Link}}/dependency/delete" id="removeDependencyForm"> + <form method="post" action="{{.Issue.Link}}/dependency/delete" id="removeDependencyForm"> {{$.CsrfTokenHtml}} <input type="hidden" value="" name="removeDependencyID" id="removeDependencyID"> <input type="hidden" value="" name="dependencyType" id="dependencyType"> @@ -556,7 +556,7 @@ <div class="ui divider"></div> {{if or .PinEnabled .Issue.IsPinned}} - <form class="gt-mt-2" method="POST" {{if $.NewPinAllowed}}action="{{.Issue.Link}}/pin"{{else}}data-tooltip-content="{{.locale.Tr "repo.issues.max_pinned"}}"{{end}}> + <form class="gt-mt-2" method="post" {{if $.NewPinAllowed}}action="{{.Issue.Link}}/pin"{{else}}data-tooltip-content="{{.locale.Tr "repo.issues.max_pinned"}}"{{end}}> {{$.CsrfTokenHtml}} <button class="fluid ui button {{if not $.NewPinAllowed}}disabled{{end}}"> {{if not .Issue.IsPinned}} diff --git a/templates/repo/settings/lfs_locks.tmpl b/templates/repo/settings/lfs_locks.tmpl index 8fa3dfd3d3..c003500bb6 100644 --- a/templates/repo/settings/lfs_locks.tmpl +++ b/templates/repo/settings/lfs_locks.tmpl @@ -5,7 +5,7 @@ <a href="{{.LFSFilesLink}}">{{.locale.Tr "repo.settings.lfs"}}</a> / {{.locale.Tr "repo.settings.lfs_locks"}} ({{.locale.Tr "admin.total" .Total}}) </h4> <div class="ui attached segment"> - <form class="ui form ignore-dirty" method="POST"> + <form class="ui form ignore-dirty" method="post"> {{$.CsrfTokenHtml}} <div class="ui fluid action input"> <input name="path" value="" placeholder="{{.locale.Tr "repo.settings.lfs_lock_path"}}" autofocus> @@ -37,7 +37,7 @@ </td> <td>{{TimeSince .Created $.locale}}</td> <td class="right aligned"> - <form action="{{$.LFSFilesLink}}/locks/{{$lock.ID}}/unlock" method="POST"> + <form action="{{$.LFSFilesLink}}/locks/{{$lock.ID}}/unlock" method="post"> {{$.CsrfTokenHtml}} <button class="ui primary button"><span class="btn-octicon">{{svg "octicon-lock"}}</span>{{$.locale.Tr "repo.settings.lfs_force_unlock"}}</button> </form> diff --git a/templates/repo/settings/options.tmpl b/templates/repo/settings/options.tmpl index a1fe1ad5af..cc7005c4fa 100644 --- a/templates/repo/settings/options.tmpl +++ b/templates/repo/settings/options.tmpl @@ -285,47 +285,35 @@ <input type="hidden" name="action" value="advanced"> {{$isCodeEnabled := .Repository.UnitEnabled $.Context $.UnitTypeCode}} + {{$isCodeGlobalDisabled := .UnitTypeCode.UnitGlobalDisabled}} <div class="inline field"> <label>{{.locale.Tr "repo.code"}}</label> - {{if .UnitTypeCode.UnitGlobalDisabled}} - <div class="ui checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui checkbox"> - {{end}} + <div class="ui checkbox{{if $isCodeGlobalDisabled}} disabled{{end}}"{{if $isCodeGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system" name="enable_code" type="checkbox"{{if $isCodeEnabled}} checked{{end}}> <label>{{.locale.Tr "repo.code.desc"}}</label> </div> </div> {{$isWikiEnabled := or (.Repository.UnitEnabled $.Context $.UnitTypeWiki) (.Repository.UnitEnabled $.Context $.UnitTypeExternalWiki)}} + {{$isWikiGlobalDisabled := .UnitTypeWiki.UnitGlobalDisabled}} + {{$isExternalWikiGlobalDisabled := .UnitTypeExternalWiki.UnitGlobalDisabled}} + {{$isBothWikiGlobalDisabled := and $isWikiGlobalDisabled $isBothWikiGlobalDisabled}} <div class="inline field"> <label>{{.locale.Tr "repo.wiki"}}</label> - {{if and (.UnitTypeWiki.UnitGlobalDisabled) (.UnitTypeExternalWiki.UnitGlobalDisabled)}} - <div class="ui checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui checkbox"> - {{end}} + <div class="ui checkbox{{if $isBothWikiGlobalDisabled}} disabled{{end}}"{{if $isBothWikiGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system" name="enable_wiki" type="checkbox" data-target="#wiki_box" {{if $isWikiEnabled}}checked{{end}}> <label>{{.locale.Tr "repo.settings.wiki_desc"}}</label> </div> </div> - <div class="field {{if not $isWikiEnabled}}disabled{{end}}" id="wiki_box"> + <div class="field{{if not $isWikiEnabled}} disabled{{end}}" id="wiki_box"> <div class="field"> - {{if .UnitTypeWiki.UnitGlobalDisabled}} - <div class="ui radio checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui radio checkbox"> - {{end}} + <div class="ui radio checkbox{{if $isWikiGlobalDisabled}} disabled{{end}}"{{if $isWikiGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system-radio" tabindex="0" name="enable_external_wiki" type="radio" value="false" data-target="#external_wiki_box" {{if not (.Repository.UnitEnabled $.Context $.UnitTypeExternalWiki)}}checked{{end}}> <label>{{.locale.Tr "repo.settings.use_internal_wiki"}}</label> </div> </div> <div class="field"> - {{if .UnitTypeExternalWiki.UnitGlobalDisabled}} - <div class="ui radio checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui radio checkbox"> - {{end}} + <div class="ui radio checkbox{{if $isExternalWikiGlobalDisabled}} disabled{{end}}"{{if $isExternalWikiGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system-radio" tabindex="0" name="enable_external_wiki" type="radio" value="true" data-target="#external_wiki_box" {{if .Repository.UnitEnabled $.Context $.UnitTypeExternalWiki}}checked{{end}}> <label>{{.locale.Tr "repo.settings.use_external_wiki"}}</label> </div> @@ -340,24 +328,19 @@ <div class="ui divider"></div> {{$isIssuesEnabled := or (.Repository.UnitEnabled $.Context $.UnitTypeIssues) (.Repository.UnitEnabled $.Context $.UnitTypeExternalTracker)}} + {{$isIssuesGlobalDisabled := .UnitTypeIssues.UnitGlobalDisabled}} + {{$isExternalTrackerGlobalDisabled := .UnitTypeExternalTracker.UnitGlobalDisabled}} + {{$isIssuesAndExternalGlobalDisabled := and $isIssuesGlobalDisabled $isExternalTrackerGlobalDisabled}} <div class="inline field"> <label>{{.locale.Tr "repo.issues"}}</label> - {{if and (.UnitTypeIssues.UnitGlobalDisabled) (.UnitTypeExternalTracker.UnitGlobalDisabled)}} - <div class="ui checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui checkbox"> - {{end}} + <div class="ui checkbox{{if $isIssuesAndExternalGlobalDisabled}} disabled{{end}}"{{if $isIssuesAndExternalGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system" name="enable_issues" type="checkbox" data-target="#issue_box" {{if $isIssuesEnabled}}checked{{end}}> <label>{{.locale.Tr "repo.settings.issues_desc"}}</label> </div> </div> <div class="field {{if not $isIssuesEnabled}}disabled{{end}}" id="issue_box"> <div class="field"> - {{if .UnitTypeIssues.UnitGlobalDisabled}} - <div class="ui radio checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui radio checkbox"> - {{end}} + <div class="ui radio checkbox{{if $isIssuesGlobalDisabled}} disabled{{end}}"{{if $isIssuesGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system-radio" tabindex="0" name="enable_external_tracker" type="radio" value="false" data-context="#internal_issue_box" data-target="#external_issue_box" {{if not (.Repository.UnitEnabled $.Context $.UnitTypeExternalTracker)}}checked{{end}}> <label>{{.locale.Tr "repo.settings.use_internal_issue_tracker"}}</label> </div> @@ -389,11 +372,7 @@ </div> </div> <div class="field"> - {{if .UnitTypeExternalTracker.UnitGlobalDisabled}} - <div class="ui radio checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui radio checkbox"> - {{end}} + <div class="ui radio checkbox{{if $isExternalTrackerGlobalDisabled}} disabled{{end}}"{{if $isExternalTrackerGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system-radio" tabindex="0" name="enable_external_tracker" type="radio" value="true" data-context="#internal_issue_box" data-target="#external_issue_box" {{if .Repository.UnitEnabled $.Context $.UnitTypeExternalTracker}}checked{{end}}> <label>{{.locale.Tr "repo.settings.use_external_issue_tracker"}}</label> </div> @@ -406,7 +385,7 @@ </div> <div class="field"> <label for="tracker_url_format">{{.locale.Tr "repo.settings.tracker_url_format"}}</label> - <input id="tracker_url_format" name="tracker_url_format" type="url" value="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalTracker).ExternalTrackerConfig.ExternalTrackerFormat}}" placeholder="e.g. https://github.com/{user}/{repo}/issues/{index}"> + <input id="tracker_url_format" name="tracker_url_format" type="url" value="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalTracker).ExternalTrackerConfig.ExternalTrackerFormat}}" placeholder="https://github.com/{user}/{repo}/issues/{index}"> <p class="help">{{.locale.Tr "repo.settings.tracker_url_format_desc" | Str2html}}</p> </div> <div class="inline fields"> @@ -443,39 +422,30 @@ <div class="ui divider"></div> {{$isProjectsEnabled := .Repository.UnitEnabled $.Context $.UnitTypeProjects}} + {{$isProjectsGlobalDisabled := .UnitTypeProjects.UnitGlobalDisabled}} <div class="inline field"> <label>{{.locale.Tr "repo.project_board"}}</label> - {{if .UnitTypeProjects.UnitGlobalDisabled}} - <div class="ui checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui checkbox"> - {{end}} + <div class="ui checkbox{{if $isProjectsGlobalDisabled}} disabled{{end}}"{{if $isProjectsGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system" name="enable_projects" type="checkbox" {{if $isProjectsEnabled}}checked{{end}}> <label>{{.locale.Tr "repo.settings.projects_desc"}}</label> </div> </div> {{$isReleasesEnabled := .Repository.UnitEnabled $.Context $.UnitTypeReleases}} + {{$isReleasesGlobalDisabled := .UnitTypeReleases.UnitGlobalDisabled}} <div class="inline field"> <label>{{.locale.Tr "repo.releases"}}</label> - {{if .UnitTypeReleases.UnitGlobalDisabled}} - <div class="ui checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui checkbox"> - {{end}} + <div class="ui checkbox{{if $isReleasesGlobalDisabled}} disabled{{end}}"{{if $isReleasesGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system" name="enable_releases" type="checkbox" {{if $isReleasesEnabled}}checked{{end}}> <label>{{.locale.Tr "repo.settings.releases_desc"}}</label> </div> </div> {{$isPackagesEnabled := .Repository.UnitEnabled $.Context $.UnitTypePackages}} + {{$isPackagesGlobalDisabled := .UnitTypePackages.UnitGlobalDisabled}} <div class="inline field"> <label>{{.locale.Tr "repo.packages"}}</label> - {{if .UnitTypePackages.UnitGlobalDisabled}} - <div class="ui checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui checkbox"> - {{end}} + <div class="ui checkbox{{if $isPackagesGlobalDisabled}} disabled{{end}}"{{if $isPackagesGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system" name="enable_packages" type="checkbox" {{if $isPackagesEnabled}}checked{{end}}> <label>{{.locale.Tr "repo.settings.packages_desc"}}</label> </div> @@ -483,13 +453,10 @@ {{if .EnableActions}} {{$isActionsEnabled := .Repository.UnitEnabled $.Context $.UnitTypeActions}} + {{$isActionsGlobalDisabled := .UnitTypeActions.UnitGlobalDisabled}} <div class="inline field"> <label>{{.locale.Tr "actions.actions"}}</label> - {{if .UnitTypeActions.UnitGlobalDisabled}} - <div class="ui checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui checkbox"> - {{end}} + <div class="ui checkbox{{if $isActionsGlobalDisabled}} disabled{{end}}"{{if $isActionsGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system" name="enable_actions" type="checkbox" {{if $isActionsEnabled}}checked{{end}}> <label>{{.locale.Tr "repo.settings.actions_desc"}}</label> </div> @@ -499,14 +466,11 @@ {{if not .IsMirror}} <div class="ui divider"></div> {{$pullRequestEnabled := .Repository.UnitEnabled $.Context $.UnitTypePullRequests}} + {{$pullRequestGlobalDisabled := .UnitTypePullRequests.UnitGlobalDisabled}} {{$prUnit := .Repository.MustGetUnit $.Context $.UnitTypePullRequests}} <div class="inline field"> <label>{{.locale.Tr "repo.pulls"}}</label> - {{if .UnitTypePullRequests.UnitGlobalDisabled}} - <div class="ui checkbox disabled" data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"> - {{else}} - <div class="ui checkbox"> - {{end}} + <div class="ui checkbox{{if $pullRequestGlobalDisabled}} disabled{{end}}"{{if $pullRequestGlobalDisabled}} data-tooltip-content="{{.locale.Tr "repo.unit_disabled"}}"{{end}}> <input class="enable-system" name="enable_pulls" type="checkbox" data-target="#pull_box" {{if $pullRequestEnabled}}checked{{end}}> <label>{{.locale.Tr "repo.settings.pulls_desc"}}</label> </div> diff --git a/templates/repo/settings/webhook/base_list.tmpl b/templates/repo/settings/webhook/base_list.tmpl index 663fde1528..8db9a9263e 100644 --- a/templates/repo/settings/webhook/base_list.tmpl +++ b/templates/repo/settings/webhook/base_list.tmpl @@ -50,7 +50,7 @@ <div class="item truncated-item-container"> <span class="text {{if eq .LastStatus 1}}green{{else if eq .LastStatus 2}}red{{else}}grey{{end}} gt-mr-3">{{svg "octicon-dot-fill" 22}}</span> <a class="text truncate gt-f1 gt-mr-3" title="{{.URL}}" href="{{$.BaseLink}}/{{.ID}}">{{.URL}}</a> - <a class="muted gt-p-3" href="{{$.BaseLink}}/{{.ID}}">{{svg "octicon-pencil"}}</a></span> + <a class="muted gt-p-3" href="{{$.BaseLink}}/{{.ID}}">{{svg "octicon-pencil"}}</a> <a class="delete-button gt-p-3" data-url="{{$.Link}}/delete" data-id="{{.ID}}">{{svg "octicon-trash"}}</a> </div> {{end}} diff --git a/templates/repo/settings/webhook/discord.tmpl b/templates/repo/settings/webhook/discord.tmpl index 76c7c6b7b1..3d943c8219 100644 --- a/templates/repo/settings/webhook/discord.tmpl +++ b/templates/repo/settings/webhook/discord.tmpl @@ -8,11 +8,11 @@ </div> <div class="field"> <label for="username">{{.locale.Tr "repo.settings.discord_username"}}</label> - <input id="username" name="username" value="{{.DiscordHook.Username}}" placeholder="e.g. Gitea"> + <input id="username" name="username" value="{{.DiscordHook.Username}}" placeholder="Gitea"> </div> <div class="field"> <label for="icon_url">{{.locale.Tr "repo.settings.discord_icon_url"}}</label> - <input id="icon_url" name="icon_url" value="{{.DiscordHook.IconURL}}" placeholder="e.g. https://example.com/assets/img/logo.svg"> + <input id="icon_url" name="icon_url" value="{{.DiscordHook.IconURL}}" placeholder="https://example.com/assets/img/logo.svg"> </div> {{template "repo/settings/webhook/settings" .}} </form> diff --git a/templates/repo/settings/webhook/history.tmpl b/templates/repo/settings/webhook/history.tmpl index 7020bf0ba4..fac4a11b88 100644 --- a/templates/repo/settings/webhook/history.tmpl +++ b/templates/repo/settings/webhook/history.tmpl @@ -3,8 +3,7 @@ {{.locale.Tr "repo.settings.recent_deliveries"}} {{if .Permission.IsAdmin}} <div class="ui right"> - <button class="ui teal tiny button" id="test-delivery" data-tooltip-content= - "{{.locale.Tr "repo.settings.webhook.test_delivery_desc"}}" data-link="{{.Link}}/test" data-redirect="{{.Link}}">{{.locale.Tr "repo.settings.webhook.test_delivery"}}</button> + <button class="ui teal tiny button" id="test-delivery" data-tooltip-content="{{.locale.Tr "repo.settings.webhook.test_delivery_desc"}}" data-link="{{.Link}}/test" data-redirect="{{.Link}}">{{.locale.Tr "repo.settings.webhook.test_delivery"}}</button> </div> {{end}} </h4> diff --git a/templates/repo/settings/webhook/packagist.tmpl b/templates/repo/settings/webhook/packagist.tmpl index 43c1f17d41..b8033c1043 100644 --- a/templates/repo/settings/webhook/packagist.tmpl +++ b/templates/repo/settings/webhook/packagist.tmpl @@ -4,15 +4,15 @@ {{.CsrfTokenHtml}} <div class="required field {{if .Err_Username}}error{{end}}"> <label for="username">{{.locale.Tr "repo.settings.packagist_username"}}</label> - <input id="username" name="username" value="{{.PackagistHook.Username}}" placeholder="e.g. Gitea" autofocus required> + <input id="username" name="username" value="{{.PackagistHook.Username}}" placeholder="Gitea" autofocus required> </div> <div class="required field {{if .Err_APIToken}}error{{end}}"> <label for="api_token">{{.locale.Tr "repo.settings.packagist_api_token"}}</label> - <input id="api_token" name="api_token" value="{{.PackagistHook.APIToken}}" placeholder="e.g. X5F_tZ-Wj3c1vqaU2Rky" required> + <input id="api_token" name="api_token" value="{{.PackagistHook.APIToken}}" placeholder="X5F_tZ-Wj3c1vqaU2Rky" required> </div> <div class="required field {{if .Err_PackageURL}}error{{end}}"> <label for="package_url">{{.locale.Tr "repo.settings.packagist_package_url"}}</label> - <input id="package_url" name="package_url" value="{{.PackagistHook.PackageURL}}" placeholder="e.g. https://packagist.org/packages/laravel/framework" required> + <input id="package_url" name="package_url" value="{{.PackagistHook.PackageURL}}" placeholder="https://packagist.org/packages/laravel/framework" required> </div> {{template "repo/settings/webhook/settings" .}} </form> diff --git a/templates/repo/settings/webhook/slack.tmpl b/templates/repo/settings/webhook/slack.tmpl index 762cfb3ba2..335966a6d1 100644 --- a/templates/repo/settings/webhook/slack.tmpl +++ b/templates/repo/settings/webhook/slack.tmpl @@ -8,20 +8,20 @@ </div> <div class="required field {{if .Err_Channel}}error{{end}}"> <label for="channel">{{.locale.Tr "repo.settings.slack_channel"}}</label> - <input id="channel" name="channel" value="{{.SlackHook.Channel}}" placeholder="e.g. #general" required> + <input id="channel" name="channel" value="{{.SlackHook.Channel}}" placeholder="#general" required> </div> <div class="field"> <label for="username">{{.locale.Tr "repo.settings.slack_username"}}</label> - <input id="username" name="username" value="{{.SlackHook.Username}}" placeholder="e.g. Gitea"> + <input id="username" name="username" value="{{.SlackHook.Username}}" placeholder="Gitea"> </div> <div class="field"> <label for="icon_url">{{.locale.Tr "repo.settings.slack_icon_url"}}</label> - <input id="icon_url" name="icon_url" value="{{.SlackHook.IconURL}}" placeholder="e.g. https://example.com/img/favicon.png"> + <input id="icon_url" name="icon_url" value="{{.SlackHook.IconURL}}" placeholder="https://example.com/img/favicon.png"> </div> <div class="field"> <label for="color">{{.locale.Tr "repo.settings.slack_color"}}</label> - <input id="color" name="color" value="{{.SlackHook.Color}}" placeholder="e.g. #dd4b39, good, warning, danger"> + <input id="color" name="color" value="{{.SlackHook.Color}}" placeholder="#dd4b39, good, warning, danger"> </div> {{template "repo/settings/webhook/settings" .}} </form> |