Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
e3ac508
index page
suhearsawho May 24, 2019
c0366a3
Barebones flask app for everyone to work with
jozsa May 24, 2019
d24e624
Added user tier path and setup for User class to be passed into tier
jozsa May 24, 2019
4fafcbc
Merge branch 'backend' of https://github.com/stak19/TripleTail into b…
suhearsawho May 24, 2019
016b81e
Frontend basic
suhearsawho May 24, 2019
1f2d4b3
first commit
May 24, 2019
769a849
Removed jinja for block content
suhearsawho May 24, 2019
22a113f
Settign up file structure for flask
suhearsawho May 24, 2019
75b2a6a
Preparations for OAuth:
suhearsawho May 24, 2019
ee85c27
Feature: get the percentage of repos that have a README
jozsa May 24, 2019
b22e1fe
added account_age method
May 24, 2019
df382b7
Reorganized template structure
suhearsawho May 24, 2019
bfda26e
fixed conflicts
May 24, 2019
88fc8f4
Change 'userinfo' to 'username' for User object instantiation
jozsa May 24, 2019
4536cf4
Merge branch 'backend' of github.com:stak21/TripleTail into backend
jozsa May 24, 2019
3dea87f
Merge branch 'master' of github.com:stak21/TripleTail into frontend
stak21 May 24, 2019
81b7449
resolved conflicts
stefansilverio May 24, 2019
1e0931c
added more basic methods to get data about user
stefansilverio May 24, 2019
322cd3c
more setup for frontend
suhearsawho May 24, 2019
cb188b7
erge branch 'frontend' of https://github.com/stak20/TripleTail into f…
suhearsawho May 24, 2019
d2de324
added methods for retrieving user's pic and tier
May 24, 2019
9b1f9b2
resolved conflicts
May 24, 2019
3a2fd71
Initial Commit: New gitignore
stak21 May 24, 2019
4e2e7f3
Initial Commit: adding out package.json
stak21 May 24, 2019
4c82827
Merge branch 'frontend' of github.com:stak21/TripleTail into frontend
stak21 May 24, 2019
610494d
Fixing instance attribute setter methods, TODO: remove user_dict from…
jozsa May 24, 2019
2ce3091
erge branch 'backend' of github.com:stak21/TripleTail into backend
jozsa May 24, 2019
c8a3251
more html for frontend
suhearsawho May 24, 2019
9167849
Adding out MIT license
stak21 May 24, 2019
c7c6144
Initial Commit: Adding A blank README.md file
stak21 May 24, 2019
f0fbc47
Uploading requirements text to repo
May 24, 2019
eea4d48
Frontend basic
suhearsawho May 24, 2019
078088e
Removed jinja for block content
suhearsawho May 24, 2019
efc65f5
Settign up file structure for flask
suhearsawho May 24, 2019
31203e6
Preparations for OAuth:
suhearsawho May 24, 2019
4c52582
Reorganized template structure
suhearsawho May 24, 2019
f39d4bd
more setup for frontend
suhearsawho May 24, 2019
232149e
Initial Commit: New gitignore
stak21 May 24, 2019
07afaed
Initial Commit: adding out package.json
stak21 May 24, 2019
6e2e7b8
more html for frontend
suhearsawho May 24, 2019
97fd2e7
Merge branch 'backend' of https://github.com/stak20/TripleTail into b…
suhearsawho May 24, 2019
170f865
backend changes in frontend branch
suhearsawho May 24, 2019
202973e
changes to app file
suhearsawho May 24, 2019
0c57d86
More frontend
suhearsawho May 24, 2019
b7703e4
more stuff in the __init__
May 24, 2019
2451fea
for samie!
suhearsawho May 24, 2019
f667641
Updating app.py to run with 0.0.0.0
May 24, 2019
b78c9cd
Uploading deploy script to frontend branch for debugging
May 24, 2019
e2c2a6d
fixed zero division in README method
stefansilverio May 24, 2019
d866665
adding cors to the app
stak21 May 24, 2019
e5808aa
yMerge branch 'frontend' of github.com:stak21/TripleTail into frontend
stak21 May 24, 2019
ffac2ed
Changed main route to take in oauth token and test if authentication …
jozsa May 24, 2019
51493e4
Merge branch 'backend' of github.com:stak21/TripleTail into backend
jozsa May 24, 2019
1204728
remove print statement
stefansilverio May 24, 2019
9f2770d
Merge branch 'backend' of https://github.com/stak21/TripleTail into b…
stefansilverio May 24, 2019
f2cb88e
fix account_age index out of range
May 24, 2019
9af20d1
Functional frontend design
suhearsawho May 24, 2019
65b95f0
fixed conflict in account_age method
May 24, 2019
be03c58
Working template for rankings
suhearsawho May 24, 2019
7cdddba
logo image for login page
truong21 May 24, 2019
0281a70
Merge branch 'frontend' of https://github.com/stak21/TripleTail into …
truong21 May 24, 2019
bc01004
Restructure app and user class to work with oauth token instead of ba…
jozsa May 24, 2019
ea5781c
Merge branch 'backend' of github.com:stak21/TripleTail into backend
jozsa May 24, 2019
23867eb
Updating requirements.txt with bs4
May 24, 2019
146c329
Merge branch 'backend' of https://github.com/stak20/TripleTail into b…
suhearsawho May 24, 2019
822dae1
Merge branch 'frontend' of github.com:stak21/TripleTail into frontend
stak21 May 24, 2019
e949d00
Merge branch 'backend' of https://github.com/stak21/TripleTail into b…
suhearsawho May 24, 2019
7fa91e4
Added: a login and oauth authenticator
stak21 May 24, 2019
f675cc7
Changed the jquery import
stak21 May 24, 2019
4415739
app conflicts
suhearsawho May 24, 2019
4e7a2d2
merged backend and frontend
suhearsawho May 24, 2019
805ba13
added logo for login page
truong21 May 24, 2019
d57d8b7
Merge branch 'frontend' of https://github.com/stak21/TripleTail into …
truong21 May 24, 2019
54bf99a
feat(github oauth): Added a handle for the github callback
stak21 May 24, 2019
1331f57
Merge branch 'frontend' of github.com:stak21/TripleTail into frontend
stak21 May 24, 2019
5204129
Updating app.py to use 0.0.0.0 as host
May 24, 2019
b6467a2
Updating app.py file
May 24, 2019
4f8628d
links is open in new tabs; buttons are in line
truong21 May 24, 2019
836d5d3
Merge branch 'frontend' of https://github.com/stak21/TripleTail into …
truong21 May 24, 2019
abe126a
Updating html files with typing for css and javascript
May 24, 2019
a5f9aeb
new method to signing in to github
stak21 May 24, 2019
28b0eac
added additional description for rankings
truong21 May 24, 2019
963fdea
Merge branch 'frontend' of github.com:stak21/TripleTail into frontend
stak21 May 24, 2019
5b137e4
Merge branch 'frontend' of github.com:stak21/TripleTail into frontend
stak21 May 24, 2019
c4dff6c
click event is now a simple redirect
stak21 May 24, 2019
e6b74c6
Merge branch 'frontend' of github.com:stak21/TripleTail into frontend
stak21 May 24, 2019
ae4618b
added jquery form google cdn
stak21 May 24, 2019
4532dc2
Oauth working but redirects too early before serving up login page
jozsa May 24, 2019
976ef08
changes to ranking html
suhearsawho May 24, 2019
0cf2209
Added button
suhearsawho May 24, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*~
node_modules

71 changes: 71 additions & 0 deletions 3-deploy_web_static.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/python3
"""Fab file to archive web_static content"""
from os import remove
from os.path import isfile
from fabric.api import *
from datetime import datetime


env.hosts = ['35.245.121.190']


def do_pack():
"""Pack web_static files into archive"""
try:
dt = datetime.now().strftime("%Y%m%d%H%M%S")
local("mkdir -p versions/")
path = local("tar -cvzf versions/tript_{}.tgz tript"
.format(dt))
return "versions/tript_{}.tgz".format(dt)
except:
return None


def do_deploy(archive_path):
"""Deploy function for archive to get deployed to servers"""
if not isfile(archive_path):
return False
fileNameExt = archive_path.split('/')[-1]
fileName = fileNameExt.split(".")[0]
result = put(archive_path, '/tmp/{}'.format(fileNameExt))
if result.failed:
return False
result = sudo("rm -rf /data/tript/releases/{}/".format(fileName))
if result.failed:
return False
result = sudo("mkdir -p /data/tript/releases/{}/".format(fileName))
if result.failed:
return False
result = sudo("tar -xzf /tmp/{} -C /data/tript/releases/{}/"
.format(fileNameExt, fileName))
if result.failed:
return False
result = sudo("rm /tmp/{}".format(fileNameExt))
if result.failed:
return False
input = "mv /data/tript/releases/{}/tript/*\
/data/tript/releases/{}/".format(fileName, fileName)
result = sudo(input)
if result.failed:
return False
result = sudo("rm -rf /data/tript/releases/{}/tript"
.format(fileName))
if result.failed:
return False
result = sudo("rm -rf /data/tript/current")
if result.failed:
return False
result = sudo("ln -s /data/tript/releases/{}/ /data/tript/current"
.format(fileName))
if result.failed:
return False
print("New version deployed!")
return True


