Commit ddeb0e11 authored by Mark Stenglein's avatar Mark Stenglein
Browse files

Merge branch 'issue22' into '1.0'

Issue22

fixes #22 
- The api still needs to be rewritten and there may be other issues.
- Mainly merging now because there are some larger structure issues that need to be fixed in 1.0 and not here.

See merge request !10
parents 7916c1eb c402270a
......@@ -22,25 +22,16 @@ if [ "$DISTRIB_ID" == "Ubuntu" ]
then
echo "** Installing Node.js"
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get install -y nodejs
fi
if ! haveProg mongod
then
echo "** Installing MongoDB"
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo "deb http://repo.mongodb.org/apt/ubuntu $DISTRIB_CODENAME/mongodb-org/3.2 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.2.list
sudo apt-get update
sudo apt-get install -y mongodb-org
## Service is started in start.sh file
fi
if ! haveProg redis-server
then
echo "** Installing redis-server"
sudo apt-get install -y redis-server
sudo mv /etc/redis/redis.conf /etc/redis/redis.conf.backup
sudo cp setupFiles/redis.conf /etc/redis/redis.conf
echo "** redis-server installed and configured"
sudo apt-get install -y nodejs npm
fi
#if ! haveProg redis-server
# then
# echo "** Installing redis-server"
# sudo apt-get install -y redis-server
# sudo mv /etc/redis/redis.conf /etc/redis/redis.conf.backup
# sudo cp setupFiles/redis.conf /etc/redis/redis.conf
# echo "** redis-server installed and configured"
#fi
elif haveProg yum
then
echo "** Installing as yum manager"
......
This diff is collapsed.
This diff is collapsed.
node extract2016.js
node extractClasses.js
echo "Copy the json file to the appropriate folder in the app and"
echo "add it's information to config.js"
// Read in excel file
if(typeof require !== 'undefined') XLSX = require('xlsx');
// convert file to workbook
var workbook = XLSX.readFile('GMU2015F.xlsx');
var workbook = XLSX.readFile('GMU2017SP.xlsx');
// get sheet
var worksheet = workbook.Sheets[workbook.SheetNames[0]];
// convert sheet to JSON
var jsonContents = XLSX.utils.sheet_to_json(worksheet)
console.log("\n *START* \n");
var yr = 2015;
var yr = 2017;
var term_classes = [];
// Loop through al of the different objects parsed by the xlsx to json conversion
for (var i=0; i < jsonContents.length; i++) {
......@@ -19,6 +19,7 @@ for (var i=0; i < jsonContents.length; i++) {
// skip to next if there is no crn (really only needed for last row)
if (!c.crn) { continue; }
// use last section if blank (for multi-crn sections)
console.log(c.crn);
if (currentItem['COURSE SECTION']) {
var courseNameSection = currentItem['COURSE SECTION'].split(" ");
} else {
......@@ -84,8 +85,8 @@ for (var i=0; i < jsonContents.length; i++) {
}
var semester = {
school: 'GMU',
semester: 'Fall 2015',
slug: 'GMU2015F',
semester: 'Spring 2017',
slug: 'GMU2017SP',
classes: term_classes
}
var semesterJSON = JSON.stringify(semester);
......@@ -96,13 +97,13 @@ try {
var resultPretty = prettyJSON;
// write a JSON file.
var fs = require('fs');
fs.writeFile('GMU2015F.min.json', result, function (err) {
fs.writeFile('GMU2017SP.min.json', result, function (err) {
if (err) return console.log(err);
console.log('File written to GMU2015F.min.json');
console.log('File written to GMU2017SP.min.json');
});
fs.writeFile('GMU2015F.json', resultPretty, function (err) {
fs.writeFile('GMU2017SP.json', resultPretty, function (err) {
if (err) return console.log(err);
console.log('File written to GMU201F.json');
console.log('File written to GMU2017SP.json');
});
} catch (err) {
// Errors are thrown for bad options, or if the data is empty and no fields are provided.
......
{
"name": "schedules",
"version": "1.0.0",
"description": "Schedules is a web app that allows students to import their class schedules into popular calendar managers.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git@git.gmu.edu:srct/schedules.git"
},
"author": "GMU Student Run Computing and Technology",
"license": "MIT",
"dependencies": {
"express": "^4.14.0",
"mongoose": "^4.5.5"
}
}
......@@ -28,3 +28,7 @@ node_modules
# Debug log from npm
npm-debug.log
# databases
*.sqlite
////////////////////////////////////////////////////////////////////////////////
// Mason SRCT: Schedules Application Main File
// - This is the main file for the schedules app, which loads in all of the
// configuration and routing files. Essentially, any other file eventually
// leads here.
// - Take care with this file, it can hurt if you mess it up.
////////////////////////////////////////////////////////////////////////////////
// Load in the different packages
var express = require('express');
var path = require('path');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
var mongooseRedisCache = require("mongoose-redis-cache");
// Load site wide configurations
var config = require('./config');
require('app-module-path').addPath(__dirname)
var express = require('express')
var path = require('path')
var logger = require('morgan')
var cookieParser = require('cookie-parser')
var bodyParser = require('body-parser')
// Load in Routes
// TODO: Make this a dynamic loading system that simply scans the directory
var routes = require('./routes/index');
var docs = require('./routes/docs');
var apiV1 = require('./routes/api/v1');
var routes = require('./routes/index')
var docs = require('./routes/docs')
var apiV1 = require('./routes/api/v1')
// Instantiate the application
var app = express();
var app = express()
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');
app.set('views', path.join(__dirname, 'views'))
app.set('view engine', 'pug')
app.use(logger('dev'))
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({ extended: false }))
app.use(cookieParser())
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(require('node-sass-middleware')({
src: path.join(__dirname, 'public'),
dest: path.join(__dirname, 'public'),
indentedSyntax: true,
sourceMap: true
}));
app.use(express.static(path.join(__dirname, 'public')));
}))
app.use(express.static(path.join(__dirname, 'public')))
// Connect to mongo
mongoose.connect(config.mongoDBURL);
// Setup the mongo redis caching for performance
mongooseRedisCache(mongoose);
// Initialize the Database and Connection
var db = require(path.join(__dirname, 'models'))
db.sequelize.sync({force: true})
// Populate initial data
var populateDB = require('./setup/populateDB');
populateDB();
// TODO: populate the information
// Actually use the loaded routes
// TODO: make this automatic instead of being manually entered
app.use('/', routes);
app.use('/docs', docs);
app.use('/api/v1', apiV1);
app.use('/', routes)
app.use('/docs', docs)
app.use('/api/v1', apiV1)
// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
app.use(function (req, res, next) {
var err = new Error('Not Found')
err.status = 404
next(err)
})
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
res.status(err.status || 500);
app.use(function (err, req, res, next) {
res.status(err.status || 500)
res.render('error', {
message: err.message,
error: err
});
});
})
})
}
// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
app.use(function (err, req, res, next) {
res.status(err.status || 500)
res.render('error', {
message: err.message,
error: {}
});
});
})
})
module.exports = app;
module.exports = app
#!/bin/bash
NPMBIN="$(npm bin)"
$NPMBIN/standard --verbose | $NPMBIN/snazzy
////////////////////////////////////////////////////////////////////////////////
// Mason SRCT: Schedules Main Configuration File
// - This file holds many of the global options for ease of use. Some of these
// settings are temporary because the dynamic methods have not been written in
// yet.
////////////////////////////////////////////////////////////////////////////////
var config = {}
// Application Name
config.siteName = "Schedules";
// Application Description (subtitle)
config.siteDescription = "A simple application to add your class schedule to calendar applications like Outlook and Google Calendar."
// MongoDB config
config.mongoDBURL = 'mongodb://localhost/schedules';
config.ReloadDB = false;
// Object given to the front end to populate the semester and school selection
// dropdown lists.
// TODO: Make this dynamic instead of hard coding it into the system.
config.schoolSlugs = {
'schools': [
'GMU',
'VT'
],
'GMU': {
'longName': 'George Mason University',
'semesters': [
{
slug: 'GMU2016F',
longName: 'Fall 2016'
},
{
slug: 'GMU2016S',
longName: 'Summer 2016'
},
{
slug: 'GMU2016SP',
longName: 'Spring 2016'
}
]
},
'VT' : {
'longName': 'Virginia Tech',
'semesters': []
},
}
// Data files to load:
// TODO: Make this dynamic instead of hard coding it into the system. This is
// neccessary in order to make it so that the system can be updated from
// the site itself instead of relying on @patriot_down to upload the files
// from the backend.
config.dataFiles = [
'GMU2016F.min.json',
'GMU2016S.min.json',
'GMU2016SP.min.json'
]
module.exports = config;
# Schedules
*By Mason SRCT*
## Configuration Directory
The configuration of this application is managed by
[node-config](https://github.com/lorenwest/node-config). This allows for
environment based configuration that uses an override schema instead of fresh
sets of configs for each environment we want to run. Look at the docs for that
node module to really get a good idea of what is going on, but what follows is
a general description of what is in this foldler.
### Structure
#### default.yaml
This file holds all of the standard values that are suitible for a development
environment. Everything that needs to be configured should be set up here first
unless it is only applicable to a production environment.
#### test.yaml
This file holds special overrides for the testing environment.
Notably, the main set of configuration here is that it instructs sequelize to
use RAM to store the sqlite database.
#### production.yaml
This file holds the overrides for a production environment.
Anything that is specific to a particular deployment should use null values
in this file. These should be overriden in a `local-production.yaml` file which
is **not** tracked by git.
#### local-production.yaml.example
This is the example local production file that needs to be copied, renamed to
`local-production.yaml` and have it's contents filled out for a production
deployment. For normal development, this file is pretty irrelevant.
For more information on deployment, see the deployment section of the docs.
(You'll also have to wait for the app to be finished before that's even an
issue).
# General Application Settings
general :
name : "Schedules"
description : >
"A simple application to add your class schedules
to calendar applications, like your phone."
organization :
name : "Mason SRCT"
description : >
"Student Run Computing and Technology"
website : "srct.gmu.edu"
websiteURL : "https://srct.gmu.edu"
# Sequelize Settings (Database)
sequelize :
dialect : "sqlite"
storage : "./.devDB/schedules.sqlite"
# Data Sources etc
schools :
- slug : GMU
longName : George Mason University
semesters :
- slug : "GMU2016SP"
longName : "Spring 2016"
dataFile : "GMU2016SP.min.json"
- slug : "GMU2016S"
longName : "Summer 2016"
dataFile : "GMU2016S.min.json"
- slug : "GMU2016F"
longName : "Fall 2016"
dataFile : "GMU2016F.min.json"
- slug : "GMU2017SP"
longName : "Spring 2017"
dataFile : "GMU2017SP.min.json"
schoolSlugs :
- "GMU"
- "VT"
# General Application Settings
# Sequelize Settings (Database)
sequelize :
dialect : "mysql"
host : "localhost"
database : "schedules"
username : "schedules"
password : "srct"
pool :
max : 5
min : 0
idle : 10000
# Data Sources etc
# General Application Settings
# Sequelize Settings (Database)
sequelize :
dialect : "sqlite"
storage : ":memory:"
# Data Sources etc
# Schedules
*By Mason SRCT*
## Models Directory
This directory stores the different models used by the application.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment