loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Refactor dashboard/feed.tmpl (#26956)

- ~~Refactor `ActionType` to `models/activities/action_type.go`~~
- Replace the magic number in `feed.tmlp` with `InAction`

authored by

CaiCandong and committed by
GitHub
30cea70d f20e317d

+39 -30
+9
models/activities/action.go
··· 126 126 } 127 127 } 128 128 129 + func (at ActionType) InActions(actions ...string) bool { 130 + for _, action := range actions { 131 + if action == at.String() { 132 + return true 133 + } 134 + } 135 + return false 136 + } 137 + 129 138 // Action represents user operation type and other information to 130 139 // repository. It implemented interface base.Actioner so that can be 131 140 // used in template render.
+30 -30
templates/user/dashboard/feeds.tmpl
··· 11 11 {{else}} 12 12 {{.ShortActUserName}} 13 13 {{end}} 14 - {{if eq .GetOpType 1}} 14 + {{if .GetOpType.InActions "create_repo"}} 15 15 {{$.locale.Tr "action.create_repo" (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}} 16 - {{else if eq .GetOpType 2}} 16 + {{else if .GetOpType.InActions "rename_repo"}} 17 17 {{$.locale.Tr "action.rename_repo" (.GetContent|Escape) (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}} 18 - {{else if eq .GetOpType 5}} 18 + {{else if .GetOpType.InActions "commit_repo"}} 19 19 {{if .Content}} 20 20 {{$.locale.Tr "action.commit_repo" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}} 21 21 {{else}} 22 22 {{$.locale.Tr "action.create_branch" (.GetRepoLink|Escape) (.GetRefLink|Escape) (Escape .GetBranch) (.ShortRepoPath|Escape) | Str2html}} 23 23 {{end}} 24 - {{else if eq .GetOpType 6}} 24 + {{else if .GetOpType.InActions "create_issue"}} 25 25 {{$index := index .GetIssueInfos 0}} 26 26 {{$.locale.Tr "action.create_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 27 - {{else if eq .GetOpType 7}} 27 + {{else if .GetOpType.InActions "create_pull_request"}} 28 28 {{$index := index .GetIssueInfos 0}} 29 29 {{$.locale.Tr "action.create_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 30 - {{else if eq .GetOpType 8}} 30 + {{else if .GetOpType.InActions "transfer_repo"}} 31 31 {{$.locale.Tr "action.transfer_repo" .GetContent (.GetRepoLink|Escape) (.ShortRepoPath|Escape) | Str2html}} 32 - {{else if eq .GetOpType 9}} 32 + {{else if .GetOpType.InActions "push_tag"}} 33 33 {{$.locale.Tr "action.push_tag" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}} 34 - {{else if eq .GetOpType 10}} 34 + {{else if .GetOpType.InActions "comment_issue"}} 35 35 {{$index := index .GetIssueInfos 0}} 36 36 {{$.locale.Tr "action.comment_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 37 - {{else if eq .GetOpType 11}} 37 + {{else if .GetOpType.InActions "merge_pull_request"}} 38 38 {{$index := index .GetIssueInfos 0}} 39 39 {{$.locale.Tr "action.merge_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 40 - {{else if eq .GetOpType 12}} 40 + {{else if .GetOpType.InActions "close_issue"}} 41 41 {{$index := index .GetIssueInfos 0}} 42 42 {{$.locale.Tr "action.close_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 43 - {{else if eq .GetOpType 13}} 43 + {{else if .GetOpType.InActions "reopen_issue"}} 44 44 {{$index := index .GetIssueInfos 0}} 45 45 {{$.locale.Tr "action.reopen_issue" ((printf "%s/issues/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 46 - {{else if eq .GetOpType 14}} 46 + {{else if .GetOpType.InActions "close_pull_request"}} 47 47 {{$index := index .GetIssueInfos 0}} 48 48 {{$.locale.Tr "action.close_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 49 - {{else if eq .GetOpType 15}} 49 + {{else if .GetOpType.InActions "reopen_pull_request"}} 50 50 {{$index := index .GetIssueInfos 0}} 51 51 {{$.locale.Tr "action.reopen_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 52 - {{else if eq .GetOpType 16}} 52 + {{else if .GetOpType.InActions "delete_tag"}} 53 53 {{$index := index .GetIssueInfos 0}} 54 54 {{$.locale.Tr "action.delete_tag" (.GetRepoLink|Escape) (.GetTag|Escape) (.ShortRepoPath|Escape) | Str2html}} 55 - {{else if eq .GetOpType 17}} 55 + {{else if .GetOpType.InActions "delete_branch"}} 56 56 {{$index := index .GetIssueInfos 0}} 57 57 {{$.locale.Tr "action.delete_branch" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}} 58 - {{else if eq .GetOpType 18}} 58 + {{else if .GetOpType.InActions "mirror_sync_push"}} 59 59 {{$.locale.Tr "action.mirror_sync_push" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}} 60 - {{else if eq .GetOpType 19}} 60 + {{else if .GetOpType.InActions "mirror_sync_create"}} 61 61 {{$.locale.Tr "action.mirror_sync_create" (.GetRepoLink|Escape) (.GetRefLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}} 62 - {{else if eq .GetOpType 20}} 62 + {{else if .GetOpType.InActions "mirror_sync_delete"}} 63 63 {{$.locale.Tr "action.mirror_sync_delete" (.GetRepoLink|Escape) (.GetBranch|Escape) (.ShortRepoPath|Escape) | Str2html}} 64 - {{else if eq .GetOpType 21}} 64 + {{else if .GetOpType.InActions "approve_pull_request"}} 65 65 {{$index := index .GetIssueInfos 0}} 66 66 {{$.locale.Tr "action.approve_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 67 - {{else if eq .GetOpType 22}} 67 + {{else if .GetOpType.InActions "reject_pull_request"}} 68 68 {{$index := index .GetIssueInfos 0}} 69 69 {{$.locale.Tr "action.reject_pull_request" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 70 - {{else if eq .GetOpType 23}} 70 + {{else if .GetOpType.InActions "comment_pull"}} 71 71 {{$index := index .GetIssueInfos 0}} 72 72 {{$.locale.Tr "action.comment_pull" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) | Str2html}} 73 - {{else if eq .GetOpType 24}} 73 + {{else if .GetOpType.InActions "publish_release"}} 74 74 {{$linkText := .Content | RenderEmoji $.Context}} 75 75 {{$.locale.Tr "action.publish_release" (.GetRepoLink|Escape) ((printf "%s/releases/tag/%s" .GetRepoLink .GetTag)|Escape) (.ShortRepoPath|Escape) $linkText | Str2html}} 76 - {{else if eq .GetOpType 25}} 76 + {{else if .GetOpType.InActions "review_dismissed"}} 77 77 {{$index := index .GetIssueInfos 0}} 78 78 {{$reviewer := index .GetIssueInfos 1}} 79 79 {{$.locale.Tr "action.review_dismissed" ((printf "%s/pulls/%s" .GetRepoLink $index) |Escape) $index (.ShortRepoPath|Escape) $reviewer | Str2html}} 80 80 {{end}} 81 81 </div> 82 - {{if or (eq .GetOpType 5) (eq .GetOpType 18)}} 82 + {{if .GetOpType.InActions "commit_repo" "mirror_sync_push"}} 83 83 {{$push := ActionContent2Commits .}} 84 84 {{$repoLink := .GetRepoLink}} 85 85 {{range $push.Commits}} ··· 95 95 {{if and (gt $push.Len 1) $push.CompareURL}} 96 96 <a href="{{AppSubUrl}}/{{$push.CompareURL}}">{{$.locale.Tr "action.compare_commits" $push.Len}} »</a> 97 97 {{end}} 98 - {{else if eq .GetOpType 6}} 98 + {{else if .GetOpType.InActions "create_issue"}} 99 99 <span class="text truncate issue title">{{index .GetIssueInfos 1 | RenderEmoji $.Context | RenderCodeBlock}}</span> 100 - {{else if eq .GetOpType 7}} 100 + {{else if .GetOpType.InActions "create_pull_request"}} 101 101 <span class="text truncate issue title">{{index .GetIssueInfos 1 | RenderEmoji $.Context | RenderCodeBlock}}</span> 102 - {{else if or (eq .GetOpType 10) (eq .GetOpType 21) (eq .GetOpType 22) (eq .GetOpType 23)}} 102 + {{else if .GetOpType.InActions "comment_issue" "approve_pull_request" "reject_pull_request" "comment_pull"}} 103 103 <a href="{{.GetCommentLink}}" class="text truncate issue title">{{.GetIssueTitle | RenderEmoji $.Context | RenderCodeBlock}}</a> 104 104 {{$comment := index .GetIssueInfos 1}} 105 105 {{if gt (len $comment) 0}} 106 106 <div class="flex-item-body">{{$comment | RenderEmoji $.Context | RenderCodeBlock}}</div> 107 107 {{end}} 108 - {{else if eq .GetOpType 11}} 108 + {{else if .GetOpType.InActions "merge_pull_request"}} 109 109 <div class="flex-item-body">{{index .GetIssueInfos 1}}</div> 110 - {{else if or (eq .GetOpType 12) (eq .GetOpType 13) (eq .GetOpType 14) (eq .GetOpType 15)}} 110 + {{else if .GetOpType.InActions "close_issue" "reopen_issue" "close_pull_request" "reopen_pull_request"}} 111 111 <span class="text truncate issue title">{{.GetIssueTitle | RenderEmoji $.Context | RenderCodeBlock}}</span> 112 - {{else if eq .GetOpType 25}} 112 + {{else if .GetOpType.InActions "pull_review_dismissed"}} 113 113 <div class="flex-item-body">{{$.locale.Tr "action.review_dismissed_reason"}}</div> 114 114 <div class="flex-item-body">{{index .GetIssueInfos 2 | RenderEmoji $.Context}}</div> 115 115 {{end}}