added needed information to SHOWlITE route

This commit is contained in:
bill bittner 2017-11-09 14:20:25 -08:00
parent 3dcc714a13
commit 71e5b7ca7a
3 changed files with 39 additions and 35 deletions

View file

@ -67,7 +67,7 @@ module.exports = {
resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim; resolve(publishResults); // resolve the promise with the result from lbryApi.publishClaim;
}) })
.catch(error => { .catch(error => {
logger.error('publishController.publish, error', error); logger.error('caught a publishController.publish error');
publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file publishHelpers.deleteTemporaryFile(publishParams.file_path); // delete the local file
reject(error); reject(error);
}); });

View file

@ -204,7 +204,7 @@ module.exports = {
} else { } else {
fileInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.') + 1); fileInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.') + 1);
} }
// add stats table // add a record to the stats table
postToStats(method, originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success'); postToStats(method, originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success');
// serve or show // serve or show
switch (method) { switch (method) {
@ -213,8 +213,17 @@ module.exports = {
sendGoogleAnalytics(method, headers, ip, originalUrl); sendGoogleAnalytics(method, headers, ip, originalUrl);
return fileInfo; return fileInfo;
case SHOWLITE: case SHOWLITE:
showFileLite(fileInfo, res); return db.Claim.resolveClaim(fileInfo.name, fileInfo.claimId)
return fileInfo; .then(claimRecord => {
fileInfo['title'] = claimRecord.title;
fileInfo['description'] = claimRecord.description;
showFileLite(fileInfo, res);
return fileInfo;
})
.catch(error => {
logger.error('throwing serverOrShowAsset SHOWLITE error...');
throw error;
});
case SHOW: case SHOW:
return db.Claim return db.Claim
.getShortClaimIdFromLongClaimId(fileInfo.claimId, fileInfo.name) .getShortClaimIdFromLongClaimId(fileInfo.claimId, fileInfo.name)
@ -233,7 +242,7 @@ module.exports = {
return fileInfo; return fileInfo;
}) })
.catch(error => { .catch(error => {
logger.error('throwing serve/show error...'); logger.error('throwing serverOrShowAsset SHOW error...');
throw error; throw error;
}); });
default: default:

View file

@ -17,37 +17,32 @@ module.exports = {
); );
}, },
addOpenGraph (title, mimeType, showUrl, source, description, thumbnail) { addOpenGraph (title, mimeType, showUrl, source, description, thumbnail) {
let basicTags = `<meta property="og:title" content="${title}"> console.log('title', title);
<meta property="og:url" content="${showUrl}" > console.log('description', description);
<meta property="og:site_name" content="Spee.ch" > let ogTitle = `<meta property="og:title" content="${title}" >`;
<meta property="og:description" content="${description}">`; let ogUrl = `<meta property="og:url" content="${showUrl}" >`;
let ogSiteName = `<meta property="og:site_name" content="Spee.ch" >`;
let ogDescription = `<meta property="og:description" content="${description}" >`;
let ogImageWidth = '<meta property="og:image:width" content="600" >';
let ogImageHeight = '<meta property="og:image:height" content="315" >';
let basicTags = `${ogTitle} ${ogUrl} ${ogSiteName} ${ogDescription} ${ogImageWidth} ${ogImageHeight}`;
let ogImage = `<meta property="og:image" content="${source}" >`;
let ogImageType = `<meta property="og:image:type" content="${mimeType}" >`;
let ogType = `<meta property="og:type" content="article" >`;
if (mimeType === 'video/mp4') { if (mimeType === 'video/mp4') {
return new Handlebars.SafeString( let ogVideo, ogVideoSecureUrl, ogVideoType;
`${basicTags} <meta property="og:image" content="${thumbnail}" > ogImage = `<meta property="og:image" content="${thumbnail}" >`;
<meta property="og:image:type" content="image/png" > ogImageType = `<meta property="og:image:type" content="image/png" >`;
<meta property="og:image:width" content="600" > ogType = `<meta property="og:type" content="video" >`;
<meta property="og:image:height" content="315" > ogVideo = `<meta property="og:video" content="${source}" >`;
<meta property="og:type" content="video" > ogVideoSecureUrl = `<meta property="og:video:secure_url" content="${source}" >`;
<meta property="og:video" content="${source}" > ogVideoType = `<meta property="og:video:type" content="${mimeType}" >`;
<meta property="og:video:secure_url" content="${source}" > return new Handlebars.SafeString(`${basicTags} ${ogImage} ${ogImageType} ${ogType} ${ogVideo} ${ogVideoSecureUrl} ${ogVideoType}`);
<meta property="og:video:type" content="${mimeType}" >`
);
} else if (mimeType === 'image/gif') {
return new Handlebars.SafeString(
`${basicTags} <meta property="og:image" content="${source}" >
<meta property="og:image:type" content="${mimeType}" >
<meta property="og:image:width" content="600" >
<meta property="og:image:height" content="315" >
<meta property="og:type" content="video.other" >`
);
} else { } else {
return new Handlebars.SafeString( if (mimeType === 'image/gif') {
`${basicTags} <meta property="og:image" content="${source}" > ogType = `<meta property="og:type" content="video.other" >`;
<meta property="og:image:type" content="${mimeType}" > };
<meta property="og:image:width" content="600" > return new Handlebars.SafeString(`${basicTags} ${ogImage} ${ogImageType} ${ogType}`);
<meta property="og:image:height" content="315" >
<meta property="og:type" content="article" >`
);
} }
}, },
addTwitterCard (mimeType, source, embedUrl, directFileUrl) { addTwitterCard (mimeType, source, embedUrl, directFileUrl) {
@ -55,7 +50,7 @@ module.exports = {
if (mimeType === 'video/mp4') { if (mimeType === 'video/mp4') {
return new Handlebars.SafeString( return new Handlebars.SafeString(
`${basicTwitterTags} <meta name="twitter:card" content="player" > `${basicTwitterTags} <meta name="twitter:card" content="player" >
<meta name="twitter:player" content="${embedUrl}> <meta name="twitter:player" content="${embedUrl}" >
<meta name="twitter:player:width" content="600" > <meta name="twitter:player:width" content="600" >
<meta name="twitter:text:player_width" content="600" > <meta name="twitter:text:player_width" content="600" >
<meta name="twitter:player:height" content="337" > <meta name="twitter:player:height" content="337" >