fix(main): static page links and constantStrings

This commit is contained in:
dhcodes
2017-06-23 14:12:58 -05:00
parent 4c016216b9
commit 63a147257b
6 changed files with 21 additions and 120 deletions

View File

@@ -1,87 +0,0 @@
import { Observable } from 'rx';
import dedent from 'dedent';
import moment from 'moment';
import { timeCache, observeMethod } from '../utils/rx';
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',');
}
// userCount(where: Object) => Observable[Number]
// getCertCount(userCount: userCount, cert: String) => Observable[Number]
function getCertCount(userCount, cert) {
return userCount({ [cert]: true })
// using This-Bind operator
::timeCache(2, 'hours');
}
function getAllThreeCertsCount(userCount) {
return userCount({
isFrontEndCert: true,
isDataVisCert: true,
isBackEndCert: true
})
::timeCache(2, 'hours');
}
export default function about(app) {
const router = app.loopback.Router();
const User = app.models.User;
const userCount = observeMethod(User, 'count');
const frontEndCount$ = getCertCount(userCount, 'isFrontEndCert');
const dataVisCount$ = getCertCount(userCount, 'isDataVisCert');
const backEndCount$ = getCertCount(userCount, 'isBackEndCert');
const allThreeCount$ = getAllThreeCertsCount(userCount);
function showAbout(req, res, next) {
const daysRunning = moment().diff(new Date('10/15/2014'), 'days');
Observable.combineLatest(
frontEndCount$,
dataVisCount$,
backEndCount$,
allThreeCount$,
(
frontEndCount = 0,
dataVisCount = 0,
backEndCount = 0,
allThreeCount = 0
) => ({
frontEndCount,
dataVisCount,
backEndCount,
allThreeCount
})
)
.doOnNext(({
frontEndCount,
dataVisCount,
backEndCount,
allThreeCount
}) => {
res.render('resources/about', {
frontEndCount: numberWithCommas(frontEndCount),
dataVisCount: numberWithCommas(dataVisCount),
backEndCount: numberWithCommas(backEndCount),
allThreeCount: numberWithCommas(allThreeCount),
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) / 1800))
),
globalPledgedAmount: numberWithCommas(Math.floor(
28000 +
((Date.now() - 1456207176902) / (2629746000 / 2000) * 8.30)
))
});
})
.subscribe(() => {}, next);
}
router.get('/about', showAbout);
app.use('/:lang', router);
}

View File

@@ -20,8 +20,6 @@ module.exports = function(app) {
'/the-fastest-web-page-on-the-internet',
theFastestWebPageOnTheInternet
);
noLangRouter.get('/shop/cancel-stickers', cancelStickers);
noLangRouter.get('/shop/confirm-stickers', confirmStickers);
router.get('/unsubscribed', unsubscribed);
router.get('/nonprofits', nonprofits);
@@ -30,7 +28,6 @@ module.exports = function(app) {
router.get('/pmi-acp-agile-project-managers-form', agileProjectManagersForm);
router.get('/coding-bootcamp-cost-calculator', bootcampCalculator);
router.get('/stories', showTestimonials);
router.get('/shop', showShop);
router.get('/all-stories', showAllTestimonials);
router.get('/how-nonprofit-projects-work', howNonprofitProjectsWork);
router.get(
@@ -88,28 +85,6 @@ module.exports = function(app) {
});
}
function showShop(req, res) {
res.render('resources/shop', {
title: 'Support freeCodeCamp by Buying t-shirts, ' +
'stickers, and other goodies'
});
}
function confirmStickers(req, res) {
req.flash('success', {
msg: 'Thank you for supporting our community! You should receive ' +
'your stickers in the mail soon!'
});
res.redirect('/shop');
}
function cancelStickers(req, res) {
req.flash('info', {
msg: 'You\'ve cancelled your purchase of our stickers. You can ' +
'support our community any time by buying some.'
});
res.redirect('/shop');
}
function submitCatPhoto(req, res) {
res.send('Submitted!');
}