Skip to content

Commit a1cc628

Browse files
Merge pull request #10 from JohnnyTheTank/userSearch
Added user model and readded access token
2 parents c4c1ac5 + b25ed3e commit a1cc628

10 files changed

Lines changed: 250 additions & 63 deletions

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2016 Jonathan Hornung
3+
Copyright (c) 2018 Jonathan Hornung
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
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 may needs an [access token](#2-access-token) :warning:
1314
* Used promise library: [angular-github-api-factory](https://github.com/JohnnyTheTank/angular-github-api-factory) _(included in distribution files)_
1415

1516
# Documentation
@@ -19,7 +20,10 @@
1920
2. Include file
2021
3. Add dependency
2122
4. Add plugin
22-
2. [USAGE](#3-usage)
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)
2327
1. Models
2428
2. Requests
2529
3. Rate limit
@@ -72,14 +76,40 @@ Add the plugin's directive `aping-github="[]"` to your apiNG directive and [conf
7276
</aping>
7377
```
7478

75-
## 2. USAGE
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
76105

77106
### I. Models
78107
Supported apiNG models
79108

80109
| model | content | support | max items<br>per request | (native) default items<br>per request |
81110
|----------|---------|---------|--------|---------|
82111
| `repo` | **repositories** | full | `100` | `30` |
112+
| `user` | **users** | full | `100` | `30` |
83113

84114
**support:**
85115
* full: _the source platform provides a full list with usable results_ <br>
@@ -100,6 +130,7 @@ Every **apiNG plugin** expects an array of **requests** as html attribute.
100130
Sample requests:
101131
* `[{'user':'JohnnyTheTank'}, {'user':'xremix', 'items':10}]`
102132
* `[{'user':'JohnnyTheTank', 'repo':'apiNG'}]`
133+
* `[{'user':'JohnnyTheTank'}]`
103134

104135
#### Requests by Search
105136
| parameter | sample | default | description | optional |
@@ -111,6 +142,7 @@ Sample requests:
111142

112143
Sample requests:
113144
* `[{'search':'apiNG', 'sort':'stars', 'order':'desc', 'items':50}]`
145+
* `[{'search':'JohnnyTheTank', 'items':10}]`
114146

115147
### III. Rate limit
116148
Visit the official [GitHub Data API documentation](https://developer.github.com/v3/#rate-limiting)

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.9",
7+
"version": "0.8.0",
88
"description": "GitHub plugin for apiNG",
99
"main": "dist/aping-plugin-github.min.js",
1010
"moduleType": [],

demo/aping-config.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use strict";
2+
angular.module('jtt_aping').config(['$provide', function ($provide) {
3+
$provide.value("apingDefaultSettings", {
4+
orderBy: "updated_timestamp",
5+
orderReverse: "true",
6+
apingApiKeys: {
7+
'github': [
8+
{'access_token':'<YOUR_GITHUB_ACCESS_TOKEN>'},
9+
]
10+
//...
11+
}
12+
});
13+
}]);

demo/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,26 @@
88
<script src="../bower_components/apiNG/dist/aping.min.js"></script>
99
<script src="app.js"></script>
1010
<script src="../dist/aping-plugin-github.js"></script>
11+
<script src="aping-config.js"></script>
1112
</head>
1213
<body ng-app="app">
1314

15+
<h1>User by name</h1>
16+
<aping template-url="template.html"
17+
model="user"
18+
items="40"
19+
aping-github="[{'user':'JohnnyTheTank'}]">
20+
</aping>
21+
22+
<hr>
23+
24+
<h1>Users by name</h1>
25+
<aping template-url="template.html"
26+
model="user"
27+
items="40"
28+
aping-github="[{'search':'miriam'}]">
29+
</aping>
30+
1431
<h1>Repos by User</h1>
1532
<aping template-url="template.html"
1633
model="repo"
@@ -37,5 +54,6 @@ <h1>Repos by Name</h1>
3754
order-reverse="true"
3855
aping-github="[{'search':'apiNG', 'sort':'stars', 'order':'desc'}]">
3956
</aping>
57+
-->
4058
</body>
4159
</html>

0 commit comments

Comments
 (0)