Skip to content

Commit bb9f964

Browse files
committed
Adding gitigniter spark
1 parent 36a729b commit bb9f964

File tree

8 files changed

+1127
-2
lines changed

8 files changed

+1127
-2
lines changed

.gitignore

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.DS_Store
2+
3+
application/config/config.php
4+
5+
application/config/database.php
6+
7+
.htaccess

application/config/autoload.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
$autoload['packages'] = array();
4141

4242

43+
4344
/*
4445
| -------------------------------------------------------------------
4546
| Auto-load Libraries
@@ -52,7 +53,7 @@
5253
| $autoload['libraries'] = array('database', 'session', 'xmlrpc');
5354
*/
5455

55-
$autoload['libraries'] = array();
56+
$autoload['libraries'] = array('database', 'gitigniter' );
5657

5758

5859
/*
@@ -64,7 +65,7 @@
6465
| $autoload['helper'] = array('url', 'file');
6566
*/
6667

67-
$autoload['helper'] = array();
68+
$autoload['helper'] = array('url');
6869

6970

7071
/*

application/config/gitigniter.php

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2+
/**
3+
* Name: GitIgniter Config
4+
*
5+
* Author: Nic Rosental
6+
7+
* @nicdev
8+
*
9+
* Location: https://github.com/nicdev/GitIgniter
10+
*
11+
* Created: 10.28.2011
12+
*
13+
* Description: Library to use Github API, including authentication.
14+
*
15+
*/
16+
17+
//Your application's client ID
18+
$config['gh_client_id'] = '';
19+
20+
//Your application's secret
21+
$config['gh_secret'] = '';
22+
23+
//Github's auth URL
24+
$config['gh_auth_url'] = 'https://github.com/login/oauth/authorize';
25+
26+
//Github's access token URL
27+
$config['gh_token_url'] = 'https://github.com/login/oauth/access_token';
28+
29+
//Github's API endpoint URL
30+
$config['gh_api_url'] = 'https://api.github.com/';
31+
32+
//Controller/action responsible for accepting the temporary code (you should also place the process_code() call in this controller
33+
$config['gh_redir_url'] = 'test/index'; //controller/action
34+
35+
//Comma separated list of scope options (leave blank for public access only)
36+
$config['gh_scope'] = 'user,public_repo,repo,gist';
37+
38+
//DB table used to store Github token
39+
$config['gh_table'] = 'meta';
40+
41+
//DB field used to match the user in the DB table
42+
$config['gh_where_field'] = 'user_id';
43+
44+
//DB field used to store the Github token
45+
$config['gh_token_field'] = 'gh_token';
46+
47+
//Optional. If you need to create repos for an organization.
48+
//$config['gh_org'] = '';
49+
50+
51+
/* End of file gitigniter.php */
52+
/* Location: ./application/config/github.php */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2+
3+
class Test extends CI_Controller {
4+
5+
/**
6+
* Demo controller for GitIgniter library
7+
*
8+
*/
9+
10+
public function index(){
11+
12+
$this->load->library('gitigniter');
13+
14+
15+
if ( ! $_GET['code'] )
16+
{
17+
18+
$this->gitigniter->authorize_request();
19+
20+
}
21+
else
22+
{
23+
24+
$token = $this->gitigniter->process_code();
25+
26+
/*You should pass a real user id corresponding to your table instead of "1"
27+
The TRUE and TRUE are default values, showing them here to make you see that you can
28+
opt for session and/or DB storage of tokens. */
29+
30+
$this->gitigniter->store_token( $token, 1, TRUE, TRUE );
31+
32+
echo '<pre>Don\'t show the token, please -> ';
33+
print_r( $token );
34+
echo '<pre>';
35+
36+
37+
}
38+
39+
//Assuming token has been saved to session. If it hasn't, use $this->gitigniter->retrieve_token();
40+
41+
42+
}
43+
44+
public function test_post(){
45+
46+
$this->load->library('gitigniter');
47+
$repo_options = array(
48+
'name' => 'test' . time()
49+
);
50+
51+
$test = $this->gitigniter->post_call( 'user/repos', $repo_options );
52+
$this->firephp->log($test); //debug only
53+
54+
echo '<pre>';
55+
print_r( $test );
56+
echo '<pre>';
57+
58+
}
59+
60+
public function test_get(){
61+
62+
$this->load->library('gitigniter');
63+
64+
$test = $this->gitigniter->get_call( 'user/followers' );
65+
66+
echo '<pre>';
67+
print_r( $test );
68+
echo '<pre>';
69+
70+
}
71+
72+
public function retrieve_token( $id ){
73+
74+
$this->load->library('gitigniter');
75+
76+
$test = $this->gitigniter->retrieve_token( $id );
77+
78+
echo '<pre>';
79+
print_r( $test );
80+
echo '<pre>';
81+
82+
}
83+
84+
85+
86+
}
87+
88+
/* End of file test.php */
89+
/* Location: ./application/controllers/test.php */

0 commit comments

Comments
 (0)