From ffddf3f8a6ca5e3db46e5731d717a55eb58e858f Mon Sep 17 00:00:00 2001 From: silverwind Date: Fri, 11 Sep 2020 22:19:00 +0200 Subject: [PATCH] Make SVG size argument optional (#12814) Now defaults to 16 on both frontend and backend. Co-authored-by: techknowlogick --- modules/templates/helper.go | 5 +- templates/admin/dashboard.tmpl | 20 +++--- templates/admin/monitor.tmpl | 2 +- templates/admin/org/list.tmpl | 2 +- templates/admin/repo/list.tmpl | 2 +- templates/base/head_navbar.tmpl | 32 ++++----- templates/explore/navbar.tmpl | 8 +-- templates/explore/organizations.tmpl | 8 +-- templates/explore/repo_list.tmpl | 8 +-- templates/explore/users.tmpl | 6 +- templates/home.tmpl | 8 +-- templates/org/header.tmpl | 4 +- templates/org/home.tmpl | 10 +-- templates/org/member/members.tmpl | 6 +- templates/org/settings/delete.tmpl | 2 +- templates/org/team/navbar.tmpl | 4 +- templates/org/team/repositories.tmpl | 8 +-- templates/org/team/sidebar.tmpl | 2 +- templates/org/team/teams.tmpl | 2 +- templates/repo/activity.tmpl | 20 +++--- templates/repo/branch/list.tmpl | 26 +++---- templates/repo/branch_dropdown.tmpl | 6 +- templates/repo/commit_page.tmpl | 12 ++-- templates/repo/commits.tmpl | 2 +- templates/repo/commits_list_small.tmpl | 2 +- templates/repo/commits_table.tmpl | 4 +- templates/repo/diff/blob_excerpt.tmpl | 12 ++-- templates/repo/diff/box.tmpl | 16 ++--- templates/repo/diff/comment_form.tmpl | 2 +- templates/repo/diff/compare.tmpl | 2 +- templates/repo/diff/section_unified.tmpl | 10 +-- templates/repo/editor/commit_form.tmpl | 6 +- templates/repo/editor/edit.tmpl | 8 +-- templates/repo/editor/upload.tmpl | 2 +- templates/repo/empty.tmpl | 2 +- templates/repo/graph.tmpl | 4 +- templates/repo/header.tmpl | 24 +++---- templates/repo/home.tmpl | 6 +- .../repo/issue/branch_selector_field.tmpl | 2 +- templates/repo/issue/labels/label_list.tmpl | 18 ++--- templates/repo/issue/list.tmpl | 32 ++++----- templates/repo/issue/milestone_issues.tmpl | 44 ++++++------ templates/repo/issue/milestones.tmpl | 26 +++---- templates/repo/issue/new_form.tmpl | 22 +++--- .../repo/issue/view_content/add_reaction.tmpl | 2 +- .../repo/issue/view_content/attachments.tmpl | 4 +- .../repo/issue/view_content/comments.tmpl | 70 +++++++++---------- .../repo/issue/view_content/context_menu.tmpl | 2 +- templates/repo/issue/view_content/pull.tmpl | 54 +++++++------- .../repo/issue/view_content/sidebar.tmpl | 46 ++++++------ templates/repo/issue/view_title.tmpl | 10 +-- templates/repo/migrate/github.tmpl | 2 +- templates/repo/migrate/gitlab.tmpl | 2 +- templates/repo/projects/list.tmpl | 20 +++--- templates/repo/projects/view.tmpl | 12 ++-- templates/repo/pulls/tab_menu.tmpl | 6 +- templates/repo/release/list.tmpl | 12 ++-- templates/repo/release/new.tmpl | 2 +- templates/repo/settings/collaboration.tmpl | 4 +- templates/repo/settings/deploy_keys.tmpl | 2 +- templates/repo/settings/githooks.tmpl | 2 +- templates/repo/settings/lfs.tmpl | 6 +- templates/repo/settings/lfs_file_find.tmpl | 4 +- templates/repo/settings/lfs_locks.tmpl | 8 +-- templates/repo/settings/protected_branch.tmpl | 6 +- templates/repo/settings/webhook/history.tmpl | 4 +- templates/repo/settings/webhook/list.tmpl | 6 +- templates/repo/shabox_badge.tmpl | 6 +- templates/repo/sub_menu.tmpl | 6 +- templates/repo/user_cards.tmpl | 6 +- templates/repo/view_file.tmpl | 8 +-- templates/repo/view_list.tmpl | 8 +-- templates/repo/wiki/pages.tmpl | 2 +- templates/repo/wiki/revision.tmpl | 4 +- templates/repo/wiki/view.tmpl | 4 +- templates/swagger/ui.tmpl | 2 +- templates/user/dashboard/issues.tmpl | 24 +++---- templates/user/dashboard/milestones.tmpl | 24 +++---- templates/user/dashboard/navbar.tmpl | 10 +-- templates/user/dashboard/repolist.tmpl | 12 ++-- .../user/notification/notification_div.tmpl | 20 +++--- templates/user/profile.tmpl | 22 +++--- templates/user/settings/account.tmpl | 2 +- templates/user/settings/applications.tmpl | 2 +- templates/user/settings/keys_ssh.tmpl | 2 +- templates/user/settings/repos.tmpl | 8 +-- templates/user/settings/security_u2f.tmpl | 2 +- web_src/js/features/contextpopup.js | 2 +- web_src/js/markdown/anchors.js | 2 +- 89 files changed, 458 insertions(+), 455 deletions(-) diff --git a/modules/templates/helper.go b/modules/templates/helper.go index 9037af89919..9e1c2fd3814 100644 --- a/modules/templates/helper.go +++ b/modules/templates/helper.go @@ -470,7 +470,10 @@ var heightRe = regexp.MustCompile(`height="[0-9]+?"`) // SVG render icons - arguments icon name (string), size (int), class (string) func SVG(icon string, others ...interface{}) template.HTML { - var size = others[0].(int) + size := 16 + if len(others) > 0 && others[0].(int) != 0 { + size = others[0].(int) + } class := "" if len(others) > 1 && others[1].(string) != "" { diff --git a/templates/admin/dashboard.tmpl b/templates/admin/dashboard.tmpl index 0fd87f92564..99c215493db 100644 --- a/templates/admin/dashboard.tmpl +++ b/templates/admin/dashboard.tmpl @@ -21,44 +21,44 @@ {{.i18n.Tr "admin.dashboard.delete_inactive_accounts"}} - + {{.i18n.Tr "admin.dashboard.delete_repo_archives"}} - + {{.i18n.Tr "admin.dashboard.delete_missing_repos"}} - + {{.i18n.Tr "admin.dashboard.git_gc_repos"}} - + {{.i18n.Tr "admin.dashboard.resync_all_sshkeys"}}
{{.i18n.Tr "admin.dashboard.resync_all_sshkeys.desc"}} - + {{.i18n.Tr "admin.dashboard.resync_all_hooks"}} - + {{.i18n.Tr "admin.dashboard.reinit_missing_repos"}} - + {{.i18n.Tr "admin.dashboard.sync_external_users"}} - + {{.i18n.Tr "admin.dashboard.repo_health_check"}} - + {{.i18n.Tr "admin.dashboard.delete_generated_repository_avatars"}} - + diff --git a/templates/admin/monitor.tmpl b/templates/admin/monitor.tmpl index 8dd0d939d7f..c3600fa9960 100644 --- a/templates/admin/monitor.tmpl +++ b/templates/admin/monitor.tmpl @@ -24,7 +24,7 @@ {{range .Entries}} - + {{$.i18n.Tr (printf "admin.dashboard.%s" .Name)}} {{.Spec}} {{DateFmtLong .Next}} diff --git a/templates/admin/org/list.tmpl b/templates/admin/org/list.tmpl index 4f6bc50342b..4a0fd161112 100644 --- a/templates/admin/org/list.tmpl +++ b/templates/admin/org/list.tmpl @@ -38,7 +38,7 @@ {{.Name}} {{if .Visibility.IsPrivate}} - {{svg "octicon-lock" 16}} + {{svg "octicon-lock"}} {{end}} {{.NumTeams}} diff --git a/templates/admin/repo/list.tmpl b/templates/admin/repo/list.tmpl index b9b88653829..4c3b77dcfb4 100644 --- a/templates/admin/repo/list.tmpl +++ b/templates/admin/repo/list.tmpl @@ -45,7 +45,7 @@ {{.Owner.Name}} {{if .Owner.Visibility.IsPrivate}} - {{svg "octicon-lock" 16}} + {{svg "octicon-lock"}} {{end}} {{.Name}} diff --git a/templates/base/head_navbar.tmpl b/templates/base/head_navbar.tmpl index 832b8cf3c7f..e960f7fe175 100644 --- a/templates/base/head_navbar.tmpl +++ b/templates/base/head_navbar.tmpl @@ -50,7 +50,7 @@ {{.i18n.Tr "user_profile_and_more"}} {{.SignedUser.Name}} - {{svg "octicon-triangle-down" 16}} + {{svg "octicon-triangle-down"}} diff --git a/templates/home.tmpl b/templates/home.tmpl index 5daea544fe8..721bb50dba1 100644 --- a/templates/home.tmpl +++ b/templates/home.tmpl @@ -16,7 +16,7 @@

- {{svg "octicon-flame" 16}} {{.i18n.Tr "startpage.install"}} + {{svg "octicon-flame"}} {{.i18n.Tr "startpage.install"}}

{{.i18n.Tr "startpage.install_desc" | Str2html}} @@ -24,7 +24,7 @@

- {{svg "octicon-device-desktop" 16}} {{.i18n.Tr "startpage.platform"}} + {{svg "octicon-device-desktop"}} {{.i18n.Tr "startpage.platform"}}

{{.i18n.Tr "startpage.platform_desc" | Str2html}} @@ -34,7 +34,7 @@

- {{svg "octicon-rocket" 16}} {{.i18n.Tr "startpage.lightweight"}} + {{svg "octicon-rocket"}} {{.i18n.Tr "startpage.lightweight"}}

{{.i18n.Tr "startpage.lightweight_desc" | Str2html}} @@ -42,7 +42,7 @@

- {{svg "octicon-code" 16}} {{.i18n.Tr "startpage.license"}} + {{svg "octicon-code"}} {{.i18n.Tr "startpage.license"}}

{{.i18n.Tr "startpage.license_desc" | Str2html}} diff --git a/templates/org/header.tmpl b/templates/org/header.tmpl index 6593900c1eb..17cc58fcbb0 100644 --- a/templates/org/header.tmpl +++ b/templates/org/header.tmpl @@ -9,11 +9,11 @@

diff --git a/templates/org/home.tmpl b/templates/org/home.tmpl index 7fc2a5c2de8..01c1fe66b04 100644 --- a/templates/org/home.tmpl +++ b/templates/org/home.tmpl @@ -7,12 +7,12 @@
{{.Org.DisplayName}} - {{if .IsOrganizationOwner}}{{svg "octicon-gear" 16}}{{end}} + {{if .IsOrganizationOwner}}{{svg "octicon-gear"}}{{end}}
{{if .Org.Description}}

{{.Org.Description}}

{{end}}
- {{if .Org.Location}}
{{svg "octicon-location" 16}} {{.Org.Location}}
{{end}} - {{if .Org.Website}}
{{svg "octicon-link" 16}} {{.Org.Website}}
{{end}} + {{if .Org.Location}}
{{svg "octicon-location"}} {{.Org.Location}}
{{end}} + {{if .Org.Website}}
{{svg "octicon-link"}} {{.Org.Website}}
{{end}}
@@ -38,7 +38,7 @@ {{.i18n.Tr "org.people"}} {{if .IsOrganizationMember}} {{end}} @@ -55,7 +55,7 @@
diff --git a/templates/org/member/members.tmpl b/templates/org/member/members.tmpl index 1c33c55c5a6..f33f9be927a 100644 --- a/templates/org/member/members.tmpl +++ b/templates/org/member/members.tmpl @@ -34,7 +34,7 @@ {{$.i18n.Tr "org.members.member_role"}}
- {{if index $.MembersIsUserOrgOwner .ID}}{{svg "octicon-shield-lock" 16}} {{$.i18n.Tr "org.members.owner"}}{{else}}{{$.i18n.Tr "org.members.member"}}{{end}} + {{if index $.MembersIsUserOrgOwner .ID}}{{svg "octicon-shield-lock"}} {{$.i18n.Tr "org.members.owner"}}{{else}}{{$.i18n.Tr "org.members.member"}}{{end}}
@@ -44,9 +44,9 @@
{{if index $.MembersTwoFaStatus .ID}} - {{svg "octicon-check" 16}} + {{svg "octicon-check"}} {{else}} - {{svg "octicon-x" 16}} + {{svg "octicon-x"}} {{end}}
diff --git a/templates/org/settings/delete.tmpl b/templates/org/settings/delete.tmpl index 729126b7b9c..a189a2f5e3e 100644 --- a/templates/org/settings/delete.tmpl +++ b/templates/org/settings/delete.tmpl @@ -11,7 +11,7 @@
-

{{svg "octicon-alert" 16}} {{.i18n.Tr "org.settings.delete_prompt" | Str2html}}

+

{{svg "octicon-alert"}} {{.i18n.Tr "org.settings.delete_prompt" | Str2html}}

{{.CsrfTokenHtml}} diff --git a/templates/org/team/navbar.tmpl b/templates/org/team/navbar.tmpl index 95329a2be33..18d638796c1 100644 --- a/templates/org/team/navbar.tmpl +++ b/templates/org/team/navbar.tmpl @@ -1,4 +1,4 @@ diff --git a/templates/org/team/repositories.tmpl b/templates/org/team/repositories.tmpl index f6cb4f028a3..de39fee2ea9 100644 --- a/templates/org/team/repositories.tmpl +++ b/templates/org/team/repositories.tmpl @@ -42,13 +42,13 @@ {{end}} {{if .IsPrivate}} - {{svg "octicon-lock" 16}} + {{svg "octicon-lock"}} {{else if .IsFork}} - {{svg "octicon-repo-forked" 16}} + {{svg "octicon-repo-forked"}} {{else if .IsMirror}} - {{svg "octicon-mirror" 16}} + {{svg "octicon-mirror"}} {{else}} - {{svg "octicon-repo" 16}} + {{svg "octicon-repo"}} {{end}} {{$.Org.Name}}/{{.Name}} diff --git a/templates/org/team/sidebar.tmpl b/templates/org/team/sidebar.tmpl index d3bd0828758..9ab6e8f4cd7 100644 --- a/templates/org/team/sidebar.tmpl +++ b/templates/org/team/sidebar.tmpl @@ -55,7 +55,7 @@
{{if .IsOrganizationOwner}} {{end}}
diff --git a/templates/org/team/teams.tmpl b/templates/org/team/teams.tmpl index 6aef18dfffe..e4be11ee52a 100644 --- a/templates/org/team/teams.tmpl +++ b/templates/org/team/teams.tmpl @@ -5,7 +5,7 @@ {{template "base/alert" .}} {{if .IsOrganizationOwner}}
{{end}} diff --git a/templates/repo/activity.tmpl b/templates/repo/activity.tmpl index 41f6be64309..fd24499fccb 100644 --- a/templates/repo/activity.tmpl +++ b/templates/repo/activity.tmpl @@ -63,21 +63,21 @@
{{if .Permission.CanRead $.UnitTypePullRequests}} - {{svg "octicon-git-pull-request" 16}} {{.Activity.MergedPRCount}}
+ {{svg "octicon-git-pull-request"}} {{.Activity.MergedPRCount}}
{{.i18n.Tr (TrN .i18n.Lang .Activity.MergedPRCount "repo.activity.merged_prs_count_1" "repo.activity.merged_prs_count_n") }}
- {{svg "octicon-git-branch" 16}} {{.Activity.OpenedPRCount}}
+ {{svg "octicon-git-branch"}} {{.Activity.OpenedPRCount}}
{{.i18n.Tr (TrN .i18n.Lang .Activity.OpenedPRCount "repo.activity.opened_prs_count_1" "repo.activity.opened_prs_count_n") }}
{{end}} {{if .Permission.CanRead $.UnitTypeIssues}} - {{svg "octicon-issue-closed" 16}} {{.Activity.ClosedIssueCount}}
+ {{svg "octicon-issue-closed"}} {{.Activity.ClosedIssueCount}}
{{.i18n.Tr (TrN .i18n.Lang .Activity.ClosedIssueCount "repo.activity.closed_issues_count_1" "repo.activity.closed_issues_count_n") }}
- {{svg "octicon-issue-opened" 16}} {{.Activity.OpenedIssueCount}}
+ {{svg "octicon-issue-opened"}} {{.Activity.OpenedIssueCount}}
{{.i18n.Tr (TrN .i18n.Lang .Activity.OpenedIssueCount "repo.activity.new_issues_count_1" "repo.activity.new_issues_count_n") }}
{{end}} @@ -120,7 +120,7 @@ {{if gt .Activity.PublishedReleaseCount 0}}

- {{svg "octicon-tag" 16}} + {{svg "octicon-tag"}} {{.i18n.Tr "repo.activity.title.releases_published_by" (.i18n.Tr (TrN .i18n.Lang .Activity.PublishedReleaseCount "repo.activity.title.releases_1" "repo.activity.title.releases_n") .Activity.PublishedReleaseCount) (.i18n.Tr (TrN .i18n.Lang .Activity.PublishedReleaseAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n") .Activity.PublishedReleaseAuthorCount) }}

@@ -139,7 +139,7 @@ {{if gt .Activity.MergedPRCount 0}}

- {{svg "octicon-git-pull-request" 16}} + {{svg "octicon-git-pull-request"}} {{.i18n.Tr "repo.activity.title.prs_merged_by" (.i18n.Tr (TrN .i18n.Lang .Activity.MergedPRCount "repo.activity.title.prs_1" "repo.activity.title.prs_n") .Activity.MergedPRCount) (.i18n.Tr (TrN .i18n.Lang .Activity.MergedPRAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n") .Activity.MergedPRAuthorCount) }}

@@ -155,7 +155,7 @@ {{if gt .Activity.OpenedPRCount 0}}

- {{svg "octicon-git-branch" 16}} + {{svg "octicon-git-branch"}} {{.i18n.Tr "repo.activity.title.prs_opened_by" (.i18n.Tr (TrN .i18n.Lang .Activity.OpenedPRCount "repo.activity.title.prs_1" "repo.activity.title.prs_n") .Activity.OpenedPRCount) (.i18n.Tr (TrN .i18n.Lang .Activity.OpenedPRAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n") .Activity.OpenedPRAuthorCount) }}

@@ -171,7 +171,7 @@ {{if gt .Activity.ClosedIssueCount 0}}

- {{svg "octicon-issue-closed" 16}} + {{svg "octicon-issue-closed"}} {{.i18n.Tr "repo.activity.title.issues_closed_by" (.i18n.Tr (TrN .i18n.Lang .Activity.ClosedIssueCount "repo.activity.title.issues_1" "repo.activity.title.issues_n") .Activity.ClosedIssueCount) (.i18n.Tr (TrN .i18n.Lang .Activity.ClosedIssueAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n") .Activity.ClosedIssueAuthorCount) }}

@@ -187,7 +187,7 @@ {{if gt .Activity.OpenedIssueCount 0}}

- {{svg "octicon-issue-opened" 16}} + {{svg "octicon-issue-opened"}} {{.i18n.Tr "repo.activity.title.issues_created_by" (.i18n.Tr (TrN .i18n.Lang .Activity.OpenedIssueCount "repo.activity.title.issues_1" "repo.activity.title.issues_n") .Activity.OpenedIssueCount) (.i18n.Tr (TrN .i18n.Lang .Activity.OpenedIssueAuthorCount "repo.activity.title.user_1" "repo.activity.title.user_n") .Activity.OpenedIssueAuthorCount) }}

@@ -203,7 +203,7 @@ {{if gt .Activity.UnresolvedIssueCount 0}}

- {{svg "octicon-comment-discussion" 16}} + {{svg "octicon-comment-discussion"}} {{.i18n.Tr (TrN .i18n.Lang .Activity.UnresolvedIssueCount "repo.activity.title.unresolved_conv_1" "repo.activity.title.unresolved_conv_n") .Activity.UnresolvedIssueCount }}

diff --git a/templates/repo/branch/list.tmpl b/templates/repo/branch/list.tmpl index 74025bd5304..51ddf6c1e1b 100644 --- a/templates/repo/branch/list.tmpl +++ b/templates/repo/branch/list.tmpl @@ -16,10 +16,10 @@ {{range .Branches}} {{if eq .Name $.DefaultBranch}} {{if .IsProtected}} - {{svg "octicon-shield-lock" 16}} + {{svg "octicon-shield-lock"}} {{end}} {{$.DefaultBranch}} -

{{svg "octicon-git-commit" 16}}{{ShortSha .Commit.ID.String}} · {{RenderCommitMessage .Commit.CommitMessage $.RepoLink $.Repository.ComposeMetas}} · {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}

+

{{svg "octicon-git-commit"}}{{ShortSha .Commit.ID.String}} · {{RenderCommitMessage .Commit.CommitMessage $.RepoLink $.Repository.ComposeMetas}} · {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}

{{end}} {{end}} @@ -27,8 +27,8 @@ @@ -53,10 +53,10 @@

{{$.i18n.Tr "repo.branch.deleted_by" .DeletedBranch.DeletedBy.Name}} {{TimeSinceUnix .DeletedBranch.DeletedUnix $.i18n.Lang}}

{{else}} {{if .IsProtected}} - {{svg "octicon-shield-lock" 16}} + {{svg "octicon-shield-lock"}} {{end}} {{.Name}} -

{{svg "octicon-git-commit" 16}}{{ShortSha .Commit.ID.String}} · {{RenderCommitMessage .Commit.CommitMessage $.RepoLink $.Repository.ComposeMetas}} · {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}

+

{{svg "octicon-git-commit"}}{{ShortSha .Commit.ID.String}} · {{RenderCommitMessage .Commit.CommitMessage $.RepoLink $.Repository.ComposeMetas}} · {{$.i18n.Tr "org.repo_updated"}} {{TimeSince .Commit.Committer.When $.i18n.Lang}}

{{end}} @@ -77,7 +77,7 @@ {{if not .LatestPullRequest}} {{if .IsIncluded}} - {{svg "octicon-git-pull-request" 16}} {{$.i18n.Tr "repo.branch.included"}} + {{svg "octicon-git-pull-request"}} {{$.i18n.Tr "repo.branch.included"}} {{else if and (not .IsDeleted) $.AllowsPulls (gt .CommitsAhead 0)}} @@ -93,11 +93,11 @@ {{else}} {{if not .LatestPullRequest.IsSameRepo}}{{.LatestPullRequest.BaseRepo.FullName}}{{end}}#{{.LatestPullRequest.Issue.Index}} {{if .LatestPullRequest.HasMerged}} - {{svg "octicon-git-merge" 16}} {{$.i18n.Tr "repo.pulls.merged"}} + {{svg "octicon-git-merge"}} {{$.i18n.Tr "repo.pulls.merged"}} {{else if .LatestPullRequest.Issue.IsClosed}} - {{svg "octicon-git-pull-request" 16}} {{$.i18n.Tr "repo.issues.closed_title"}} + {{svg "octicon-git-pull-request"}} {{$.i18n.Tr "repo.issues.closed_title"}} {{else}} - {{svg "octicon-git-pull-request" 16}} {{$.i18n.Tr "repo.issues.open_title"}} + {{svg "octicon-git-pull-request"}} {{$.i18n.Tr "repo.issues.open_title"}} {{end}} {{end}} @@ -106,14 +106,14 @@ {{end}} {{if and $.IsWriter (not $.IsMirror) (not $.Repository.IsArchived) (not .IsProtected)}} {{if .IsDeleted}} - {{svg "octicon-reply" 16}} + {{svg "octicon-reply"}} {{else}} {{end}} diff --git a/templates/repo/branch_dropdown.tmpl b/templates/repo/branch_dropdown.tmpl index 28aa14abea0..6a8e16c1016 100644 --- a/templates/repo/branch_dropdown.tmpl +++ b/templates/repo/branch_dropdown.tmpl @@ -2,7 +2,7 @@