2018-05-12 12:03:21 +02:00
< template >
2018-05-18 07:39:36 +02:00
< div id = "github-feed" class = "github-feed" >
< h3 > GitHub < / h3 >
< h5 class = "last-updated" v -on :click = "updateFeed" > Last updated : { { formatDate ( lastUpdated ) } } < / h5 >
2018-05-12 12:03:21 +02:00
2018-05-18 07:39:36 +02:00
< div v-for = "event in events" class="github-feed__event" >
2018-06-19 00:09:11 +02:00
< a v -bind : href = "generateGithubUrl('actor', event)" target = "_blank" rel = "noopener noreferrer" >
2018-05-18 07:39:36 +02:00
< img v -bind :src = "event.actor.avatar_url" class = "github-feed__event__avatar" >
2018-05-12 12:03:21 +02:00
< / a >
2018-05-18 07:39:36 +02:00
< p >
< template v-if = "event.type == 'CommitCommentEvent'" >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > commented on
2018-06-19 00:09:11 +02:00
< a v -bind : href = "generateGithubUrl('comment', event)" title = "View this comment on GitHub" > commit < / a > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' CreateEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > created
2018-05-21 22:26:15 +02:00
{ { event . payload . ref _type } } < code > { { event . payload . ref } } < / code > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' DeleteEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > deleted
2018-05-21 22:26:15 +02:00
{ { event . payload . ref _type } } < code > { { event . payload . ref } } < / code > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' ForkEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > forked
2018-06-19 00:09:11 +02:00
< strong > < a v -bind : href = "generateGithubUrl('repo', event)" title = "View this repo on GitHub" target = "_blank" rel = "noopener noreferrer" > { { event . repo . name } } < / a > < / strong > to
< strong > < a v -bind : href = "generateGithubUrl('forkee', event)" title = "View this repo fork on GitHub" target = "_blank" rel = "noopener noreferrer" > { { event . payload . forkee . name } } < / a > < / strong > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' IssueCommentEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > commented on
< template v-if = "event.payload.issue.pull_request" > pull request < / template > < template v-else > issue < / template >
2018-06-19 00:09:11 +02:00
< em > < a v -bind : href = "generateGithubUrl('issue', event)" title = "View this comment on GitHub" target = "_blank" rel = "noopener noreferrer" > { { event . payload . issue . title } } < / a > < / em > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' IssuesEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > { { event . payload . action } } issue
2018-06-19 00:09:11 +02:00
< em > < a v -bind : href = "generateGithubUrl('issue', event)" title = "View this issue on GitHub" target = "_blank" rel = "noopener noreferrer" > { { event . payload . issue . title } } < / a > < / em > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' PullRequestEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > { { event . payload . action } } pull request
2018-06-19 00:09:11 +02:00
< em > < a v -bind : href = "generateGithubUrl('pull_request', event)" title = "View this pull request on GitHub" target = "_blank" rel = "noopener noreferrer" > { { event . payload . pull _request . title } } < / a > < / em > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' PullRequestReviewCommentEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > commented on pull request
2018-06-19 00:09:11 +02:00
< em > < a v -bind : href = "generateGithubUrl('pull_request', event)" title = "View this comment on GitHub" target = "_blank" rel = "noopener noreferrer" > { { event . payload . pull _request . title } } < / a > < / em > in
2018-05-18 07:39:36 +02:00
< / template >
2018-05-12 12:03:21 +02:00
2018-05-18 07:39:36 +02:00
< template v -else -if = " event.type = = ' PushEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > pushed to
2018-06-19 00:09:11 +02:00
< code > < a v -bind : href = "generateGithubUrl('push', event)" title = "View this branch on GitHub" target = "_blank" rel = "noopener noreferrer" > { { refToBranch ( event . payload . ref ) } } < / a > < / code > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' ReleaseEvent ' " >
2018-05-18 08:03:45 +02:00
< strong > { { event . actor . display _login } } < / strong > released
2018-06-19 00:09:11 +02:00
< em > < a v -bind : href = "generateGithubUrl('release', event)" title = "View this release on GitHub" target = "_blank" rel = "noopener noreferrer" > { { event . payload . release . tag _name } } < / a > < / em > in
2018-05-18 07:39:36 +02:00
< / template >
< template v -else -if = " event.type = = ' WatchEvent ' " >
< strong > { { event . actor . display _login } } < / strong > starred the repo
< / template >
2018-06-19 00:09:11 +02:00
< a v -bind : href = "generateGithubUrl('repo', event)" title = "View this repo on GitHub" target = "_blank" rel = "noopener noreferrer" > < strong > { { event . repo . name } } < / strong > < / a >
2018-05-18 07:39:36 +02:00
< em class = "github-feed__event__time" > { { event . created _at | moment ( 'from' ) } } < / em >
< / p >
< / div >
< / div >
2018-05-12 12:03:21 +02:00
< / template >
< script >
2018-06-21 00:08:47 +02:00
export default {
data ( ) {
return {
events : [ ] ,
updateInterval : { } ,
lastUpdated : new Date ( )
}
2018-05-12 12:03:21 +02:00
} ,
2018-05-18 07:39:36 +02:00
2018-06-21 00:08:47 +02:00
mounted ( ) {
this . updateFeed ( ) ;
this . updateInterval = setInterval ( this . updateFeed , 60 * 1000 ) ;
2018-05-12 12:03:21 +02:00
} ,
2018-05-12 20:13:12 +02:00
2018-06-21 00:08:47 +02:00
methods : {
updateFeed ( ) {
const component = this ;
component . $http . get ( "https://lbry.tech/github-feed" ) . then ( response => {
component . events = response . body ;
} ) . catch ( error => {
console . log ( "Unable to display GitHub feed:\n" , error ) ;
} ) ;
component . lastUpdated = new Date ( ) ;
} ,
refToBranch ( ref ) {
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 ;
}
2018-05-12 20:13:12 +02:00
}
2018-06-21 00:08:47 +02:00
} ,
2018-05-12 20:13:12 +02:00
2018-06-21 00:08:47 +02:00
name : "GithubFeed"
} ;
2018-05-12 12:03:21 +02:00
< / script >
< style lang = "scss" >
2018-05-18 07:39:36 +02:00
@ import "../scss/init/colors" ;
2018-05-12 12:03:21 +02:00
2018-05-18 07:39:36 +02:00
. github - feed {
border - bottom : 1 px solid rgba ( $black , 0.05 ) ;
border - left : 1 px solid rgba ( $black , 0.05 ) ;
font - size : 0.8 rem ;
grid - area : github ;
position : relative ;
@ media ( min - width : 1301 px ) {
padding - top : 3.7 rem ;
}
@ media ( min - width : 1001 px ) and ( max - width : 1300 px ) {
padding - top : 2.95 rem ;
}
@ media ( min - width : 1001 px ) {
padding - bottom : 2 rem ;
padding - right : 10 % ;
padding - left : 2 rem ;
}
@ media ( max - width : 1000 px ) {
padding - top : 2 rem ;
padding - bottom : 2 rem ;
}
@ media ( min - width : 901 px ) {
padding - right : 1 rem ;
padding - left : 1 rem ;
}
@ media ( max - width : 900 px ) {
padding - right : 2 rem ;
padding - left : 2 rem ;
}
@ media ( max - width : 700 px ) {
overflow - x : auto ;
overflow - y : hidden ;
white - space : nowrap ;
}
h3 , h5 {
@ media ( min - width : 1001 px ) {
text - align : center ;
}
}
h3 {
letter - spacing : 0.1 rem ;
line - height : 1 ;
text - transform : uppercase ;
width : 100 % ;
@ media ( min - width : 1301 px ) {
top : 2.15 rem ; left : 0 ;
color : rgba ( $black , 0.045 ) ;
font - size : 4 rem ;
position : absolute ;
}
@ media ( max - width : 1300 px ) {
color : $black ;
}
@ media ( min - width : 901 px ) and ( max - width : 1300 px ) {
font - size : 3 rem ;
}
@ media ( max - width : 900 px ) {
font - size : 2 rem ;
margin - bottom : 1 rem ;
}
}
h5 {
font - style : italic ;
font - weight : normal ;
@ media ( min - width : 1001 px ) {
margin - bottom : 3 rem ;
}
@ media ( min - width : 901 px ) and ( max - width : 1000 px ) {
margin - bottom : 2 rem ;
}
@ media ( max - width : 900 px ) {
margin - bottom : 0.5 rem ;
position : relative ;
top : - 1 rem ;
}
}
2018-05-12 12:03:21 +02:00
}
2018-05-18 07:39:36 +02:00
. github - feed _ _event {
2018-05-24 02:39:04 +02:00
line - height : 1.55 ;
2018-05-18 07:39:36 +02:00
@ media ( max - width : 700 px ) {
display : inline - block ;
margin - right : 1.25 rem ;
vertical - align : top ;
width : 200 px ;
}
& : not ( : last - of - type ) {
@ media ( min - width : 701 px ) {
margin - bottom : 1.25 rem ;
}
}
> a : first - of - type {
font - weight : 700 ;
margin - bottom : 0.5 rem ;
2018-06-06 22:05:18 +02:00
width : 100 % ;
2018-05-18 07:39:36 +02:00
}
> p : first - of - type {
2018-05-21 22:26:15 +02:00
@ media ( max - width : 700 px ) {
box - shadow : 0 2 px 5 px rgba ( $black , 0.025 ) ;
}
2018-05-18 08:03:45 +02:00
code {
background - color : $black ;
border - radius : 3 px ;
color : $white ;
font - size : 80 % ;
letter - spacing : 0.05 rem ;
padding : 0.2 rem 0.5 rem ;
2018-05-24 02:39:04 +02:00
position : relative ;
top : - 1 px ;
2018-05-18 08:03:45 +02:00
}
em : not ( . github - feed _ _event _ _time ) {
text - decoration : underline ;
}
2018-05-18 07:39:36 +02:00
@ media ( min - width : 701 px ) {
display : inline - block ;
margin - left : 0.5 rem ;
vertical - align : top ;
width : calc ( 100 % - 4.5 rem ) ;
}
@ media ( max - width : 700 px ) {
top : - 3.5 rem ; left : 5 % ;
background - color : $white ;
border : 1 px solid rgba ( $gray , 0.1 ) ;
border - radius : 3 px ;
padding : 1 rem ;
position : relative ;
white - space : normal ;
width : 90 % ;
}
}
2018-05-12 12:03:21 +02:00
}
2018-05-18 07:39:36 +02:00
. github - feed _ _event _ _avatar {
border : 1 px solid rgba ( $gray , 0.1 ) ;
border - radius : 3 px ;
object - position : center ;
object - fit : cover ;
@ media ( min - width : 701 px ) {
width : 2.5 rem ; height : 2.5 rem ;
}
@ media ( max - width : 700 px ) {
width : 100 % ; height : 100 % ;
}
2018-05-12 12:18:55 +02:00
}
2018-05-12 12:03:21 +02:00
2018-05-18 07:39:36 +02:00
. github - feed _ _event _ _time {
color : $gray ;
display : block ;
2018-05-18 08:03:45 +02:00
@ media ( max - width : 700 px ) {
padding - top : 1 rem ;
}
2018-05-18 07:39:36 +02:00
}
< / style >