Add stats to about page
parent
a6c4ed77a5
commit
918ea56e33
|
@ -0,0 +1,37 @@
|
||||||
|
import dedent from 'dedent';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
import { observeMethod } from '../utils/rx';
|
||||||
|
|
||||||
|
function numberWithCommas(x) {
|
||||||
|
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function about(app) {
|
||||||
|
const router = app.loopback.Router();
|
||||||
|
const User = app.models.User;
|
||||||
|
const userCount$ = observeMethod(User, 'count');
|
||||||
|
|
||||||
|
function showAbout(req, res, next) {
|
||||||
|
const daysRunning = moment().diff(new Date('10/15/2014'), 'days');
|
||||||
|
|
||||||
|
userCount$()
|
||||||
|
.map(camperCount => numberWithCommas(camperCount))
|
||||||
|
.doOnNext(camperCount => {
|
||||||
|
res.render('resources/about', {
|
||||||
|
camperCount,
|
||||||
|
daysRunning,
|
||||||
|
title: dedent`
|
||||||
|
About our Open Source Community, our social media presence,
|
||||||
|
and how to contact us`.split('\n').join(' '),
|
||||||
|
globalCompletedCount: numberWithCommas(
|
||||||
|
5612952 + (Math.floor((Date.now() - 1446268581061) / 2000))
|
||||||
|
)
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.subscribe(() => {}, next);
|
||||||
|
}
|
||||||
|
|
||||||
|
router.get('/about', showAbout);
|
||||||
|
app.use(router);
|
||||||
|
}
|
|
@ -35,7 +35,6 @@ module.exports = function(app) {
|
||||||
router.get('/labs', showLabs);
|
router.get('/labs', showLabs);
|
||||||
router.get('/stories', showTestimonials);
|
router.get('/stories', showTestimonials);
|
||||||
router.get('/all-stories', showAllTestimonials);
|
router.get('/all-stories', showAllTestimonials);
|
||||||
router.get('/about', showAbout);
|
|
||||||
router.get('/terms', terms);
|
router.get('/terms', terms);
|
||||||
router.get('/privacy', privacy);
|
router.get('/privacy', privacy);
|
||||||
router.get('/code-of-conduct', codeOfConduct);
|
router.get('/code-of-conduct', codeOfConduct);
|
||||||
|
@ -198,13 +197,6 @@ module.exports = function(app) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAbout(req, res) {
|
|
||||||
res.render('resources/about', {
|
|
||||||
title: 'About our Open Source Community, our social media presence, ' +
|
|
||||||
'and how to contact us'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function terms(req, res) {
|
function terms(req, res) {
|
||||||
res.render('resources/terms-of-service', {
|
res.render('resources/terms-of-service', {
|
||||||
title: 'Terms of Service'
|
title: 'Terms of Service'
|
||||||
|
|
|
@ -178,6 +178,7 @@ module.exports = function(app) {
|
||||||
req.flash('errors', {
|
req.flash('errors', {
|
||||||
msg: `404: We couldn't find path ${ path }`
|
msg: `404: We couldn't find path ${ path }`
|
||||||
});
|
});
|
||||||
|
console.log('404');
|
||||||
return res.redirect('/');
|
return res.redirect('/');
|
||||||
}
|
}
|
||||||
profileUser = profileUser.toJSON();
|
profileUser = profileUser.toJSON();
|
||||||
|
|
|
@ -5,6 +5,25 @@ block content
|
||||||
br
|
br
|
||||||
| who learn to code and help nonprofits.
|
| who learn to code and help nonprofits.
|
||||||
.spacer
|
.spacer
|
||||||
|
.row
|
||||||
|
.col-xs-12.col-sm-10.col-sm-offset-1.col-md-6.col-md-offset-3
|
||||||
|
h2
|
||||||
|
table.population-table.img-center
|
||||||
|
tr
|
||||||
|
td Established: 
|
||||||
|
td
|
||||||
|
span.text-primary #{daysRunning} 
|
||||||
|
| days ago
|
||||||
|
tr
|
||||||
|
td Population:   
|
||||||
|
td
|
||||||
|
span.text-primary #{camperCount} 
|
||||||
|
| campers
|
||||||
|
tr
|
||||||
|
td Completed:   
|
||||||
|
td
|
||||||
|
span.text-primary #{globalCompletedCount} 
|
||||||
|
| challenges
|
||||||
|
|
||||||
.row
|
.row
|
||||||
.col-xs-12.col-sm-10.col-sm-offset-1.col-md-6.col-md-offset-3
|
.col-xs-12.col-sm-10.col-sm-offset-1.col-md-6.col-md-offset-3
|
||||||
|
|
Loading…
Reference in New Issue