Skip to content

Commit

Permalink
Use the comments of #127 to fetch kktix events automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
yhsiang committed Feb 19, 2016
1 parent f2386be commit 56aef99
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion app/app.ls
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ angular.module "g0v.tw" <[firebase btford.markdown pascalprecht.translate]>
http://g0v-tw.kktix.cc/events.json
http://moe.kktix.cc/events.json
http://g0vlawthon.kktix.cc/events.json
http://fr0ntend.kktix.cc/events.json"
http://fr0ntend.kktix.cc/events.json
]>

$scope.events-of = (url) ->
Expand All @@ -51,6 +51,23 @@ angular.module "g0v.tw" <[firebase btford.markdown pascalprecht.translate]>
defer.resolve([event if moment(event.published).diff(moment()) > 0 for event in result.entry])
return defer.promise

$scope.from-github = ->
defer = $q.defer!
result <- $http
.get 'https://api.github.com/repos/g0v/g0v.tw/issues/127/comments'
.success
defer.resolve result
return defer.promise

{ data } <- $scope
.from-github!
.then
re = /http:\/\/(.+\.cc)\/?/
$scope.event-sources = $scope.event-sources.concat ( data
.filter -> re.test it.body
.map -> "http://#{it.body.match re .1}/events.json"
)

$scope.event-sources.map (source) ->
$scope.events-of(source)
.then (events) ->
Expand Down

0 comments on commit 56aef99

Please sign in to comment.