Skip to content

Commit ac40d5f

Browse files
committed
first stable version
1 parent 761e07c commit ac40d5f

File tree

9 files changed

+461
-2
lines changed

9 files changed

+461
-2
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/bower_components
2+
/.idea/
3+
/.codekit-cache/
4+
/config.codekit
5+
/node_modules

Gruntfile.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
module.exports = function(grunt) {
2+
3+
grunt.initConfig({
4+
pkg: grunt.file.readJSON('package.json'),
5+
uglify: {
6+
js: {
7+
files : {
8+
'dist/angular-github-api-factory.min.js' : ['src/angular-github-api-factory.js']
9+
}
10+
},
11+
options: {
12+
banner: '\n/*! <%= pkg.name %> v<%= pkg.version %> (<%= grunt.template.today("dd-mm-yyyy") %>) by <%= pkg.author %> */\n',
13+
}
14+
},
15+
watch: {
16+
minifiyJs: {
17+
files: [
18+
'src/angular-github-api-factory.js'
19+
],
20+
tasks: ['uglify'],
21+
options: {
22+
spawn: true,
23+
},
24+
},
25+
},
26+
});
27+
28+
grunt.loadNpmTasks('grunt-contrib-uglify');
29+
grunt.loadNpmTasks('grunt-contrib-watch');
30+
31+
grunt.registerTask('default', ['watch']);
32+
33+
};

README.md

