diff --git a/app.js b/app.js index debd5c3632871c1bc29c6cf4dce6fec8abff6a60..f3ed756b08f43e2b00d9a2ba38528dca12308b2f 100644 --- a/app.js +++ b/app.js @@ -58,12 +58,24 @@ app.use(function(req, res, next) { next(); }); -//require('./routes/routes')(app, config, passport, i18n); require('./routes/routes-account')(app, config, passport, i18n); require('./routes/routes-project')(app, config, passport); -//require('./routes/dbconn')(app, config); require('./routes/api')(app, config, passport); +// Handle 404 +app.use(function (req, res, next) { + //res.status(404).send('404: Page not Found', 404) + res.status(404).render('./DE/404') +}) + +// Handle 500 - any server error +app.use(function (err, req, res, next) { + console.error(err.stack) + res.status(500).render('./DE/500', { + error: err + }) +}) + app.listen(app.get('port'), function () { console.log('Express server listening on port ' + app.get('port')); }); \ No newline at end of file diff --git a/routes/methods.js b/routes/methods.js index cefda4b7249c3a64bdf4e1638eb38fd2f91f1d8a..9864273b4322e89b4d4e3093f1979b4b8b01986b 100644 --- a/routes/methods.js +++ b/routes/methods.js @@ -165,9 +165,10 @@ var methods = { }, addProjectOverview: function(data, callback) { dbconn.project.query('INSERT INTO project_overview SET ?', data, function (err, results, fields){ - if (err) throw err; - //console.log(results.insertId) - callback(results.insertId, err); + if (err) { + console.error(err); + } + callback(results, err); }) } }; diff --git a/routes/routes-account.js b/routes/routes-account.js index 06e9633a788020a64d558574948dd97ff89904da..e63438162f3874cd49b853e1cd3fe8c84d7f2c3e 100644 --- a/routes/routes-account.js +++ b/routes/routes-account.js @@ -9,7 +9,7 @@ const salt = 64; // salt length // forgot pwd const async = require('async') const crypto = require('crypto') -const nodemailer = require('./mailer') +const mailer = require('./mailer') module.exports = function (app, config, passport, i18n) { @@ -75,25 +75,25 @@ module.exports = function (app, config, passport, i18n) { } ); - var updatePasswordMailSubject = "Ihr Passwort für das Transferportal wurde gespeichert." - var mailSignature = "Mit den besten Grüßen,\ndas Transferportal-Team der HFT Stuttgart\n\n"+ - "Transferportal der Hochschule für Technik Stuttgart\n"+ - "Schellingstr. 24\n"+ - "70174 Stuttgart\n"+ - "m4lab@hft-stuttgart.de\n"+ - "https://transfer.hft-stuttgart.de" - var updatePasswordMailContent = "Lieber Nutzer,\n\n"+"Ihr Passwort wurde erfolgreich geändert.\n\n"+mailSignature - // ================ test i18n ================== i18n.setLocale('de'); app.get('/de', function(req, res) { var greeting = i18n.__('Hello World') res.send(greeting) }); - + var lang = 'DE' // ======== APP ROUTES - ACCOUNT ==================== + var updatePasswordMailSubject = "Ihr Passwort für das Transferportal wurde gespeichert." + var mailSignature = "Mit den besten Grüßen,\ndas Transferportal-Team der HFT Stuttgart\n\n"+ + "Transferportal der Hochschule für Technik Stuttgart\n"+ + "Schellingstr. 24\n"+ + "70174 Stuttgart\n"+ + "m4lab@hft-stuttgart.de\n"+ + "https://transfer.hft-stuttgart.de" + var updatePasswordMailContent = "Lieber Nutzer,\n\n"+"Ihr Passwort wurde erfolgreich geändert.\n\n"+mailSignature + app.get('/', function (req, res) { if (req.isAuthenticated()) { methods.getUserByEmail(req.user.email, function(data, err){ @@ -108,10 +108,6 @@ module.exports = function (app, config, passport, i18n) { } }); - app.get('/error', function (req, res) { - res.render(lang+'/error') - }); - app.get('/login', passport.authenticate(config.passport.strategy, { @@ -251,7 +247,8 @@ module.exports = function (app, config, passport, i18n) { req.flash('error', "Failed"); } else { - req.flash('success', 'Profile updated!'); + //req.flash('success', 'Profile updated!'); + req.flash('success', 'Ihr Benutzerprofil wurde aktualisiert!'); } res.redirect('/account/profile'); }) @@ -272,7 +269,7 @@ module.exports = function (app, config, passport, i18n) { // Load hashed passwd from DB dbconn.user.query('SELECT password FROM credential WHERE user_id='+userId, function (err, rows, fields) { if (err) { - res.redirect('/account/500') + res.redirect('/500') throw err } var userPwd = rows[0].password @@ -280,7 +277,7 @@ module.exports = function (app, config, passport, i18n) { // check if the password is correct bcrypt.compare(currPwd, userPwd, function(err, isMatch) { if (err) { - res.redirect('/account/500') + res.redirect('/500') throw err } else if (!isMatch) { @@ -311,11 +308,11 @@ module.exports = function (app, config, passport, i18n) { else { //req.flash('success', "Pasword updated!") req.flash('success', "Passwort aktualisiert!") - mailOptions.to = req.user.email + mailer.options.to = req.user.email //mailOptions.subject = "Your M4_LAB Password has been updated." - mailOptions.subject = updatePasswordMailSubject - mailOptions.text = updatePasswordMailContent - smtpTransport.sendMail(mailOptions, function(err) { + mailer.options.subject = updatePasswordMailSubject + mailer.options.text = updatePasswordMailContent + mailer.transport.sendMail(mailer.options, function(err) { if (err) { console.log(err) } @@ -386,10 +383,10 @@ module.exports = function (app, config, passport, i18n) { }); // send email - mailOptions.to = emailAddress; - mailOptions.subject = emailSubject; - mailOptions.text = emailContent; - smtpTransport.sendMail(mailOptions, function(err) { + mailer.options.to = emailAddress; + mailer.options.subject = emailSubject; + mailer.options.text = emailContent; + mailer.transport.sendMail(mailer.options, function(err) { done(err, 'done'); }); } @@ -449,10 +446,10 @@ module.exports = function (app, config, passport, i18n) { //req.flash('success', "Your pasword has been updated.") req.flash('success', "Passwort aktualisiert!") // send notifiaction email - mailOptions.to = user.email - mailOptions.subject = updatePasswordMailSubject - mailOptions.text = updatePasswordMailContent - smtpTransport.sendMail(mailOptions, function(err) { + mailer.options.to = user.email + mailer.options.subject = updatePasswordMailSubject + mailer.options.text = updatePasswordMailContent + mailer.transport.sendMail(mailer.options, function(err) { if (err) { console.log(err) } diff --git a/routes/routes-project.js b/routes/routes-project.js index 0c92d98fd2df3699a65b53d6f1543b8a92e3bbf6..3816d36f2e4cc3a0f210eb1844d835b2d48fff34 100644 --- a/routes/routes-project.js +++ b/routes/routes-project.js @@ -39,7 +39,7 @@ module.exports = function (app) { ]) }); - app.get('/project', function (req, res) { + app.get('/project_', function (req, res) { async.waterfall([ // get all projects from projectdb function(done) { @@ -92,6 +92,10 @@ module.exports = function (app) { ]) }) + app.get('/project', function (req, res) { + res.render(lang+'/project/project-simplified'); + }) + app.get('/addprojectoverview', function (req, res) { if (req.isAuthenticated()) { res.render(lang+'/project/addProjectOverview') @@ -195,9 +199,14 @@ module.exports = function (app) { }, // add project overview function(done) { - methods.addProjectOverview(projectOverviewData, function(projectOverviewId, err){ - if (!err) { - done(err, projectOverviewId) + methods.addProjectOverview(projectOverviewData, function(data, err){ + if (err) { + res.status(500).render(lang+'/500', { + error: err + }) + } + else { + done(err, data.insertId) } }) }, diff --git a/views/DE/404.pug b/views/DE/404.pug index dc9e0a8c7ee898d69e8d78b4a1cc11c0a54831bc..c4178253b9cec40907906ccd33fc39ac6e85c990 100644 --- a/views/DE/404.pug +++ b/views/DE/404.pug @@ -1,4 +1,30 @@ -extends error - -block content - h2 Cannot find #{url} \ No newline at end of file +doctype html +html(lang="de") + head + title= "404 - Page not found" + meta(charset="UTF-8") + meta(name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no") + link(rel="stylesheet", type="text/css", href="https://transfer.hft-stuttgart.de/css/bootstrap/bootstrap.css") + style. + .container { + height: 400px; + position: relative; + } + .center { + margin: 0; + position: absolute; + top: 50%; + left: 50%; + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + } + body + div(class="container") + div(class="center", align="center") + a(href="https://m4lab.hft-stuttgart.de") + img(src="https://transfer.hft-stuttgart.de/images/demo/m4lab_logo.jpg", class="img-responsive center-block", width="185", height="192") + br + br + p(class="h5") 404. The requested URL was not found. + // Bootstrap + script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") \ No newline at end of file diff --git a/views/DE/500.pug b/views/DE/500.pug index cbc47e79df7455b95490f0288aa35542df297d85..704573397c7252fc0a8034428da47602afa9b994 100644 --- a/views/DE/500.pug +++ b/views/DE/500.pug @@ -1,8 +1,31 @@ -extends error - -block content - h1 Error: #{error.message} - if settings['verbose errors'] - pre= error.stack - else - p An error ocurred! \ No newline at end of file +doctype html +html(lang="de") + head + title= "500 - Internal Server Error" + meta(charset="UTF-8") + meta(name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no") + link(rel="stylesheet", type="text/css", href="https://transfer.hft-stuttgart.de/css/bootstrap/bootstrap.css") + style. + .container { + height: 400px; + position: relative; + } + .center { + margin: 0; + position: absolute; + top: 50%; + left: 50%; + -ms-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + } + body + div(class="container") + div(class="center", align="center") + a(href="https://m4lab.hft-stuttgart.de") + img(src="https://transfer.hft-stuttgart.de/images/demo/m4lab_logo.jpg", class="img-responsive center-block", width="185", height="192") + br + br + p(class="h5") 500. Unexpected Error :( + p #{ error } + // Bootstrap + script(src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous") \ No newline at end of file diff --git a/views/DE/account/profile.pug b/views/DE/account/profile.pug index 32a2aff116c487f82b6c6b2bd6d50637c5cedd2f..1f73274856754bac468681482f15c7cbe19ba25a 100644 --- a/views/DE/account/profile.pug +++ b/views/DE/account/profile.pug @@ -68,7 +68,6 @@ html(lang="de") option(value="Prof.") Prof. option(value="Dr.") Dr. option(value="Dipl.-Ing.") Dipl.-Ing. - option(value="etc.") etc. script. var titleOptions = document.getElementById('inputTitle').options; for (i=0; i < titleOptions.length; i++) { diff --git a/views/DE/account/registration.pug b/views/DE/account/registration.pug index 108afdeffadfd5b56e906cc7d307206ffa49726d..f3a4e51f1091f9058bde17b92930c9af57c8092e 100644 --- a/views/DE/account/registration.pug +++ b/views/DE/account/registration.pug @@ -68,7 +68,6 @@ html(lang="de") option(value="Prof.") Prof. option(value="Dr.") Dr. option(value="Dipl.-Ing.") Dipl.-Ing. - option(value="etc.") etc. div(class='form-group col-md-4') input#inputFirstname(name="inputFirstname", type="text", class="form-control", placeholder="Vorname*", maxlength="45" required) div(class='form-group col-md-4') diff --git a/views/DE/account/security.pug b/views/DE/account/security.pug index 560d32bc554c360f2cc32783f4aeda33b546d0fe..7df0964e91dc7c5ce494a23ced5b032a0a6df703 100644 --- a/views/DE/account/security.pug +++ b/views/DE/account/security.pug @@ -49,7 +49,7 @@ html(lang="de") for error, i in errors div.alert.alert-danger.alert-dismissible.fade.show #{ error } a(class="close", href="#", data-dismiss="alert", aria-label="close") × - form(class="needs-validation", method="post", action="/account/changePwd" novalidate) + form(class="needs-validation", method="post", action="/changePwd" novalidate) div(class="form-group row") label(for="currPwd") Aktuelles Passwort input(id="inputCurrPwd", name="inputCurrPwd", type="password", class="form-control" required) diff --git a/views/DE/error.pug b/views/DE/error.pug deleted file mode 100644 index bf750c0087880c06604b3d1bc9bb1bfe8e522372..0000000000000000000000000000000000000000 --- a/views/DE/error.pug +++ /dev/null @@ -1,6 +0,0 @@ -html - head - title Error - body - h1 An error occurred! - block content \ No newline at end of file diff --git a/views/DE/project/project-simplified.pug b/views/DE/project/project-simplified.pug new file mode 100644 index 0000000000000000000000000000000000000000..0e16cae022289a70870818a2b92ffefa48544937 --- /dev/null +++ b/views/DE/project/project-simplified.pug @@ -0,0 +1 @@ +include project.html \ No newline at end of file diff --git a/views/DE/project/project.html b/views/DE/project/project.html new file mode 100644 index 0000000000000000000000000000000000000000..6c25dbe8f06d48d1ebdce67cba4ac777c10d38c6 --- /dev/null +++ b/views/DE/project/project.html @@ -0,0 +1,95 @@ +<!DOCTYPE html> +<html> + <head> + <title>Project List</title> + <meta charset="UTF-8"> + <meta name="viewport", content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> + <link rel="stylesheet" href="https://transfer.hft-stuttgart.de/css/bootstrap/bootstrap.css" type="text/css"> + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css" integrity="sha384-oS3vJWv+0UjzBfQzYUhtDYW+Pj2yciDJxpsK1OYPAYjqT085Qq/1cq5FLXAZQ7Ay" crossorigin="anonymous"> + <style> + .collapse {display: none;} + .collapse.in {display: block;} + .collapsing {position: relative;height: 0;overflow: hidden;-webkit-transition-timing-function: ease;-o-transition-timing-function: ease;transition-timing-function: ease;-webkit-transition-duration: .35s;-o-transition-duration: .35s;transition-duration: .35s;-webkit-transition-property: height,visibility;-o-transition-property: height,visibility;transition-property: height,visibility;} + </style> + </head> + + <body> + <div class="container"> + <hr /> + <!-- text: Zweck dieser Seite / purpose of this page --> + <i class="fas fa-info-circle"></i> Diese Seite bietet den Einstieg zu den unterschiedlichen Projekten, die in unserem Portal für die Öffentlichkeit bereitgestellt werden. + Für diesen Zweck steht zur Zeit ein Dienst bereit: eine von der HFT selbst verwaltete Gitlab-Instanz. + Alle der in diesem Gitlab erfassten Projektinhalte unterliegen einer Open Source bzw. Open Data Lizenz. + <p>Hinweis: Die Nutzeroberfläche von GitLab ist in Englisch.</p> + + <!-- link: Gitlab Projekte / Gitlab project list --> + <h2> Direkteinstieg </h2> + <a href="https://transfer.hft-stuttgart.de/gitlab/explore/projects"> <i class="fas fa-chevron-right">Gitlab Projects</i></a> + + <!-- text: Hilfestellung zu Gitlab / short help about Gitlab --> + <hr /> + <h2> Hilfestellung zu GitLab </h2> + + <h3> <i class="fas fa-question-circle"></i> Möchten Sie die Projektinhalte ansehen oder herunterladen? </h3> + <p> + Dann klicken Sie auf diesen <a href="https://transfer.hft-stuttgart.de/gitlab/explore/projects"> <i class="fas fa-chevron-right">Link zu den Gitlab-Projekten</i></a> um die Liste aller im Gitlab erfassten Projekte zu sehen. + Vor dort können Sie dann auf die einzelnen Projekte zugreifen. + Ein Anmelden am Portal ist dazu nicht nötig. + </p> + + <h3> <i class="fas fa-question-circle"></i> Möchten Sie zu einem Projekt beitragen? </h3> + <p> + Wenn Sie dem Projekteigentümer eine Rückmeldung bzw. einen Fehler melden wollen, navigieren Sie im Gitlab zunächst zum entsprechenden Projekt. + Anschließend können Sie dann dort die Möglichkeit nutzen, ein neues "Issues" einzureichen. + Ein Anmelden am Portal ist dazu nicht nötig. + </p> + <p> + Wenn Sie darüberhinaus beitragen wollen, befolgen Sie bitte folgende Schritte: + </p> + <ol> + <li> + Melden Sie sich bitte im Portal an. <br> + Sofern Sie noch nicht als Nutzer im Portal eingetragen sind, wird das System Sie durch die Registrierung leiten. <br> + Zur Anmeldung bzw. Registrierung gelangen Sie entweder über das Menü am oberen Seitenrand oder durch Klicken auf diesen <a href="https://m4lab.hft-stuttgart.de/account/"> <i class="fas fa-chevron-right">Link zum Benutzerkonto</i></a>. + </li> + <li> + Folgen Sie dem <a href="https://transfer.hft-stuttgart.de/gitlab/explore/projects"> <i class="fas fa-chevron-right">Link zu den Gitlab-Projekten</i></a>, um zum Gitlab zu gelangen. + </li> + <li> + Fragen Sie beim Projekteigentümer um Zugang, indem Sie im Gitlab bei der entsprechende Projektseite auf den Link <em>Request Access</em> klicken. Solbald dieser ihre Anfrage bestätigt hat, können Sie loslegen. + </li> + </ol> + + <h3> <i class="fas fa-question-circle"></i> Möchten Sie selbst ein Projekt anlegen, um es der Öffentlichkeit bereitzustellen? </h3> + + </p> + Vorraussetzung dazu ist, dass Sie aktives oder ehemaliges Mitglied der Hochschule für Technik sind, d.h. eine (noch) gültige HFT-Emailadresse haben. + Dann befolgen Sie bitte folgende Schritte: + </p> + + <ol> + <li> + Melden Sie sich bitte im Portal an. <br> + Sofern Sie noch nicht als Nutzer im Portal eingetragen sind, wird das System Sie durch die Registrierung leiten. <br> + Zur Anmeldung bzw. Registrierung gelangen Sie entweder über das Menü am oberen Seitenrand oder durch Klicken auf diesen <a href="https://m4lab.hft-stuttgart.de/account/"> <i class="fas fa-chevron-right">Link zum Benutzerkonto</i></a>. + </li> + <li> + Folgen Sie dem <a href="https://transfer.hft-stuttgart.de/gitlab/explore/projects"> <i class="fas fa-chevron-right">Link zu den Gitlab-Projekten</i></a>, um zum Gitlab zu gelangen. + </li> + <li> + Erstellen Sie dann in Gitlab ein neues Projekt durch Klicken auf den grünen <em>New Project</em>-Knopf und anschließendem Befolgen der Eingabemaske von Gitlab. <br> + Weitere Hilfestellung zum Anlegen von Projekten in Gitlab finden Sie in der <a href="https://docs.gitlab.com/ee/gitlab-basics/create-project.html"> <i class="fas fa-chevron-right">Gitlab-Dokumentation</i></a>. + </li> + </ol> + + <!-- / content body --> + </div> + + <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script> + <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script> + <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script> + <!-- M4_LAB --> + <script src="https://transfer.hft-stuttgart.de/js/headfoot.js"></script> + </body> + +</html> \ No newline at end of file