From d23f0390ecb431c54df41b99e9afc688871453d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=83=9D=E3=83=BC=E3=83=AB=20=E3=82=A6=E3=82=A7=E3=83=83?= =?UTF-8?q?=E3=83=96?= Date: Fri, 28 Sep 2018 11:41:24 -0500 Subject: [PATCH] Improved GitHub feed --- app/helpers/github.js | 185 +++++++++++++++++++++++----- app/sass/partials/_github-feed.scss | 1 + 2 files changed, 158 insertions(+), 28 deletions(-) diff --git a/app/helpers/github.js b/app/helpers/github.js index da4f721..c978423 100644 --- a/app/helpers/github.js +++ b/app/helpers/github.js @@ -48,75 +48,197 @@ function generateEvent(event) { switch (event.type) { case "CommitCommentEvent": return ` - ${event.actor.display_login} commented on - commit in + ${event.actor.display_login} commented on + + commit in `; case "CreateEvent": return ` - ${event.actor.display_login} created - ${event.payload.ref_type} ${event.payload.ref} in + ${event.actor.display_login} created ${event.payload.ref_type} + + ${refToBranch(event.payload.ref)} in `; case "DeleteEvent": return ` - ${event.actor.display_login} deleted + ${event.actor.display_login} deleted + ${event.payload.ref_type} ${event.payload.ref} in `; case "ForkEvent": return ` - ${event.actor.display_login} forked - ${event.repo.name} to - ${event.payload.forkee.name} in + ${event.actor.display_login} forked + + ${event.repo.name} to + + ${event.payload.forkee.full_name} `; case "IssueCommentEvent": if (event.payload.issue.pull_request) { return ` - ${event.actor.display_login} commented on pull request - ${event.payload.issue.title} in + ${event.actor.display_login} commented on pull request + + ${event.payload.issue.title} in `; } else { return ` ${event.actor.display_login} commented on issue - ${event.payload.issue.title} in + + ${event.payload.issue.title} in `; } case "IssuesEvent": return ` - ${event.actor.display_login} ${event.payload.action} issue - ${event.payload.issue.title} in + ${event.actor.display_login} ${event.payload.action} issue + + ${event.payload.issue.title} in `; case "PullRequestEvent": return ` - ${event.actor.display_login} ${event.payload.action} pull request - ${event.payload.pull_request.title} in + ${event.actor.display_login} pull request + + ${event.payload.pull_request.title} in `; case "PullRequestReviewCommentEvent": return ` - ${event.actor.display_login} commented on pull request - ${event.payload.pull_request.title} in + ${event.actor.display_login} commented on pull request + + ${event.payload.pull_request.title} in `; case "PushEvent": return ` - ${event.actor.display_login} pushed to - ${refToBranch(event.payload.ref)} in + ${event.actor.display_login} pushed to + + ${refToBranch(event.payload.ref)} in `; case "ReleaseEvent": return ` - ${event.actor.display_login} released - ${event.payload.release.tag_name} in + ${event.actor.display_login} released + + ${event.payload.release.tag_name} in `; case "WatchEvent": return ` - ${event.actor.display_login} starred the repo + ${event.actor.display_login} starred the repo `; default: @@ -135,15 +257,19 @@ function generateGitHubFeed(displayGitHubFeed) { reply.forEach(item => events.push(JSON.parse(item))); for (const event of events) { + const repoName = ` + ${event.repo.name} + `; + renderedEvents.push(`
- + ${event.actor.login}'s avatar

${generateEvent(event)} - ${event.repo.name} + ${event.type !== "ForkEvent" ? repoName : ""} ${relativeDate(new Date(event.created_at))}

@@ -170,8 +296,8 @@ function generateUrl(type, event) { case "comment": return event.payload.comment.html_url; - case "repo": - return `https://github.com/${event.repo.name}`; + case "create": + return `https://github.com/${event.repo.name}/tree/${event.payload.ref}`; case "forkee": return `https://github.com/${event.payload.forkee.full_name}`; @@ -182,11 +308,14 @@ function generateUrl(type, event) { case "pull_request": return event.payload.pull_request.html_url; + case "push": + return `https://github.com/${event.repo.name}/tree/${event.payload.ref.replace("refs/heads/", "")}`; + case "release": return event.payload.release.html_url; - case "push": - return `https://github.com/${event.repo.name}/tree/${event.payload.ref.replace("refs/heads/", "")}`; + case "repo": + return `https://github.com/${event.repo.name}`; default: break; diff --git a/app/sass/partials/_github-feed.scss b/app/sass/partials/_github-feed.scss index 46d1dbd..1c6542a 100644 --- a/app/sass/partials/_github-feed.scss +++ b/app/sass/partials/_github-feed.scss @@ -95,6 +95,7 @@ } .github-feed__event { + cursor: default; line-height: 1.55; @media (max-width: 700px) {