-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5914 from topcoder-platform/develop
Release v1.14.6
- Loading branch information
Showing
27 changed files
with
508 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* The routes that expose assets and content from Contentful CMS to the CDN. | ||
*/ | ||
|
||
import express from 'express'; | ||
import RSS from 'rss'; | ||
import ReactDOMServer from 'react-dom/server'; | ||
import md from 'utils/markdown'; | ||
import { | ||
getService, | ||
} from '../services/contentful'; | ||
|
||
const cors = require('cors'); | ||
|
||
const routes = express.Router(); | ||
|
||
// Enables CORS on those routes according config above | ||
// ToDo configure CORS for set of our trusted domains | ||
routes.use(cors()); | ||
routes.options('*', cors()); | ||
|
||
routes.get('/thrive', async (req, res, next) => { | ||
try { | ||
const data = await getService('EDU', 'master', true).queryEntries({ | ||
content_type: 'article', | ||
limit: 20, | ||
order: '-sys.createdAt', | ||
include: 2, | ||
}); | ||
const feed = new RSS({ | ||
title: 'Topcoder Thrive', | ||
description: 'Tutorials And Workshops That Matter | Thrive | Topcoder', | ||
feed_url: 'https://topcoder.com/api/feeds/thrive', | ||
site_url: 'https://topcoder.com/thrive', | ||
image_url: 'https://www.topcoder.com/wp-content/uploads/2020/05/cropped-TC-Icon-32x32.png', | ||
docs: 'https://www.topcoder.com/thrive/tracks?track=Topcoder', | ||
webMaster: '<[email protected]> Kiril Kartunov', | ||
copyright: '2021 - today, Topcoder', | ||
language: 'en', | ||
categories: ['Competitive Programming', 'Data Science', 'Design', 'Development', 'QA', 'Gig work', 'Topcoder'], | ||
ttl: '60', | ||
}); | ||
if (data && data.total) { | ||
data.items.forEach((entry) => { | ||
feed.item({ | ||
title: entry.fields.title, | ||
description: ReactDOMServer.renderToString(md(entry.fields.content)), | ||
url: `https://topcoder.com/thrive/articles/${entry.fields.slug || encodeURIComponent(entry.fields.title)}?utm_source=community&utm_campaign=thrive-feed&utm_medium=promotion`, | ||
date: entry.fields.creationDate, | ||
categories: entry.fields.tags, | ||
author: entry.fields.contentAuthor[0].fields.name, | ||
}); | ||
}); | ||
} | ||
res.set('Content-Type', 'application/rss+xml'); | ||
res.send(feed.xml({ indent: true })); | ||
} catch (e) { | ||
next(e); | ||
} | ||
}); | ||
|
||
export default routes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.