Skip to content

Commit

Permalink
Merge pull request #2 from JamesPhillipsUK/2.0.0-dev
Browse files Browse the repository at this point in the history
2.0.0 Development
  • Loading branch information
JamesPhillipsUK authored Jul 2, 2018
2 parents cf15371 + 94947f7 commit 0851ff1
Show file tree
Hide file tree
Showing 8 changed files with 319 additions and 55 deletions.
122 changes: 122 additions & 0 deletions Bootstrap3/GitHub-Profile-Web-App.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
<?php
/**
*
* GitHub Profile Web App, Version 2.0.0, Bootstrap 3 variant
*
* GitHub Profile Web App is designed to give a rundown of your GitHub Profile on your PHP Website
* Copyright (C) 2017, 2018 James Phillips <james@jamesphillipsuk.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**/

//Put this block in the header of the page to decrease load time.
define("PERSONALACCESSTOKEN","IT-GOES-HERE"); //Add your Personal Access Token here
define("GITHUBUSERNAME","IT-GOES-HERE"); //Add your GitHub username here

function CallGitHub() //this function pulls the user's GitHub Profile data
{
$GitHubURL = "https://api.github.com/user"; //pull your user data from GitHub
$GitHubHeaders = array('User-Agent: jamesphillipsuk-GitHubPHPApp','Authorization: token ' . PERSONALACCESSTOKEN . '',); //insert your personal access token
$GitHubcURL = curl_init(); //initialize cURL
if(curl_error($GitHubcURL))
{
echo 'error: ' . curl_error($GitHubcURL); // executes if GitHub dies, or cURL dies
}
curl_setopt($GitHubcURL, CURLOPT_URL,$GitHubURL); //Connect to GitHub
curl_setopt($GitHubcURL, CURLOPT_HTTPHEADER, $GitHubHeaders); //send our authorization headers
curl_setopt($GitHubcURL, CURLOPT_RETURNTRANSFER, 1); //don't print it to the screen yet
curl_setopt($GitHubcURL, CURLOPT_CUSTOMREQUEST, "GET"); //use GET to grab the data
$GitHubJSON = json_decode(curl_exec($GitHubcURL)); //decode the returned JSON data
curl_close($GitHubcURL); //close cURL
return $GitHubJSON; //return the decoded JSON
}
$GitHubJSON = CallGitHub(); //grab the return value of CallGitHub()
$GitHubName = $GitHubJSON->name; //save the name to use later
$GitHubHTMLURL = $GitHubJSON->html_url; //save the profile url to use later
$GitHubAvatarURL = $GitHubJSON->avatar_url; //save the avatar url to use later
$GitHubLogin = $GitHubJSON->login; //save the login name to use later
$GitHubBio = $GitHubJSON->bio; //save the user bio to use later
$GitHubPubRepos = $GitHubJSON->public_repos; //save the number of public repos to use later
$GitHubFollowers = $GitHubJSON->followers; //save the number of followers to use later
$GitHubFollowing = $GitHubJSON->following; //save the number of users following to use later

function CallGitHubRepos() //this function pulls the user's GitHub repository data
{
$GitHubURL = "https://api.github.com/users/" . GITHUBUSERNAME . "/repos"; //the GitHub URL for the user's repos
$GitHubHeaders = array('User-Agent: jamesphillipsuk-GitHubPHPApp','Authorization: token ' . PERSONALACCESSTOKEN . '',); //insert your personal access token
$GitHubcURL = curl_init(); //initialize cURL
if(curl_error($GitHubcURL))
{
echo 'error: ' . curl_error($GitHubcURL); // executes if GitHub dies, or cURL dies
}
curl_setopt($GitHubcURL, CURLOPT_URL,$GitHubURL); //
curl_setopt($GitHubcURL, CURLOPT_HTTPHEADER, $GitHubHeaders); //These headers are as before
curl_setopt($GitHubcURL, CURLOPT_RETURNTRANSFER, 1); //
curl_setopt($GitHubcURL, CURLOPT_CUSTOMREQUEST, "GET"); //
$GitHubJSON = json_decode(curl_exec($GitHubcURL)); //decode the response
curl_close($GitHubcURL); // close cURL
return $GitHubJSON; //return the value of the decoded JSON data
}
?>

