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,33 +9,37 @@ router.use(function(req, res, next) {
|
||||
});
|
||||
|
||||
router.route('/:channel_name').get(function(req, res, next){
|
||||
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") {
|
||||
res.redirect("https://zoff.me");
|
||||
return;
|
||||
}
|
||||
if(subdomain[0] == "remote") {
|
||||
var data = {
|
||||
year: 2017,
|
||||
javascript_file: "remote.min.js"
|
||||
}
|
||||
res.render('layouts/remote', data);
|
||||
} else if(subdomain.length >= 2 && subdomain[0] == "www") {
|
||||
res.redirect("https://zoff.me");
|
||||
} else {
|
||||
if(req.params.channel_name == "_embed") {
|
||||
res.sendFile(path.join(__dirname, '/views/assets/html/embed.html'));
|
||||
} else if(req.params.channel_name == "o_callback") {
|
||||
res.sendFile(path.join(__dirname, '/views/assets/html/callback.html'));
|
||||
} else {
|
||||
var data = {
|
||||
list_name: capitalizeFirstLetter(req.params.channel_name),
|
||||
year: 2017,
|
||||
javascript_file: "main.min.js"
|
||||
}
|
||||
res.render('layouts/channel', data);
|
||||
}
|
||||
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") {
|
||||
res.redirect("https://zoff.me");
|
||||
return;
|
||||
}
|
||||
if(subdomain[0] == "remote") {
|
||||
var data = {
|
||||
year: 2017,
|
||||
javascript_file: "remote.min.js"
|
||||
}
|
||||
res.render('layouts/remote', data);
|
||||
} else if(subdomain.length >= 2 && subdomain[0] == "www") {
|
||||
res.redirect("https://zoff.me");
|
||||
} else {
|
||||
if(req.params.channel_name == "_embed") {
|
||||
res.sendFile(path.join(__dirname, '/views/assets/html/embed.html'));
|
||||
} else if(req.params.channel_name == "o_callback") {
|
||||
res.sendFile(path.join(__dirname, '/views/assets/html/callback.html'));
|
||||
} else {
|
||||
var data = {
|
||||
list_name: capitalizeFirstLetter(req.params.channel_name),
|
||||
year: 2017,
|
||||
javascript_file: "main.min.js"
|
||||
}
|
||||
res.render('layouts/channel', data);
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
res.redirect("https://zoff.me");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -121,26 +125,30 @@ router.route('/api/mail').post(function(req, res) {
|
||||
});
|
||||
|
||||
router.route('/').get(function(req, res, next){
|
||||
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") {
|
||||
res.redirect("https://zoff.me");
|
||||
return;
|
||||
}
|
||||
if(subdomain[0] == "remote") {
|
||||
var data = {
|
||||
year: 2017,
|
||||
javascript_file: "remote.min.js"
|
||||
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") {
|
||||
res.redirect("https://zoff.me");
|
||||
return;
|
||||
}
|
||||
res.render('layouts/remote', data);
|
||||
} else if(subdomain[0] == "www") {
|
||||
res.redirect("https://zoff.me");
|
||||
} else {
|
||||
var data = {
|
||||
year: 2017,
|
||||
javascript_file: "main.min.js"
|
||||
if(subdomain[0] == "remote") {
|
||||
var data = {
|
||||
year: 2017,
|
||||
javascript_file: "remote.min.js"
|
||||
}
|
||||
res.render('layouts/remote', data);
|
||||
} else if(subdomain[0] == "www") {
|
||||
res.redirect("https://zoff.me");
|
||||
} else {
|
||||
var data = {
|
||||
year: 2017,
|
||||
javascript_file: "main.min.js"
|
||||
}
|
||||
res.render('layouts/frontpage', data);
|
||||
}
|
||||
res.render('layouts/frontpage', data);
|
||||
} catch(e) {
|
||||
res.redirect("https://zoff.me");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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){
|
||||
|
||||