fixed bug in og meta tags
This commit is contained in:
parent
478b8983fa
commit
6e20f89317
3 changed files with 15 additions and 14 deletions
|
@ -16,11 +16,9 @@ module.exports = {
|
||||||
res.status(200).sendFile(filePath, options);
|
res.status(200).sendFile(filePath, options);
|
||||||
},
|
},
|
||||||
showFile (claimInfo, shortId, res) {
|
showFile (claimInfo, shortId, res) {
|
||||||
const openGraphInfo = module.exports.createOpenGraphInfo(claimInfo);
|
res.status(200).render('show', { layout: 'show', claimInfo, shortId });
|
||||||
res.status(200).render('show', { layout: 'show', claimInfo, shortId, openGraphInfo });
|
|
||||||
},
|
},
|
||||||
showFileLite (claimInfo, shortId, res) {
|
showFileLite (claimInfo, shortId, res) {
|
||||||
const openGraphInfo = module.exports.createOpenGraphInfo(claimInfo);
|
res.status(200).render('showLite', { layout: 'showlite', claimInfo, shortId });
|
||||||
res.status(200).render('showLite', { layout: 'showlite', claimInfo, shortId, openGraphInfo });
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
const logger = require('winston');
|
const logger = require('winston');
|
||||||
const { returnShortId } = require('../helpers/sequelizeHelpers.js');
|
const { returnShortId } = require('../helpers/sequelizeHelpers.js');
|
||||||
const DEFAULT_THUMBNAIL = 'https://spee.ch/assets/img/video_thumb_default.png';
|
const DEFAULT_THUMBNAIL = 'https://spee.ch/assets/img/video_thumb_default.png';
|
||||||
const DEFAULT_TITLE = '';
|
const DEFAULT_TITLE = 'Spee<ch';
|
||||||
const DEFAULT_DESCRIPTION = '';
|
const DEFAULT_DESCRIPTION = 'Decentralized video and content hosting.';
|
||||||
|
|
||||||
function determineFileExtensionFromContentType (contentType) {
|
function determineFileExtensionFromContentType (contentType) {
|
||||||
switch (contentType) {
|
switch (contentType) {
|
||||||
|
@ -72,13 +72,15 @@ function addOpengraphDataToClaim (claim) {
|
||||||
claim['ogTitle'] = determineOgTitle(claim.title, DEFAULT_TITLE);
|
claim['ogTitle'] = determineOgTitle(claim.title, DEFAULT_TITLE);
|
||||||
claim['ogDescription'] = determineOgDescription(claim.description, DEFAULT_DESCRIPTION);
|
claim['ogDescription'] = determineOgDescription(claim.description, DEFAULT_DESCRIPTION);
|
||||||
claim['ogThumbnailContentType'] = determineOgThumbnailContentType(claim.thumbnail);
|
claim['ogThumbnailContentType'] = determineOgThumbnailContentType(claim.thumbnail);
|
||||||
|
return claim;
|
||||||
};
|
};
|
||||||
|
|
||||||
function prepareClaimData (claimData) {
|
function prepareClaimData (claim) {
|
||||||
claimData['thumbnail'] = determineThumbnail(claimData.thumbnail, DEFAULT_THUMBNAIL);
|
// logger.debug('preparing claim data based on resolved data:', claim);
|
||||||
claimData['fileExt'] = determineFileExtensionFromContentType(claimData.contentType);
|
claim['thumbnail'] = determineThumbnail(claim.thumbnail, DEFAULT_THUMBNAIL);
|
||||||
claimData = addOpengraphDataToClaim(claimData);
|
claim['fileExt'] = determineFileExtensionFromContentType(claim.contentType);
|
||||||
return claimData;
|
claim = addOpengraphDataToClaim(claim);
|
||||||
|
return claim;
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DECIMAL }) => {
|
module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DECIMAL }) => {
|
||||||
|
@ -393,6 +395,7 @@ module.exports = (sequelize, { STRING, BOOLEAN, INTEGER, TEXT, DECIMAL }) => {
|
||||||
where: { name, claimId },
|
where: { name, claimId },
|
||||||
})
|
})
|
||||||
.then(claimArray => {
|
.then(claimArray => {
|
||||||
|
logger.debug('claims found on resolve:', claimArray.length);
|
||||||
switch (claimArray.length) {
|
switch (claimArray.length) {
|
||||||
case 0:
|
case 0:
|
||||||
return resolve(null);
|
return resolve(null);
|
||||||
|
|
|
@ -184,9 +184,9 @@ function showAssetToClient (claimId, name, res) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showPlainAssetToClient (claimId, name, res) {
|
function showLiteAssetToClient (claimId, name, res) {
|
||||||
return Promise
|
return Promise
|
||||||
.all([db.Claim.resolveClaim(claimId, name), db.Claim.getShortClaimIdFromLongClaimId(claimId, name)])
|
.all([db.Claim.resolveClaim(name, claimId), db.Claim.getShortClaimIdFromLongClaimId(claimId, name)])
|
||||||
.then(([claimInfo, shortClaimId]) => {
|
.then(([claimInfo, shortClaimId]) => {
|
||||||
logger.debug('claimInfo:', claimInfo);
|
logger.debug('claimInfo:', claimInfo);
|
||||||
logger.debug('shortClaimId:', shortClaimId);
|
logger.debug('shortClaimId:', shortClaimId);
|
||||||
|
@ -217,7 +217,7 @@ function showOrServeAsset (responseType, claimId, claimName, res) {
|
||||||
case SHOW:
|
case SHOW:
|
||||||
return showAssetToClient(claimId, claimName, res);
|
return showAssetToClient(claimId, claimName, res);
|
||||||
case SHOWLITE:
|
case SHOWLITE:
|
||||||
return showPlainAssetToClient(claimId, claimName, res);
|
return showLiteAssetToClient(claimId, claimName, res);
|
||||||
case SERVE:
|
case SERVE:
|
||||||
return serveAssetToClient(claimId, claimName, res);
|
return serveAssetToClient(claimId, claimName, res);
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue