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" - } -} diff --git a/controllers/serveController.js b/controllers/serveController.js index aaa4eb22..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'); @@ -153,10 +161,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['directUrlLong'] = `/${channelName}:${longChannelId}/${element.name}.${fileExtenstion}`; + element['directUrlShort'] = `/${channelName}:${shortChannelId}/${element.name}.${fileExtenstion}`; + element['thumbnail'] = chooseThumbnail(element, DEFAULT_THUMBNAIL); }); } return resolve(allChannelClaims); @@ -192,6 +201,7 @@ module.exports = { return db.resolveClaim(fileInfo.name, fileInfo.claimId); }) .then(resolveResult => { + fileInfo['thumbnail'] = chooseThumbnail(resolveResult, DEFAULT_THUMBNAIL); fileInfo['title'] = resolveResult.title; fileInfo['description'] = resolveResult.description; showFile(fileInfo, res); diff --git a/controllers/statsController.js b/controllers/statsController.js index cd103781..915c9d81 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'] = 'https://spee.ch/assets/img/content-freedom-large.png'; + }); + } resolve(results); }) .catch(error => { diff --git a/models/index.js b/models/index.js index 5316993e..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: @@ -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/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/public/assets/js/generalFunctions.js b/public/assets/js/generalFunctions.js index 3c3a60d9..7c46344e 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.target.id||event.srcElement.id); + var masterElement = document.getElementById(event.srcElement.id); var slaveElement = document.getElementById(dataSet.slaveelementid); if (status === "false") { 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/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) => { 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/channel.handlebars b/views/channel.handlebars index 00b64c87..899b3e80 100644 --- a/views/channel.handlebars +++ b/views/channel.handlebars @@ -2,30 +2,9 @@ {{> topBar}}

{{this.channelName}}

-

Below are all the free claims in this channel.

+

Below is all the free content in this channel.

{{#each channelContents}} - + {{> contentListItem}} {{/each}}
{{> footer}} 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 }} diff --git a/views/partials/contentListItem.handlebars b/views/partials/contentListItem.handlebars new file mode 100644 index 00000000..128241c5 --- /dev/null +++ b/views/partials/contentListItem.handlebars @@ -0,0 +1,15 @@ +
+ + {{#ifConditional this.contentType '===' 'video/mp4'}} + + {{else}} + + {{/ifConditional}} +
+ +
+
+ diff --git a/views/partials/trendingAssets.handlebars b/views/partials/trendingAssets.handlebars deleted file mode 100644 index 90e6d4d1..00000000 --- a/views/partials/trendingAssets.handlebars +++ /dev/null @@ -1,39 +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}}