Better handling of og_image

This commit is contained in:
Kasper Rynning-Tønnesen
2018-05-31 15:31:54 +02:00
parent 4bdf9447f1
commit ded625ae25
3 changed files with 42 additions and 21 deletions

View File

@@ -5,7 +5,7 @@
<div id="channel-load" class="progress"> <div id="channel-load" class="progress">
<div class="indeterminate" id="channel-load-move"></div> <div class="indeterminate" id="channel-load-move"></div>
</div> </div>
<main class="center-align"> <main class="center-align container">
<div id="main_section_frontpage" class="section"> <div id="main_section_frontpage" class="section">
<div class="col s12"> <div class="col s12">
<div class="row"> <div class="row">

View File

@@ -16,7 +16,7 @@
<meta name="apple-mobile-web-app-capable" content="yes"> <meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes"> <meta name="mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#2D2D2D" /> <meta name="theme-color" content="#2D2D2D" />
<meta property="og:image" content="https://zoff.me/assets/images/small-square.jpg" /> <meta property="og:image" content="{{og_image}}" />
<meta property="og:url" content="https://zoff.me" /> <meta property="og:url" content="https://zoff.me" />
<meta property="og:title" content="Zoff"/> <meta property="og:title" content="Zoff"/>
<meta property="og:description" content="The Shared (free) YouTube and SoundCloud radio."/> <meta property="og:description" content="The Shared (free) YouTube and SoundCloud radio."/>

View File

@@ -7,6 +7,8 @@ var analytics = "xx";
var mongojs = require('mongojs'); var mongojs = require('mongojs');
var token_db = mongojs("tokens"); var token_db = mongojs("tokens");
var Functions = require(pathThumbnails + '/handlers/functions.js'); var Functions = require(pathThumbnails + '/handlers/functions.js');
//var db = require(pathThumbnails + '/handlers/db.js');
try { try {
analytics = require(path.join(path.join(__dirname, '../../config/'), 'analytics.js')); analytics = require(path.join(path.join(__dirname, '../../config/'), 'analytics.js'));
} catch(e) { } catch(e) {
@@ -63,6 +65,7 @@ router.route('/api/apply/:id').get(function(req,res) {
correct: true, correct: true,
stylesheet: "style.css", stylesheet: "style.css",
embed: false, embed: false,
og_image: "https://zoff.me/assets/images/small-square.jpg",
} }
res.render('layouts/client/token', data); res.render('layouts/client/token', data);
}); });
@@ -78,6 +81,7 @@ router.route('/api/apply/:id').get(function(req,res) {
correct: false, correct: false,
stylesheet: "style.css", stylesheet: "style.css",
embed: false, embed: false,
og_image: "https://zoff.me/assets/images/small-square.jpg",
} }
res.render('layouts/client/token', data); res.render('layouts/client/token', data);
} }
@@ -96,6 +100,7 @@ router.route('/api/apply').get(function(req, res, next) {
correct: false, correct: false,
stylesheet: "style.css", stylesheet: "style.css",
embed: false, embed: false,
og_image: "https://zoff.me/assets/images/small-square.jpg",
} }
res.render('layouts/client/token', data); res.render('layouts/client/token', data);
}); });
@@ -117,6 +122,7 @@ function root(req, res, next) {
stylesheet: "style.css", stylesheet: "style.css",
embed: false, embed: false,
client: false, client: false,
og_image: "https://zoff.me/assets/images/small-square.jpg",
} }
res.render('layouts/client/remote', data); res.render('layouts/client/remote', data);
} else if(subdomain[0] == "www") { } else if(subdomain[0] == "www") {
@@ -130,6 +136,7 @@ function root(req, res, next) {
stylesheet: "style.css", stylesheet: "style.css",
embed: false, embed: false,
client: false, client: false,
og_image: "https://zoff.me/assets/images/small-square.jpg",
} }
if(subdomain[0] == "client") { if(subdomain[0] == "client") {
data.client = true; data.client = true;
@@ -159,6 +166,7 @@ function channel(req, res, next) {
stylesheet: "style.css", stylesheet: "style.css",
embed: false, embed: false,
client: false, client: false,
og_image: "https://zoff.me/assets/images/small-square.jpg",
} }
res.render('layouts/client/remote', data); res.render('layouts/client/remote', data);
} else if(subdomain.length >= 2 && subdomain[0] == "www") { } else if(subdomain.length >= 2 && subdomain[0] == "www") {
@@ -173,30 +181,43 @@ function channel(req, res, next) {
analytics: analytics, analytics: analytics,
stylesheet: "embed.css", stylesheet: "embed.css",
embed: true, embed: true,
og_image: "https://zoff.me/assets/images/small-square.jpg",
} }
res.render('layouts/client/embed', data); res.render('layouts/client/embed', data);
} else if(req.params.channel_name == "o_callback") { } else if(req.params.channel_name == "o_callback") {
res.sendFile(path.join(pathThumbnails, '/public/assets/html/callback.html')); 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) {
var data = { console.log(docs);
title: "404: File Not Found", var og_image = "https://zoff.me/assets/images/small-square.jpg";
list_name: capitalizeFirstLetter(Functions.decodeChannelName(req.params.channel_name)), if(docs.length == 1) {
year: year, if(docs[0].hasOwnProperty("thumbnail")) {
javascript_file: "main.min.js", if(docs[0].thumbnail.indexOf("mqdefault.jpg") > -1) docs[0].thumbnail = docs[0].thumbnail.replace("mqdefault", "hqdefault");
captcha: res.recaptcha, og_image = docs[0].thumbnail;
analytics: analytics, } else {
stylesheet: "style.css", og_image = "https://img.youtube.com/vi/" + docs[0].id + "/hqdefault.jpg";
embed: false, }
client:false, }*/
} var data = {
if(subdomain[0] == "client") { title: "404: File Not Found",
data.client = true; list_name: capitalizeFirstLetter(Functions.decodeChannelName(req.params.channel_name)),
} year: year,
if(req.params.channel_name == "404") { javascript_file: "main.min.js",
res.status(404); captcha: res.recaptcha,
} analytics: analytics,
res.render('layouts/client/channel', data); stylesheet: "style.css",
embed: false,
client:false,
og_image: "https://zoff.me/assets/images/small-square.jpg"
}
if(subdomain[0] == "client") {
data.client = true;
}
if(req.params.channel_name == "404") {
res.status(404);
}
res.render('layouts/client/channel', data);
//});
} }
} }
} catch(e) { } catch(e) {