added masonry.js to display trending images
This commit is contained in:
parent
4c8157e38e
commit
4d61a897d9
7 changed files with 52 additions and 23 deletions
|
@ -81,10 +81,9 @@ button.copy-button {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* trending claims */
|
/* trending claims */
|
||||||
.asset-trending {
|
.grid-item {
|
||||||
width: 21%;
|
width: 23%;
|
||||||
margin: 2%;
|
margin: 0px 1% 20px 1%;
|
||||||
float: left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* learn more */
|
/* learn more */
|
||||||
|
|
|
@ -91,13 +91,6 @@ h4 {
|
||||||
|
|
||||||
/* other */
|
/* other */
|
||||||
|
|
||||||
.asset-small {
|
|
||||||
width: 30%;
|
|
||||||
padding: 0px;
|
|
||||||
margin: 10px;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
input {
|
input {
|
||||||
padding: 0.3em;
|
padding: 0.3em;
|
||||||
}
|
}
|
||||||
|
|
9
public/vendors/masonry/masonry.pkgd.min.js
vendored
Normal file
9
public/vendors/masonry/masonry.pkgd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -29,6 +29,7 @@ module.exports = (app) => {
|
||||||
startDate.setDate(startDate.getDate() - 1);
|
startDate.setDate(startDate.getDate() - 1);
|
||||||
getTrendingClaims(startDate)
|
getTrendingClaims(startDate)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
|
// logger.debug(result);
|
||||||
res.status(200).render('trending', { trendingAssets: result });
|
res.status(200).render('trending', { trendingAssets: result });
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
|
|
|
@ -66,6 +66,8 @@ const hbs = expressHandlebars.create({
|
||||||
return (varOne && varTwo) ? options.fn(this) : options.inverse(this);
|
return (varOne && varTwo) ? options.fn(this) : options.inverse(this);
|
||||||
case '||':
|
case '||':
|
||||||
return (varOne || varTwo) ? options.fn(this) : options.inverse(this);
|
return (varOne || varTwo) ? options.fn(this) : options.inverse(this);
|
||||||
|
case 'mod3':
|
||||||
|
return ((parseInt(varOne) % 3) === 0) ? options.fn(this) : options.inverse(this);
|
||||||
default:
|
default:
|
||||||
return options.inverse(this);
|
return options.inverse(this);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="top-bar">
|
<div class="top-bar">
|
||||||
<img id="logo" src="/assets/img/content-freedom-64px.png"/>
|
<img id="logo" src="/assets/img/content-freedom-64px.png"/>
|
||||||
<h1 id="title"><a href="/">Spee.ch</a></h1>
|
<h1 id="title"><a href="/">Spee.ch</a></h1><span >(beta)</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
|
@ -1,23 +1,48 @@
|
||||||
|
<script src="/vendors/masonry/masonry.pkgd.min.js"></script>
|
||||||
|
|
||||||
<div class="full">
|
<div class="full">
|
||||||
<h2>Trending</h2>
|
<h2>Trending</h2>
|
||||||
{{#grouped_each 3 trendingAssets}}
|
<div class="grid" data-masonry='{ "itemSelector": ".grid-item" }'>
|
||||||
<div>
|
{{#each trendingAssets}}
|
||||||
{{#each this}}
|
{{#unless this.nsfw}}
|
||||||
{{#if this.nsfw}}
|
|
||||||
{{else }}
|
|
||||||
<a href="/show/{{this.name}}/{{this.claimId}}">
|
<a href="/show/{{this.name}}/{{this.claimId}}">
|
||||||
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
||||||
<video class="asset-small" controls>
|
<video class="grid-item trending-video" controls>
|
||||||
<source src="/api/streamFile/{{this.fileName}}">
|
<source src="/api/streamFile/{{this.fileName}}">
|
||||||
{{!--fallback--}}
|
{{!--fallback--}}
|
||||||
Your browser does not support the <code>video</code> element.
|
Your browser does not support the <code>video</code> element.
|
||||||
</video>
|
</video>
|
||||||
{{else}}
|
{{else}}
|
||||||
<img class="asset-small" src="/api/streamFile/{{this.fileName}}" />
|
<img class="grid-item trending-image" src="/api/streamFile/{{this.fileName}}" />
|
||||||
{{/ifConditional}}
|
{{/ifConditional}}
|
||||||
</a>
|
</a>
|
||||||
{{/if}}
|
|
||||||
|
{{/unless}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
{{/grouped_each}}
|
</div>
|
||||||
</div>
|
|
||||||
|
<script>
|
||||||
|
var elem = document.querySelector('.grid');
|
||||||
|
var trendingImages = document.querySelectorAll('.trending-image');
|
||||||
|
console.log(trendingImages)
|
||||||
|
var trendingVideos = document.querySelectorAll('.trending-video');
|
||||||
|
var msnry = new Masonry( elem, {
|
||||||
|
itemSelector: '.grid-item'
|
||||||
|
});
|
||||||
|
// after images are loaded, reset layout
|
||||||
|
for (var i = 0; i < trendingVideos.length; i++) {
|
||||||
|
trendingImages[i].addEventListener('load', function(){
|
||||||
|
console.log('image loaded');
|
||||||
|
msnry.layout();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
// after videos are loaded, reset layout
|
||||||
|
for (var i = 0; i < trendingVideos.length; i++) {
|
||||||
|
trendingVideos[i].addEventListener('loadeddata', function(){
|
||||||
|
console.log('video loaded');
|
||||||
|
msnry.layout();
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in a new issue