mirror of
https://github.com/Lissy93/twitter-sentiment-visualisation.git
synced 2021-05-12 19:52:18 +03:00
Created initial project structure
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
node_modules
|
||||||
|
bower_components
|
||||||
|
.idea
|
||||||
|
*.idea
|
||||||
|
.log
|
||||||
|
*.log
|
||||||
63
app.js
Normal file
63
app.js
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
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 map = require('./routes/map');
|
||||||
|
var timeline = require('./routes/timeline');
|
||||||
|
|
||||||
|
var app = express();
|
||||||
|
|
||||||
|
// view engine setup
|
||||||
|
app.set('views', path.join(__dirname, 'views'));
|
||||||
|
app.set('view engine', 'jade');
|
||||||
|
|
||||||
|
// uncomment after placing your favicon in /public
|
||||||
|
//app.use(favicon(__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('/bower_components', express.static(__dirname + '/bower_components'));
|
||||||
|
|
||||||
|
app.use('/', routes);
|
||||||
|
app.use('/map', map);
|
||||||
|
app.use('/timeline', timeline);
|
||||||
|
|
||||||
|
// 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
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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: {}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
module.exports = app;
|
||||||
90
bin/www
Normal file
90
bin/www
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Module dependencies.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var app = require('../app');
|
||||||
|
var debug = require('debug')('twitter-sentiment-visualisation: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);
|
||||||
|
}
|
||||||
1
public/data/map-style.json
Normal file
1
public/data/map-style.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[{"featureType":"landscape","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"poi","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"stylers":[{"hue":"#00aaff"},{"saturation":-100},{"gamma":2.15},{"lightness":12}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"visibility":"on"},{"lightness":24}]},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":57}]}]
|
||||||
BIN
public/images/loading.gif
Normal file
BIN
public/images/loading.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
6
public/javascripts/loading.js
Normal file
6
public/javascripts/loading.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
(function() {
|
||||||
|
$(window).load(function() {
|
||||||
|
$('#loading-graphic').fadeOut('slow');
|
||||||
|
});
|
||||||
|
|
||||||
|
}).call(this);
|
||||||
1
public/stylesheets/all.min.css
vendored
Normal file
1
public/stylesheets/all.min.css
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
a,h1,h2,h3,h4,h5,li,p,span{font-family:Roboto,"Helvetica Neue",Helvetica,Arial,sans-serif}#loading-graphic{position:fixed;left:0;top:0;width:100%;height:100%;z-index:998;background:url(/images/loading.gif) center no-repeat #fff}.card{box-shadow:0 1px 3px rgba(0,0,0,.15);background:#fff;display:inline-block;border-radius:2px}.card:hover{box-shadow:0 1px 4px 1px rgba(0,0,0,.2)}.card.home-panels{width:24em;height:15em;margin:.5em;padding:.5em 1em}body{font:14px "Lucida Grande",Helvetica,Arial,sans-serif;margin:0;background:#efefef}h1,h2,h3,h4,h5{font-weight:400}h3{font-size:1.3em}google-map{height:600px}.content.dashboard{margin:1.5em 3em}.content.map{margin:0}
|
||||||
9
routes/index.js
Normal file
9
routes/index.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
var express = require('express');
|
||||||
|
var router = express.Router();
|
||||||
|
|
||||||
|
/* GET home page. */
|
||||||
|
router.get('/', function(req, res, next) {
|
||||||
|
res.render('index', { title: 'Express', pageNum: 0 });
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
9
routes/map.js
Normal file
9
routes/map.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
var express = require('express');
|
||||||
|
var router = express.Router();
|
||||||
|
|
||||||
|
/* GET home page. */
|
||||||
|
router.get('/', function(req, res, next) {
|
||||||
|
res.render('page_map', { title: 'Map', pageNum: 1 });
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
9
routes/timeline.js
Normal file
9
routes/timeline.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
var express = require('express');
|
||||||
|
var router = express.Router();
|
||||||
|
|
||||||
|
/* GET home page. */
|
||||||
|
router.get('/', function(req, res, next) {
|
||||||
|
res.render('page_timeline', { title: 'Time Line', pageNum: 2 });
|
||||||
|
});
|
||||||
|
|
||||||
|
module.exports = router;
|
||||||
3
source/scripts/loading.coffee
Normal file
3
source/scripts/loading.coffee
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
$(window).load ->
|
||||||
|
$('#loading-graphic').fadeOut 'slow'
|
||||||
|
return
|
||||||
22
source/styles/components.less
Normal file
22
source/styles/components.less
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
@import "constants";
|
||||||
|
|
||||||
|
|
||||||
|
.card{
|
||||||
|
box-shadow: @shadow_panel_default;
|
||||||
|
background: @col_white;
|
||||||
|
display: inline-block;
|
||||||
|
border-radius: 2px;
|
||||||
|
|
||||||
|
&:hover{
|
||||||
|
box-shadow: @shadow_panel_hover;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.home-panels{
|
||||||
|
width: 24em;
|
||||||
|
height: 15em;
|
||||||
|
margin: 0.5em;
|
||||||
|
padding: 0.5em 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
25
source/styles/constants.less
Normal file
25
source/styles/constants.less
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************\
|
||||||
|
*---- COLORS ----*
|
||||||
|
\******************/
|
||||||
|
|
||||||
|
@col_primary: #47D5E8;
|
||||||
|
@col_white: #fff;
|
||||||
|
@col_palegrey: #EFEFEF;
|
||||||
|
|
||||||
|
|
||||||
|
/******************\
|
||||||
|
*---- FONTS -----*
|
||||||
|
\******************/
|
||||||
|
|
||||||
|
@font_default: "Roboto","Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************\
|
||||||
|
*---- SHADOWS ---*
|
||||||
|
\******************/
|
||||||
|
@shadow_panel_default: 0 1px 3px rgba(0,0,0,0.15);
|
||||||
|
@shadow_panel_hover: 0 1px 4px 1px rgba(0,0,0,0.2);
|
||||||
30
source/styles/general.less
Normal file
30
source/styles/general.less
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
@import "constants";
|
||||||
|
|
||||||
|
|
||||||
|
/******************\
|
||||||
|
*-- PAGE LAYOUT -*
|
||||||
|
\******************/
|
||||||
|
body {
|
||||||
|
font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
|
||||||
|
margin: 0;
|
||||||
|
background: @col_palegrey;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/******************\
|
||||||
|
*----- TEXT -----*
|
||||||
|
\******************/
|
||||||
|
p, a, span, li{
|
||||||
|
font-family: @font_default;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3, h4, h5{
|
||||||
|
font-family: @font_default;
|
||||||
|
font-weight: normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
h3{
|
||||||
|
font-size: 1.3em;
|
||||||
|
}
|
||||||
9
source/styles/loading.css
Normal file
9
source/styles/loading.css
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#loading-graphic{
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
z-index: 998;
|
||||||
|
background: url(/images/loading.gif) center no-repeat #fff;
|
||||||
|
}
|
||||||
5
source/styles/map.less
Normal file
5
source/styles/map.less
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
@import 'constants';
|
||||||
|
|
||||||
|
google-map {
|
||||||
|
height: 600px;
|
||||||
|
}
|
||||||
11
source/styles/pages.less
Normal file
11
source/styles/pages.less
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
|
||||||
|
.content.dashboard{
|
||||||
|
margin: 1.5em 3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content.map{
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
6
views/error.jade
Normal file
6
views/error.jade
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
extends layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
h1= message
|
||||||
|
h2= error.status
|
||||||
|
pre #{error.stack}
|
||||||
4
views/footer_scripts.jade
Normal file
4
views/footer_scripts.jade
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
script(type='text/javascript', src='/bower_components/jquery/dist/jquery.min.js')
|
||||||
|
script(type='text/javascript', src='/bower_components/materialize/dist/js/materialize.min.js')
|
||||||
|
script(type='text/javascript', src='/javascripts/loading.js')
|
||||||
|
|
||||||
2
views/head.jade
Normal file
2
views/head.jade
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
link(rel='stylesheet', href='/bower_components/materialize/dist/css/materialize.min.css')
|
||||||
|
link(rel='stylesheet', href='/stylesheets/all.min.css')
|
||||||
7
views/index.jade
Normal file
7
views/index.jade
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
extends layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
div.content.dashboard
|
||||||
|
each val, index in {1:'One',2:'Two',3:'Three'}
|
||||||
|
div.card.home-panels
|
||||||
|
h3='Title of Page ' + val
|
||||||
10
views/layout.jade
Normal file
10
views/layout.jade
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
doctype html
|
||||||
|
html
|
||||||
|
head
|
||||||
|
title= title
|
||||||
|
include ./head
|
||||||
|
body.vertical.layout
|
||||||
|
div#loading-graphic
|
||||||
|
include ./navbar
|
||||||
|
block content
|
||||||
|
include ./footer_scripts
|
||||||
1
views/map_style.jade
Normal file
1
views/map_style.jade
Normal file
@@ -0,0 +1 @@
|
|||||||
|
- var mapstyle = '[{"featureType":"landscape","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"transit","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"poi","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"water","elementType":"labels","stylers":[{"visibility":"off"}]},{"featureType":"road","elementType":"labels.icon","stylers":[{"visibility":"off"}]},{"stylers":[{"hue":"#00aaff"},{"saturation":-100},{"gamma":2.15},{"lightness":12}]},{"featureType":"road","elementType":"labels.text.fill","stylers":[{"visibility":"on"},{"lightness":24}]},{"featureType":"road","elementType":"geometry","stylers":[{"lightness":57}]}]'
|
||||||
10
views/navbar.jade
Normal file
10
views/navbar.jade
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
nav
|
||||||
|
.nav-wrapper
|
||||||
|
a.brand-logo(href='#') Twitter Sentiment Visualisation
|
||||||
|
ul#nav-mobile.right.hide-on-med-and-down
|
||||||
|
li.active
|
||||||
|
a(href='/') Dashboard
|
||||||
|
li
|
||||||
|
a(href='/map') Map
|
||||||
|
li
|
||||||
|
a(href='/timeline') Timeline
|
||||||
8
views/page_map.jade
Normal file
8
views/page_map.jade
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
extends layout
|
||||||
|
block content
|
||||||
|
div.content.map
|
||||||
|
script(src="/bower_components/webcomponentsjs/webcomponents.min.js")
|
||||||
|
link(rel="import", href="/bower_components/google-map/google-map.html")
|
||||||
|
include map_style
|
||||||
|
google-map(latitude="37.77493", longitude="-122.41942", fit-to-markers, styles="#{mapstyle}")
|
||||||
|
script(src='/javascripts/map.js')
|
||||||
6
views/page_timeline.jade
Normal file
6
views/page_timeline.jade
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
extends layout
|
||||||
|
|
||||||
|
block content
|
||||||
|
div.content.timeline
|
||||||
|
h4 timeline
|
||||||
|
|
||||||
Reference in New Issue
Block a user