added thumbnail to meta tags

This commit is contained in:
bill bittner 2017-09-11 12:45:07 -07:00
parent aa7f6d567c
commit bd2dd78200
4 changed files with 11 additions and 5 deletions

View file

@ -192,6 +192,12 @@ module.exports = {
return db.resolveClaim(fileInfo.name, fileInfo.claimId); return db.resolveClaim(fileInfo.name, fileInfo.claimId);
}) })
.then(resolveResult => { .then(resolveResult => {
logger.debug(resolveResult);
if (!resolveResult.thumbnail || resolveResult.thumbnail === '') {
fileInfo['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png';
} else {
fileInfo['thumbnail'] = resolveResult.thumbnail;
}
fileInfo['title'] = resolveResult.title; fileInfo['title'] = resolveResult.title;
fileInfo['description'] = resolveResult.description; fileInfo['description'] = resolveResult.description;
showFile(fileInfo, res); showFile(fileInfo, res);

View file

@ -226,7 +226,7 @@ db['getAllFreeClaims'] = (name) => {
db['resolveClaim'] = (name, claimId) => { db['resolveClaim'] = (name, claimId) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
db db
.sequelize.query(`SELECT name, claimId, outpoint, height, address, title, description FROM Claim WHERE name = '${name}' AND claimId = '${claimId}'`, { type: db.sequelize.QueryTypes.SELECT }) .sequelize.query(`SELECT name, claimId, outpoint, height, address, title, description, thumbnail FROM Claim WHERE name = '${name}' AND claimId = '${claimId}'`, { type: db.sequelize.QueryTypes.SELECT })
.then(result => { .then(result => {
switch (result.length) { switch (result.length) {
case 0: case 0:

View file

@ -48,14 +48,14 @@ const hbs = expressHandlebars.create({
</script>` </script>`
); );
}, },
addOpenGraph (title, mimeType, showUrl, source, description) { addOpenGraph (title, mimeType, showUrl, source, description, thumbnail) {
let basicTags = `<meta property="og:title" content="${title}"> let basicTags = `<meta property="og:title" content="${title}">
<meta property="og:url" content="${showUrl}" > <meta property="og:url" content="${showUrl}" >
<meta property="og:site_name" content="Spee.ch" > <meta property="og:site_name" content="Spee.ch" >
<meta property="og:description" content="${description}">`; <meta property="og:description" content="${description}">`;
if (mimeType === 'video/mp4') { if (mimeType === 'video/mp4') {
return new Handlebars.SafeString( return new Handlebars.SafeString(
`${basicTags} <meta property="og:image" content="https://spee.ch/assets/img/content-freedom-large.png" > `${basicTags} <meta property="og:image" content="${thumbnail}" >
<meta property="og:image:type" content="image/png" > <meta property="og:image:type" content="image/png" >
<meta property="og:image:width" content="600" > <meta property="og:image:width" content="600" >
<meta property="og:image:height" content="315" > <meta property="og:image:height" content="315" >

View file

@ -9,8 +9,8 @@
<link rel="stylesheet" href="/assets/css/componentStyle.css" type="text/css"> <link rel="stylesheet" href="/assets/css/componentStyle.css" type="text/css">
<meta property="fb:app_id" content="1371961932852223"> <meta property="fb:app_id" content="1371961932852223">
{{#unless fileInfo.nsfw}} {{#unless fileInfo.nsfw}}
{{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.embedUrl openGraphInfo.directFileUrl}}} {{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.embedUrl openGraphInfo.directFileUrl}}}
{{{addOpenGraph fileInfo.title fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source fileInfo.description}}} {{{addOpenGraph fileInfo.title fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source fileInfo.description fileInfo.thumbnail}}}
{{/unless}} {{/unless}}
<!-- google analytics --> <!-- google analytics -->
{{ googleAnalytics }} {{ googleAnalytics }}