diff --git a/controllers/serveController.js b/controllers/serveController.js
index 18280057..233906c5 100644
--- a/controllers/serveController.js
+++ b/controllers/serveController.js
@@ -204,7 +204,7 @@ module.exports = {
} else {
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');
// serve or show
switch (method) {
@@ -213,8 +213,17 @@ module.exports = {
sendGoogleAnalytics(method, headers, ip, originalUrl);
return fileInfo;
case SHOWLITE:
- showFileLite(fileInfo, res);
- return fileInfo;
+ return db.Claim.resolveClaim(fileInfo.name, fileInfo.claimId)
+ .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:
return db.Claim
.getShortClaimIdFromLongClaimId(fileInfo.claimId, fileInfo.name)
@@ -233,7 +242,7 @@ module.exports = {
return fileInfo;
})
.catch(error => {
- logger.error('throwing serve/show error...');
+ logger.error('throwing serverOrShowAsset SHOW error...');
throw error;
});
default:
diff --git a/helpers/handlebarsHelpers.js b/helpers/handlebarsHelpers.js
index 33ccb49d..59275e0c 100644
--- a/helpers/handlebarsHelpers.js
+++ b/helpers/handlebarsHelpers.js
@@ -2,71 +2,62 @@ const Handlebars = require('handlebars');
const config = require('../config/speechConfig.js');
module.exports = {
- // define any extra helpers you may need
googleAnalytics () {
const googleApiKey = config.analytics.googleId;
- return new Handlebars.SafeString(
- ``
- );
+ ga('send', 'pageview');`;
+ return new Handlebars.SafeString(gaCode);
},
addOpenGraph (title, mimeType, showUrl, source, description, thumbnail) {
- let basicTags = `
-
-
- `;
+ if (title === null || title.trim() === '') {
+ title = 'Spee.ch';
+ }
+ if (description === null || description.trim() === '') {
+ description = 'Open-source, decentralized image and video sharing.';
+ }
+ const ogTitle = ``;
+ const ogUrl = ``;
+ const ogSiteName = ``;
+ const ogDescription = ``;
+ const ogImageWidth = '';
+ const ogImageHeight = '';
+ const basicTags = `${ogTitle} ${ogUrl} ${ogSiteName} ${ogDescription} ${ogImageWidth} ${ogImageHeight}`;
+ let ogImage = ``;
+ let ogImageType = ``;
+ let ogType = ``;
if (mimeType === 'video/mp4') {
- return new Handlebars.SafeString(
- `${basicTags}
-
-
-
-
-
-
- `
- );
- } else if (mimeType === 'image/gif') {
- return new Handlebars.SafeString(
- `${basicTags}
-
-
-
- `
- );
+ const ogVideo = ``;
+ const ogVideoSecureUrl = ``;
+ const ogVideoType = ``;
+ ogImage = ``;
+ ogImageType = ``;
+ ogType = ``;
+ return new Handlebars.SafeString(`${basicTags} ${ogImage} ${ogImageType} ${ogType} ${ogVideo} ${ogVideoSecureUrl} ${ogVideoType}`);
} else {
- return new Handlebars.SafeString(
- `${basicTags}
-
-
-
- `
- );
+ if (mimeType === 'image/gif') {
+ ogType = ``;
+ };
+ return new Handlebars.SafeString(`${basicTags} ${ogImage} ${ogImageType} ${ogType}`);
}
},
addTwitterCard (mimeType, source, embedUrl, directFileUrl) {
- let basicTwitterTags = ``;
+ const basicTwitterTags = ``;
if (mimeType === 'video/mp4') {
- return new Handlebars.SafeString(
- `${basicTwitterTags}
-
-
-
-
-
- `
- );
+ const twitterName = '';
+ const twitterPlayer = ``;
+ const twitterPlayerWidth = '';
+ const twitterTextPlayerWidth = '';
+ const twitterPlayerHeight = '';
+ const twitterPlayerStream = ``;
+ const twitterPlayerStreamContentType = '';
+ return new Handlebars.SafeString(`${basicTwitterTags} ${twitterName} ${twitterPlayer} ${twitterPlayerWidth} ${twitterTextPlayerWidth} ${twitterPlayerHeight} ${twitterPlayerStream} ${twitterPlayerStreamContentType}`);
} else {
- return new Handlebars.SafeString(
- `${basicTwitterTags} `
- );
+ const twitterCard = '';
+ return new Handlebars.SafeString(`${basicTwitterTags} ${twitterCard}`);
}
},
ifConditional (varOne, operator, varTwo, options) {