-
Notifications
You must be signed in to change notification settings - Fork 6
/
github-example.js
54 lines (47 loc) · 1.64 KB
/
github-example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* global angular */
(function() {
'use strict';
var app =
angular.module('traverson-angular-github-example',
['traverson', 'ngSanitize']);
var rootUri = 'https://api.github.com/';
app.controller('generalSetup', function($scope) {
$scope.code =
'var rootUri = \'' + rootUri + '\';<br>' +
'var api = traverson.from(rootUri);<br>';
});
app.service('apiService', function(traverson) {
var api = traverson.from(rootUri);
this.commitComment = function() {
return api
.json()
.follow('repository_url', 'commits_url', 'comments_url')
.withTemplateParameters({
owner: 'traverson',
repo: 'traverson',
sha: '5c82c74583ee67eae727466179dd66c91592dd4a'
}).getResource();
};
});
app.controller('commitCommentController', function($scope, apiService) {
$scope.start = function() {
$scope.response = '... talking to GitHub, please stand by ...';
apiService.commitComment().result.then(function(resource) {
$scope.response = JSON.stringify(resource, null, 2);
}, function(err) {
$scope.response = err.message || JSON.stringify(err);
});
};
$scope.code =
'api<br/>' +
'.json()<br>' +
'.follow(\'repository_url\', \'commits_url\', \'comments_url\')<br>' +
'.withTemplateParameters({<br>' +
' owner: \'traverson\',<br>' +
' repo: \'traverson\',<br>' +
' sha: \'5c82c74583ee67eae727466179dd66c91592dd4a\'<br>' +
')}.result.then(function(resource) {<br>' +
' // do something with the resource...<br>' +
'});<br>';
});
})();