Updated routing somewhat, so it should be possible to run the server without being in the correct folder
| Before Width: | Height: | Size: 322 KiB After Width: | Height: | Size: 322 KiB | 
| Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB | 
| Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB | 
| Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 36 KiB | 
| Before Width: | Height: | Size: 697 B After Width: | Height: | Size: 697 B | 
| Before Width: | Height: | Size: 56 KiB After Width: | Height: | Size: 56 KiB | 
| Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB | 
| Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB | 
| Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB | 
| Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 66 KiB | 
| Before Width: | Height: | Size: 786 B After Width: | Height: | Size: 786 B | 
| Before Width: | Height: | Size: 299 B After Width: | Height: | Size: 299 B | 
| Before Width: | Height: | Size: 1.6 KiB After Width: | Height: | Size: 1.6 KiB | 
| Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2.7 KiB | 
| Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB | 
| Before Width: | Height: | Size: 3.0 KiB After Width: | Height: | Size: 3.0 KiB | 
| Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 4.5 KiB | 
| Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB | 
| Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB | 
| Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB | 
| Before Width: | Height: | Size: 980 B After Width: | Height: | Size: 980 B | 
| Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB | 
| Before Width: | Height: | Size: 4.6 KiB After Width: | Height: | Size: 4.6 KiB | 
| @@ -9,6 +9,7 @@ router.use(function(req, res, next) { | ||||
| }); | ||||
|  | ||||
| router.route('/:channel_name').get(function(req, res, next){ | ||||
|     try{ | ||||
|       var url = req.headers['x-forwarded-host']; | ||||
|       var subdomain = req.headers['x-forwarded-host'].split("."); | ||||
|       if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") { | ||||
| @@ -37,6 +38,9 @@ router.route('/:channel_name').get(function(req, res, next){ | ||||
|               res.render('layouts/channel', data); | ||||
|           } | ||||
|       } | ||||
|     } catch(e) { | ||||
|       res.redirect("https://zoff.me"); | ||||
|     } | ||||
| }); | ||||
|  | ||||
| router.route('/api/imageblob').post(function(req, res) { | ||||
| @@ -121,6 +125,7 @@ router.route('/api/mail').post(function(req, res) { | ||||
| }); | ||||
|  | ||||
| router.route('/').get(function(req, res, next){ | ||||
|     try{ | ||||
|         var url = req.headers['x-forwarded-host']; | ||||
|         var subdomain = req.headers['x-forwarded-host'].split("."); | ||||
|         if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") { | ||||
| @@ -142,6 +147,9 @@ router.route('/').get(function(req, res, next){ | ||||
|             } | ||||
|             res.render('layouts/frontpage', data); | ||||
|         } | ||||
|     } catch(e) { | ||||
|         res.redirect("https://zoff.me"); | ||||
|     } | ||||
| }); | ||||
|  | ||||
| function capitalizeFirstLetter(string) { | ||||
|   | ||||
| @@ -1,14 +1,25 @@ | ||||
| var server; | ||||
| var add = ""; | ||||
| const path = require('path'); | ||||
| const publicPath = path.join(__dirname, 'public'); | ||||
| var express = require('express'); | ||||
| var app = express(); | ||||
| var exphbs = require('express-handlebars'); | ||||
| var hbs = exphbs.create({ | ||||
|   defaultLayout: publicPath + '/layouts/main', | ||||
|   layoutsDir: publicPath + '/layouts', | ||||
|   partialsDir: publicPath + '/partials' | ||||
| }); | ||||
| var uniqid = require('uniqid'); | ||||
| var mongo_db_cred = {config: 'mydb'}; | ||||
|  | ||||
| app.engine('handlebars',exphbs({defaultLayout: 'main'})); | ||||
|  | ||||
| app.engine('handlebars', hbs.engine); | ||||
| //hbs.loadPartials(publicPath + "/layouts/"); | ||||
| app.set('view engine', 'handlebars'); | ||||
|  | ||||
| app.set('views', publicPath); | ||||
|  | ||||
| try{ | ||||
|     var fs = require('fs'); | ||||
|     var privateKey  = fs.readFileSync('/etc/letsencrypt/live/zoff.me/privkey.pem').toString(); | ||||
| @@ -76,8 +87,8 @@ var names      = {names: []}; | ||||
| var locks      = {}; | ||||
| var skipped    = {}; | ||||
| var tot_view   = 0; | ||||
| const path = require('path'); | ||||
| const publicPath = path.join(__dirname, '../views'); | ||||
|  | ||||
|  | ||||
|  | ||||
| server.listen(port, function () { | ||||
|     console.log('Server listening at port %d', port); | ||||
| @@ -92,8 +103,10 @@ app.use(function (req, res, next) { | ||||
|   } | ||||
|   next(); | ||||
| }); | ||||
|  | ||||
|  | ||||
| app.use('/', router); | ||||
| app.use('/assets', express.static('views/assets')); | ||||
| app.use('/assets', express.static(publicPath + '/assets')); | ||||
|  | ||||
|  | ||||
| /*process.on('uncaughtException', function(e){ | ||||
|   | ||||