Skip to content
This repository has been archived by the owner on Nov 12, 2017. It is now read-only.

Commit

Permalink
Initial commit of website
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephGarrone committed Mar 23, 2016
1 parent b78574f commit 6211909
Show file tree
Hide file tree
Showing 69 changed files with 22,483 additions and 1 deletion.
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history

# Ignore all compiled JS
public/js/components/**/*.js
public/js/components/**/*.map
public/js/core/**/*.js
public/js/core/**/*.map
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,38 @@ master
**Note: Please do not submit Pull Requests straight to master as they will not be accepted.**

### Directory Structure
...
```
/bin - MEAN Entry point
/database - Database files (Exports + patches)
/lib - All other server files
/public - All publicly accessible files
/css - CSS
/js - Javascript
/lib - Third party client side files
/routes - All webservices
/api - API only routes
index.js - All web page routes
/views - Templates to be rendered (.ejs only currently)
/shared - All shared view components
```
### Running A Local Copy
First clone the repository
```
git clone https://github.com/UQComputingSociety/uniber
cd uniber
```

Now you will need to install all the Node packages
```
npm install
```

Once this is finished simply run
```
npm start
```

And then access your [localhost:3000](http://localhost:3000).

## Copyright and Licensing
The project is currently licensed under the GNU GPL V3. The full license can be found under LICENSE.
62 changes: 62 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');

var routes = require('./routes/index');
var api = require('./routes/api/api');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use('/', routes);
app.use('/api/', api);

// catch 404 and forward to error handler
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);
res.render('error', {
message: err.message,
error: err,
code: err.status
});
});
}

// production error handler
// no stacktraces leaked to user
app.use(function(err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {},
code: err.status
});
});


module.exports = app;
90 changes: 90 additions & 0 deletions bin/www
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('uq-parking-stats:server');
var http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
9 changes: 9 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
mysql: {
host: "localhost",
port: 3306,
user: "uniber",
password: "uniber",
database: "uniber"
}
}
64 changes: 64 additions & 0 deletions database/DATABASE.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
CREATE DATABASE IF NOT EXISTS `uniber` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE `uniber`;

/* Remove the user if they already exist */
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ANSI';
DROP PROCEDURE IF EXISTS uniber.drop_user_if_exists ;
DELIMITER $$
CREATE PROCEDURE uniber.drop_user_if_exists()
BEGIN
DECLARE foo BIGINT DEFAULT 0 ;
SELECT COUNT(*)
INTO foo
FROM mysql.user
WHERE User = 'uniber' and Host = 'localhost';
IF foo > 0 THEN
DROP USER 'uniber'@'localhost' ;
END IF;
END ;$$
DELIMITER ;
CALL uniber.drop_user_if_exists() ;
DROP PROCEDURE IF EXISTS uniber.drop_users_if_exists ;
SET SQL_MODE=@OLD_SQL_MODE ;
FLUSH PRIVILEGES;

/* And make a new one */
CREATE USER 'uniber'@'localhost' IDENTIFIED BY 'uniber';
GRANT ALL PRIVILEGES ON uniber.* TO 'uniber'@'localhost' WITH GRANT OPTION;

/* Examples left here for new tables
DROP TABLE IF EXISTS `car_park_info`;
CREATE TABLE IF NOT EXISTS `car_park_info` (
`id` int(11) NOT NULL,
`car_park` int(11) NOT NULL,
`available` int(11) NOT NULL,
`time` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
DROP TABLE IF EXISTS `car_parks`;
CREATE TABLE IF NOT EXISTS `car_parks` (
`id` int(11) NOT NULL,
`name` text NOT NULL,
`data_name` text NOT NULL,
`casual` tinyint(1) NOT NULL DEFAULT '1',
`active` tinyint(1) NOT NULL DEFAULT '1'
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `car_parks`
ADD PRIMARY KEY (`id`);
ALTER TABLE `car_park_info`
ADD PRIMARY KEY (`id`),
ADD KEY `car_park` (`car_park`);
ALTER TABLE `car_parks`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `car_park_info`
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;
ALTER TABLE `car_park_info`
ADD CONSTRAINT `car_park_info_ibfk_1` FOREIGN KEY (`car_park`) REFERENCES `car_parks` (`id`);
*/
13 changes: 13 additions & 0 deletions lib/database.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
var mysql = require('mysql');

var config = require('../config');

var conn = null;

module.exports = function() {
if (!conn) {
var conn = mysql.createConnection(config.mysql);
}

return conn;
}
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "uniber",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "npm run tsc && node ./bin/www",
"tsc": "tsc",
"typings": "typings",
"postinstall": "typings install"
},
"dependencies": {
"angular2": "^2.0.0-beta.11",
"body-parser": "~1.13.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"ejs": "^2.4.1",
"express": "~4.13.1",
"jade": "~1.11.0",
"morgan": "~1.6.1",
"mysql": "^2.10.2",
"serve-favicon": "~2.3.0",
"es6-promise": "^3.0.2",
"es6-shim": "^0.35.0",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.2",
"zone.js": "0.6.4"
},
"devDependencies": {
"typescript": "^1.8.9",
"typings": "^0.7.9"
}
}
Loading

0 comments on commit 6211909

Please sign in to comment.