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){
|
router.route('/:channel_name').get(function(req, res, next){
|
||||||
var url = req.headers['x-forwarded-host'];
|
try{
|
||||||
var subdomain = req.headers['x-forwarded-host'].split(".");
|
var url = req.headers['x-forwarded-host'];
|
||||||
if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") {
|
var subdomain = req.headers['x-forwarded-host'].split(".");
|
||||||
res.redirect("https://zoff.me");
|
if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") {
|
||||||
return;
|
res.redirect("https://zoff.me");
|
||||||
}
|
return;
|
||||||
if(subdomain[0] == "remote") {
|
}
|
||||||
var data = {
|
if(subdomain[0] == "remote") {
|
||||||
year: 2017,
|
var data = {
|
||||||
javascript_file: "remote.min.js"
|
year: 2017,
|
||||||
}
|
javascript_file: "remote.min.js"
|
||||||
res.render('layouts/remote', data);
|
}
|
||||||
} else if(subdomain.length >= 2 && subdomain[0] == "www") {
|
res.render('layouts/remote', data);
|
||||||
res.redirect("https://zoff.me");
|
} else if(subdomain.length >= 2 && subdomain[0] == "www") {
|
||||||
} else {
|
res.redirect("https://zoff.me");
|
||||||
if(req.params.channel_name == "_embed") {
|
} else {
|
||||||
res.sendFile(path.join(__dirname, '/views/assets/html/embed.html'));
|
if(req.params.channel_name == "_embed") {
|
||||||
} else if(req.params.channel_name == "o_callback") {
|
res.sendFile(path.join(__dirname, '/views/assets/html/embed.html'));
|
||||||
res.sendFile(path.join(__dirname, '/views/assets/html/callback.html'));
|
} else if(req.params.channel_name == "o_callback") {
|
||||||
} else {
|
res.sendFile(path.join(__dirname, '/views/assets/html/callback.html'));
|
||||||
var data = {
|
} else {
|
||||||
list_name: capitalizeFirstLetter(req.params.channel_name),
|
var data = {
|
||||||
year: 2017,
|
list_name: capitalizeFirstLetter(req.params.channel_name),
|
||||||
javascript_file: "main.min.js"
|
year: 2017,
|
||||||
}
|
javascript_file: "main.min.js"
|
||||||
res.render('layouts/channel', data);
|
}
|
||||||
}
|
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){
|
router.route('/').get(function(req, res, next){
|
||||||
var url = req.headers['x-forwarded-host'];
|
try{
|
||||||
var subdomain = req.headers['x-forwarded-host'].split(".");
|
var url = req.headers['x-forwarded-host'];
|
||||||
if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") {
|
var subdomain = req.headers['x-forwarded-host'].split(".");
|
||||||
res.redirect("https://zoff.me");
|
if(url != "zoff.me" && url != "remote.zoff.me" && url != "remote.localhost" && url != "localhost") {
|
||||||
return;
|
res.redirect("https://zoff.me");
|
||||||
}
|
return;
|
||||||
if(subdomain[0] == "remote") {
|
|
||||||
var data = {
|
|
||||||
year: 2017,
|
|
||||||
javascript_file: "remote.min.js"
|
|
||||||
}
|
}
|
||||||
res.render('layouts/remote', data);
|
if(subdomain[0] == "remote") {
|
||||||
} else if(subdomain[0] == "www") {
|
var data = {
|
||||||
res.redirect("https://zoff.me");
|
year: 2017,
|
||||||
} else {
|
javascript_file: "remote.min.js"
|
||||||
var data = {
|
}
|
||||||
year: 2017,
|
res.render('layouts/remote', data);
|
||||||
javascript_file: "main.min.js"
|
} 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 server;
|
||||||
var add = "";
|
var add = "";
|
||||||
|
const path = require('path');
|
||||||
|
const publicPath = path.join(__dirname, 'public');
|
||||||
var express = require('express');
|
var express = require('express');
|
||||||
var app = express();
|
var app = express();
|
||||||
var exphbs = require('express-handlebars');
|
var exphbs = require('express-handlebars');
|
||||||
|
var hbs = exphbs.create({
|
||||||
|
defaultLayout: publicPath + '/layouts/main',
|
||||||
|
layoutsDir: publicPath + '/layouts',
|
||||||
|
partialsDir: publicPath + '/partials'
|
||||||
|
});
|
||||||
var uniqid = require('uniqid');
|
var uniqid = require('uniqid');
|
||||||
var mongo_db_cred = {config: 'mydb'};
|
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('view engine', 'handlebars');
|
||||||
|
|
||||||
|
app.set('views', publicPath);
|
||||||
|
|
||||||
try{
|
try{
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var privateKey = fs.readFileSync('/etc/letsencrypt/live/zoff.me/privkey.pem').toString();
|
var privateKey = fs.readFileSync('/etc/letsencrypt/live/zoff.me/privkey.pem').toString();
|
||||||
@@ -76,8 +87,8 @@ var names = {names: []};
|
|||||||
var locks = {};
|
var locks = {};
|
||||||
var skipped = {};
|
var skipped = {};
|
||||||
var tot_view = 0;
|
var tot_view = 0;
|
||||||
const path = require('path');
|
|
||||||
const publicPath = path.join(__dirname, '../views');
|
|
||||||
|
|
||||||
server.listen(port, function () {
|
server.listen(port, function () {
|
||||||
console.log('Server listening at port %d', port);
|
console.log('Server listening at port %d', port);
|
||||||
@@ -92,8 +103,10 @@ app.use(function (req, res, next) {
|
|||||||
}
|
}
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.use('/', router);
|
app.use('/', router);
|
||||||
app.use('/assets', express.static('views/assets'));
|
app.use('/assets', express.static(publicPath + '/assets'));
|
||||||
|
|
||||||
|
|
||||||
/*process.on('uncaughtException', function(e){
|
/*process.on('uncaughtException', function(e){
|
||||||
|
|||||||