From b393de8268c4e048bac3014bb8a9d54b6ab82992 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 24 Jul 2017 16:09:44 -0700 Subject: [PATCH 1/4] added 'show' layout with custom header info --- routes/show-routes.js | 4 ++-- speech.js | 24 +++++++++--------------- views/layouts/main.handlebars | 1 + views/layouts/show.handlebars | 23 +++++++++++++++++++++++ 4 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 views/layouts/show.handlebars diff --git a/routes/show-routes.js b/routes/show-routes.js index ee080bf7..f8d2334d 100644 --- a/routes/show-routes.js +++ b/routes/show-routes.js @@ -79,7 +79,7 @@ module.exports = (app) => { } // serve the file or the show route postToStats('show', originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success'); - res.status(200).render('show', { fileInfo }); + res.status(200).render('show', { layout: 'show', fileInfo }); }) .catch(error => { errorHandlers.handleRequestError('show', originalUrl, ip, error, res); @@ -97,7 +97,7 @@ module.exports = (app) => { } // serve the show route postToStats('show', originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success'); - res.status(200).render('show', { fileInfo }); + res.status(200).render('show', { layout: 'show', fileInfo }); }) .catch(error => { errorHandlers.handleRequestError('show', originalUrl, ip, error, res); diff --git a/speech.js b/speech.js index 11390776..51854570 100644 --- a/speech.js +++ b/speech.js @@ -72,21 +72,15 @@ const hbs = expressHandlebars.create({ return options.inverse(this); } }, - grouped_each (every, context, options) { - let out = ''; - let subcontext = []; - let i; - if (context && context.length > 0) { - for (i = 0; i < context.length; i++) { - if (i > 0 && i % every === 0) { - out += options.fn(subcontext); - subcontext = []; - } - subcontext.push(context[i]); - } - out += options.fn(subcontext); - } - return out; + twitterCard (type) { + return new Handlebars.SafeString(` + + + + + + + `); }, }, }); diff --git a/views/layouts/main.handlebars b/views/layouts/main.handlebars index a3babda6..dc6c235c 100644 --- a/views/layouts/main.handlebars +++ b/views/layouts/main.handlebars @@ -7,6 +7,7 @@ Spee.ch + {{ twitterCard }} {{{ body }}} diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars new file mode 100644 index 00000000..662242c0 --- /dev/null +++ b/views/layouts/show.handlebars @@ -0,0 +1,23 @@ + + + + + + + Spee.ch + + + + + + + + + + + + {{{ body }}} + + {{ googleAnalytics }} + + \ No newline at end of file From e9f421b51a36c2e2b23be4ec3927ffa7bef87bb0 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 24 Jul 2017 16:12:11 -0700 Subject: [PATCH 2/4] changed 'showLite' to use 'show' layout --- routes/serve-routes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/routes/serve-routes.js b/routes/serve-routes.js index 25710854..4a7073fc 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -36,7 +36,7 @@ module.exports = (app) => { const mimetypes = headers['accept'].split(','); if (mimetypes.includes('text/html')) { postToStats('show', originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success'); - res.status(200).render('showLite', { fileInfo }); + res.status(200).render('showLite', { layout: 'show', fileInfo }); } else { postToStats('serve', originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success'); serveFile(fileInfo, res); @@ -67,7 +67,7 @@ module.exports = (app) => { const mimetypes = headers['accept'].split(','); if (mimetypes.includes('text/html')) { postToStats('show', originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success'); - res.status(200).render('showLite', { fileInfo }); + res.status(200).render('showLite', { layout: 'show', fileInfo }); } else { postToStats('serve', originalUrl, ip, fileInfo.name, fileInfo.claimId, 'success'); serveFile(fileInfo, res); From 34606f68dc0c155467ae8531f37847054fd76b0d Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 24 Jul 2017 16:28:47 -0700 Subject: [PATCH 3/4] added https:// to image location --- views/layouts/show.handlebars | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index 662242c0..47b7ad3c 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -13,7 +13,7 @@ - + {{{ body }}} From 4421bf2dc01cd0aec1de123b48b4260674159a2b Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 24 Jul 2017 17:04:46 -0700 Subject: [PATCH 4/4] removed unused handlebars helper --- speech.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/speech.js b/speech.js index 51854570..ae6a7e7d 100644 --- a/speech.js +++ b/speech.js @@ -72,16 +72,6 @@ const hbs = expressHandlebars.create({ return options.inverse(this); } }, - twitterCard (type) { - return new Handlebars.SafeString(` - - - - - - - `); - }, }, }); app.engine('handlebars', hbs.engine);