Closes #151 #162
2 changed files with 158 additions and 28 deletions
|
@ -48,75 +48,197 @@ function generateEvent(event) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case "CommitCommentEvent":
|
case "CommitCommentEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> commented on
|
<strong><a
|
||||||
<a href="${generateUrl("comment", event)}" title="View this comment on GitHub">commit</a> in
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> commented on
|
||||||
|
|
||||||
|
<a
|
||||||
|
href="${generateUrl("comment", event)}"
|
||||||
|
target="_blank"
|
||||||
|
title="View this comment on GitHub"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>commit</a> in
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "CreateEvent":
|
case "CreateEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> created
|
<strong><a
|
||||||
${event.payload.ref_type} <code>${event.payload.ref}</code> in
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> created ${event.payload.ref_type}
|
||||||
|
|
||||||
|
<code><a
|
||||||
|
href="${generateUrl("create", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this branch on GitHub"
|
||||||
|
>${refToBranch(event.payload.ref)}</a></code> in
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "DeleteEvent":
|
case "DeleteEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> deleted
|
<strong><a
|
||||||
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> deleted
|
||||||
|
|
||||||
${event.payload.ref_type} <code>${event.payload.ref}</code> in
|
${event.payload.ref_type} <code>${event.payload.ref}</code> in
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "ForkEvent":
|
case "ForkEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> forked
|
<strong><a
|
||||||
<strong><a href="${generateUrl("repo", event)}" title="View this repo on GitHub" target="_blank" rel="noopener noreferrer">${event.repo.name}</a></strong> to
|
href="${generateUrl("actor", event)}"
|
||||||
<strong><a href="${generateUrl("forkee", event)}" title="View this repo fork on GitHub" target="_blank" rel="noopener noreferrer">${event.payload.forkee.name}</a></strong> in
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> forked
|
||||||
|
|
||||||
|
<strong><a
|
||||||
|
href="${generateUrl("repo", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this repo on GitHub"
|
||||||
|
>${event.repo.name}</a></strong> to
|
||||||
|
|
||||||
|
<strong><a
|
||||||
|
href="${generateUrl("forkee", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this repo fork on GitHub"
|
||||||
|
>${event.payload.forkee.full_name}</a></strong>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "IssueCommentEvent":
|
case "IssueCommentEvent":
|
||||||
if (event.payload.issue.pull_request) {
|
if (event.payload.issue.pull_request) {
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> commented on pull request
|
<strong><a
|
||||||
<em><a href="${generateUrl("issue", event)}" title="View this comment on GitHub" target="_blank" rel="noopener noreferrer">${event.payload.issue.title}</a></em> in
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> commented on pull request
|
||||||
|
|
||||||
|
<em><a
|
||||||
|
href="${generateUrl("issue", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this comment on GitHub"
|
||||||
|
>${event.payload.issue.title}</a></em> in
|
||||||
`;
|
`;
|
||||||
} else {
|
} else {
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> commented on issue
|
<strong>${event.actor.display_login}</strong> commented on issue
|
||||||
<em><a href="${generateUrl("issue", event)}" title="View this comment on GitHub" target="_blank" rel="noopener noreferrer">${event.payload.issue.title}</a></em> in
|
|
||||||
|
<em><a
|
||||||
|
href="${generateUrl("issue", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this comment on GitHub"
|
||||||
|
>${event.payload.issue.title}</a></em> in
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
|
|
||||||
case "IssuesEvent":
|
case "IssuesEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> ${event.payload.action} issue
|
<strong><a
|
||||||
<em><a href="${generateUrl("issue", event)}" title="View this issue on GitHub" target="_blank" rel="noopener noreferrer">${event.payload.issue.title}</a></em> in
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> ${event.payload.action} issue
|
||||||
|
|
||||||
|
<em><a
|
||||||
|
href="${generateUrl("issue", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this issue on GitHub"
|
||||||
|
>${event.payload.issue.title}</a></em> in
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "PullRequestEvent":
|
case "PullRequestEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> ${event.payload.action} pull request
|
<strong><a
|
||||||
<em><a href="${generateUrl("pull_request", event)}" title="View this pull request on GitHub" target="_blank" rel="noopener noreferrer">${event.payload.pull_request.title}</a></em> in
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> pull request
|
||||||
|
|
||||||
|
<em><a
|
||||||
|
href="${generateUrl("pull_request", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this pull request on GitHub"
|
||||||
|
>${event.payload.pull_request.title}</a></em> in
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "PullRequestReviewCommentEvent":
|
case "PullRequestReviewCommentEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> commented on pull request
|
<strong><a
|
||||||
<em><a href="${generateUrl("pull_request", event)}" title="View this comment on GitHub" target="_blank" rel="noopener noreferrer">${event.payload.pull_request.title}</a></em> in
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> commented on pull request
|
||||||
|
|
||||||
|
<em><a
|
||||||
|
href="${generateUrl("pull_request", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this comment on GitHub"
|
||||||
|
>${event.payload.pull_request.title}</a></em> in
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "PushEvent":
|
case "PushEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> pushed to
|
<strong><a
|
||||||
<code><a href="${generateUrl("push", event)}" title="View this branch on GitHub" target="_blank" rel="noopener noreferrer">${refToBranch(event.payload.ref)}</a></code> in
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> pushed to
|
||||||
|
|
||||||
|
<code><a
|
||||||
|
href="${generateUrl("push", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="View this branch on GitHub"
|
||||||
|
>${refToBranch(event.payload.ref)}</a></code> in
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "ReleaseEvent":
|
case "ReleaseEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> released
|
<strong><a
|
||||||
<em><a href="${generateUrl("release", event)}" title="View this release on GitHub" target="_blank" rel="noopener noreferrer">${event.payload.release.tag_name}</a></em> in
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> released
|
||||||
|
|
||||||
|
<em><a
|
||||||
|
href="${generateUrl("release", event)}"
|
||||||
|
title="View this release on GitHub"
|
||||||
|
target="_blank"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
>${event.payload.release.tag_name}</a></em> in
|
||||||
`;
|
`;
|
||||||
|
|
||||||
case "WatchEvent":
|
case "WatchEvent":
|
||||||
return `
|
return `
|
||||||
<strong>${event.actor.display_login}</strong> starred the repo
|
<strong><a
|
||||||
|
href="${generateUrl("actor", event)}"
|
||||||
|
rel="noopener noreferrer"
|
||||||
|
target="_blank"
|
||||||
|
title="Visit ${event.actor.login}'s profile on GitHub"
|
||||||
|
>${event.actor.display_login}</a></strong> starred the repo
|
||||||
`;
|
`;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -135,15 +257,19 @@ function generateGitHubFeed(displayGitHubFeed) {
|
||||||
reply.forEach(item => events.push(JSON.parse(item)));
|
reply.forEach(item => events.push(JSON.parse(item)));
|
||||||
|
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
|
const repoName = `
|
||||||
|
<a href="${generateUrl("repo", event)}" title="View this repo on GitHub" target="_blank" rel="noopener noreferrer"><strong>${event.repo.name}</strong></a>
|
||||||
|
`;
|
||||||
|
|
||||||
renderedEvents.push(`
|
renderedEvents.push(`
|
||||||
<div class='github-feed__event'>
|
<div class='github-feed__event'>
|
||||||
<a href="${generateUrl("actor", event)}" target="_blank" rel="noopener noreferrer">
|
<a href="${generateUrl("actor", event)}" target="_blank" rel="noopener noreferrer">
|
||||||
<img src="${event.actor.avatar_url}" class="github-feed__event__avatar" alt=""/>
|
<img src="${event.actor.avatar_url}" class="github-feed__event__avatar" alt="${event.actor.login}'s avatar"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
${generateEvent(event)}
|
${generateEvent(event)}
|
||||||
<a href="${generateUrl("repo", event)}" title="View this repo on GitHub" target="_blank" rel="noopener noreferrer"><strong>${event.repo.name}</strong></a>
|
${event.type !== "ForkEvent" ? repoName : ""}
|
||||||
<em class="github-feed__event__time">${relativeDate(new Date(event.created_at))}</em>
|
<em class="github-feed__event__time">${relativeDate(new Date(event.created_at))}</em>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -170,8 +296,8 @@ function generateUrl(type, event) {
|
||||||
case "comment":
|
case "comment":
|
||||||
return event.payload.comment.html_url;
|
return event.payload.comment.html_url;
|
||||||
|
|
||||||
case "repo":
|
case "create":
|
||||||
return `https://github.com/${event.repo.name}`;
|
return `https://github.com/${event.repo.name}/tree/${event.payload.ref}`;
|
||||||
|
|
||||||
case "forkee":
|
case "forkee":
|
||||||
return `https://github.com/${event.payload.forkee.full_name}`;
|
return `https://github.com/${event.payload.forkee.full_name}`;
|
||||||
|
@ -182,11 +308,14 @@ function generateUrl(type, event) {
|
||||||
case "pull_request":
|
case "pull_request":
|
||||||
return event.payload.pull_request.html_url;
|
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":
|
case "release":
|
||||||
return event.payload.release.html_url;
|
return event.payload.release.html_url;
|
||||||
|
|
||||||
case "push":
|
case "repo":
|
||||||
return `https://github.com/${event.repo.name}/tree/${event.payload.ref.replace("refs/heads/", "")}`;
|
return `https://github.com/${event.repo.name}`;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -95,6 +95,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.github-feed__event {
|
.github-feed__event {
|
||||||
|
cursor: default;
|
||||||
line-height: 1.55;
|
line-height: 1.55;
|
||||||
|
|
||||||
@media (max-width: 700px) {
|
@media (max-width: 700px) {
|
||||||
|
|
Loading…
Reference in a new issue