Connect and sync your HabitRPG and GitHub accounts. Built on my HabitRPG_PHP API class as well as Bootstrap and a little jQuery.
##Purpose:
If you love playing HabitRPG, and love using GitHub too, why not sync them? For every x number of commits you push to a repository, you will get x number of upvotes on your HabitRPG account!* This way, your hard work coding pays off with your HabitRPG account.
*Both of the "x" values are configurable in when you add a repository to your account.
##File Structure:
index.php
about.php
changelog.php
myaccount.php
README.md
- mysql
import.sql
- scripts
- js
submission.js
HabitRPG_PHP.ph
connect.php
logout.php
process.php
serviceFunctions.php
serviceHook.php
session.php
- styles
main.css
- views
account.php
login.php
##How to run locally:
###MySQL:
Use the SQL file located in mysql/import.sql
to clone the database structure into a MySQL database service such as SQLBuddy or phpMyAdmin. Don't forget to start MySQL on your localhost, though!
The process above is fairly straight forward, and all you know have to do to be able to interact with the database is to set your host values in scripts/connect.php
.
Table Structure, users:
username | realName | password | userId | apiToken | alerts | token |
---|---|---|---|---|---|---|
user's username | github user's real name | sha256 with salt "habitrpg" | habitrpg userid | habitrpg apitoken | not used. future alerts to be stored in alerts table | unique token for user's |
Table Structure, userInfo:
forUser | repoName | forEvery | current | direction | totalHabit | totalCommits | id |
---|---|---|---|---|---|---|---|
username of user with repo | repository name of github repo | number of commits per vote | current number of commits til next vote | direction of vote: up/down | total amount of habit votes cast | total amount of commits pushed to the repo | unique id for repo |
###PHP:
Start your PHP server on your computer, and then navigate to localhost/habitrpg-github, and you should arrive at the home screen if you have set it up properly. Any PDO
errors are a result from inproperly setting up the database! Be sure you have done that first!
###Double check:
Just to double check, your scripts/connect.php
script should look like this after you have entered the values:
<?php
$hostname = "{Path to MySQL database}";
$username = "{MySQL database username, most default to root";
$password = "{MySQL database password, most default to no password}";
$dbname = "{Name of the database you imported the SQL into, I use HabitRPGGitHub}";
//Starts new PDO instance - mysql_query_* is going to be depracated, so whole site is built on PDO...
$db= new PDO("mysql:host=".$hostname.";dbname=".$dbname.";charset=utf8", $username, $password);
?>
##Screenshot:
###View current stats for your GitHub repositories, including how many past commits you've pushed, as well as how many votes HabitRPG-GitHub has executed for you: