From 0ffca02ec1f378d791819ca0e99bda3eb6a045b6 Mon Sep 17 00:00:00 2001
From: Mrugesh Mohapatra
Date: Sat, 15 Jun 2019 23:45:30 +0530
Subject: [PATCH] fix: remove medium links and rss feeds
---
api-server/server/rss/index.js | 11 +++---
api-server/server/rss/medium.js | 36 -------------------
client/src/components/Footer/index.js | 1 -
client/src/pages/about.js | 6 +---
.../createRedirects.test.js.snap | 2 +-
tools/scripts/createRedirects.js | 2 +-
6 files changed, 7 insertions(+), 51 deletions(-)
delete mode 100644 api-server/server/rss/medium.js
diff --git a/api-server/server/rss/index.js b/api-server/server/rss/index.js
index a80a2419ab..1112970ba4 100644
--- a/api-server/server/rss/index.js
+++ b/api-server/server/rss/index.js
@@ -2,7 +2,6 @@ import _ from 'lodash';
import compareDesc from 'date-fns/compare_desc';
import debug from 'debug';
-import { getMediumFeed } from './medium';
import { getLybsynFeed } from './lybsyn';
const log = debug('fcc:rss:news-feed');
@@ -13,7 +12,6 @@ class NewsFeed {
constructor() {
this.state = {
readyState: false,
- mediumFeed: [],
lybsynFeed: [],
combinedFeed: []
};
@@ -31,18 +29,17 @@ class NewsFeed {
refreshFeeds = () => {
const currentFeed = this.state.combinedFeed.slice(0);
log('grabbing feeds');
- return Promise.all([getMediumFeed(), getLybsynFeed()])
- .then(([mediumFeed, lybsynFeed]) =>
+ return Promise.all([getLybsynFeed()])
+ .then(([lybsynFeed]) =>
this.setState(state => ({
...state,
- mediumFeed,
lybsynFeed
}))
)
.then(() => {
log('crossing the streams');
- const { mediumFeed, lybsynFeed } = this.state;
- const combinedFeed = [...mediumFeed, ...lybsynFeed].sort((a, b) => {
+ const { lybsynFeed } = this.state;
+ const combinedFeed = [...lybsynFeed].sort((a, b) => {
return compareDesc(a.isoDate, b.isoDate);
});
this.setState(state => ({
diff --git a/api-server/server/rss/medium.js b/api-server/server/rss/medium.js
deleted file mode 100644
index 88c87da2b6..0000000000
--- a/api-server/server/rss/medium.js
+++ /dev/null
@@ -1,36 +0,0 @@
-import Parser from 'rss-parser';
-import _ from 'lodash';
-
-const parser = new Parser();
-
-const mediumFeed = 'https://medium.freecodecamp.org/feed';
-
-function getExtract(str) {
- return str.slice(0, str.indexOf('
') + 4);
-}
-
-function addResponsiveClass(str) {
- return str.replace(/
{
- parser.parseURL(mediumFeed, (err, feed) => {
- if (err) {
- reject(err);
- }
-
- const items = feed.items
- .map(item =>
- _.pick(item, ['title', 'link', 'isoDate', 'content:encoded'])
- )
- .map(item => ({
- ...item,
- extract: getExtract(item['content:encoded'])
- }))
- .map(item => _.omit(item, ['content:encoded']))
- .map(item => ({ ...item, extract: addResponsiveClass(item.extract) }));
- resolve(items);
- });
- });
-}
diff --git a/client/src/components/Footer/index.js b/client/src/components/Footer/index.js
index 32425f9414..18930b6116 100644
--- a/client/src/components/Footer/index.js
+++ b/client/src/components/Footer/index.js
@@ -80,7 +80,6 @@ function Footer() {
Youtube
Podcast
Twitter
- Medium
Instagram
diff --git a/client/src/pages/about.js b/client/src/pages/about.js
index 07eaf5f9a6..3a14973558 100644
--- a/client/src/pages/about.js
+++ b/client/src/pages/about.js
@@ -52,11 +52,7 @@ const AboutPage = () => {
How big is the freeCodeCamp community?
If you add up all the people who use our learning platform, read
- our{' '}
-
- Medium publication
-
- , watch our{' '}
+ our news articles, watch our{' '}
YouTube channel
, and post on{' '}
diff --git a/tools/scripts/__snapshots__/createRedirects.test.js.snap b/tools/scripts/__snapshots__/createRedirects.test.js.snap
index ac05d74af4..41458fadce 100644
--- a/tools/scripts/__snapshots__/createRedirects.test.js.snap
+++ b/tools/scripts/__snapshots__/createRedirects.test.js.snap
@@ -42,7 +42,7 @@ exports[`createRedirects matches the snapshot 1`] = `
/forum/* https://forum.example.com/:splat 200
/privacy https://forum.example.com/t/free-code-camp-privacy-policy/19545 301
/nonprofit-project-instructions https://forum.example.com/t/how-free-code-camps-nonprofits-projects-work/19547 301
-/how-nonprofit-projects-work https://medium.freecodecamp.org/open-source-for-good-1a0ea9f32d5a 301
+/how-nonprofit-projects-work https://www.freecodecamp.org/news/open-source-for-good-1a0ea9f32d5a 301
"
`;
diff --git a/tools/scripts/createRedirects.js b/tools/scripts/createRedirects.js
index 277c1b0325..e34b8a4fb7 100644
--- a/tools/scripts/createRedirects.js
+++ b/tools/scripts/createRedirects.js
@@ -63,7 +63,7 @@ const template = `#api redirect
/forum/* #{{FORUM}}/:splat 200
/privacy #{{FORUM}}/t/free-code-camp-privacy-policy/19545 301
/nonprofit-project-instructions #{{FORUM}}/t/how-free-code-camps-nonprofits-projects-work/19547 301
-/how-nonprofit-projects-work https://medium.freecodecamp.org/open-source-for-good-1a0ea9f32d5a 301
+/how-nonprofit-projects-work https://www.freecodecamp.org/news/open-source-for-good-1a0ea9f32d5a 301
`;
/* eslint-enable max-len */