Merge pull request #517 from zoff-music/fix/404

Fix/404
This commit is contained in:
Kasper Rynning-Tønnesen
2019-07-29 15:56:07 +02:00
committed by GitHub

View File

@@ -13,7 +13,6 @@ var Functions = require(pathThumbnails + "/handlers/functions.js");
var Frontpage = require(pathThumbnails + "/handlers/frontpage.js"); var Frontpage = require(pathThumbnails + "/handlers/frontpage.js");
var db = require(pathThumbnails + "/handlers/db.js"); var db = require(pathThumbnails + "/handlers/db.js");
//var db = require(pathThumbnails + '/handlers/db.js');
try { try {
google = require(path.join( google = require(path.join(
@@ -168,10 +167,6 @@ function root(req, res, next) {
var subdomain = req.headers["x-forwarded-host"] var subdomain = req.headers["x-forwarded-host"]
? req.headers["x-forwarded-host"].split(".") ? req.headers["x-forwarded-host"].split(".")
: req.headers.host.split(":")[0].split("."); : req.headers.host.split(":")[0].split(".");
/*if(url != "zoff.me" && url != "admin.localhost" && url != "admin.zoff.me" && url != "remote.zoff.me" && url != "fb.zoff.me" && url != "remote.localhost" && url != "localhost") {
res.redirect("https://zoff.me");
return;
}*/
if (subdomain[0] == "remote") { if (subdomain[0] == "remote") {
var data = { var data = {
year: year, year: year,
@@ -228,7 +223,6 @@ function root(req, res, next) {
} }
} catch (e) { } catch (e) {
console.log(e); console.log(e);
//res.redirect("https://zoff.me");
} }
} }
@@ -240,10 +234,6 @@ function channel(req, res, next) {
var subdomain = req.headers["x-forwarded-host"] var subdomain = req.headers["x-forwarded-host"]
? req.headers["x-forwarded-host"].split(".") ? req.headers["x-forwarded-host"].split(".")
: req.headers.host.split(":")[0].split("."); : req.headers.host.split(":")[0].split(".");
/*if(url != "zoff.me" && url != "admin.localhost" && url != "admin.zoff.me" && url != "remote.zoff.me" && url != "fb.zoff.me" && url != "remote.localhost" && url != "localhost") {
res.redirect("https://zoff.me");
return;
}*/
if (subdomain[0] == "remote") { if (subdomain[0] == "remote") {
var data = { var data = {
year: year, year: year,
@@ -264,22 +254,9 @@ function channel(req, res, next) {
} else { } else {
if (req.params.channel_name == "o_callback") { if (req.params.channel_name == "o_callback") {
res.redirect("/api/oauth"); res.redirect("/api/oauth");
//res.sendFile(path.join(pathThumbnails, '/public/assets/html/callback.html'));
} else { } else {
/*db.collection("frontpage_lists").find({"_id": Functions.encodeChannelName(req.params.channel_name)}, function(err, docs) {
console.log(docs);
var og_image = "https://zoff.me/assets/images/small-square.jpg";
if(docs.length == 1) {
if(docs[0].hasOwnProperty("thumbnail")) {
if(docs[0].thumbnail.indexOf("mqdefault.jpg") > -1) docs[0].thumbnail = docs[0].thumbnail.replace("mqdefault", "hqdefault");
og_image = docs[0].thumbnail;
} else {
og_image = "https://img.youtube.com/vi/" + docs[0].id + "/hqdefault.jpg";
}
}*/
var data = { var data = {
title: "404: File Not Found", title: "404: File Not Found",
//list_name: capitalizeFirstLetter(Functions.decodeChannelName(req.params.channel_name)),
list_name: capitalizeFirstLetter(req.params.channel_name), list_name: capitalizeFirstLetter(req.params.channel_name),
year: year, year: year,
javascript_file: "main.min.js", javascript_file: "main.min.js",
@@ -296,11 +273,7 @@ function channel(req, res, next) {
if (subdomain[0] == "client") { if (subdomain[0] == "client") {
data.client = true; data.client = true;
} }
if (req.params.channel_name == "404") {
res.status(404);
}
res.render("layouts/client/channel", data); res.render("layouts/client/channel", data);
//});
} }
} }
} catch (e) { } catch (e) {