Removed Camper News completely
parent
606051c87e
commit
62946689dc
|
@ -836,74 +836,14 @@ div.CodeMirror-scroll {
|
|||
padding: 15px 0 15px 0;
|
||||
}
|
||||
|
||||
.img-news {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.url-preview {
|
||||
max-width: 250px;
|
||||
max-height: 250px;
|
||||
}
|
||||
|
||||
//.media ~ .media .media-body-wrapper:nth-child(odd) {
|
||||
// background-color: #e5e5e5;
|
||||
//}
|
||||
|
||||
.news-box {
|
||||
@media (min-width: 768px) {
|
||||
margin-top: -40px;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
padding: 5px;
|
||||
border-color: @brand-info;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-radius: 5px;
|
||||
width: 100%;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
.news-box-search {
|
||||
@media (min-width: 768px) {
|
||||
margin-top: -30px;
|
||||
padding-bottom: 20px;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
padding: 5px;
|
||||
border-color: @brand-info;
|
||||
border-width: 1px;
|
||||
border-style: solid;
|
||||
border-radius: 5px;
|
||||
width: 100%;
|
||||
float: left;
|
||||
}
|
||||
}
|
||||
|
||||
.story-headline {
|
||||
font-size: 20px;
|
||||
margin-left: 14px;
|
||||
margin-top: -5px;
|
||||
}
|
||||
|
||||
.landing-heading {
|
||||
font-size: 50px !important;
|
||||
}
|
||||
|
||||
.mobile-story-headline {
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.story-byline {
|
||||
margin-top: 5px;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.media-stories {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
hr {
|
||||
border: 0;
|
||||
height: 1px;
|
||||
|
|
|
@ -186,75 +186,6 @@ $(document).ready(function() {
|
|||
);
|
||||
});
|
||||
|
||||
function upvoteHandler(e) {
|
||||
e.preventDefault();
|
||||
var upvoteBtn = this;
|
||||
var id = upvoteBtn.id;
|
||||
var upVotes = $(upvoteBtn).data().upVotes;
|
||||
var username = typeof username !== 'undefined' ? username : '';
|
||||
var alreadyUpvoted = false;
|
||||
for (var i = 0; i < upVotes.length; i++) {
|
||||
if (upVotes[i].upVotedBy === username) {
|
||||
alreadyUpvoted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!alreadyUpvoted) {
|
||||
$.post('/stories/upvote', { id: id })
|
||||
.fail(function() {
|
||||
$(upvoteBtn).bind('click', upvoteHandler);
|
||||
})
|
||||
.done(function(data) {
|
||||
$(upvoteBtn)
|
||||
.text('Upvoted!')
|
||||
.addClass('disabled');
|
||||
|
||||
$('#storyRank').text(data.rank + ' points');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$('#story-list').on('click', 'button.btn-upvote', upvoteHandler);
|
||||
|
||||
var storySubmitButtonHandler = function storySubmitButtonHandler() {
|
||||
|
||||
if (!$('#story-submission-form')[0].checkValidity()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var link = $('#story-url').val();
|
||||
var headline = $('#story-title').val();
|
||||
var description = $('#description-box').val();
|
||||
var data = {
|
||||
data: {
|
||||
link: link,
|
||||
headline: headline,
|
||||
timePosted: Date.now(),
|
||||
description: description,
|
||||
storyMetaDescription: main.storyMetaDescription,
|
||||
rank: 1,
|
||||
image: main.storyImage
|
||||
}
|
||||
};
|
||||
|
||||
$('#story-submit').unbind('click');
|
||||
return $.post('/stories/', data)
|
||||
.fail(function() {
|
||||
$('#story-submit').bind('click', storySubmitButtonHandler);
|
||||
})
|
||||
.done(function({ storyLink, isBanned }) {
|
||||
if (isBanned) {
|
||||
window.location = '/news';
|
||||
return null;
|
||||
}
|
||||
window.location = '/stories/' + storyLink;
|
||||
return null;
|
||||
});
|
||||
};
|
||||
|
||||
$('#story-submit').on('click', storySubmitButtonHandler);
|
||||
|
||||
|
||||
// map sharing
|
||||
var alreadyShared = main.getMapShares();
|
||||
|
||||
|
|
|
@ -1,128 +1,12 @@
|
|||
import moment from 'moment';
|
||||
|
||||
import { unDasherize } from '../utils';
|
||||
import { observeMethod } from '../utils/rx';
|
||||
|
||||
const foundationDate = 1413298800000;
|
||||
const time48Hours = 172800000;
|
||||
|
||||
function hotRank(timeValue, rank) {
|
||||
/*
|
||||
* Hotness ranking algorithm: http://amix.dk/blog/post/19588
|
||||
* tMS = postedOnDate - foundationTime;
|
||||
* Ranking...
|
||||
* f(ts, 1, rank) = log(10)z + (ts)/45000;
|
||||
*/
|
||||
var z = Math.log(rank) / Math.log(10);
|
||||
var hotness = z + (timeValue / time48Hours);
|
||||
return hotness;
|
||||
}
|
||||
|
||||
function sortByRank(a, b) {
|
||||
return hotRank(b.timePosted - foundationDate, b.rank) -
|
||||
hotRank(a.timePosted - foundationDate, a.rank);
|
||||
}
|
||||
|
||||
module.exports = function(app) {
|
||||
const router = app.loopback.Router();
|
||||
const Story = app.models.Story;
|
||||
const findStory = observeMethod(Story, 'find');
|
||||
const findOneStory = observeMethod(Story, 'findOne');
|
||||
const query = {
|
||||
order: 'timePosted DESC',
|
||||
limit: 1000
|
||||
};
|
||||
const storiesData$ = findStory(query)
|
||||
.map(stories => {
|
||||
const sliceVal = stories.length >= 100 ? 100 : stories.length;
|
||||
return stories.sort(sortByRank).slice(0, sliceVal);
|
||||
})
|
||||
.shareReplay();
|
||||
|
||||
const redirectToNews = (req, res) => res.redirect('/news');
|
||||
const deprecated = (req, res) => res.sendStatus(410);
|
||||
router.get('/news', showNews);
|
||||
router.post('/news/userstories', deprecated);
|
||||
router.get('/news/hot', hotJSON);
|
||||
router.get('/news/feed', RSSFeed);
|
||||
router.get('/stories/hotStories', hotJSON);
|
||||
router.get('/stories/submit', redirectToNews);
|
||||
router.get('/stories/submit/new-story', redirectToNews);
|
||||
router.post('/stories/preliminary', deprecated);
|
||||
router.post('/stories/', deprecated);
|
||||
router.post('/stories/search', deprecated);
|
||||
router.get('/news/:storyName', returnIndividualStory);
|
||||
router.post('/stories/upvote/', deprecated);
|
||||
router.get('/stories/:storyName', replaceStoryWithNews);
|
||||
const redirectToReddit = (req, res) =>
|
||||
res.redirect('https://www.reddit.com/r/FreeCodeCamp/');
|
||||
|
||||
router.get('/news', redirectToReddit);
|
||||
router.get('/news/:storyName', redirectToReddit);
|
||||
router.get('/stories/:storyName', redirectToReddit);
|
||||
|
||||
app.use(router);
|
||||
|
||||
function showNews(req, res) {
|
||||
res.render('news/deprecated', { title: 'Camper News' });
|
||||
}
|
||||
|
||||
function replaceStoryWithNews(req, res) {
|
||||
var url = req.originalUrl.replace(/^\/stories/, '/news');
|
||||
return res.redirect(url);
|
||||
}
|
||||
|
||||
function hotJSON(req, res, next) {
|
||||
storiesData$.subscribe(
|
||||
stories => res.json(stories),
|
||||
next
|
||||
);
|
||||
}
|
||||
|
||||
function RSSFeed(req, res, next) {
|
||||
storiesData$.subscribe(
|
||||
data => {
|
||||
res.set('Content-Type', 'text/xml');
|
||||
res.render('news/feed', {
|
||||
title: 'FreeCodeCamp Camper News RSS Feed',
|
||||
description: 'RSS Feed for FreeCodeCamp Top 100 Hot Camper News',
|
||||
url: 'http://www.freecodecamp.com/news',
|
||||
FeedPosts: data
|
||||
});
|
||||
},
|
||||
next
|
||||
);
|
||||
}
|
||||
|
||||
function returnIndividualStory(req, res, next) {
|
||||
var dashedName = req.params.storyName;
|
||||
var storyName = unDasherize(dashedName);
|
||||
|
||||
findOneStory({ where: { storyLink: storyName } }).subscribe(
|
||||
function(story) {
|
||||
if (!story) {
|
||||
req.flash('errors', {
|
||||
msg: "404: We couldn't find a story with that name. " +
|
||||
'Please double check the name.'
|
||||
});
|
||||
return res.redirect('/news');
|
||||
}
|
||||
|
||||
var dashedNameFull = story.storyLink.toLowerCase()
|
||||
.replace(/\s+/g, ' ')
|
||||
.replace(/\s/g, '-');
|
||||
|
||||
if (dashedNameFull !== dashedName) {
|
||||
return res.redirect('../stories/' + dashedNameFull);
|
||||
}
|
||||
|
||||
return res.render('news/index', {
|
||||
title: story.headline || 'news',
|
||||
link: story.link,
|
||||
originalStoryLink: dashedName,
|
||||
author: story.author,
|
||||
rank: story.upVotes.length,
|
||||
id: story.id,
|
||||
timeAgo: moment(story.timePosted).fromNow(),
|
||||
image: story.image,
|
||||
storyMetaDescription: story.metaDescription
|
||||
});
|
||||
},
|
||||
next
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -103,7 +103,7 @@ block content
|
|||
a.close(href='#', data-dismiss='modal', aria-hidden='true') ×
|
||||
h3 You don't really want to delete your account, do you?
|
||||
.modal-body
|
||||
p This will really delete all your data, including all your progress, news stories and brownie points.
|
||||
p This will really delete all your data, including all your progress and brownie points.
|
||||
p We won't be able to recover any of it for you later, even if you change your mind.
|
||||
p If there's something we could do better, send us an email instead and we'll do our best:  
|
||||
a(href="mailto:team@freecodecamp.com") team@freecodecamp.com
|
||||
|
@ -115,4 +115,4 @@ block content
|
|||
form(action='/account/delete', method='POST')
|
||||
input(type='hidden', name='_csrf', value=_csrf)
|
||||
button.btn.btn-danger.btn-block(type='submit')
|
||||
| I am 100% sure I want to delete my account and all of my progress
|
||||
| I am 100% sure I want to delete my account and all of my progress
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
extends ../layout
|
||||
block content
|
||||
h1.text-center We have discontinued Camper News.
|
||||
h2.text-center We are now using our subreddit instead.
|
||||
h3.text-center Here is a 
|
||||
a(href='https://www.reddit.com/r/FreeCodeCamp/search?sort=top&q=flair%3AArticle&restrict_sr=on&t=week' target='_blank') Camper News-like way to use our subreddit
|
||||
| .
|
|
@ -1,15 +0,0 @@
|
|||
doctype xml
|
||||
rss(version="2.0", xmlns:atom="http://www.w3.org/2005/Atom")
|
||||
channel
|
||||
title= title
|
||||
link= url
|
||||
description= description
|
||||
atom:link(href="http://www.freecodecamp.com/news/feed", rel="self", type="application/rss+xml")
|
||||
for post in FeedPosts
|
||||
if (post.link).match(/https*:\/\/\w+(\.\w+)*/)
|
||||
item
|
||||
title #{ post.headline.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"') }
|
||||
description <![CDATA[!{ post.metaDescription }]]>
|
||||
pubDate= (new Date(post.timePosted)).toUTCString()
|
||||
link= post.link
|
||||
guid(isPermaLink="false")= post.link
|
|
@ -1,48 +0,0 @@
|
|||
extends ../layout
|
||||
block content
|
||||
h1.text-center Camper News
|
||||
hr
|
||||
.spacer
|
||||
.row
|
||||
.col-xs-12
|
||||
h2 We have discontinued Camper News in favor of our
|
||||
a(href='http://reddit.com/r/freecodecamp')  Subreddit
|
||||
| .
|
||||
h3 Thank you to all of the campers who have contributed links over the past year. Our
|
||||
a(href='http://reddit.com/r/freecodecamp')  Subreddit
|
||||
|   is now the best place to share coding-related links.
|
||||
.spacer
|
||||
hr
|
||||
#search-results
|
||||
.spacer
|
||||
#story-list
|
||||
ul#stories
|
||||
.spacer
|
||||
h3.row
|
||||
.col-xs-2.col-sm-1
|
||||
a(href="/" + author.username)
|
||||
img(src="#{author.picture}", class='img-news')
|
||||
.col-xs-10.col-sm-10
|
||||
.col-xs-12.negative-28
|
||||
a(href="#{link}", target="_blank")
|
||||
h3= title
|
||||
h6
|
||||
.col-xs-12.positive-15.hidden-element#image-display
|
||||
.media
|
||||
.media-left
|
||||
img.url-preview.media-object(src="#{image}", alt="#{storyMetaDescription}")
|
||||
.media-body
|
||||
.col-xs-12.col-sm-12.col-md-6
|
||||
h4= storyMetaDescription
|
||||
.col-xs-12
|
||||
.spacer
|
||||
span#storyRank= rank + (rank > 1 ? " points" : " point")
|
||||
|  · 
|
||||
span Posted #{timeAgo}
|
||||
span  by 
|
||||
a(href="/" + author.username) @#{author.username}
|
||||
|
||||
script.
|
||||
if (image) {
|
||||
$('#image-display').removeClass('hidden-element')
|
||||
}
|
|
@ -60,4 +60,3 @@ link(rel="mstile", sizes="310x150", href="https://s3.amazonaws.com/freecodecamp/
|
|||
link(rel="mstile", sizes="70x70", href="https://s3.amazonaws.com/freecodecamp/favicons/mstile-70x70.png")
|
||||
link(rel="favicon", href="https://s3.amazonaws.com/freecodecamp/favicons/favicon.ico")
|
||||
link(rel='shortcut icon', href='//s3.amazonaws.com/freecodecamp/favicons/favicon.ico')
|
||||
link(rel="alternate" type="application/rss+xml" title="RSS Feed for FreeCodeCamp Camper News" href="http://www.freecodecamp.com/news/feed")
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -56,13 +56,6 @@ urlset(xmlns="http://www.sitemaps.org/schemas/sitemap/0.9")
|
|||
changefreq weekly
|
||||
priority= 0.9
|
||||
|
||||
each story in stories
|
||||
url
|
||||
loc #{appUrl}/news/#{story}
|
||||
lastmod= now
|
||||
changefreq monthly
|
||||
priority= 0.5
|
||||
|
||||
each job in jobs
|
||||
url
|
||||
loc #{appUrl}/jobs/#{job}
|
||||
|
|
Loading…
Reference in New Issue