Skip to content

Commit 2d4062c

Browse files
committed
removed access_token & fixed bug
1 parent 4fff6de commit 2d4062c

File tree

8 files changed

+39
-66
lines changed

8 files changed

+39
-66
lines changed

README.md

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
# Information
1111
* **Supported apiNG models: `repo`**
1212
* This plugin supports the [`get-native-data` parameter](https://aping.readme.io/docs/advanced#parameters)
13-
* This plugin needs an [access token](#2-access-token) :warning:
1413
* Used promise library: [angular-github-api-factory](https://github.com/JohnnyTheTank/angular-github-api-factory) _(included in distribution files)_
1514

1615
# Documentation
@@ -20,10 +19,7 @@
2019
2. Include file
2120
3. Add dependency
2221
4. Add plugin
23-
2. [ACCESS TOKEN](#2-access-token)
24-
1. Generate your `access_token`
25-
2. Insert your `access_token` into `aping-config.js`
26-
3. [USAGE](#3-usage)
22+
2. [USAGE](#3-usage)
2723
1. Models
2824
2. Requests
2925
3. Rate limit
@@ -76,32 +72,7 @@ Add the plugin's directive `aping-github="[]"` to your apiNG directive and [conf
7672
</aping>
7773
```
7874

79-
## 2. ACCESS TOKEN
80-
81-
### I. Generate your `access_token`
82-
1. Login on [github.com](https://github.com)
83-
2. Open [github.com/settings/tokens/new](https://github.com/settings/tokens/new)
84-
* Remove all scopes except **public_repo**
85-
* Generate your access_token
86-
87-
### II. Insert your `access_token` into `aping-config.js`
88-
Create and open `js/apiNG/aping-config.js` in your application folder. It should be look like this snippet:
89-
```js
90-
angular.module('jtt_aping').config(['$provide', function ($provide) {
91-
$provide.value("apingDefaultSettings", {
92-
apingApiKeys : {
93-
github: [
94-
{'access_token':'<YOUR_GITHUB_ACCESS_TOKEN>'}
95-
],
96-
//...
97-
}
98-
});
99-
}]);
100-
```
101-
102-
:warning: Replace `<YOUR_GITHUB_ACCESS_TOKEN>` with your github `access_token`
103-
104-
## 3. USAGE
75+
## 2. USAGE
10576

10677
### I. Models
10778
Supported apiNG models

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"authors": [
55
"Jonathan Hornung <jonathan.hornung@gmail.com>"
66
],
7-
"version": "0.7.8",
7+
"version": "0.7.9",
88
"description": "GitHub plugin for apiNG",
99
"main": "dist/aping-plugin-github.min.js",
1010
"moduleType": [],

demo/index.html

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,32 @@
1111
<script src="../dist/aping-plugin-github.js"></script>
1212
</head>
1313
<body ng-app="app">
14+
1415
<h1>Repos by User</h1>
15-
<aping template-url="template.html" model="repo" items="40" aping-github="[{'user':'JohnnyTheTank'}]"></aping>
16+
<aping template-url="template.html"
17+
model="repo"
18+
items="40"
19+
order-by="updated_timestamp"
20+
order-reverse="true"
21+
aping-github="[{'user':'JohnnyTheTank'}]">
22+
</aping>
23+
1624
<hr>
1725
<h1>Repo by User and Name</h1>
18-
<aping template-url="template.html" model="repo" items="40" aping-github="[{'user':'JohnnyTheTank', 'repo':'apiNG'}]"></aping>
26+
<aping template-url="template.html"
27+
model="repo"
28+
items="40"
29+
aping-github="[{'user':'JohnnyTheTank', 'repo':'apiNG'}]">
30+
</aping>
1931
<hr>
20-
<h1>Repos by Name</h1>
21-
<aping template-url="template.html" model="repo" items="20" aping-github="[{'search':'apiNG', 'sort':'stars', 'order':'desc'}]"></aping>
2232

23-
<!--
24-
<h1>Activity by User</h1>
25-
<aping
26-
model="activity"
27-
items="40"
28-
aping-github="[{'user':'passy'}]">
33+
<h1>Repos by Name</h1>
34+
<aping template-url="template.html"
35+
model="repo"
36+
items="20"
37+
order-by="updated_timestamp"
38+
order-reverse="true"
39+
aping-github="[{'search':'apiNG', 'sort':'stars', 'order':'desc'}]">
2940
</aping>
30-
<hr>
31-
-->
3241
</body>
3342
</html>

dist/aping-plugin-github.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
@name: aping-plugin-github
3-
@version: 0.7.8 (03-02-2016)
3+
@version: 0.7.9 (01-06-2016)
44
@author: Jonathan Hornung
55
@url: https://github.com/JohnnyTheTank/apiNG-plugin-github
66
@license: MIT
@@ -31,9 +31,7 @@ angular.module("jtt_aping_github", ['jtt_github'])
3131
}
3232

3333
//create requestObject for api request call
34-
var requestObject = {
35-
access_token: apingUtilityHelper.getApiCredentials(apingGithubHelper.getThisPlatformString(), "access_token"),
36-
};
34+
var requestObject = {};
3735

3836
if (angular.isDefined(request.items)) {
3937
requestObject.per_page = request.items;
@@ -128,7 +126,6 @@ angular.module("jtt_aping_github")
128126
var _this = this;
129127

130128
if (_data.data.constructor === Array) {
131-
132129
angular.forEach(_data.data, function (value, key) {
133130
var tempResult;
134131
if (_helperObject.getNativeData === true || _helperObject.getNativeData === "true") {
@@ -141,7 +138,6 @@ angular.module("jtt_aping_github")
141138
}
142139
});
143140
} else {
144-
145141
if (_data.data.items) {
146142
angular.forEach(_data.data.items, function (value, key) {
147143
var tempResult;
@@ -159,7 +155,7 @@ angular.module("jtt_aping_github")
159155
if (_helperObject.getNativeData === true || _helperObject.getNativeData === "true") {
160156
tempResult = _data.data;
161157
} else {
162-
tempResult = _this.getItemByJsonData(_data, _helperObject.model);
158+
tempResult = _this.getItemByJsonData(_data.data, _helperObject.model);
163159
}
164160
if (tempResult) {
165161
requestResults.push(tempResult);
@@ -291,7 +287,7 @@ angular.module("jtt_github", [])
291287
this.fillDataInObjectByList = function (_object, _params, _list) {
292288

293289
angular.forEach(_list, function (value, key) {
294-
if (typeof _params[value] !== "undefined") {
290+
if (angular.isDefined(_params[value])) {
295291
_object.object[value] = _params[value];
296292
}
297293
});
@@ -301,16 +297,18 @@ angular.module("jtt_github", [])
301297

302298
this.getNew = function (_type, _params) {
303299
var githubSearchData = {
304-
object: {
305-
access_token: _params.access_token,
306-
},
300+
object: {},
307301
url: "",
308302
};
309303

310-
if (typeof _params.per_page !== "undefined") {
304+
if (angular.isDefined(_params.per_page)) {
311305
githubSearchData.object.per_page = _params.per_page;
312306
}
313307

308+
if (angular.isDefined(_params.access_token)) {
309+
githubSearchData.object.access_token = _params.access_token;
310+
}
311+
314312
switch (_type) {
315313
case "user":
316314
githubSearchData.object.per_page = undefined;
@@ -356,7 +354,6 @@ angular.module("jtt_github", [])
356354
githubSearchData.url = this.getApiBaseUrl() + "repos/" + _params.user + "/" + _params.repo + "/events";
357355
break;
358356
}
359-
360357
return githubSearchData;
361358
};
362359
});

dist/aping-plugin-github.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aping-plugin-github",
3-
"version": "0.7.8",
3+
"version": "0.7.9",
44
"description": "GitHub plugin for apiNG",
55
"main": "dist/aping-plugin-github.min.js",
66
"scripts": {

src/aping-github-directive.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ angular.module("jtt_aping_github", ['jtt_github'])
2424
}
2525

2626
//create requestObject for api request call
27-
var requestObject = {
28-
access_token: apingUtilityHelper.getApiCredentials(apingGithubHelper.getThisPlatformString(), "access_token"),
29-
};
27+
var requestObject = {};
3028

3129
if (angular.isDefined(request.items)) {
3230
requestObject.per_page = request.items;

src/aping-github-helper.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ angular.module("jtt_aping_github")
1717
var _this = this;
1818

1919
if (_data.data.constructor === Array) {
20-
2120
angular.forEach(_data.data, function (value, key) {
2221
var tempResult;
2322
if (_helperObject.getNativeData === true || _helperObject.getNativeData === "true") {
@@ -30,7 +29,6 @@ angular.module("jtt_aping_github")
3029
}
3130
});
3231
} else {
33-
3432
if (_data.data.items) {
3533
angular.forEach(_data.data.items, function (value, key) {
3634
var tempResult;
@@ -48,7 +46,7 @@ angular.module("jtt_aping_github")
4846
if (_helperObject.getNativeData === true || _helperObject.getNativeData === "true") {
4947
tempResult = _data.data;
5048
} else {
51-
tempResult = _this.getItemByJsonData(_data, _helperObject.model);
49+
tempResult = _this.getItemByJsonData(_data.data, _helperObject.model);
5250
}
5351
if (tempResult) {
5452
requestResults.push(tempResult);

0 commit comments

Comments
 (0)