updated new and trending pages
This commit is contained in:
parent
722bf055a0
commit
a23aa0bb82
5 changed files with 72 additions and 15 deletions
|
@ -156,4 +156,18 @@ module.exports = {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
getRecentClaims (startDate) {
|
||||||
|
logger.debug('retrieving most recent claims');
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
// get the raw requests data
|
||||||
|
db.sequelize.query(`SELECT * FROM File WHERE nsfw != 1 AND trendingEligible = 1 ORDER BY createdAt DESC LIMIT 25;`, { type: db.sequelize.QueryTypes.SELECT })
|
||||||
|
.then(results => {
|
||||||
|
resolve(results);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
logger.error('sequelize error', error);
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
const errorHandlers = require('../helpers/errorHandlers.js');
|
const errorHandlers = require('../helpers/errorHandlers.js');
|
||||||
const { getAllFreeClaims } = require('../helpers/serveHelpers.js');
|
const { getAllFreeClaims } = require('../helpers/serveHelpers.js');
|
||||||
const { postToStats, getStatsSummary, getTrendingClaims } = require('../controllers/statsController.js');
|
const { postToStats, getStatsSummary, getTrendingClaims, getRecentClaims } = require('../controllers/statsController.js');
|
||||||
|
|
||||||
module.exports = (app) => {
|
module.exports = (app) => {
|
||||||
// route to show 'about' page for spee.ch
|
// route to show 'about' page for spee.ch
|
||||||
|
@ -9,7 +9,7 @@ module.exports = (app) => {
|
||||||
res.status(200).render('about');
|
res.status(200).render('about');
|
||||||
});
|
});
|
||||||
// route to display a list of the trending images
|
// route to display a list of the trending images
|
||||||
app.get('/trending', ({ params, headers }, res) => {
|
app.get('/popular', ({ params, headers }, res) => {
|
||||||
const startDate = new Date();
|
const startDate = new Date();
|
||||||
startDate.setDate(startDate.getDate() - 1);
|
startDate.setDate(startDate.getDate() - 1);
|
||||||
getTrendingClaims(startDate)
|
getTrendingClaims(startDate)
|
||||||
|
@ -21,6 +21,19 @@ module.exports = (app) => {
|
||||||
errorHandlers.handleRequestError(error, res);
|
errorHandlers.handleRequestError(error, res);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
// route to display a list of the trending images
|
||||||
|
app.get('/new', ({ params, headers }, res) => {
|
||||||
|
const startDate = new Date();
|
||||||
|
startDate.setDate(startDate.getDate() - 1);
|
||||||
|
getRecentClaims(startDate)
|
||||||
|
.then(result => {
|
||||||
|
// logger.debug(result);
|
||||||
|
res.status(200).render('new', { newClaims: result });
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
errorHandlers.handleRequestError(error, res);
|
||||||
|
});
|
||||||
|
});
|
||||||
// route to show statistics for spee.ch
|
// route to show statistics for spee.ch
|
||||||
app.get('/stats', ({ ip, originalUrl }, res) => {
|
app.get('/stats', ({ ip, originalUrl }, res) => {
|
||||||
// get and render the content
|
// get and render the content
|
||||||
|
|
26
views/new.handlebars
Normal file
26
views/new.handlebars
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<div class="wrapper">
|
||||||
|
{{> topBar}}
|
||||||
|
<div>
|
||||||
|
<h2>New on Spee.ch</h2>
|
||||||
|
<p><i>The 25 most recent publishes on spee.ch</i></p>
|
||||||
|
{{#each newClaims}}
|
||||||
|
<div class="all-claims-item">
|
||||||
|
<a href="/{{this.claimId}}/{{this.name}}">
|
||||||
|
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
||||||
|
<img class="all-claims-asset" src="/assets/img/content-freedom-large.png"/>
|
||||||
|
{{else}}
|
||||||
|
<img class="all-claims-asset" src="/{{this.claimId}}/{{this.name}}.ext" />
|
||||||
|
{{/ifConditional}}
|
||||||
|
</a>
|
||||||
|
<div class="all-claims-details">
|
||||||
|
<ul style="list-style-type:none">
|
||||||
|
<li><bold>{{this.name}}</bold></li>
|
||||||
|
<li><i>Claim Id: {{this.claimId}}</i></li>
|
||||||
|
<li><a href="/{{this.claimId}}/{{this.name}}">Link</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
|
{{> footer}}
|
||||||
|
</div>
|
|
@ -1,7 +1,8 @@
|
||||||
<div class="top-bar">
|
<div class="top-bar">
|
||||||
<a href="https://en.wikipedia.org/wiki/Freedom_of_information" target="_blank"><img id="logo" src="/assets/img/content-freedom-64px.png"/></a>
|
<a href="https://en.wikipedia.org/wiki/Freedom_of_information" target="_blank"><img id="logo" src="/assets/img/content-freedom-64px.png"/></a>
|
||||||
<h1 id="title"><a href="/">Spee.ch</a></h1><span class="top-bar-left">(beta)</span>
|
<h1 id="title"><a href="/">Spee.ch</a></h1><span class="top-bar-left">(beta)</span>
|
||||||
<a href="/trending" class="top-bar-right">trending</a>
|
<a href="/new" class="top-bar-right">new</a>
|
||||||
|
<a href="/popular" class="top-bar-right">popular</a>
|
||||||
<a href="https://github.com/lbryio/spee.ch" target="_blank" class="top-bar-right">source</a>
|
<a href="https://github.com/lbryio/spee.ch" target="_blank" class="top-bar-right">source</a>
|
||||||
<a href="/about" class="top-bar-right">help</a>
|
<a href="/about" class="top-bar-right">help</a>
|
||||||
<div class="top-bar-tagline">Open-source, decentralized image and video hosting.</div>
|
<div class="top-bar-tagline">Open-source, decentralized image and video hosting.</div>
|
||||||
|
|
|
@ -2,22 +2,25 @@
|
||||||
|
|
||||||
<div class="full">
|
<div class="full">
|
||||||
<h2>Trending</h2>
|
<h2>Trending</h2>
|
||||||
|
<p><i>The 25 most popular assets on spee.ch</i></p>
|
||||||
<div class="grid" data-masonry='{ "itemSelector": ".grid-item" }'>
|
<div class="grid" data-masonry='{ "itemSelector": ".grid-item" }'>
|
||||||
{{#each trendingAssets}}
|
{{#each trendingAssets}}
|
||||||
{{#unless this.nsfw}}
|
<div class="all-claims-item">
|
||||||
<a href="/{{this.claimId}}/{{this.name}}">
|
<a href="/{{this.claimId}}/{{this.name}}">
|
||||||
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
{{#ifConditional this.fileType '===' 'video/mp4'}}
|
||||||
<video class="grid-item trending-video" controls onloadeddata="resetTrendingLayout()">
|
<img class="all-claims-asset" src="/assets/img/content-freedom-large.png"/>
|
||||||
<source src="/media/{{this.fileName}}" >
|
|
||||||
{{!--fallback--}}
|
|
||||||
Your browser does not support the <code>video</code> element.
|
|
||||||
</video>
|
|
||||||
{{else}}
|
{{else}}
|
||||||
<img class="grid-item trending-image" src="/media/{{this.fileName}}" onload="resetTrendingLayout()"/>
|
<img class="all-claims-asset" src="/{{this.claimId}}/{{this.name}}.ext" />
|
||||||
{{/ifConditional}}
|
{{/ifConditional}}
|
||||||
</a>
|
</a>
|
||||||
{{/unless}}
|
<div class="all-claims-details">
|
||||||
|
<ul style="list-style-type:none">
|
||||||
|
<li><bold>{{this.name}}</bold></li>
|
||||||
|
<li><i>Claim Id: {{this.claimId}}</i></li>
|
||||||
|
<li><strong>{{this.title}}</strong></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue