Skip to content

Commit

Permalink
Merge branch 'master' into better-tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
georgiashay committed Dec 29, 2020
2 parents 7efd689 + 8f998b1 commit 6e9e919
Show file tree
Hide file tree
Showing 36 changed files with 9,254 additions and 5,908 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"overrides": [
{
"files": [
"tests/unit/*.spec.js"
"tests/unit/**/*.spec.js"
],
"env": {
"jest": true
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,6 @@ public

# TernJS port file
.tern-port

# Credentials for the MIT People API
credentials.ini
13 changes: 13 additions & 0 deletions build/webpack.config.dev.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
'use strict'
const webpack = require('webpack')
const { VueLoaderPlugin } = require('vue-loader')
const { resolve } = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const cgi = require('cgi')

module.exports = (env) => {
return {
Expand All @@ -11,9 +13,17 @@ module.exports = (env) => {
'./src/app.js'
],
devServer: {
historyApiFallback: true,
hot: true,
watchOptions: {
poll: true
},
before: function (app, server, compiler) {
// Before handing all other dev server requests, check if the route is to the People API middleware and pass
// it to the CGI handler.
app.get('/cgi-bin/people.py', function (req, res) {
cgi(resolve(__dirname, '..', 'cgi-bin', 'people.py'))(req, res)
})
}
},
module: {
Expand Down Expand Up @@ -54,6 +64,9 @@ module.exports = (env) => {
}
]
},
output: {
publicPath: env.APP_URL.indexOf('dev') !== -1 ? '/dev/' : '/'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new VueLoaderPlugin(),
Expand Down
44 changes: 44 additions & 0 deletions cgi-bin/people.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/python3
from cgi import FieldStorage
from configparser import ConfigParser
from json import dumps, loads
from os import path
from requests import get

args = FieldStorage()

error = 'Status: 400 Bad Request\n'
header = 'Content-Type: application/json\n\n'

if 'kerb' not in args:
output = {"error": "kerb was not specified"}
header = error + header
else:
c = ConfigParser()
try:
with open(path.join(path.dirname(path.realpath(__file__)), 'credentials.ini')) as fp:
c.read_file(fp)
response = get('https://mit-people-v3.cloudhub.io/people/v3/people/{0}'.format(args['kerb'].value), headers={'client_id': c['Credentials']['ID'], 'client_secret': c['Credentials']['Secret']})
if response.status_code != 200:
header = error + header
output = {"error": "could not get user data"}
else:
data = loads(response.text)
if data['item']['affiliations'][0]['type'] != "student":
header = error + header
output = {"error": "user is not a student"}
else:
year = data['item']['affiliations'][0]['classYear']
if year == "G":
header = error + header
output = {"error": "user is a graduate student (currently unhandled)"}
else:
year = int(year)
year = year - 1
output = {"year": year}
except Exception:
header = error + header
output = {"error": "could not read credentials"}

print(header)
print(dumps(output))
4 changes: 2 additions & 2 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ if [ "$1" = "prod" ]; then
echo -n "You are about to deploy to the production site, are you sure? (y/n)? "
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/
scp -r deploy/production/.htaccess dist/* cgi-bin/ $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/
else
echo cancelled
fi
elif [ "$1" = "dev" ]; then
scp -r dist/* $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/dev/
scp -r deploy/development/.htaccess dist/* cgi-bin/ $2@athena.dialup.mit.edu:/mit/courseroad/web_scripts/courseroad/dev/
else
echo "Invalid build location"
fi
1 change: 1 addition & 0 deletions deploy/development/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ErrorDocument 404 /dev/index.html
1 change: 1 addition & 0 deletions deploy/production/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ErrorDocument 404 /index.html
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<meta name="description" content="CourseRoad is a tool for planning out your classes over your entire time at MIT.
It makes it easy to explore different majors and minors, view your progress towards their requirements, and
choose which classes to take when in order to maximize your time at MIT.">
<!-- <link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto" /> -->
<title>CourseRoad</title>
</head>
Expand Down
Loading

0 comments on commit 6e9e919

Please sign in to comment.