def deploy():
"""Call pack and deploy"""
path = do_pack()
if path is None:
return False
do_deploy(path)
Empty file added backend/__init__.py
Empty file.
71 changes: 71 additions & 0 deletions backend/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
#!/usr/bin/python3
"""Start Flask web app for our TripleTail
website"""

from flask import Flask, jsonify, render_template, request
from flask_cors import CORS, cross_origin
from user import User

import requests

# Flask setup
app = Flask(__name__)
app.url_map.strict_slashes = False
host = '0.0.0.0'
host = '127.0.0.1'
# Cross-Origin Resource sharing
cors = CORS(app, resouces={r"/*": {"origins": "*"}})

authorization_base_url = 'https://github.com/login/oauth/authorize'
token_url = 'https://github.com/login/oauth/access_token'
request_url = 'https://api.github.com'


def page_not_found(e):
"""404 error page for nonexistent routes"""
return jsonify({'error': "Not found"}), 404


@app.route('/', methods=['GET', 'POST'])
def homepage():
"""
Landing page
"""
return render_template('index.html')


@app.route('/testing')
def test():
userinfo = {'tier': 'tier1', 'username': 'hello', 'name': 'Random Name'}
return render_template('ranking.html', userinfo=userinfo)


@app.route('/tier', methods=['GET', 'POST'])
def handle_callback():
"""
This function helps exchange temporary 'code' value with a permanent
access_token.
"""

if 'code' in request.args:
payload = {
'client_id': '926a308eec433f17e3ff',
'client_secret': '8b3e897ad2ac2e85f558fd96571f6af5eca26511',
'code': request.args['code']
}
headers = {'Accept': 'application/json'}
req = requests.post(token_url, params=payload, headers=headers)
resp = req.json()
if 'access_token' in resp:
user_info = User(resp['access_token'])
print(user_info.__dict__)
return render_template('ranking.html', userinfo=user_info.__dict__)
else:
return render_template('index.html')
else:
return render_template('index.html')

if __name__ == "__main__":
app.config['JSONIFY_PRETTYPRINT_REGULAR'] = True
app.register_error_handler(404, page_not_found)
app.run(host=host)
Binary file added backend/static/images/clogo.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 backend/static/images/elephant.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 backend/static/images/image.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 backend/static/images/kangaroo.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 backend/static/images/lion.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 backend/static/images/logo.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 backend/static/images/pig.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 backend/static/images/sloth.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions backend/static/scripts/auth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const ready = () => {
login()
}

const login = () => {
$('.signin .github-signin').click(github_oauth());
alert("hi")
}
const github_oauth = ()=> {
// Requests an api, which retrieves the auth token
window.location.href = "https://github.com/login/oauth/authorize?client_id=926a308eec433f17e3ff"
}

document.addEventListener('DOMContentLoaded', ready);
13 changes: 13 additions & 0 deletions backend/static/scripts/design.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
$('.btn-clear').on('click', () => {
if ($('body').hasClass('black'))
{
$('body').removeClass('black');
$('body').addClass('blue');
}
else
{
$('body').removeClass('blue');
$('body').addClass('black');
}
});

114 changes: 114 additions & 0 deletions backend/static/scripts/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import '@babel/polyfill';

const toParams = query => {
const q = query.replace(/^\??\//, '');

return q.split('&').reduce((values, param) => {
const [key, value] = param.split('=');

values[key] = value;

return values;
}, {});
};

const toQuery = (params, delimiter = '&') => {
const keys = Object.keys(params);

return keys.reduce((str, key, index) => {
let query = `${str}${key}=${params[key]}`;

if (index < keys.length - 1) {
query += delimiter;
}

return query;
}, '');
};

class PopupWindow {
constructor(
params,
options = { height: 1000, width: 600 },
url = `https://github.com/login/oauth/authorize`,
id = 'github-oauth-authorize'
) {
this.id = id;
this.url = url + '?' + toQuery(params);
this.options = options;
}

open() {
const { url, id, options } = this;

this.window = window.open(url, id, toQuery(options, ','));
}

close() {
this.cancel();
this.window.close();
}

poll() {
this.promise = new Promise((resolve, reject) => {
this._iid = window.setInterval(() => {
try {
const popup = this.window;

if (!popup || popup.closed !== false) {
this.close();

reject(new Error('The popup was closed'));

return;
}

if (
popup.location.href === this.url ||
popup.location.pathname === 'blank'
) {
return;
}

const params = toParams(popup.location.search.replace(/^\?/, ''));

resolve(params);

this.close();
} catch (error) {}
}, 500);
});
}

cancel() {
if (this._iid) {
window.clearInterval(this._iid);
this._iid = null;
}
}

then(...args) {
return this.promise.then(...args);
}

catch(...args) {
return this.promise.then(...args);
}

static open(...args) {
const popup = new this(...args);

popup.open();
popup.poll();

return popup;
}
}

export const loginWithGithub = (params, options, url, id) => {
return new Promise(async (resolve, reject) => {
const popup = PopupWindow.open(params, options, url, id);

popup.then(resolve, reject);
});
};
11 changes: 11 additions & 0 deletions backend/static/scripts/ranking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
$('.back').css('visibility', 'hidden');

$('#rotatefront').click(() => {
$('.front').css('visibility', 'hidden');
$('.back').css('visibility', 'visible');
});

$('#rotateback').click(() => {
$('.back').css('visibility', 'hidden');
$('.front').css('visibility', 'visible');
});
8 changes: 8 additions & 0 deletions backend/static/styles/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
h1#logo a {
max-width: 80%;
height: 80%;
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
}
45 changes: 45 additions & 0 deletions backend/static/styles/layout.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
html {
width: 100%;
height: 100%;
}

body {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
}

.header {
margin: 1rem;
box-sizing: border-box;
font-family: Avenir;
color: #6ec4db;
position: relative;
display: flex;
flex-wrap: nowrap;
}

body.black {
background-color: black;
}

body.blue {
}

.btn-clear {
border: none;
background: transparent;
}

.content {
display: flex;
justify-content: center;
width: 100%;
height: 85%;
}

.facebook-button, .twitter-button {
display: inline-block;
}
Loading