Merge pull request #15508 from dhcodes/fix/static-about
update about links
This commit is contained in:
@ -5,6 +5,12 @@ import {
|
||||
toggleNightMode,
|
||||
hardGoTo
|
||||
} from '../../common/app/redux';
|
||||
import {
|
||||
aboutUrl,
|
||||
donateUrl,
|
||||
forumUrl,
|
||||
githubUrl
|
||||
} from '../../common/utils/constantStrings.json';
|
||||
|
||||
function bindKey(key, actionCreator) {
|
||||
return Observable.fromEventPattern(
|
||||
@ -16,7 +22,6 @@ function bindKey(key, actionCreator) {
|
||||
|
||||
const softRedirects = {
|
||||
'g n n': '/challenges/next-challenge',
|
||||
'g n a': '/about',
|
||||
'g n m': '/map',
|
||||
'g n o': '/settings'
|
||||
};
|
||||
@ -25,17 +30,21 @@ export default function mouseTrapSaga(actions) {
|
||||
const traps = [
|
||||
...Object.keys(softRedirects)
|
||||
.map(key => bindKey(key, () => push(softRedirects[key]))),
|
||||
bindKey(
|
||||
'g n a',
|
||||
() => hardGoTo(aboutUrl)
|
||||
),
|
||||
bindKey(
|
||||
'g n r',
|
||||
() => hardGoTo('https://github.com/freecodecamp/freecodecamp')
|
||||
() => hardGoTo(githubUrl)
|
||||
),
|
||||
bindKey(
|
||||
'g n d',
|
||||
() => hardGoTo('https://www.freecodecamp.org/donate')
|
||||
() => hardGoTo(donateUrl)
|
||||
),
|
||||
bindKey(
|
||||
'g n w',
|
||||
() => hardGoTo('http://forum.freecodecamp.org')
|
||||
() => hardGoTo(forumUrl)
|
||||
),
|
||||
bindKey('g t n', toggleNightMode)
|
||||
];
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { donateUrl } from '../common/utils/constantStrings.json';
|
||||
import { aboutUrl, donateUrl } from '../common/utils/constantStrings.json';
|
||||
|
||||
var main = window.main || {};
|
||||
|
||||
@ -106,7 +106,7 @@ $(document).ready(function() {
|
||||
});
|
||||
window.Mousetrap.bind('g n a', () => {
|
||||
// About
|
||||
window.location = '/about';
|
||||
window.location = aboutUrl;
|
||||
});
|
||||
window.Mousetrap.bind('g n d', () => {
|
||||
// Donate
|
||||
|
@ -30,7 +30,8 @@
|
||||
},
|
||||
{
|
||||
"content": "About",
|
||||
"link": "/about"
|
||||
"link": "https://www.freecodecamp.org/about",
|
||||
"target": "_blank"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
@ -1,4 +1,7 @@
|
||||
{
|
||||
"aboutUrl": "https://www.freecodecamp.org/about",
|
||||
"defaultProfileImage": "https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png",
|
||||
"donateUrl": "https://www.freecodecamp.org/donate"
|
||||
"donateUrl": "https://www.freecodecamp.org/donate",
|
||||
"forumUrl": "https://forum.freecodecamp.org",
|
||||
"githubUrl": "https://github.com/freecodecamp/freecodecamp"
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
@ -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!');
|
||||
}
|
||||
|
Reference in New Issue
Block a user