Unverified Commit 5424dafc authored by Mark Stenglein's avatar Mark Stenglein
Browse files

Merge branch 'setRoughUI'

- I figure we dont need this anymore since it's moved _way_ beyond UI
parents d3a06fc9 6e1bddfe
#!/bin/bash +x #!/bin/bash
# Function to test whether or not a program is installed on the users machine
function haveProg() {
[ -x "$(which "$1")" ]
}
# Function to pause excecution till the user presses the enter key
function pause() {
read -r -p "$*"
}
#TODO: If you wanted to, add 'update' commands to the remaining systems that need them. # Open up version variables
. /etc/lsb-release
### For example:
### DISTRIB_ID=Ubuntu
### DISTRIB_RELEASE=12.04
### DISTRIB_CODENAME=precise
### DISTRIB_DESCRIPTION="Ubuntu 12.04.2 LTS"
# Handler for Debian based systems with apt # Check if you have a given program
function func_apt-get() { function haveProg() {
# Install nodejs [ -x "$(which "$1")" ]
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
sudo apt-get update
sudo apt-get install nodejs
}
# Handler for systems such as Fedora with yum
function func_yum() {
sudo curl --silent --location https://rpm.nodesource.com/setup_4.x | bash -
sudo yum check-update
sudo yum -y install nodejs
}
# Handler for Arch based systems with pacman
function func_pacman() {
sudo pacman -Syy
sudo pacman -S nodejs npm
}
# Handler for macOS and others with homebrew
function func_brew() {
brew update
brew install node npm #both, just in case
}
# Function to tell SUSE users to do it themselves because there are version specific instructions
function func_zypper() {
echo "Go here: http://software.opensuse.org/download.html?project=devel%3Alanguages%3Anodejs&package=nodejs"
echo "Follow the instructions on the SUSE website in a different terminal"
# Close with error code 1
end 1;
#Because the SUSE commands were version specific so I give up
}
# Handler for Gentoo systems with emerge
function func_emerge() {
emerge nodejs
}
# Handler for FreeBSD and other systems with pkg
function func_pkg() {
pkg install node
}
# Handler for macOS and others with MacPorts - because some people hate Homebrew
function func_port() {
port install nodejs
}
# Handler for a variety of other systems with pkgin
function func_pkgin() {
pkgin -y install nodejs
}
# Function which installs dependencies for the project
function func_dependencies {
# Install nodemon
if haveProg nodemon ; then echo "** nodemon already installed **"
else sudo npm install -g nodemon
fi
# Install npm dependencies
npm install
cd schedules || exit
npm install
cd ..
} }
## Installation script for Ubuntu
if [ "$DISTRIB_ID" == "Ubuntu" ]
# Skip all of this if you have node or nodejs then
if haveProg node ; then echo "** Node already installed **" echo "** Installing as Ubuntu"
elif haveProg nodejs ; then echo "** Node already installed **" echo ""
elif haveProg apt-get ; then func_apt-get if ! haveProg npm
elif haveProg yum ; then func_yum then
elif haveProg pacman ; then func_pacman echo "** Installing Node.js"
elif haveProg brew ; then func_brew curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
elif haveProg emerge ; then func_emerge sudo apt-get install -y nodejs
elif haveProg zypper ; then func_zypper fi
elif haveProg pkg ; then func_pkg if ! haveProg mongod
elif haveProg port ; then func_port then
elif haveProg pkgin ; then func_pkgin echo "** Installing MongoDB"
else sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv EA312927
echo '** No supported package manager found!' 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
echo '** Node.js not found!' sudo apt-get update
sudo apt-get install -y mongodb-org
## Service is started in start.sh file
fi
elif haveProg yum
then
echo "** Installing as yum manager"
echo ""
echo "** yum not yet supported, go to https://git.gmu.edu/srct/schedules for help"
exit 1 exit 1
# Handler for mac and macports
elif haveProg brew
then
brew update
brew install node npm
if ! haveProg mongo
then
brew install mongodb
fi
elif haveProg port
then
sudo port selfupdate
sudo port install nodejs
if ! haveProg mongo
then
sudo port install mongodb
fi
fi fi
# Install dependencies regardless ## Install node.js dependencies
func_dependencies npm install
echo "** Installation Completed **" cd schedules
echo "** Run './start.sh' to run the server" npm install
cd ..
echo "** Application installed successfuly"
echo ""
echo "** Run ./start.sh to start application"
exit 0
var express = require('express'); var express = require('express');
var path = require('path'); var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan'); var logger = require('morgan');
var cookieParser = require('cookie-parser'); var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser'); var bodyParser = require('body-parser');
var mongoose = require('mongoose');
// Load site wide configurations // Load site wide configurations
var config = require('./config'); var config = require('./config');
...@@ -17,8 +17,6 @@ var app = express(); ...@@ -17,8 +17,6 @@ var app = express();
app.set('views', path.join(__dirname, 'views')); app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade'); app.set('view engine', 'jade');
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev')); app.use(logger('dev'));
app.use(bodyParser.json()); app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.urlencoded({ extended: false }));
...@@ -31,6 +29,9 @@ app.use(require('node-sass-middleware')({ ...@@ -31,6 +29,9 @@ app.use(require('node-sass-middleware')({
})); }));
app.use(express.static(path.join(__dirname, 'public'))); app.use(express.static(path.join(__dirname, 'public')));
// Connect to mongo
mongoose.connect(config.mongoDBURL);
app.use('/', routes); app.use('/', routes);
app.use('/api', api); app.use('/api', api);
......
...@@ -5,4 +5,23 @@ config.siteName = "Schedules"; ...@@ -5,4 +5,23 @@ config.siteName = "Schedules";
// Application Description (subtitle) // Application Description (subtitle)
config.siteDescription = "A simple application to add your class schedule to calendar applications like Outlook and Google Calendar." config.siteDescription = "A simple application to add your class schedule to calendar applications like Outlook and Google Calendar."
// MongoDB config
config.mongoDBURL = 'mongodb://localhost/myappdatabase';
// Data files to load:
config.dataFiles = [
{
// Pretty Name
school: 'George Mason University',
// URL Slug for the API
slug: 'GMU',
// List of .json files to import (place in setup folder under SLUG folder)
dataSource: [
'fall2016GMU' // IE: get's put in 'setup/GMU/fall2016GMU.json'
],
// Whether to actually import the data
enabled: false
}
]
module.exports = config; module.exports = config;
...@@ -11,9 +11,9 @@ ...@@ -11,9 +11,9 @@
"debug": "~2.2.0", "debug": "~2.2.0",
"express": "~4.13.4", "express": "~4.13.4",
"jade": "~1.11.0", "jade": "~1.11.0",
"mongoose": "^4.5.5",
"morgan": "~1.7.0", "morgan": "~1.7.0",
"node-sass": "^3.8.0", "node-sass": "^3.8.0",
"node-sass-middleware": "0.8.0", "node-sass-middleware": "0.8.0"
"serve-favicon": "~2.3.0"
} }
} }
$(document).ready(function() {
$('#classSearch').DataTable();
} );
// Custom Sass entries go here and will be loaded after bootstrap
// Add center class for divs and the text within
.center-text {
text-align: center;
}
html, body {
height: 100%;
}
...@@ -5817,4 +5817,10 @@ button.close { ...@@ -5817,4 +5817,10 @@ button.close {
.hidden-print { .hidden-print {
display: none !important; } } display: none !important; } }
.center-text {
text-align: center; }
html, body {
height: 100%; }
/*# sourceMappingURL=main.css.map */ /*# sourceMappingURL=main.css.map */
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -54,3 +54,6 @@ ...@@ -54,3 +54,6 @@
// Utility classes // Utility classes
@import "bootstrap/utilities"; @import "bootstrap/utilities";
@import "bootstrap/responsive-utilities"; @import "bootstrap/responsive-utilities";
// Custom Classes
@import "_custom.scss";
...@@ -13,16 +13,16 @@ var schools = [ ...@@ -13,16 +13,16 @@ var schools = [
] ]
/* GET Schools listing. */ /* GET Schools listing. */
router.get('/lists/schools', function(req, res, next) { router.get('/api/lists/schools', function(req, res, next) {
res.send(JSON.stringify(schools)); res.send(JSON.stringify(schools));
}); });
// GET ical file // GET ical file
router.get('/ical/:year/:season/:crns', function(req, res) { router.get('/api/:format/:school/:semester/:crns', function(req, res) {
var crns = req.params['crns'].split(','); var crns = req.params['crns'].split(',');
var format = req.params['format']; var format = req.params['format'];
var year = req.params['year']; var school = req.params['school'];
var season = req.params['season']; var semester = req.params['semester'];
var crnNums = [{ var crnNums = [{
format, format,
year, year,
......
var express = require('express'); var express = require('express');
var router = express.Router(); var router = express.Router();
// Load site wide configurations // Load site wide configurations
var config = require('../config'); var config = require('../config');
...@@ -7,9 +8,11 @@ router.get('/docs', function(req, res, next) { ...@@ -7,9 +8,11 @@ router.get('/docs', function(req, res, next) {
res.render('docs', { config }); res.render('docs', { config });
}) })
// TODO: Actually learn how to make this function set be passed around properly
/* GET home page. */ /* GET home page. */
router.get('/', function(req, res, next) { router.get('/', function(req, res, next) {
res.render('index', { config }); res.render('index', { config });
}); })
module.exports = router; module.exports = router;
module.exports = initialPopulate;
// Get the title from the rendering process
title= title
head head
// Metadata // Metadata
...@@ -11,3 +9,10 @@ head ...@@ -11,3 +9,10 @@ head
script(src='/javascripts/bootstrap.js') script(src='/javascripts/bootstrap.js')
script(src="https://use.fontawesome.com/1c4cae8f2d.js") script(src="https://use.fontawesome.com/1c4cae8f2d.js")
link(href='/stylesheets/main.css', rel='stylesheet') link(href='/stylesheets/main.css', rel='stylesheet')
// Datatables
link(rel="stylesheet" type="text/css" href="https://cdn.datatables.net/v/bs/dt-1.10.12/datatables.min.css")
script(type="text/javascript" src="https://cdn.datatables.net/v/bs/dt-1.10.12/datatables.min.js")
// Favicon
link(rel='shortcut icon', href='/favicon.ico?', type='image/x-icon')
...@@ -2,37 +2,64 @@ ...@@ -2,37 +2,64 @@
extends layout extends layout
block content block content
script(src='/javascripts/mainApp.js')
div.containter-fluid div.containter-fluid
div.row div.row
// Main site column // Main site column
div.col-md-8 div.col-md-8
// Site branding row // Site title include
div.row.center include main-title.jade
center // Content div
// Font Awesome stack of circle and calendar for logo
span.fa-stack.fa-lg.fa-5x
i.fa.fa-circle-thin.fa-stack-2x(aria-hidden='true')
i.fa.fa-calendar.fa-stack-1x(aria-hidden='true')
// Title for the site
h1 #{config.siteName}
em #{config.siteDescription}
div.row div.row
// Left padding
div.col-md-1 div.col-md-1
// Content div
div.col-md-10 div.col-md-10
ul#search-type.nav.nav-tabs div.row
li#search-tab(role='presentation') div.col-md-2
a(href='#search' role='tab') Search for Classes div.col-md-8
li#import-tab(role='presentation') br
a(href='#import' role='tab') Batch Import div.input-group
div#tab-contents.tab-content span.input-group-btn
div#search.tab-pane.fade(role='tabpanel') button.btn.btn-info(type="button") Import CRN's
p input.form-control(type="text" placeholder="Enter CRN's separated by commas...")
This is the search tab. // br
div#import.tab-pane.fade(role='tabpanel') // div.input-group
p // span.input-group-btn
This is the import tab. // button.btn.btn-info(type="button")
// i.fa.fa-search
// input.form-control(type="text" placeholder="Search for classes...")
div.col-md-2
div.row
br
div.col-md-12
table#classSearch.table.table-striped.table-bordered
thead
tr
th Add
th CRN
th Class
th Title
th Section
th Campus
th Sessions
tbody
tr
td
button.btn.btn-primary(type="button") Add
td 12345
td
td
td
td
td
// Right padding
div.col-md-1
// Registration cart div
div#sidebar.col-md-4
div.row
div.col-md-11
div#registeredClasses.row
div.well
h2 Registered Classes
div.col-md-1 div.col-md-1
div#registered-classes.col-md-4(style='background-color: red;')
center
h1 Registered Classes
doctype html doctype html
html html
include head include head
body(style='padding-top: 70px;') body(style='padding-top: 50px;')
include nav div.container-fluid
block content include nav
block content
// Site branding row
div.row.center-text
// Font Awesome stack of circle and calendar for logo
span.fa-stack.fa-lg.fa-5x
i.fa.fa-circle-thin.fa-stack-2x(aria-hidden='true')
i.fa.fa-calendar.fa-stack-1x(aria-hidden='true')
// Title for the site
h1 #{config.siteName}
small #{config.siteDescription}
...@@ -5,5 +5,6 @@ block content ...@@ -5,5 +5,6 @@ block content
div.row div.row
div.col-lg-2 div.col-lg-2
div.col-lg-8 div.col-lg-8
include main-title
block docs-content block docs-content
div.col-lg-2 div.col-lg-2
cd schedules cd schedules
echo "** Your sudo privalleges are needed to start the database, MongoDB"
sudo systemctl start mongodb
echo "** visit localhost:3000 for the server" echo "** visit localhost:3000 for the server"
DEBUG=myapp:* nodemon start DEBUG=myapp:* nodemon start
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