From d8e7b9c40d4710f4abdb5564b311cbc9e8bfcde6 Mon Sep 17 00:00:00 2001 From: noliverio Date: Sat, 9 Sep 2017 02:16:19 -0400 Subject: [PATCH 01/11] Proposed solution to isue 159 toggleSection in Firefox --- public/assets/js/generalFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/assets/js/generalFunctions.js b/public/assets/js/generalFunctions.js index 7c46344e..3c3a60d9 100644 --- a/public/assets/js/generalFunctions.js +++ b/public/assets/js/generalFunctions.js @@ -3,7 +3,7 @@ function toggleSection(event){ var dataSet = event.target.dataset; var status = dataSet.open; - var masterElement = document.getElementById(event.srcElement.id); + var masterElement = document.getElementById(event.target.id||event.srcElement.id); var slaveElement = document.getElementById(dataSet.slaveelementid); if (status === "false") { -- 2.45.2 From cf65bca617cdf2dccf97b266ab5a54847a01db25 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Sun, 10 Sep 2017 15:45:35 -0700 Subject: [PATCH 02/11] removed test config file --- config/test.json | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 config/test.json diff --git a/config/test.json b/config/test.json deleted file mode 100644 index f77b0219..00000000 --- a/config/test.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "WalletConfig": { - "LbryClaimAddress": "none" - }, - "AnalyticsConfig":{ - "GoogleId": "UA-100747990-1" - }, - "Database": { - "MySqlConnectionUri": "none" - }, - "Logging": { - "LogLevel": "debug" - } -} -- 2.45.2 From 5fb652ce5f3801d760e82840271ff5c2172f63cf Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 09:07:00 -0700 Subject: [PATCH 03/11] removed unnecessary param from twitter embed route --- routes/page-routes.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/routes/page-routes.js b/routes/page-routes.js index 37c915b7..36fd1517 100644 --- a/routes/page-routes.js +++ b/routes/page-routes.js @@ -50,15 +50,14 @@ module.exports = (app) => { errorHandlers.handleRequestError(error, res); }); }); - // route to display all free public claims at a given name + // route to send embedable video player (for twitter) app.get('/embed/:claimId/:name', ({ params }, res) => { const claimId = params.claimId; const name = params.name; - const dummyParam = '.b'; console.log('claimId ==', claimId); console.log('name ==', name); // get and render the content - res.status(200).render('embed', { layout: 'embed', claimId, name, dummyParam }); + res.status(200).render('embed', { layout: 'embed', claimId, name }); }); // route to display all free public claims at a given name app.get('/:name/all', ({ ip, originalUrl, params }, res) => { -- 2.45.2 From df2ee1b026ecb83600a8bab5a2fc47fd55f856af Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 09:09:25 -0700 Subject: [PATCH 04/11] removed masonry --- public/vendors/masonry/masonry.pkgd.min.js | 9 --------- views/partials/trendingAssets.handlebars | 16 +--------------- 2 files changed, 1 insertion(+), 24 deletions(-) delete mode 100644 public/vendors/masonry/masonry.pkgd.min.js diff --git a/public/vendors/masonry/masonry.pkgd.min.js b/public/vendors/masonry/masonry.pkgd.min.js deleted file mode 100644 index a61c0ded..00000000 --- a/public/vendors/masonry/masonry.pkgd.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/*! - * Masonry PACKAGED v4.2.0 - * Cascading grid layout library - * http://masonry.desandro.com - * MIT License - * by David DeSandro - */ - -!function(t,e){"function"==typeof define&&define.amd?define("jquery-bridget/jquery-bridget",["jquery"],function(i){return e(t,i)}):"object"==typeof module&&module.exports?module.exports=e(t,require("jquery")):t.jQueryBridget=e(t,t.jQuery)}(window,function(t,e){"use strict";function i(i,r,a){function h(t,e,n){var o,r="$()."+i+'("'+e+'")';return t.each(function(t,h){var u=a.data(h,i);if(!u)return void s(i+" not initialized. Cannot call methods, i.e. "+r);var d=u[e];if(!d||"_"==e.charAt(0))return void s(r+" is not a valid method");var l=d.apply(u,n);o=void 0===o?l:o}),void 0!==o?o:t}function u(t,e){t.each(function(t,n){var o=a.data(n,i);o?(o.option(e),o._init()):(o=new r(n,e),a.data(n,i,o))})}a=a||e||t.jQuery,a&&(r.prototype.option||(r.prototype.option=function(t){a.isPlainObject(t)&&(this.options=a.extend(!0,this.options,t))}),a.fn[i]=function(t){if("string"==typeof t){var e=o.call(arguments,1);return h(this,t,e)}return u(this,t),this},n(a))}function n(t){!t||t&&t.bridget||(t.bridget=i)}var o=Array.prototype.slice,r=t.console,s="undefined"==typeof r?function(){}:function(t){r.error(t)};return n(e||t.jQuery),i}),function(t,e){"function"==typeof define&&define.amd?define("ev-emitter/ev-emitter",e):"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,function(){function t(){}var e=t.prototype;return e.on=function(t,e){if(t&&e){var i=this._events=this._events||{},n=i[t]=i[t]||[];return-1==n.indexOf(e)&&n.push(e),this}},e.once=function(t,e){if(t&&e){this.on(t,e);var i=this._onceEvents=this._onceEvents||{},n=i[t]=i[t]||{};return n[e]=!0,this}},e.off=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=i.indexOf(e);return-1!=n&&i.splice(n,1),this}},e.emitEvent=function(t,e){var i=this._events&&this._events[t];if(i&&i.length){var n=0,o=i[n];e=e||[];for(var r=this._onceEvents&&this._onceEvents[t];o;){var s=r&&r[o];s&&(this.off(t,o),delete r[o]),o.apply(this,e),n+=s?0:1,o=i[n]}return this}},t}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("get-size/get-size",[],function(){return e()}):"object"==typeof module&&module.exports?module.exports=e():t.getSize=e()}(window,function(){"use strict";function t(t){var e=parseFloat(t),i=-1==t.indexOf("%")&&!isNaN(e);return i&&e}function e(){}function i(){for(var t={width:0,height:0,innerWidth:0,innerHeight:0,outerWidth:0,outerHeight:0},e=0;u>e;e++){var i=h[e];t[i]=0}return t}function n(t){var e=getComputedStyle(t);return e||a("Style returned "+e+". Are you running this code in a hidden iframe on Firefox? See http://bit.ly/getsizebug1"),e}function o(){if(!d){d=!0;var e=document.createElement("div");e.style.width="200px",e.style.padding="1px 2px 3px 4px",e.style.borderStyle="solid",e.style.borderWidth="1px 2px 3px 4px",e.style.boxSizing="border-box";var i=document.body||document.documentElement;i.appendChild(e);var o=n(e);r.isBoxSizeOuter=s=200==t(o.width),i.removeChild(e)}}function r(e){if(o(),"string"==typeof e&&(e=document.querySelector(e)),e&&"object"==typeof e&&e.nodeType){var r=n(e);if("none"==r.display)return i();var a={};a.width=e.offsetWidth,a.height=e.offsetHeight;for(var d=a.isBorderBox="border-box"==r.boxSizing,l=0;u>l;l++){var c=h[l],f=r[c],m=parseFloat(f);a[c]=isNaN(m)?0:m}var p=a.paddingLeft+a.paddingRight,g=a.paddingTop+a.paddingBottom,y=a.marginLeft+a.marginRight,v=a.marginTop+a.marginBottom,_=a.borderLeftWidth+a.borderRightWidth,z=a.borderTopWidth+a.borderBottomWidth,E=d&&s,b=t(r.width);b!==!1&&(a.width=b+(E?0:p+_));var x=t(r.height);return x!==!1&&(a.height=x+(E?0:g+z)),a.innerWidth=a.width-(p+_),a.innerHeight=a.height-(g+z),a.outerWidth=a.width+y,a.outerHeight=a.height+v,a}}var s,a="undefined"==typeof console?e:function(t){console.error(t)},h=["paddingLeft","paddingRight","paddingTop","paddingBottom","marginLeft","marginRight","marginTop","marginBottom","borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth"],u=h.length,d=!1;return r}),function(t,e){"use strict";"function"==typeof define&&define.amd?define("desandro-matches-selector/matches-selector",e):"object"==typeof module&&module.exports?module.exports=e():t.matchesSelector=e()}(window,function(){"use strict";var t=function(){var t=window.Element.prototype;if(t.matches)return"matches";if(t.matchesSelector)return"matchesSelector";for(var e=["webkit","moz","ms","o"],i=0;is?"round":"floor";r=Math[a](r),this.cols=Math.max(r,1)},n.getContainerWidth=function(){var t=this._getOption("fitWidth"),i=t?this.element.parentNode:this.element,n=e(i);this.containerWidth=n&&n.innerWidth},n._getItemLayoutPosition=function(t){t.getSize();var e=t.size.outerWidth%this.columnWidth,i=e&&1>e?"round":"ceil",n=Math[i](t.size.outerWidth/this.columnWidth);n=Math.min(n,this.cols);for(var o=this.options.horizontalOrder?"_getHorizontalColPosition":"_getTopColPosition",r=this[o](n,t),s={x:this.columnWidth*r.col,y:r.y},a=r.y+t.size.outerHeight,h=n+r.col,u=r.col;h>u;u++)this.colYs[u]=a;return s},n._getTopColPosition=function(t){var e=this._getTopColGroup(t),i=Math.min.apply(Math,e);return{col:e.indexOf(i),y:i}},n._getTopColGroup=function(t){if(2>t)return this.colYs;for(var e=[],i=this.cols+1-t,n=0;i>n;n++)e[n]=this._getColGroupY(n,t);return e},n._getColGroupY=function(t,e){if(2>e)return this.colYs[t];var i=this.colYs.slice(t,t+e);return Math.max.apply(Math,i)},n._getHorizontalColPosition=function(t,e){var i=this.horizontalColIndex%this.cols,n=t>1&&i+t>this.cols;i=n?0:i;var o=e.size.outerWidth&&e.size.outerHeight;return this.horizontalColIndex=o?i+t:this.horizontalColIndex,{col:i,y:this._getColGroupY(i,t)}},n._manageStamp=function(t){var i=e(t),n=this._getElementOffset(t),o=this._getOption("originLeft"),r=o?n.left:n.right,s=r+i.outerWidth,a=Math.floor(r/this.columnWidth);a=Math.max(0,a);var h=Math.floor(s/this.columnWidth);h-=s%this.columnWidth?0:1,h=Math.min(this.cols-1,h);for(var u=this._getOption("originTop"),d=(u?n.top:n.bottom)+i.outerHeight,l=a;h>=l;l++)this.colYs[l]=Math.max(d,this.colYs[l])},n._getContainerSize=function(){this.maxY=Math.max.apply(Math,this.colYs);var t={height:this.maxY};return this._getOption("fitWidth")&&(t.width=this._getContainerFitWidth()),t},n._getContainerFitWidth=function(){for(var t=0,e=this.cols;--e&&0===this.colYs[e];)t++;return(this.cols-t)*this.columnWidth-this.gutter},n.needsResizeLayout=function(){var t=this.containerWidth;return this.getContainerWidth(),t!=this.containerWidth},i}); \ No newline at end of file diff --git a/views/partials/trendingAssets.handlebars b/views/partials/trendingAssets.handlebars index 90e6d4d1..c12192fb 100644 --- a/views/partials/trendingAssets.handlebars +++ b/views/partials/trendingAssets.handlebars @@ -1,6 +1,4 @@ - - -
+

