Skip to content

Commit 2672124

Browse files
authored
fix: Visual Enhancements to GitHub API Example (sahat#1351)
1 parent 2c4538a commit 2672124

File tree

1 file changed

+52
-11
lines changed

1 file changed

+52
-11
lines changed

views/api/github.pug

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,20 @@ block content
2727
ul.list-unstyled
2828
li
2929
strong Username:
30+
|
3031
| #{ userInfo.login }
3132
li
3233
strong Followers:
34+
|
3335
| #{ userInfo.followers }
3436
li
3537
strong Public Repositories:
38+
|
3639
| #{ userInfo.public_repos }
3740
li
3841
strong GitHub Profile:
3942
|
43+
|
4044
a(href=userInfo.html_url, target='_blank') #{ userInfo.html_url }
4145

4246
if userRepos.length > 0
@@ -56,38 +60,75 @@ block content
5660
each event in userEvents
5761
if event.type === 'PullRequestEvent'
5862
li
59-
| Pull request created
60-
a(href=event.payload.pull_request.html_url, target='_blank') #{ event.payload.pull_request.title }
63+
| Pull request #{ event.payload.action }
64+
|
65+
a(href=event.payload.pull_request.html_url, target='_blank') #{ event.payload.pull_request.title || `#${event.payload.number}` }
6166
|
6267
| in
68+
|
6369
a(href=event.repo.url.replace('api.github.com/repos', 'github.com'), target='_blank') #{ event.repo.name }
64-
else if event.type === 'IssuesEvent' && event.payload.action === 'opened'
70+
else if event.type === 'PushEvent'
6571
li
66-
| Issue created
67-
a(href=event.payload.issue.html_url, target='_blank') #{ event.payload.issue.title }
72+
| Pushed to
6873
|
69-
| in
7074
a(href=event.repo.url.replace('api.github.com/repos', 'github.com'), target='_blank') #{ event.repo.name }
71-
else if event.type === 'IssuesEvent' && event.payload.action === 'closed'
75+
|
76+
| (#{ event.payload.ref.replace('refs/heads/', '') })
77+
else if event.type === 'IssuesEvent'
7278
li
73-
| Issue closed
74-
a(href=event.payload.issue.html_url, target='_blank') #{ event.payload.issue.title }
79+
| Issue #{ event.payload.action }
80+
|
81+
a(href=event.payload.issue.html_url, target='_blank') #{ event.payload.issue.title || `#${event.payload.issue.number}` }
7582
|
7683
| in
84+
|
7785
a(href=event.repo.url.replace('api.github.com/repos', 'github.com'), target='_blank') #{ event.repo.name }
7886
else if event.type === 'IssueCommentEvent'
7987
li
80-
| Commented
81-
a(href=event.payload.comment.html_url, target='_blank') #{ event.payload.comment.id }
88+
| Commented on issue
89+
|
90+
a(href=event.payload.issue.html_url, target='_blank') #{ event.payload.issue.title || `#${event.payload.issue.number}` }
91+
|
92+
| in
93+
|
94+
a(href=event.repo.url.replace('api.github.com/repos', 'github.com'), target='_blank') #{ event.repo.name }
95+
else if event.type === 'CreateEvent'
96+
li
97+
| Created #{ event.payload.ref_type }
98+
|
99+
if event.payload.ref
100+
| #{ event.payload.ref }
101+
|
102+
| in
103+
|
104+
a(href=event.repo.url.replace('api.github.com/repos', 'github.com'), target='_blank') #{ event.repo.name }
105+
else if event.type === 'DeleteEvent'
106+
li
107+
| Deleted #{ event.payload.ref_type }
108+
|
109+
| #{ event.payload.ref }
82110
|
83111
| in
112+
|
84113
a(href=event.repo.url.replace('api.github.com/repos', 'github.com'), target='_blank') #{ event.repo.name }
114+
else if event.type === 'ForkEvent'
115+
li
116+
| Forked
117+
|
118+
a(href=event.repo.url.replace('api.github.com/repos', 'github.com'), target='_blank') #{ event.repo.name }
119+
else if event.type === 'WatchEvent'
120+
li
121+
| #{ event.payload.action === 'started' ? 'Starred' : event.payload.action }
122+
|
123+
a(href=event.repo.url.replace('api.github.com/repos', 'github.com'), target='_blank') #{ event.repo.name }
124+
85125
else
86126
.alert.alert-warning
87127
if authFailure === 'NotLoggedIn'
88128
| Please log in to access your GitHub profile information.
89129
else if authFailure === 'NotGitHubAuthorized'
90130
| You are logged in but have not linked your GitHub account.
131+
|
91132
a(href='/auth/github') Link your GitHub account
92133
|
93134
| to access your GitHub profile information.

0 commit comments

Comments
 (0)