added open graph meta tags

This commit is contained in:
bill bittner 2017-08-04 17:41:06 -07:00
commit b17e013584
6 changed files with 39 additions and 9 deletions

View file

@ -60,6 +60,14 @@ function checkLocalDbForClaims (name, shortUrl) {
});
}
function createOpenGraphInfo ({ fileType, claimId, name, fileExt }) {
return {
type : fileType.substring(0, fileType.indexOf('/')),
showUrl: `https://spee.ch/${claimId}/${name}`,
source : `https://spee.ch/${claimId}/${name}${fileExt}`,
};
}
module.exports = {
serveFile ({ fileName, fileType, filePath }, res) {
logger.info(`serving file ${fileName}`);
@ -86,11 +94,12 @@ module.exports = {
res.status(200).sendFile(filePath, options);
},
showFile (fileInfo, res) {
res.status(200).render('show', { layout: 'show', fileInfo });
const openGraphInfo = createOpenGraphInfo(fileInfo);
res.status(200).render('show', { layout: 'show', fileInfo, openGraphInfo });
},
showFileLite (fileInfo, res) {
logger.debug('showing file lite');
res.status(200).render('showLite', { layout: 'show', fileInfo });
const openGraphInfo = createOpenGraphInfo(fileInfo);
res.status(200).render('showLite', { layout: 'show', fileInfo, openGraphInfo });
},
getClaimIdFromShortUrl (shortUrl, name) {
return new Promise((resolve, reject) => {