Trending

The 25 most popular assets on spee.ch

@@ -25,15 +23,3 @@
- - - -- 2.45.2 From 8a9b1ea0cfdde73910bb909c90b5271db772b024 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 09:25:05 -0700 Subject: [PATCH 05/11] added thumbs to @channel page --- models/index.js | 2 +- routes/serve-routes.js | 1 + views/channel.handlebars | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/models/index.js b/models/index.js index 5316993e..dd044653 100644 --- a/models/index.js +++ b/models/index.js @@ -266,7 +266,7 @@ db['getAllChannelClaims'] = (channelId) => { return new Promise((resolve, reject) => { logger.debug(`finding all claims in channel "${channelId}"`); db - .sequelize.query(`SELECT name, claimId, outpoint, height, address, contentType, title, description, license FROM Claim WHERE certificateId = '${channelId}' ORDeR BY height DESC;`, { type: db.sequelize.QueryTypes.SELECT }) + .sequelize.query(`SELECT name, claimId, outpoint, height, address, contentType, title, description, license, thumbnail FROM Claim WHERE certificateId = '${channelId}' ORDeR BY height DESC;`, { type: db.sequelize.QueryTypes.SELECT }) .then(result => { switch (result.length) { case 0: diff --git a/routes/serve-routes.js b/routes/serve-routes.js index b7574e4b..272e47a2 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -132,6 +132,7 @@ module.exports = (app) => { channelName, channelContents, }; + logger.debug(handlebarsData); res.status(200).render('channel', handlebarsData); } }) diff --git a/views/channel.handlebars b/views/channel.handlebars index 00b64c87..e67ee69b 100644 --- a/views/channel.handlebars +++ b/views/channel.handlebars @@ -4,10 +4,11 @@

{{this.channelName}}

Below are all the free claims in this channel.

{{#each channelContents}} +
{{#ifConditional this.contentType '===' 'video/mp4'}} - + {{else}} {{/ifConditional}} -- 2.45.2 From b1dcb78a3d1e0b96324b16af781709f624ca1b27 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 11:09:38 -0700 Subject: [PATCH 06/11] refactored out generic content list format --- controllers/serveController.js | 9 ++++--- public/assets/css/componentStyle.css | 33 +++++++++++++++++++---- views/channel.handlebars | 26 ++---------------- views/partials/contentListItem.handlebars | 19 +++++++++++++ 4 files changed, 54 insertions(+), 33 deletions(-) create mode 100644 views/partials/contentListItem.handlebars diff --git a/controllers/serveController.js b/controllers/serveController.js index aaa4eb22..3c1ff340 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -153,10 +153,11 @@ module.exports = { .then(allChannelClaims => { if (allChannelClaims) { allChannelClaims.forEach(element => { - element['channelName'] = channelName; - element['longChannelId'] = longChannelId; - element['shortChannelId'] = shortChannelId; - element['fileExtension'] = element.contentType.substring(element.contentType.lastIndexOf('/') + 1); + const fileExtenstion = element.contentType.substring(element.contentType.lastIndexOf('/') + 1); + element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`; + element['showUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}`; + element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`; + element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`; }); } return resolve(allChannelClaims); diff --git a/public/assets/css/componentStyle.css b/public/assets/css/componentStyle.css index fd6d0deb..27ffd4b2 100644 --- a/public/assets/css/componentStyle.css +++ b/public/assets/css/componentStyle.css @@ -154,27 +154,50 @@ button.copy-button { height: 1em; } -/* all claims */ - -.all-claims-item { +/* content lists */ +.content-list-card { margin-top: 2px; padding-top: 2px; border-top: 1px lightgrey solid; overflow: auto; + position: relative; } -.all-claims-asset { +.content-list-card-link { + position:absolute; + width:100%; + height:100%; + top:0; + left: 0; + z-index: 1; +} + +.content-list-asset { width: 20%; float: left; margin: 5px 30px 5px 0px; } -.all-claims-details { +.content-list-title { + color: black; + font-weight: bold; +} + +.content-list-details { word-wrap: break-word; +} + +.content-list-details > ul { + position: relative; + z-index: 2; list-style: none; list-style-type: none; } +.content-list-card:hover { + background-color: #F5F0EF; +} + /* statistics */ .totals-row { border-top: 1px solid grey; diff --git a/views/channel.handlebars b/views/channel.handlebars index e67ee69b..899b3e80 100644 --- a/views/channel.handlebars +++ b/views/channel.handlebars @@ -2,31 +2,9 @@ {{> topBar}} {{> footer}} diff --git a/views/partials/contentListItem.handlebars b/views/partials/contentListItem.handlebars new file mode 100644 index 00000000..895abfbd --- /dev/null +++ b/views/partials/contentListItem.handlebars @@ -0,0 +1,19 @@ +
+ + {{#ifConditional this.contentType '===' 'video/mp4'}} + {{#ifConditional this.thumbnail '===' ''}} + + {{else}} + + {{/ifConditional}} + {{else}} + + {{/ifConditional}} +
+ +
+
+ -- 2.45.2 From aa7f6d567ceabf3e0e66055edebd9480e2600250 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 12:10:41 -0700 Subject: [PATCH 07/11] refactored /popular to use same content list --- controllers/serveController.js | 1 - controllers/statsController.js | 10 ++++++++++ routes/serve-routes.js | 1 - views/partials/trendingAssets.handlebars | 25 ------------------------ views/trending.handlebars | 9 ++++++++- 5 files changed, 18 insertions(+), 28 deletions(-) delete mode 100644 views/partials/trendingAssets.handlebars diff --git a/controllers/serveController.js b/controllers/serveController.js index 3c1ff340..89561251 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -155,7 +155,6 @@ module.exports = { allChannelClaims.forEach(element => { const fileExtenstion = element.contentType.substring(element.contentType.lastIndexOf('/') + 1); element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`; - element['showUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}`; element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`; element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`; }); diff --git a/controllers/statsController.js b/controllers/statsController.js index cd103781..413bf0ff 100644 --- a/controllers/statsController.js +++ b/controllers/statsController.js @@ -148,6 +148,16 @@ module.exports = { // get the raw requests data db.getTrendingClaims(startDate) .then(results => { + if (results) { + results.forEach(element => { + const fileExtenstion = element.fileType.substring(element.fileType.lastIndexOf('/') + 1); + element['showUrlLong'] = `/${element.claimId}/${element.name}`; + element['directUrlLong'] = `/${element.claimId}/${element.name}.${fileExtenstion}`; + element['directUrlShort'] = `/${element.claimId}/${element.name}.${fileExtenstion}`; + element['contentType'] = element.fileType; + element['thumbnail'] = ''; + }); + } resolve(results); }) .catch(error => { diff --git a/routes/serve-routes.js b/routes/serve-routes.js index 272e47a2..b7574e4b 100644 --- a/routes/serve-routes.js +++ b/routes/serve-routes.js @@ -132,7 +132,6 @@ module.exports = (app) => { channelName, channelContents, }; - logger.debug(handlebarsData); res.status(200).render('channel', handlebarsData); } }) diff --git a/views/partials/trendingAssets.handlebars b/views/partials/trendingAssets.handlebars deleted file mode 100644 index c12192fb..00000000 --- a/views/partials/trendingAssets.handlebars +++ /dev/null @@ -1,25 +0,0 @@ -
-

Trending

-

The 25 most popular assets on spee.ch

-
- {{#each trendingAssets}} -
- - {{#ifConditional this.fileType '===' 'video/mp4'}} - - {{else}} - - {{/ifConditional}} - -
-
    -
  • {{this.name}}
  • -
  • Claim Id: {{this.claimId}}
  • -
  • {{this.title}}
  • -
-
-
- {{/each}} -
-
- diff --git a/views/trending.handlebars b/views/trending.handlebars index cc9b963d..65032d6d 100644 --- a/views/trending.handlebars +++ b/views/trending.handlebars @@ -1,4 +1,11 @@
{{> topBar}} - {{> trendingAssets}} +
+

Popular

+

Below are the 25 most popular items on spee.ch

+ {{#each trendingAssets}} + {{> contentListItem}} + {{/each}} +
+ {{> footer}}
-- 2.45.2 From bd2dd782007345053c2b84371f7a35acf187bc9b Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 12:45:07 -0700 Subject: [PATCH 08/11] added thumbnail to meta tags --- controllers/serveController.js | 6 ++++++ models/index.js | 2 +- speech.js | 4 ++-- views/layouts/show.handlebars | 4 ++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/controllers/serveController.js b/controllers/serveController.js index 89561251..f4f8a570 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -192,6 +192,12 @@ module.exports = { return db.resolveClaim(fileInfo.name, fileInfo.claimId); }) .then(resolveResult => { + logger.debug(resolveResult); + if (!resolveResult.thumbnail || resolveResult.thumbnail === '') { + fileInfo['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png'; + } else { + fileInfo['thumbnail'] = resolveResult.thumbnail; + } fileInfo['title'] = resolveResult.title; fileInfo['description'] = resolveResult.description; showFile(fileInfo, res); diff --git a/models/index.js b/models/index.js index dd044653..4c5a7187 100644 --- a/models/index.js +++ b/models/index.js @@ -226,7 +226,7 @@ db['getAllFreeClaims'] = (name) => { db['resolveClaim'] = (name, claimId) => { return new Promise((resolve, reject) => { db - .sequelize.query(`SELECT name, claimId, outpoint, height, address, title, description FROM Claim WHERE name = '${name}' AND claimId = '${claimId}'`, { type: db.sequelize.QueryTypes.SELECT }) + .sequelize.query(`SELECT name, claimId, outpoint, height, address, title, description, thumbnail FROM Claim WHERE name = '${name}' AND claimId = '${claimId}'`, { type: db.sequelize.QueryTypes.SELECT }) .then(result => { switch (result.length) { case 0: diff --git a/speech.js b/speech.js index be0de1ab..259d0837 100644 --- a/speech.js +++ b/speech.js @@ -48,14 +48,14 @@ const hbs = expressHandlebars.create({ ` ); }, - addOpenGraph (title, mimeType, showUrl, source, description) { + addOpenGraph (title, mimeType, showUrl, source, description, thumbnail) { let basicTags = ` `; if (mimeType === 'video/mp4') { return new Handlebars.SafeString( - `${basicTags} + `${basicTags} diff --git a/views/layouts/show.handlebars b/views/layouts/show.handlebars index 814c130d..0bf410fb 100644 --- a/views/layouts/show.handlebars +++ b/views/layouts/show.handlebars @@ -9,8 +9,8 @@ {{#unless fileInfo.nsfw}} - {{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.embedUrl openGraphInfo.directFileUrl}}} - {{{addOpenGraph fileInfo.title fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source fileInfo.description}}} + {{{addTwitterCard fileInfo.fileType openGraphInfo.source openGraphInfo.embedUrl openGraphInfo.directFileUrl}}} + {{{addOpenGraph fileInfo.title fileInfo.fileType openGraphInfo.showUrl openGraphInfo.source fileInfo.description fileInfo.thumbnail}}} {{/unless}} {{ googleAnalytics }} -- 2.45.2 From 83b5400c9ccac40bf54c07e3f7b7e0f1ece54470 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 12:48:07 -0700 Subject: [PATCH 09/11] removed uncessary logger.debug --- controllers/serveController.js | 1 - 1 file changed, 1 deletion(-) diff --git a/controllers/serveController.js b/controllers/serveController.js index f4f8a570..4b99e03d 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -192,7 +192,6 @@ module.exports = { return db.resolveClaim(fileInfo.name, fileInfo.claimId); }) .then(resolveResult => { - logger.debug(resolveResult); if (!resolveResult.thumbnail || resolveResult.thumbnail === '') { fileInfo['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png'; } else { -- 2.45.2 From 6158ef97242f4e876c842dd9bd8625064d6d3214 Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 12:54:36 -0700 Subject: [PATCH 10/11] moved all thumbnail url decisions to server-side --- controllers/serveController.js | 3 +++ controllers/statsController.js | 2 +- views/partials/contentListItem.handlebars | 6 +----- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/controllers/serveController.js b/controllers/serveController.js index 4b99e03d..9ef246f7 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -157,6 +157,9 @@ module.exports = { element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`; element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`; element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`; + if (!element.thumbnail || element.thumbnail === '') { + element['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png'; + } }); } return resolve(allChannelClaims); diff --git a/controllers/statsController.js b/controllers/statsController.js index 413bf0ff..915c9d81 100644 --- a/controllers/statsController.js +++ b/controllers/statsController.js @@ -155,7 +155,7 @@ module.exports = { element['directUrlLong'] = `/${element.claimId}/${element.name}.${fileExtenstion}`; element['directUrlShort'] = `/${element.claimId}/${element.name}.${fileExtenstion}`; element['contentType'] = element.fileType; - element['thumbnail'] = ''; + element['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png'; }); } resolve(results); diff --git a/views/partials/contentListItem.handlebars b/views/partials/contentListItem.handlebars index 895abfbd..128241c5 100644 --- a/views/partials/contentListItem.handlebars +++ b/views/partials/contentListItem.handlebars @@ -1,11 +1,7 @@
{{#ifConditional this.contentType '===' 'video/mp4'}} - {{#ifConditional this.thumbnail '===' ''}} - - {{else}} - - {{/ifConditional}} + {{else}} {{/ifConditional}} -- 2.45.2 From 3389d3759f1953aa5a9b874508edefebca07fc8a Mon Sep 17 00:00:00 2001 From: bill bittner Date: Mon, 11 Sep 2017 17:57:51 -0700 Subject: [PATCH 11/11] DRYer default thumbnail code --- controllers/serveController.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/controllers/serveController.js b/controllers/serveController.js index 9ef246f7..c9fb5e81 100644 --- a/controllers/serveController.js +++ b/controllers/serveController.js @@ -7,6 +7,7 @@ const { postToStats, sendGoogleAnalytics } = require('../controllers/statsContro const SERVE = 'SERVE'; const SHOW = 'SHOW'; const SHOWLITE = 'SHOWLITE'; +const DEFAULT_THUMBNAIL = 'https://spee.ch/assets/img/content-freedom-large.png'; function checkForLocalAssetByClaimId (claimId, name) { return new Promise((resolve, reject) => { @@ -95,6 +96,13 @@ function getAssetByLongClaimId (fullClaimId, name) { }); } +function chooseThumbnail (claimInfo, defaultThumbnail) { + if (!claimInfo.thumbnail || claimInfo.thumbnail === '') { + return defaultThumbnail; + } + return claimInfo.thumbnail; +} + module.exports = { getAssetByClaim (claimName, claimId) { logger.debug('getting asset by claim'); @@ -157,9 +165,7 @@ module.exports = { element['showUrlLong'] = `/${channelName}:${longChannelId}/${element.name}`; element['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`; element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`; - if (!element.thumbnail || element.thumbnail === '') { - element['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png'; - } + element['thumbnail'] = chooseThumbnail(element, DEFAULT_THUMBNAIL); }); } return resolve(allChannelClaims); @@ -195,11 +201,7 @@ module.exports = { return db.resolveClaim(fileInfo.name, fileInfo.claimId); }) .then(resolveResult => { - if (!resolveResult.thumbnail || resolveResult.thumbnail === '') { - fileInfo['thumbnail'] = 'https://spee.ch/assets/img/content-freedom-large.png'; - } else { - fileInfo['thumbnail'] = resolveResult.thumbnail; - } + fileInfo['thumbnail'] = chooseThumbnail(resolveResult, DEFAULT_THUMBNAIL); fileInfo['title'] = resolveResult.title; fileInfo['description'] = resolveResult.description; showFile(fileInfo, res); -- 2.45.2