From b17e013584f481e2ee774e19d15d1076a62604e2 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 4 Aug 2017 17:41:06 -0700 Subject: [PATCH 01/14] added open graph meta tags --- helpers/serveHelpers.js | 15 ++++++++++++--- speech.js | 10 ++++++++++ views/layouts/main.handlebars | 7 ++++++- views/layouts/show.handlebars | 11 ++++++++--- views/partials/asset.handlebars | 2 +- views/showLite.handlebars | 3 ++- 6 files changed, 39 insertions(+), 9 deletions(-) diff --git a/helpers/serveHelpers.js b/helpers/serveHelpers.js index 2d2aaed8..d6107d55 100644 --- a/helpers/serveHelpers.js +++ b/helpers/serveHelpers.js @@ -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) => { diff --git a/speech.js b/speech.js index c042e8ea..9ad2c025 100644 --- a/speech.js +++ b/speech.js @@ -48,6 +48,16 @@ const hbs = expressHandlebars.create({ ` ); }, + addOpenGraph (title, url, type, source, mimeType) { + return new Handlebars.SafeString( + ` + + + + + ` + ); + }, ifConditional (varOne, operator, varTwo, options) { switch (operator) { case '===': diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index dc6c235c..5de95460 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -7,7 +7,12 @@ Spee.ch - {{ twitterCard }} + + + + + + {{{ body }}} diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index a62a2781..21a9a2a7 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -8,16 +8,21 @@ - + {{!-- - + --}} + {{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.type openGraphInfo.source fileInfo.fileType }} {{{ body }}} {{ googleAnalytics }} - \ No newline at end of file + + + \ No newline at end of file diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 9bf493a1..9e1568f3 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -1,6 +1,6 @@
\ No newline at end of file -- 2.45.2 From 7b14eda270aadd80474b1f168fb32f2661b32f0a Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 4 Aug 2017 18:01:05 -0700 Subject: [PATCH 02/14] added twitter card basics --- speech.js | 23 +++++++++++++++++++++++ views/layouts/main.handlebars | 2 +- views/layouts/show.handlebars | 10 ++-------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/speech.js b/speech.js index 9ad2c025..abfe8fd0 100644 --- a/speech.js +++ b/speech.js @@ -54,10 +54,33 @@ const hbs = expressHandlebars.create({ + ` ); }, + addTwitterCard (assetType, source) { + if (assetType === 'image') { + return new Handlebars.SafeString( + ` + + + ` + ); + } else if (assetType === 'video') { + return new Handlebars.SafeString( + ` + + + + + + + + ` + ); + } + }, ifConditional (varOne, operator, varTwo, options) { switch (operator) { case '===': diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index 5de95460..9e1d8cad 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -1,5 +1,5 @@ - + diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index 21a9a2a7..04290840 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -1,5 +1,5 @@ - + @@ -7,13 +7,7 @@ Spee.ch - - {{!-- - - - - - --}} + {{addTwitterCard openGraphInfo.type openGraphInfo.source}} {{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.type openGraphInfo.source fileInfo.fileType }} -- 2.45.2 From 01299f8beb3b89608278e87d0d130041983785e3 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Fri, 4 Aug 2017 18:04:23 -0700 Subject: [PATCH 03/14] added summary card to index page --- views/layouts/main.handlebars | 2 ++ 1 file changed, 2 insertions(+) diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index 9e1d8cad..93cd0c90 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -7,6 +7,8 @@ Spee.ch + + -- 2.45.2 From 4a2f09d5dc31b86cc577be02185d223c495592e2 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sat, 5 Aug 2017 09:51:23 -0700 Subject: [PATCH 04/14] made meta handlebars three curly brackets --- views/layouts/show.handlebars | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index 04290840..a72b1ccc 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -7,8 +7,8 @@ Spee.ch - {{addTwitterCard openGraphInfo.type openGraphInfo.source}} - {{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.type openGraphInfo.source fileInfo.fileType }} + {{{addTwitterCard openGraphInfo.type openGraphInfo.source}}} + {{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.type openGraphInfo.source fileInfo.fileType }}} {{{ body }}} -- 2.45.2 From 5756375d3dd6d185140cc176a231d5714c3de494 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sat, 5 Aug 2017 09:55:53 -0700 Subject: [PATCH 05/14] fixed click through link on show --- views/partials/asset.handlebars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/partials/asset.handlebars b/views/partials/asset.handlebars index 9e1568f3..9bf493a1 100644 --- a/views/partials/asset.handlebars +++ b/views/partials/asset.handlebars @@ -1,6 +1,6 @@
- + {{#ifConditional fileInfo.fileType '===' 'video/mp4'}} - {{addOpenGraph fileInfo.name links.showUrl 'video' links.source fileInfo.fileType }} {{else}} - {{fileInfo.fileName}} - {{addOpenGraph fileInfo.name links.showUrl 'image' links.source fileInfo.fileType }} + {
 	{{/ifConditional}}
 	</a>
 </div>
\ No newline at end of file
-- 
2.45.2


From 35cf994149727a6f3c173710045fda717c1da82d Mon Sep 17 00:00:00 2001
From: bill bittner <bittner.w@gmail.com>
Date: Mon, 7 Aug 2017 13:57:50 -0700
Subject: [PATCH 12/14] fixed issue with show lite and removed assettype from
 twitter

---
 speech.js                     | 17 ++++++++---------
 views/layouts/show.handlebars |  2 +-
 views/showLite.handlebars     |  4 +++-
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/speech.js b/speech.js
index a557b3b3..16964b7f 100644
--- a/speech.js
+++ b/speech.js
@@ -90,15 +90,8 @@ const hbs = expressHandlebars.create({
         );
       }
     },
-    addTwitterCard (assetType, source) {
-      if (assetType === 'image') {
-        return new Handlebars.SafeString(
-          `<meta name= - - - ` - ); - } else if (assetType === 'video') { + addTwitterCard (source, mimeType) { + if (mimeType === 'video/mp4') { return new Handlebars.SafeString( ` @@ -110,6 +103,12 @@ const hbs = expressHandlebars.create({ ` ); + } else { + return new Handlebars.SafeString( + ` + + ` + ); } }, ifConditional (varOne, operator, varTwo, options) { diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index 198616b3..0a6c3376 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -8,7 +8,7 @@ - {{{addTwitterCard openGraphInfo.type openGraphInfo.source}}} + {{{addTwitterCard openGraphInfo.source fileInfo.fileType}}} {{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.source fileInfo.fileType }}} diff --git a/views/showLite.handlebars b/views/showLite.handlebars index db9df9ce..413293e9 100644 --- a/views/showLite.handlebars +++ b/views/showLite.handlebars @@ -6,8 +6,10 @@ {{!--fallback--}} Your browser does not support the video element. + {{else}} - {
+		<img class= + {{/ifConditional}}
\ No newline at end of file -- 2.45.2 From 53709661c83774af10d48cb0273a86ae646ace49 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 7 Aug 2017 15:22:09 -0700 Subject: [PATCH 13/14] added twitter player card --- speech.js | 39 +++++++++++++---------------------- views/layouts/show.handlebars | 2 +- 2 files changed, 15 insertions(+), 26 deletions(-) diff --git a/speech.js b/speech.js index 16964b7f..c77d69a8 100644 --- a/speech.js +++ b/speech.js @@ -49,13 +49,13 @@ const hbs = expressHandlebars.create({ ); }, addOpenGraph (title, url, source, mimeType) { - if (mimeType === 'video/mp4') { - return new Handlebars.SafeString( - ` + let basicTags = ` - - + `; + if (mimeType === 'video/mp4') { + return new Handlebars.SafeString( + `${basicTags} @@ -66,11 +66,7 @@ const hbs = expressHandlebars.create({ ); } else if (mimeType === 'image/gif') { return new Handlebars.SafeString( - ` - - - - + `${basicTags} @@ -78,11 +74,7 @@ const hbs = expressHandlebars.create({ ); } else { return new Handlebars.SafeString( - ` - - - - + `${basicTags} @@ -90,24 +82,21 @@ const hbs = expressHandlebars.create({ ); } }, - addTwitterCard (source, mimeType) { + addTwitterCard (source, mimeType, fileName, showUrl) { + let basicTwitterTags = ` + `; if (mimeType === 'video/mp4') { return new Handlebars.SafeString( - ` - - - + `${basicTwitterTags} - - + + ` ); } else { return new Handlebars.SafeString( - ` - - ` + `${basicTwitterTags} ` ); } }, diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index 0a6c3376..34b3f3cd 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -8,7 +8,7 @@ - {{{addTwitterCard openGraphInfo.source fileInfo.fileType}}} + {{{addTwitterCard openGraphInfo.source fileInfo.fileType fileInfo.fileName openGraphInfo.showUrl}}} {{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.source fileInfo.fileType }}} -- 2.45.2 From 7f0df2511b1cfa9b5e763c9e1de2ef661c3afd98 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 7 Aug 2017 17:08:03 -0700 Subject: [PATCH 14/14] added twitter player route --- helpers/serveHelpers.js | 9 +++++---- routes/page-routes.js | 8 ++++++++ speech.js | 14 +++++++------- views/layouts/show.handlebars | 4 ++-- views/layouts/twitterPlayer.handlebars | 16 ++++++++++++++++ views/showLite.handlebars | 1 - views/twitterPlayer.handlebars | 1 + 7 files changed, 39 insertions(+), 14 deletions(-) create mode 100644 views/layouts/twitterPlayer.handlebars create mode 100644 views/twitterPlayer.handlebars diff --git a/helpers/serveHelpers.js b/helpers/serveHelpers.js index d6107d55..017d485c 100644 --- a/helpers/serveHelpers.js +++ b/helpers/serveHelpers.js @@ -60,11 +60,12 @@ function checkLocalDbForClaims (name, shortUrl) { }); } -function createOpenGraphInfo ({ fileType, claimId, name, fileExt }) { +function createOpenGraphInfo ({ fileType, claimId, name, fileName, fileExt }) { return { - type : fileType.substring(0, fileType.indexOf('/')), - showUrl: `https://spee.ch/${claimId}/${name}`, - source : `https://spee.ch/${claimId}/${name}${fileExt}`, + twitterPlayerUrl: `https://spee.ch/twitterPlayer/${claimId}/${name}`, + showUrl : `https://spee.ch/${claimId}/${name}`, + source : `https://spee.ch/${claimId}/${name}${fileExt}`, + directFileUrl : `https://spee.ch/media/${fileName}`, }; } diff --git a/routes/page-routes.js b/routes/page-routes.js index d037658f..7907e907 100644 --- a/routes/page-routes.js +++ b/routes/page-routes.js @@ -36,6 +36,14 @@ module.exports = (app) => { }); }); // route to display all free public claims at a given name + app.get('/twitterPlayer/:claimId/:fileName', ({ params }, res) => { + const claimId = params.claimId; + const fileName = params.fileName; + const fileExtension = '.mp4'; + // get and render the content + res.status(200).render('twitterPlayer', { layout: 'twitterPlayer', claimId, fileName, fileExtension }); + }); + // route to display all free public claims at a given name app.get('/:name/all', ({ ip, originalUrl, params }, res) => { // get and render the content getAllFreePublicClaims(params.name) diff --git a/speech.js b/speech.js index c77d69a8..cc2f0d4b 100644 --- a/speech.js +++ b/speech.js @@ -48,9 +48,9 @@ const hbs = expressHandlebars.create({ ` ); }, - addOpenGraph (title, url, source, mimeType) { + addOpenGraph (title, mimeType, showUrl, source) { let basicTags = ` - + `; if (mimeType === 'video/mp4') { @@ -82,15 +82,15 @@ const hbs = expressHandlebars.create({ ); } }, - addTwitterCard (source, mimeType, fileName, showUrl) { - let basicTwitterTags = ` - `; + addTwitterCard (mimeType, source, twitterPlayerUrl, directFileUrl) { + let basicTwitterTags = ``; if (mimeType === 'video/mp4') { return new Handlebars.SafeString( - `${basicTwitterTags} + `${basicTwitterTags} + - + ` ); diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index 34b3f3cd..15575e9f 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -8,8 +8,8 @@ - {{{addTwitterCard openGraphInfo.source fileInfo.fileType fileInfo.fileName openGraphInfo.showUrl}}} - {{{addOpenGraph fileInfo.name openGraphInfo.showUrl openGraphInfo.source fileInfo.fileType }}} + {{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.twitterPlayerUrl openGraphInfo.directFileUrl}}} + {{{addOpenGraph fileInfo.name fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source}}} {{{ body }}} diff --git a/views/layouts/twitterPlayer.handlebars b/views/layouts/twitterPlayer.handlebars new file mode 100644 index 00000000..1c3f0d44 --- /dev/null +++ b/views/layouts/twitterPlayer.handlebars @@ -0,0 +1,16 @@ + + + + + + +{{{body}}} + + + \ No newline at end of file diff --git a/views/showLite.handlebars b/views/showLite.handlebars index 413293e9..a061259e 100644 --- a/views/showLite.handlebars +++ b/views/showLite.handlebars @@ -9,7 +9,6 @@ {{else}} {{fileInfo.fileName}} - {{/ifConditional}}
\ No newline at end of file diff --git a/views/twitterPlayer.handlebars b/views/twitterPlayer.handlebars new file mode 100644 index 00000000..ec88ee84 --- /dev/null +++ b/views/twitterPlayer.handlebars @@ -0,0 +1 @@ + \ No newline at end of file -- 2.45.2