diff --git a/app.js b/app.js index b96c598..1602025 100644 --- a/app.js +++ b/app.js @@ -7,16 +7,16 @@ const sassMiddleware = require('node-sass-middleware'); // const favicon = require('serve-favicon'); const subdomain = require('express-subdomain'); -const index = require('./routes/index'); -const cufs = require('./routes/cufs'); -const uonetplus = require('./routes/uonetplus'); -const uonetplusOpiekun = require('./routes/uonetplus-opiekun'); -const uonetplusUzytkownik = require('./routes/uonetplus-uzytkownik'); +const index = require('./src/routes/index'); +const cufs = require('./src/routes/cufs'); +const uonetplus = require('./src/routes/uonetplus'); +const uonetplusOpiekun = require('./src/routes/uonetplus-opiekun'); +const uonetplusUzytkownik = require('./src/routes/uonetplus-uzytkownik'); const app = express(); // view engine setup -app.set('views', path.join(__dirname, 'views')); +app.set('views', path.join(__dirname, 'src/views')); app.set('view engine', 'pug'); // uncomment after placing your favicon in /public diff --git a/bin/www b/bin/www index 7cbbe30..5106f2b 100755 --- a/bin/www +++ b/bin/www @@ -3,28 +3,24 @@ /** * Module dependencies. */ - -var app = require('../app'); -var debug = require('debug')('fake-log:server'); -var http = require('http'); +const app = require('../app'); +const debug = require('debug')('fake-log:server'); +const http = require('http'); /** * Get port from environment and store in Express. */ - -var port = normalizePort(process.env.PORT || '3000'); +const port = normalizePort(process.env.PORT || '3000'); app.set('port', port); /** * Create HTTP server. */ - -var server = http.createServer(app); +const server = http.createServer(app); /** * Listen on provided port, on all network interfaces. */ - server.listen(port); server.on('error', onError); server.on('listening', onListening); @@ -32,9 +28,8 @@ server.on('listening', onListening); /** * Normalize a port into a number, string, or false. */ - function normalizePort(val) { - var port = parseInt(val, 10); + let port = parseInt(val, 10); if (isNaN(port)) { // named pipe @@ -52,13 +47,12 @@ function normalizePort(val) { /** * Event listener for HTTP server "error" event. */ - function onError(error) { if (error.syscall !== 'listen') { throw error; } - var bind = typeof port === 'string' + let bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port; @@ -80,10 +74,9 @@ function onError(error) { /** * Event listener for HTTP server "listening" event. */ - function onListening() { - var addr = server.address(); - var bind = typeof addr === 'string' + let addr = server.address(); + let bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port; debug('Listening on ' + bind); diff --git a/routes/cufs.js b/src/routes/cufs.js similarity index 100% rename from routes/cufs.js rename to src/routes/cufs.js diff --git a/routes/index.js b/src/routes/index.js similarity index 54% rename from routes/index.js rename to src/routes/index.js index cff09a2..9ab1070 100644 --- a/routes/index.js +++ b/src/routes/index.js @@ -1,8 +1,8 @@ -var express = require('express'); -var router = express.Router(); +const express = require('express'); +const router = express.Router(); /* GET home page. */ -router.get('/', function(req, res) { +router.get('/', (req, res) => { res.render('index', { title: 'fake-log', domain: req.get('host') }); }); diff --git a/routes/uonetplus-opiekun.js b/src/routes/uonetplus-opiekun.js similarity index 51% rename from routes/uonetplus-opiekun.js rename to src/routes/uonetplus-opiekun.js index 3ddf73f..0050d79 100644 --- a/routes/uonetplus-opiekun.js +++ b/src/routes/uonetplus-opiekun.js @@ -1,38 +1,38 @@ -var express = require('express'); -var router = express.Router(); +const express = require('express'); +const router = express.Router(); global.opiekunRoot = "/Default/123456"; -router.get("/", function(req, res) { +router.get("/", (req, res) => { res.json({ "name" : "uonetplus-opiekun", "message": "Not implemented yet" }); }); -router.get("/Default/123456/", function (req, res) { +router.get("/Default/123456/", (req, res) => { res.redirect("/Default/123456/Start/Index/"); }); -router.get("/Default/123456/Start/Index/", function (req, res) { +router.get("/Default/123456/Start/Index/", (req, res) => { res.render("opiekun/start", { title: "Witryna ucznia i rodzica – Strona główna" }); }); -router.get("/Default/123456/Uczen.mvc/DanePodstawowe", function (req, res) { +router.get("/Default/123456/Uczen.mvc/DanePodstawowe", (req, res) => { res.render("opiekun/dane", { title: "Witryna ucznia i rodzica – Dane ucznia", - data: require("../data/opiekun/dane.json") + data: require("../../data/opiekun/dane.json") }); }); -router.get("/Default/123456/Oceny(\.mvc|)/Wszystkie", function (req, res) { +router.get("/Default/123456/Oceny(\.mvc|)/Wszystkie", (req, res) => { if (req.query.details === '2') { res.render("opiekun/oceny-szczegolowy", { - data: require("../data/opiekun/oceny-szczegolowy.json") + data: require("../../data/opiekun/oceny-szczegolowy.json") }); } else { res.render("opiekun/oceny-skrocony", { - data: require("../data/opiekun/oceny-skrocony.json") + data: require("../../data/opiekun/oceny-skrocony.json") }); } }); diff --git a/routes/uonetplus-uzytkownik.js b/src/routes/uonetplus-uzytkownik.js similarity index 54% rename from routes/uonetplus-uzytkownik.js rename to src/routes/uonetplus-uzytkownik.js index 3e612e6..f40bc9e 100644 --- a/routes/uonetplus-uzytkownik.js +++ b/src/routes/uonetplus-uzytkownik.js @@ -1,7 +1,7 @@ -var express = require('express'); -var router = express.Router(); +const express = require('express'); +const router = express.Router(); -router.get("/", function(req, res) { +router.get("/", (req, res) => { res.json({ "name" : "uonetplus-uzytkownik", "message": "Not implemented yet" diff --git a/routes/uonetplus.js b/src/routes/uonetplus.js similarity index 58% rename from routes/uonetplus.js rename to src/routes/uonetplus.js index 0aa4b0e..07a0f0c 100644 --- a/routes/uonetplus.js +++ b/src/routes/uonetplus.js @@ -1,15 +1,15 @@ -var express = require('express'); -var router = express.Router(); -var protocol = require('../utils/connection'); +const express = require('express'); +const router = express.Router(); +const protocol = require('../utils/connection'); -router.get("/", function(req, res) { +router.get("/", (req, res) => { res.json({ "name" : "uonetplus", "message": "Not implemented yet" }); }); -router.post("/Default/LoginEndpoint.aspx", function (req, res) { +router.post("/Default/LoginEndpoint.aspx", (req, res) => { if (req.body.wa && req.body.wresult) { return res.redirect("/Default/") } @@ -17,11 +17,11 @@ router.post("/Default/LoginEndpoint.aspx", function (req, res) { res.json({message: "error"}); }); -router.get("/Default/", function (req, res) { +router.get("/Default/", (req, res) => { res.redirect("/Default/Start.mvc/Index"); }); -router.get("/Default/Start.mvc/Index", function (req, res) { +router.get("/Default/Start.mvc/Index", (req, res) => { res.render("homepage", { title: "Uonet+", uonetplusOpiekun: protocol(req) + "://" + req.get('host').replace("uonetplus", "uonetplus-opiekun") diff --git a/utils/connection.js b/src/utils/connection.js similarity index 100% rename from utils/connection.js rename to src/utils/connection.js diff --git a/views/error.pug b/src/views/error.pug similarity index 100% rename from views/error.pug rename to src/views/error.pug diff --git a/views/homepage.pug b/src/views/homepage.pug similarity index 100% rename from views/homepage.pug rename to src/views/homepage.pug diff --git a/views/index.pug b/src/views/index.pug similarity index 100% rename from views/index.pug rename to src/views/index.pug diff --git a/views/layout.pug b/src/views/layout.pug similarity index 100% rename from views/layout.pug rename to src/views/layout.pug diff --git a/views/login-cert.pug b/src/views/login-cert.pug similarity index 100% rename from views/login-cert.pug rename to src/views/login-cert.pug diff --git a/views/login-form.pug b/src/views/login-form.pug similarity index 100% rename from views/login-form.pug rename to src/views/login-form.pug diff --git a/views/opiekun/dane.pug b/src/views/opiekun/dane.pug similarity index 100% rename from views/opiekun/dane.pug rename to src/views/opiekun/dane.pug diff --git a/views/opiekun/layout.pug b/src/views/opiekun/layout.pug similarity index 100% rename from views/opiekun/layout.pug rename to src/views/opiekun/layout.pug diff --git a/views/opiekun/oceny-skrocony.pug b/src/views/opiekun/oceny-skrocony.pug similarity index 100% rename from views/opiekun/oceny-skrocony.pug rename to src/views/opiekun/oceny-skrocony.pug diff --git a/views/opiekun/oceny-szczegolowy.pug b/src/views/opiekun/oceny-szczegolowy.pug similarity index 100% rename from views/opiekun/oceny-szczegolowy.pug rename to src/views/opiekun/oceny-szczegolowy.pug diff --git a/views/opiekun/start.pug b/src/views/opiekun/start.pug similarity index 100% rename from views/opiekun/start.pug rename to src/views/opiekun/start.pug