From 40e398314fa89acfe9aedd111a6bd496e9ccf723 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 18 Aug 2017 16:52:58 -0700 Subject: [PATCH] added basic support for showing .mp4 as .givf --- routes/serve-routes.js | 14 +++++++++----- views/partials/asset.handlebars | 18 +++++++++++++----- views/partials/assetInfo.handlebars | 24 ++++++++++++++++-------- views/showLite.handlebars | 19 +++++++++++++------ 4 files changed, 51 insertions(+), 24 deletions(-) diff --git a/routes/serve-routes.js b/routes/serve-routes.js index cc3c6962..9e4cc154 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -26,9 +26,13 @@ function getAsset (claimType, channelName, shortId, fullClaimId, name) { } } -function serveOrShowAsset (fileInfo, method, headers, originalUrl, ip, res) { +function serveOrShowAsset (fileInfo, extension, method, headers, originalUrl, ip, res) { // add file extension to the file info - fileInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.')); + if (extension === '.gifv') { + fileInfo['fileExt'] = '.gifv'; + } else { + fileInfo['fileExt'] = fileInfo.fileName.substring(fileInfo.fileName.lastIndexOf('.')); + } // serve or show switch (method) { case SERVE: @@ -106,7 +110,7 @@ module.exports = (app) => { name = identifier; identifier = tempName; } - /* end */ + /* end patch */ logger.debug('claim name =', name); logger.debug('method =', method); // parse identifier for whether it is a channel, short url, or claim_id @@ -134,7 +138,7 @@ module.exports = (app) => { if (!fileInfo) { res.status(200).render('noClaims'); } else { - return serveOrShowAsset(fileInfo, method, headers, originalUrl, ip, res); + return serveOrShowAsset(fileInfo, extension, method, headers, originalUrl, ip, res); } }) // 3. update the file @@ -174,7 +178,7 @@ module.exports = (app) => { if (!fileInfo) { res.status(200).render('noClaims'); } else { - return serveOrShowAsset(fileInfo, method, headers, originalUrl, ip, res); + return serveOrShowAsset(fileInfo, null, method, headers, originalUrl, ip, res); } }) // 3. update the database diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 9bf493a1..59d4deaa 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -2,11 +2,19 @@
{{#ifConditional fileInfo.fileType '===' 'video/mp4'}} - + {{#ifConditional fileInfo.fileExt '===' '.gifv'}} + + {{else}} + + {{/ifConditional}} {{else}} {{/ifConditional}} diff --git a/views/partials/assetInfo.handlebars b/views/partials/assetInfo.handlebars index feab0b56..dc5beda2 100644 --- a/views/partials/assetInfo.handlebars +++ b/views/partials/assetInfo.handlebars @@ -4,23 +4,30 @@