Browse Source

merge

pull/11/head
Bryce Murphy 5 years ago
parent
commit
69c5e22f71
16 changed files with 468 additions and 54 deletions
  1. +5
    -0
      .gitignore
  2. +22
    -0
      about.css
  3. +50
    -0
      about.html
  4. +7
    -0
      conf.json
  5. +33
    -0
      configManager.js
  6. +32
    -0
      fileIO.js
  7. BIN
      fonts/Comfortaa-Bold.ttf
  8. BIN
      fonts/Comfortaa-Light.ttf
  9. BIN
      fonts/Comfortaa-Regular.ttf
  10. +9
    -0
      icon.svg
  11. +38
    -0
      index.html
  12. +141
    -54
      js/friendsGraph.js
  13. +10
    -0
      logo.svg
  14. +25
    -0
      package.json
  15. +36
    -0
      server.js
  16. +60
    -0
      style.css

+ 5
- 0
.gitignore View File

@ -0,0 +1,5 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################
/.vs

+ 22
- 0
about.css View File

@ -0,0 +1,22 @@
#content {
top: 120px;
position: absolute;
left: 50%;
transform: translate(-50%, 0%);
}
#content-title {
position: relative;
top: 20%;
height: 80px;
background-color: rgb(208, 208, 208);
border-radius: 20px 20px 0px 0px;
}
#content-body {
position: relative;
background-color: rgb(242, 242, 242);
border-radius: 0px 0px 20px 20px;
}
body {
background-color: #232323;
}

+ 50
- 0
about.html View File

@ -0,0 +1,50 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="./style.css" />
<link rel="stylesheet" href="./about.css" />
</head>
<body>
<div id="header-bar" class="d-flex flex-column flex-md-row shadow-sm align-items-center">
<div id="header-title">
<a href="./index.html">
<img id="icon" src="./logo.svg" />
</a>
</div>
<ul id="navigation" class="nav justify-content-end">
<li class="nav-item">
<a href="./generate">
Generate graphs
</a>
</li>
<div class="nav-sep"></div>
<li class="nav-item">
<a href="https://github.com/jrtechs/github-graphs">
View on GitHub
</a>
</li>
<div class="nav-sep"></div>
<li class="nav-item">
<a href="./about.html">
About
</a>
</li>
</ul>
</div>
<div id="main">
<div id="content" class="container">
<div id="content-title">
<h1 class="big-title text-center">Developers</h1>
</div>
<div id="content-body" class="container">
<p>
some stuff will go here
</p>
</div>
</div>
</div>
</body>
</html>

+ 7
- 0
conf.json View File

@ -0,0 +1,7 @@
{
"port": 7000,
"sessionSecret": "superDuperSecret",
"clientID": "github client id",
"clientSecret": "clientSecret"
}

+ 33
- 0
configManager.js View File

@ -0,0 +1,33 @@
const fileIO = require('./fileIO');
const CONFIG_FILE_NAME = "conf.json";
const config = fileIO.getFileAsJSON(CONFIG_FILE_NAME);
module.exports=
{
getConfiguration: function()
{
return config;
},
syncToDisk: function()
{
fileIO.writeJSONToFile(CONFIG_FILE_NAME, config);
},
getPort: function()
{
return config.port;
},
getClientID: function()
{
return config.clientID;
},
getClientSecret: function()
{
return config.clientSecret;
}
};

+ 32
- 0
fileIO.js View File

@ -0,0 +1,32 @@
/** Used to read and write files from disk */
const fs = require('fs');
module.exports =
{
writeJSONToFile: function(fileName, jsonObject)
{
const json = JSON.stringify(jsonObject, null, 4);
fs.writeFile(fileName, json, 'utf8', function()
{
console.log("Wrote to " + fileName);
});
},
/**
*
* @param fileName
* @returns {any}
*/
getFileAsJSON: function(fileName)
{
return JSON.parse(module.exports.getFile(fileName));
},
getFile: function(filename)
{
return fs.readFileSync(filename, 'utf8');
}
};

BIN
fonts/Comfortaa-Bold.ttf View File


BIN
fonts/Comfortaa-Light.ttf View File


BIN
fonts/Comfortaa-Regular.ttf View File


+ 9
- 0
icon.svg
File diff suppressed because it is too large
View File


+ 38
- 0
index.html View File

@ -0,0 +1,38 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="./style.css" />
</head>
<body>
<div id="header-bar" class="d-flex flex-column flex-md-row shadow-sm align-items-center">
<div id="header-title">
<a href="./index.html">
<img id="logo" src="./logo.svg" />
</a>
</div>
<ul id="navigation" class="nav justify-content-end">
<li class="nav-item">
<a href="./generate">
Generate graphs
</a>
</li>
<div class="nav-sep"></div>
<li class="nav-item">
<a href="https://github.com/jrtechs/github-graphs">
View on GitHub
</a>
</li>
<div class="nav-sep"></div>
<li class="nav-item">
<a href="./about.html">
About
</a>
</li>
</ul>
</div>
</body>
</html>

+ 141
- 54
js/friendsGraph.js View File

@ -4,22 +4,57 @@ var nodes;
var edges; var edges;
const options = {
nodes: {
borderWidth:4,
size:30,
color: {
border: '#222222',
background: '#666666'
},
font:{color:'#eeeeee'}
},
edges: {
color: 'lightgray'
}
};
function alreadyInGraph(userID)
{
for(var i = 0; i < nodes.length; i++)
{
if(nodes[i].id === userID)
{
return true;
}
}
return false;
}
function addPersonToGraph(profileData)
{
nodes.push(
{
id:profileData.id,
name:profileData.login,
shape: 'circularImage',
image:profileData.avatar_url
});
}
function addFollowers(username)
function addFriends(username, apiPath)
{ {
return new Promise(function(resolve, reject) return new Promise(function(resolve, reject)
{ {
queryAPIByUser(API_FOLLOWERS, username, function(data)
queryAPIByUser(apiPath, username, function(data)
{ {
for(var i = 0; i < data.length; i++) for(var i = 0; i < data.length; i++)
{ {
nodes.push(
{
id:data[i].id,
shape: 'circularImage',
image:data[i].avatar_url
});
if(!alreadyInGraph(data[i].id))
{
addPersonToGraph(data[i]);
}
} }
resolve(); resolve();
}, },
@ -30,63 +65,115 @@ function addFollowers(username)
}); });
} }
function addFollowing(username)
function addConnection(person1, person2)
{
edges.push(
{
from: person1.id,
to: person2.id
});
}
function processUserConnections(userName)
{
return new Promise(function(resolve, reject)
{
queryAPIByUser(API_FOLLOWING, userName,
function(data)
{
for(var i = 0; i < data.length; i++)
{
}
queryAPIByUser(API_FOLLOWERS, userName, function(data2)
{
for(var i = 0; i < data2.length; i++)
{
}
resolve();
},
function(error)
{
reject(error);
});
},
function(error)
{
reject(error);
})
});
}
function createConnections()
{
return new Promise(function(resolve, reject)
{
var prom = [];
for(var i = 0; i < nodes.length; i++)
{
prom.push(processUserConnections(nodes[i].name));
}
Promise.all(prom).then(function()
{
resolve();
}).catch(function(error)
{
reject(error);
});
});
}
function addSelfToGraph(username)
{ {
return new Promise(function(resolve, reject) return new Promise(function(resolve, reject)
{ {
queryAPIByUser("", username, function(data)
{
addPersonToGraph(data);
resolve();
},
function(error)
{
reject(error);
});
}); });
} }
function createFriendsGraph(username, containerName, graphsTitle) function createFriendsGraph(username, containerName, graphsTitle)
{ {
nodes = []; nodes = [];
edges = []; edges = [];
var network = null;
addFollowers(username).then(function()
addSelfToGraph(username).then(function()
{ {
var container = document.getElementById(containerName);
var data = {
nodes: nodes,
edges: edges
};
var options = {
nodes: {
borderWidth:4,
size:30,
color: {
border: '#222222',
background: '#666666'
},
font:{color:'#eeeeee'}
},
edges: {
color: 'lightgray'
}
};
network = new vis.Network(container, data, options);
addFriends(username, API_FOLLOWERS).then(function()
{
addFriends(username, API_FOLLOWING).then(function()
{
createConnections().then(function()
{
var container = document.getElementById(containerName);
var data =
{
nodes: nodes,
edges: edges
};
var network = new vis.Network(container, data, options);
});
});
})
}).catch(function(error)
{
console.log(error);
$("#" + graphsTitle).html("Error Fetching Data From API");
}); });
// // create connections between people
// // value corresponds with the amount of contact between two people
// edges = [
// {from: 1, to: 2},
// {from: 2, to: 3},
// {from: 2, to: 4},
// {from: 4, to: 5},
// {from: 4, to: 10},
// {from: 4, to: 6},
// {from: 6, to: 7},
// {from: 7, to: 8},
// {from: 8, to: 9},
// {from: 8, to: 10},
// {from: 10, to: 11},
// {from: 11, to: 12},
// {from: 12, to: 13},
// {from: 13, to: 14},
// {from: 9, to: 16}
// ];
} }

+ 10
- 0
logo.svg
File diff suppressed because it is too large
View File


+ 25
- 0
package.json View File

@ -0,0 +1,25 @@
{
"name": "github-graphs",
"version": "0.0.1",
"description": "Generates graphs of github things.",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jrtechs/github-graphs.git"
},
"author": "Jeffery Russell",
"license": "ISC",
"bugs": {
"url": "https://github.com/jrtechs/github-graphs/issues"
},
"homepage": "https://github.com/jrtechs/github-graphs#readme",
"dependencies": {
"express": "^4.16.4",
"express-session": "^1.15.6",
"fs": "0.0.1-security"
}
}

+ 36
- 0
server.js View File

@ -0,0 +1,36 @@
/** express app for routing */
const express = require("express");
/**session data for login and storing preferences*/
const session = require('express-session');
const configLoader = require('./configManager.js');
const app = express();
/**Initializes sessions for login */
app.use(session(
{ secret: configLoader.getConfiguration().sessionSecret,
cookie: { maxAge: 6000000 }}
));
app.use(express.urlencoded()); //for easy retrieval of post and get data
app.use(express.json());
app.use(express.static(__dirname,'css'));
app.use(express.static(__dirname, 'js'));
app.use(express.static(__dirname, 'img'));
app.use(express.static('html'));
app.use(express.static(__dirname, 'fonts'));
const routes = require('./routes');
app.use('/', routes);
app.listen(configLoader.getConfiguration().port, () =>
console.log(`App listening on port ${configLoader.getConfiguration().port}!`)
);

+ 60
- 0
style.css View File

@ -0,0 +1,60 @@
@font-face {
font-family: Comfortaa;
src: url(./fonts/Comfortaa-Regular.ttf);
font-weight: normal;
}
@font-face {
font-family: Comfortaa;
src: url(./fonts/Comfortaa-Light.ttf);
font-weight: lighter;
}
@font-face {
font-family: Comfortaa;
src: url(./fonts/Comfortaa-Bold.ttf);
font-weight: bold;
}
#header-bar {
height: 10%;
width: 100%;
background-color: rgb(208, 208, 208);
}
#header-title {
width: 30%;
padding-left: 20px;
font-size: 25px;
}
#logo {
height: 40px;
}
#navigation {
width: 70%;
padding-right: 20px !important;
}
.big-title {
font-family: Comfortaa;
font-weight: bold;
font-size: 60px;
}
.nav-sep {
position: relative;
left: 10px;
top: 6px;
padding-left: 20px;
border-left: 2px solid #232323;
height: 30px;
}
.nav-item {
padding: 5px;
font-size: 20px;
}
a {
color: #232323;
text-decoration: none;
}
a:hover {
color: rgb(57, 163, 225);
text-decoration: none;
}
body {
background-color: rgb(242, 242, 242);
}

Loading…
Cancel
Save