<!-- INSERT THE SECTION BELOW WHERE YOU WANT YOUR PROFILE TO APPEAR -->
<div id="GitHubAPI" style="margin: 0 auto;">
<?php
echo "
<section class='panel panel-info'>
<div class='panel-heading'>
<h3><a href='" . $GitHubHTMLURL . "'>Follow " . $GitHubName . " on GitHub</a></h3>
</div>
<br />
<div class='panel-body'>
<img src='" . $GitHubAvatarURL . "' alt='GitHub Avatar' style='width:24%;height:auto;display:inline-block;margin:0 auto;' />
<div style='display:inline-block; max-width:74%;'>
<strong>" . $GitHubName . "</strong>
<br />
<em>&nbsp;" . $GitHubLogin . "</em>
<p>" . $GitHubBio . "</p>
</div>
<table style='margin:0 auto;' class='table table-condensed table-responsive'>
<thead>
<tr>
<th>Repos</th>
<th>Followers</th>
<th>Following</th>
</tr>
</thead>
<tbody>
<tr>
<td>" . $GitHubPubRepos . "</td>
<td>" . $GitHubFollowers . "</td>
<td>" . $GitHubFollowing . "</td>
</tr>
</tbody>
</table>
<br />"; //Echo out the values we saved in the CallGitHub() function as fromatted HTML and CSS.
foreach($Repos = CallGitHubRepos() as $Data)
{
echo "
<div>
<strong><a href='" . $Data->html_url . "'>" . $Data->name . "</a></strong>
<p>" . $Data->description . "</p>
<p>Primary Language: " . $Data->language . "</p>
</div>";
} //list each of the user's repos individually. This is optional as calling the function repeatedly adds to page load time drastically.
echo "
</div>
</section>
</div>"; //close off the UI
//That's all!
?>
120 changes: 120 additions & 0 deletions Bootstrap4/GitHub-Profile-Web-App.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?php
/**
*
* GitHub Profile Web App, Version 2.0.0, Bootstrap 4 variant
*
* GitHub Profile Web App is designed to give a rundown of your GitHub Profile on your PHP Website
* Copyright (C) 2017, 2018 James Phillips <james@jamesphillipsuk.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
**/
//Put this block in the header of the page to decrease load time.
define("PERSONALACCESSTOKEN","IT-GOES-HERE"); //Add your Personal Access Token here
define("GITHUBUSERNAME","IT-GOES-HERE"); //Add your GitHub username here
function CallGitHub() //this function pulls the user's GitHub Profile data
{
$GitHubURL = "https://api.github.com/user"; //pull your user data from GitHub
$GitHubHeaders = array('User-Agent: jamesphillipsuk-GitHubPHPApp','Authorization: token ' . PERSONALACCESSTOKEN . '',); //insert your personal access token
$GitHubcURL = curl_init(); //initialize cURL
if(curl_error($GitHubcURL))
{
echo 'error: ' . curl_error($GitHubcURL); // executes if GitHub dies, or cURL dies
}
curl_setopt($GitHubcURL, CURLOPT_URL,$GitHubURL); //Connect to GitHub
curl_setopt($GitHubcURL, CURLOPT_HTTPHEADER, $GitHubHeaders); //send our authorization headers
curl_setopt($GitHubcURL, CURLOPT_RETURNTRANSFER, 1); //don't print it to the screen yet
curl_setopt($GitHubcURL, CURLOPT_CUSTOMREQUEST, "GET"); //use GET to grab the data
$GitHubJSON = json_decode(curl_exec($GitHubcURL)); //decode the returned JSON data
curl_close($GitHubcURL); //close cURL
return $GitHubJSON; //return the decoded JSON
}
$GitHubJSON = CallGitHub(); //grab the return value of CallGitHub()
$GitHubName = $GitHubJSON->name; //save the name to use later
$GitHubHTMLURL = $GitHubJSON->html_url; //save the profile url to use later
$GitHubAvatarURL = $GitHubJSON->avatar_url; //save the avatar url to use later
$GitHubLogin = $GitHubJSON->login; //save the login name to use later
$GitHubBio = $GitHubJSON->bio; //save the user bio to use later
$GitHubPubRepos = $GitHubJSON->public_repos; //save the number of public repos to use later
$GitHubFollowers = $GitHubJSON->followers; //save the number of followers to use later
$GitHubFollowing = $GitHubJSON->following; //save the number of users following to use later

function CallGitHubRepos() //this function pulls the user's GitHub repository data
{
$GitHubURL = "https://api.github.com/users/" . GITHUBUSERNAME . "/repos"; //the GitHub URL for the user's repos
$GitHubHeaders = array('User-Agent: jamesphillipsuk-GitHubPHPApp','Authorization: token ' . PERSONALACCESSTOKEN . '',); //insert your personal access token
$GitHubcURL = curl_init(); //initialize cURL
if(curl_error($GitHubcURL))
{
echo 'error: ' . curl_error($GitHubcURL); // executes if GitHub dies, or cURL dies
}
curl_setopt($GitHubcURL, CURLOPT_URL,$GitHubURL); //
curl_setopt($GitHubcURL, CURLOPT_HTTPHEADER, $GitHubHeaders); //These headers are as before
curl_setopt($GitHubcURL, CURLOPT_RETURNTRANSFER, 1); //
curl_setopt($GitHubcURL, CURLOPT_CUSTOMREQUEST, "GET"); //
$GitHubJSON = json_decode(curl_exec($GitHubcURL)); //decode the response
curl_close($GitHubcURL); // close cURL
return $GitHubJSON; //return the value of the decoded JSON data
}
?>

