Add recent shares to homepage

This commit is contained in:
Jonathan Cremin 2014-12-06 11:14:46 +00:00
parent f4da977276
commit a104d86eec
3 changed files with 24 additions and 5 deletions

6
app.js
View file

@ -63,7 +63,11 @@ app.get('/', function(req, res) {
{artist: "Hozier", album: "self-titled album", url: '/google/album/Bd3mxcy3otokg4yc45qktq7l35q'},
{artist: "Daft Punk", album: "Discovery", url: '/google/album/B4t6yqqvhnb2hy4st4uisjrcsrm'}
];
res.render('index', { page: "home", samples: samples, error: req.flash('search-error') });
// shitty sort until I add more metadata on cached items
req.db.matches.find().sort({$natural:-1}).limit(4).toArray().then(function(docs){
res.render('index', { page: "home", samples: samples, recent: docs, error: req.flash('search-error') });
});
});
app.post('/search', search);

View file

@ -88,7 +88,7 @@ h3 {
}
.share-form {
margin-top: 30vh;
margin-top: 25vh;
margin-bottom: 20px;
text-align: center;
}
@ -105,7 +105,11 @@ h3 {
}
.blurb {
margin-bottom: 100px;
margin-bottom: 50px;
}
.recent {
margin-bottom: 30px;
}
.service {

View file

@ -24,8 +24,19 @@
<div class="col-md-6 col-md-offset-3">
<p>Make sharing from music services better.
We match album and track links from Rdio, Spotify, Deezer, Beats Music, Google Music and iTunes and give you back a link with all of them.</p>
<% var sample = samples[Math.floor(Math.random() * samples.length)] %>
<p><a href="<%= sample.url %>">Here's an example with <%= sample.artist %>'s <%= sample.album %></a>.</p>
</div>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<% if (recent.length) { %><h2>Recently Shared</h2><% } %>
<div class="row recent">
<% for (var i=0;i < recent.length;i++) { var item = recent[i].items[0]; %>
<div class="col-md-6">
<a href="/<%= item.service.replace("playmusic", "") %>/<%= item.type %>/<%= item.id %>"><img src="<%= item.artwork %>" width="100%"></a>
</div><% if((i+1)%2 == 0) { %></div><div class="row"><% } %>
<% } %>
</div>
</div>
</div>
</div>