Lines changed: 120 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,120 @@
1-
# angular-github-api-factory
2-
AngularJS Factory for GitHub v3 JSON REST API requests
1+
**angular-github-api-factory** is an angularjs module with a github api factory.
2+
3+
Author: Jonathan Hornung ([JohnnyTheTank](https://github.com/JohnnyTheTank))
4+
5+
## Usage
6+
7+
1. Install via [bower](http://bower.io/) :
8+
1. `bower install --save angular-github-api-factory`
9+
2. Add `jtt_github` to your application's module dependencies.
10+
3. Include dependencies in your HTML.
11+
1. When using bower:
12+
13+
```html
14+
<script src="bower_components/angular/angular.js"></script>
15+
<script src="bower_components/angular-github-api-factory/src/angular-github-api-factory.js"></script>
16+
```
17+
18+
4. Use the factory `githubFactory`.
19+
20+
21+
### factory methods
22+
23+
#### getUser
24+
```js
25+
githubFactory.getUser({
26+
user:"<USERNAME_NAME>",
27+
access_token:"<ACCESS_TOKEN>"
28+
}).success(function(_data){
29+
//on success
30+
}).error(function (_data) {
31+
//on error
32+
});
33+
```
34+
35+
#### getRepo
36+
```js
37+
githubFactory.getRepoByUserAndName({
38+
user:"<USER_NAME>",
39+
repo:"<REPO_NAME>",
40+
access_token:"<ACCESS_TOKEN>"
41+
}).success(function(_data){
42+
//on success
43+
}).error(function (_data) {
44+
//on error
45+
});
46+
```
47+
48+
#### getRepos
49+
```js
50+
// https://developer.github.com/v3/search/#search-repositories
51+
githubFactory.getReposByName({
52+
q:"<SEARCH_STRING>",
53+
sort:"<SORT_STRING>", // (optional) 'stars', 'forks', or 'updated'
54+
order:"<SORT_ORDER>", // (optional) 'desc', 'asc'
55+
per_page:"<ITEMS_PER_PAGE>", // (optional) default: 20
56+
access_token:"<ACCESS_TOKEN>"
57+
}).success(function(_data){
58+
//on success
59+
}).error(function (_data) {
60+
//on error
61+
});
62+
```
63+
64+
```js
65+
githubFactory.getReposByUser({
66+
user:"<USER_NAME>",
67+
q:"<SEARCH_STRING>", // (optional)
68+
sort:"<SORT_STRING>", // (optional) 'stars', 'forks', or 'updated'
69+
order:"<SORT_ORDER>", // (optional) 'desc', 'asc'
70+
per_page:"<ITEMS_PER_PAGE>", // (optional) default: 20
71+
access_token:"<ACCESS_TOKEN>"
72+
}).success(function(_data){
73+
//on success
74+
}).error(function (_data) {
75+
//on error
76+
});
77+
```
78+
79+
#### getEvents
80+
```js
81+
githubFactory.getEventsFromRepoByUserAndName({
82+
user:"<USER_NAME>",
83+
repo:"<REPO_NAME>",
84+
q:"<SEARCH_STRING>", // (optional)
85+
sort:"<SORT_STRING>", // (optional)
86+
order:"<SORT_ORDER>", // (optional) 'desc', 'asc'
87+
per_page:"<ITEMS_PER_PAGE>", // (optional) default: 20
88+
access_token:"<ACCESS_TOKEN>"
89+
}).success(function(_data){
90+
//on success
91+
}).error(function (_data) {
92+
//on error
93+
});
94+
```
95+
96+
```js
97+
githubFactory.getEventsByUser({
98+
user:"<USER_NAME>",
99+
q:"<SEARCH_STRING>", // (optional)
100+
sort:"<SORT_STRING>", // (optional)
101+
order:"<SORT_ORDER>", // (optional) 'desc', 'asc'
102+
per_page:"<ITEMS_PER_PAGE>", // (optional) default: 20
103+
access_token:"<ACCESS_TOKEN>"
104+
}).success(function(_data){
105+
//on success
106+
}).error(function (_data) {
107+
//on error
108+
});
109+
```
110+
111+
112+
## Github JSON API
113+
114+
* docs: https://developer.github.com/v3/
115+
* api playground: https://apigee.com/console/github
116+
117+
118+
## License
119+
120+
MIT

bower.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "angular-github-api-factory",
3+
"description": "angularjs factory for github json rest api requests",
4+
"version": "0.1.0",
5+
"main": "Gruntfile.js",
6+
"authors": [
7+
"Jonathan Hornung"
8+
],
9+
"license": "MIT",
10+
"keywords": [
11+
"angularjs",
12+
"angular",
13+
"github",
14+
"api",
15+
"factory"
16+
],
17+
"homepage": "https://github.com/JohnnyTheTank/angular-github-api-factory",
18+
"moduleType": [
19+
"globals"
20+
],
21+
"ignore": [
22+
"**/.*",
23+
"node_modules",
24+
"bower_components",
25+
"test",
26+
"tests"
27+
],
28+
"dependencies": {
29+
"angular": "*"
30+
}
31+
}

demo/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!doctype html>
2+
<html lang="de">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>angular-github-api-factory</title>
6+
7+
<script src="../bower_components/angular/angular.min.js"></script>
8+
<script src="js/app.js"></script>
9+
<script src="../src/angular-github-api-factory.js"></script>
10+
11+
</head>
12+
<body ng-app="app">
13+
<div ng-controller="controller">
14+
Look in your console
15+
</div>
16+
17+
</body>
18+
</html>

demo/js/app.js

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
var app = angular.module("app", ['jtt_github']);
2+
app.controller('controller', ['$scope', 'githubFactory', function($scope, githubFactory) {
3+
4+
//var _access_token = "<YOUR_GITHUB_ACCESS_TOKEN>";
5+
var _access_token = "3448ed82e2f52693030ab139a3fef133a8b01853";
6+
7+
githubFactory.getUser({
8+
user:"xremix",
9+
access_token:_access_token
10+
}).success(function(_data){
11+
console.info("user", _data);
12+
});
13+
14+
githubFactory.getReposByUser({
15+
user:"xremix",
16+
per_page: 20,
17+
access_token:_access_token
18+
}).success(function(_data){
19+
console.info("repos by user", _data);
20+
});
21+
22+
githubFactory.getReposByName({
23+
q:"apiNG-plugin",
24+
per_page: 20,
25+
access_token:_access_token
26+
}).success(function(_data){
27+
console.info("repos by name", _data);
28+
});
29+
30+
githubFactory.getEventsByUser({
31+
user:"xremix",
32+
per_page: 20,
33+
access_token:_access_token
34+
}).success(function(_data){
35+
console.info("events by user", _data);
36+
});
37+
38+
githubFactory.getEventsFromRepoByUserAndName({
39+
user:"xremix",
40+
repo:"xGallerify",
41+
per_page: 20,
42+
access_token:_access_token
43+
}).success(function(_data){
44+
console.info("events from repo by user and name", _data);
45+
});
46+
47+
githubFactory.getRepoByUserAndName({
48+
user:"xremix",
49+
repo:"xGallerify",
50+
per_page: 20,
51+
access_token:_access_token
52+
}).success(function(_data){
53+
console.info("repo by user and name", _data);
54+
});
55+
56+
57+
}]);

dist/angular-github-api-factory.min.js

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

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "angular-github-api-factory",
3+
"version": "0.1.0",
4+
"description": "angularjs factory for github json rest api requests",
5+
"main": "Gruntfile.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1"
8+
},
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/JohnnyTheTank/angular-github-api-factory.git"
12+
},
13+
"keywords": [
14+
"angularjs",
15+
"angular",
16+
"github",
17+
"api",
18+
"factory"
19+
],
20+
"author": "Jonathan Hornung",
21+
"license": "MIT",
22+
"bugs": {
23+
"url": "https://github.com/JohnnyTheTank/angular-github-api-factory/issues"
24+
},
25+
"homepage": "https://github.com/JohnnyTheTank/angular-github-api-factory#readme",
26+
"devDependencies": {
27+
"grunt": "^0.4.5",
28+
"grunt-contrib-uglify": "^0.11.0",
29+
"grunt-contrib-watch": "^0.6.1"
30+
}
31+
}

0 commit comments

Comments
 (0)