<!-- INSERT THE SECTION BELOW WHERE YOU WANT YOUR PROFILE TO APPEAR -->
<div id="GitHubAPI" style="margin: 0 auto;">
<?php
echo "
<section class='card'>
<div class='card-header'>
<h3><a href='" . $GitHubHTMLURL . "'>Follow " . $GitHubName . " on GitHub</a></h3>
</div>
<br />
<div class='card-body'>
<img src='" . $GitHubAvatarURL . "' alt='GitHub Avatar' style='width:24%;height:auto;display:inline-block;margin:0 auto;' />
<div style='display:inline-block; max-width:74%;'>
<strong>" . $GitHubName . "</strong>
<br />
<em>&nbsp;" . $GitHubLogin . "</em>
<p>" . $GitHubBio . "</p>
</div>
<table style='margin:0 auto;' class='table table-sm table-responsive'>
<thead>
<tr>
<th>Repos</th>
<th>Followers</th>
<th>Following</th>
</tr>
</thead>
<tbody>
<tr>
<td>" . $GitHubPubRepos . "</td>
<td>" . $GitHubFollowers . "</td>
<td>" . $GitHubFollowing . "</td>
</tr>
</tbody>
</table>
<br />"; //Echo out the values we saved in the CallGitHub() function as fromatted HTML and CSS.
foreach($Repos = CallGitHubRepos() as $Data)
{
echo "
<div>
<strong><a href='" . $Data->html_url . "'>" . $Data->name . "</a></strong>
<p>" . $Data->description . "</p>
<p>Primary Language: " . $Data->language . "</p>
</div>";
} //list each of the user's repos individually. This is optional as calling the function repeatedly adds to page load time drastically.
echo "
</div>
</section>
</div>"; //close off the UI
//That's all!
?>
Binary file added Images/Example1.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/Example2.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed Images/Screenshot (14).png
Binary file not shown.
Binary file removed Images/Screenshot (15).png
Binary file not shown.
18 changes: 10 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,24 @@ There are other plugins that do this, but they often come in the form of: excess

### Features
- Runs entirely on Server-Side
- PHP 5, HTML5.1, and CSS3 compatible
- Your choice of Bootstrap 3, Bootstrap 4, or your own CSS
- Can be modified for GitHub Organizations
- PHP 5 or 7, HTML5.x, and CSS3 compatible
- Professional and responsive design
- Secure data transfer through Personal Access Keys and the GitHub API
- Easy Setup
- Libre and open-source software

### Installation
1. Take the first block of code from: `<?php` to `?>`, and paste it into your web page, just after your `<head>` HTML tag.
2. Generate a Personal Access Token on GitHub.com, and find the two instances of `INSERT YOUR TOKEN HERE` in what you've just pasted, and replace them with your token.
3. Find the instance of `YOUR GITHUB USERNAME` in what you've just pasted, and replace it with your GitHub username.
4. Pick a spot on your web page where you'd like to see the GitHub Plugin appear. Paste the rest of the code there.
0. Choose the version you want, and open GitHub-Profile-Web-App.php in your text editor or IDE of choice.
1. Take the first block of code from: `<?php` on line 1 to `?>` on line 72, and paste it into your web page, just after your `<head>` HTML tag.
2. Generate a Personal Access Token on GitHub.com, and paste it into the space provided on line 25.
3. Paste your GitHub Username into the space provided on line 26.
4. Pick a spot on your web page where you'd like to see the plugin appear. Paste the rest of the code there.
5. Save it and open up your page.

## Let's see it then...
![Narrow View](https://github.com/JamesPhillipsUK/GitHub-Profile-Web-App/blob/master/Images/Screenshot%20(14).png)
![Wide View](https://github.com/JamesPhillipsUK/GitHub-Profile-Web-App/blob/master/Images/Screenshot%20(15).png)
<table><tr><td><img src="https://github.com/JamesPhillipsUK/GitHub-Profile-Web-App/blob/master/Images/Example1.PNG" alt="Example One" /></td><td><img src="https://github.com/JamesPhillipsUK/GitHub-Profile-Web-App/blob/master/Images/Example2.PNG" alt="Example Two" /></td></tr></table>

## Contact Me!
Should you wish to contact me, you can find me at: [jamesphillipsuk.com/Contact](http://jamesphillipsuk.com/Contact/ "Contact me!").
Should you wish to contact me, you can find me at: [jamesphillipsuk.com/Contact](https://jamesphillipsuk.com/contact "Contact me!").
Loading

0 comments on commit 0851ff1

Please sign in to comment.