Correct Github urls
This commit is contained in:
parent
60e8ba04ad
commit
4d8e6b735e
1 changed files with 54 additions and 12 deletions
|
@ -5,11 +5,11 @@
|
|||
<div class="last-updated" v-on:click="updateFeed">Last updated: {{ formatDate(lastUpdated) }}</div>
|
||||
|
||||
<div v-for="event in events" class="event">
|
||||
<a v-bind:href="event.actor.url" target="_blank">
|
||||
<a v-bind:href="generateGithubUrl('actor',event)" target="_blank">
|
||||
<img v-bind:src="event.actor.avatar_url" class="avatar"> {{ event.actor.display_login }}
|
||||
</a>
|
||||
<template v-if="event.type == 'CommitCommentEvent'">
|
||||
commented on <a v-bind:href="event.payload.comment.url">commit</a>
|
||||
commented on <a v-bind:href="generateGithubUrl('comment', event)">commit</a>
|
||||
</template>
|
||||
<template v-else-if="event.type == 'CreateEvent'">
|
||||
created {{ event.payload.ref_type }} '{{ event.payload.ref }}'
|
||||
|
@ -18,30 +18,30 @@
|
|||
deleted {{ event.payload.ref_type }} '{{ event.payload.ref }}'
|
||||
</template>
|
||||
<template v-else-if="event.type == 'ForkEvent'">
|
||||
forked <a v-bind:href="event.repo.url" target="_blank">{{ event.repo.name }}</a> to <a v-bind:href="event.payload.forkee.url" target="_blank">{{ event.payload.forkee.name }}</a>
|
||||
forked <a v-bind:href="generateGithubUrl('repo', event)" target="_blank">{{ event.repo.name }}</a> to <a v-bind:href="generateGithubUrl('forkee', event)" target="_blank">{{ event.payload.forkee.name }}</a>
|
||||
</template>
|
||||
<template v-else-if="event.type == 'IssueCommentEvent'">
|
||||
commented on <template v-if="event.payload.issue.pull_request">pull request</template><template v-else>issue</template> <a v-bind:href="event.payload.issue.url" target="_blank">{{ event.payload.issue.title }}</a>
|
||||
commented on <template v-if="event.payload.issue.pull_request">pull request</template><template v-else>issue</template> <a v-bind:href="generateGithubUrl('issue', event)" target="_blank">{{ event.payload.issue.title }}</a>
|
||||
</template>
|
||||
<template v-else-if="event.type == 'IssuesEvent'">
|
||||
{{ event.payload.action }} issue <a v-bind:href="event.payload.issue.url" target="_blank">{{ event.payload.issue.title }}</a>
|
||||
{{ event.payload.action }} issue <a v-bind:href="generateGithubUrl('issue', event)" target="_blank">{{ event.payload.issue.title }}</a>
|
||||
</template>
|
||||
<template v-else-if="event.type == 'PullRequestEvent'">
|
||||
{{ event.payload.action }} pull request <a v-bind:href="event.payload.pull_request.url" target="_blank">{{ event.payload.pull_request.title }}</a>
|
||||
{{ event.payload.action }} pull request <a v-bind:href="generateGithubUrl('pull_request', event)" target="_blank">{{ event.payload.pull_request.title }}</a>
|
||||
</template>
|
||||
<template v-else-if="event.type == 'PullRequestReviewCommentEvent'">
|
||||
commented on pull request <a v-bind:href="event.payload.pull_request.url" target="_blank">{{ event.payload.pull_request.title }}</a>
|
||||
commented on pull request <a v-bind:href="generateGithubUrl('pull_request', event)" target="_blank">{{ event.payload.pull_request.title }}</a>
|
||||
</template>
|
||||
<template v-else-if="event.type == 'PushEvent'">
|
||||
pushed to <span v-html="refToLink(event.payload.ref, event.repo.name)"></span>
|
||||
pushed to <a v-bind:href="generateGithubUrl('push', event)" target="_blank">{{ refToBranch(event.payload.ref) }}</a>
|
||||
</template>
|
||||
<template v-else-if="event.type == 'ReleaseEvent'">
|
||||
released <a v-bind:href="event.payload.release.url" target="_blank">{{ event.payload.release.tag_name }}</a>
|
||||
released <a v-bind:href="generateGithubUrl('release', event)" target="_blank">{{ event.payload.release.tag_name }}</a>
|
||||
</template>
|
||||
<template v-else-if="event.type == 'WatchEvent'">
|
||||
starred the repo
|
||||
</template>
|
||||
in <a v-bind:href="event.repo.url" target="_blank">{{ event.repo.name }}</a>
|
||||
in <a v-bind:href="generateGithubUrl('repo', event)" target="_blank">{{ event.repo.name }}</a>
|
||||
<div class="time-ago">{{ event.created_at | moment('from') }}</div>
|
||||
</div>
|
||||
|
||||
|
@ -78,15 +78,57 @@ export default {
|
|||
component.lastUpdated = new Date();
|
||||
|
||||
},
|
||||
refToLink (ref, repo) {
|
||||
refToBranch (ref) {
|
||||
|
||||
return "<a target='_blank' href='https://github.com/" + repo + "/tree/" + ref.replace('refs/heads/','') + "'>" + ref.replace('refs/heads/','') + "</a>";
|
||||
return ref.replace('refs/heads/','');
|
||||
|
||||
},
|
||||
formatDate (date) {
|
||||
|
||||
return date.toLocaleString('en-US');
|
||||
|
||||
},
|
||||
generateGithubUrl (type, event) {
|
||||
|
||||
switch(type) {
|
||||
case 'actor':
|
||||
return 'https://github.com/' + event.actor.display_login;
|
||||
break;
|
||||
case 'comment':
|
||||
return event.payload.comment.html_url;
|
||||
break;
|
||||
case 'repo':
|
||||
return 'https://github.com' + event.repo.name;
|
||||
break;
|
||||
case 'forkee':
|
||||
return 'https://github.com' + event.payload.forkee.full_name;
|
||||
break;
|
||||
case 'issue':
|
||||
return event.payload.issue.html_url;
|
||||
break;
|
||||
case 'pull_request':
|
||||
return event.payload.pull_request.html_url;
|
||||
break;
|
||||
case 'release':
|
||||
return event.payload.release.html_url;
|
||||
break;
|
||||
case 'push':
|
||||
return 'https://github.com/' + event.repo.name + '/tree/' + event.payload.ref.replace('refs/heads/','');
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
rewriteGithubApiUrl (url) {
|
||||
|
||||
url = url.replace('api.github.com', 'github.com');
|
||||
|
||||
var urlParts = url.split('/');
|
||||
|
||||
urlParts.push(urlParts.splice(4).join('/'));
|
||||
|
||||
return urlParts[0] + '/' + urlParts[1] + '/' + urlParts[2] + '/' + urlParts[4];
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue