From 63a147257b1ee6fd2b8e5a6e135e57833095d657 Mon Sep 17 00:00:00 2001 From: dhcodes Date: Fri, 23 Jun 2017 14:12:58 -0500 Subject: [PATCH] fix(main): static page links and constantStrings --- client/epics/mouse-trap-epic.js | 17 ++++-- client/main.js | 4 +- common/app/Nav/links.json | 3 +- common/utils/constantStrings.json | 5 +- server/boot/about.js | 87 ------------------------------- server/boot/randomAPIs.js | 25 --------- 6 files changed, 21 insertions(+), 120 deletions(-) delete mode 100644 server/boot/about.js diff --git a/client/epics/mouse-trap-epic.js b/client/epics/mouse-trap-epic.js index 8cb0cd9f36..72d4887e56 100644 --- a/client/epics/mouse-trap-epic.js +++ b/client/epics/mouse-trap-epic.js @@ -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) ]; diff --git a/client/main.js b/client/main.js index d753bb6cc2..bb60948d10 100644 --- a/client/main.js +++ b/client/main.js @@ -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 diff --git a/common/app/Nav/links.json b/common/app/Nav/links.json index 9b7281e390..a3f0b6f16f 100644 --- a/common/app/Nav/links.json +++ b/common/app/Nav/links.json @@ -30,7 +30,8 @@ }, { "content": "About", - "link": "/about" + "link": "https://www.freecodecamp.org/about", + "target": "_blank" } ] }, diff --git a/common/utils/constantStrings.json b/common/utils/constantStrings.json index a4a363a6e8..37657970f1 100644 --- a/common/utils/constantStrings.json +++ b/common/utils/constantStrings.json @@ -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" } diff --git a/server/boot/about.js b/server/boot/about.js deleted file mode 100644 index 2665dffaef..0000000000 --- a/server/boot/about.js +++ /dev/null @@ -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); -} diff --git a/server/boot/randomAPIs.js b/server/boot/randomAPIs.js index 60dc1a7ce3..d81ee72e19 100644 --- a/server/boot/randomAPIs.js +++ b/server/boot/randomAPIs.js @@ -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!'); }