Fix news jade pages

Remove unused pages
This commit is contained in:
Berkeley Martinez
2016-04-07 10:12:29 -07:00
parent 0d0f4253ec
commit 258597f053
11 changed files with 57 additions and 402 deletions

View File

@ -43,7 +43,6 @@ module.exports = function(app) {
router.get('/how-nonprofit-projects-work', howNonprofitProjectsWork); router.get('/how-nonprofit-projects-work', howNonprofitProjectsWork);
router.get('/code-of-conduct', codeOfConduct); router.get('/code-of-conduct', codeOfConduct);
router.get('/academic-honesty', academicHonesty); router.get('/academic-honesty', academicHonesty);
router.get('/news', news);
router.get( router.get(
'/the-fastest-web-page-on-the-internet', '/the-fastest-web-page-on-the-internet',
@ -285,12 +284,6 @@ module.exports = function(app) {
}); });
} }
function news(req, res) {
res.render('resources/camper-news-deprecated', {
title: 'Camper News'
});
}
function twitch(req, res) { function twitch(req, res) {
res.redirect('https://twitch.tv/freecodecamp'); res.redirect('https://twitch.tv/freecodecamp');
} }

View File

@ -41,6 +41,7 @@ module.exports = function(app) {
const redirectToNews = (req, res) => res.redirect('/news'); const redirectToNews = (req, res) => res.redirect('/news');
const deprecated = (req, res) => res.sendStatus(410); const deprecated = (req, res) => res.sendStatus(410);
router.get('/news', showNews);
router.post('/news/userstories', deprecated); router.post('/news/userstories', deprecated);
router.get('/news/hot', hotJSON); router.get('/news/hot', hotJSON);
router.get('/news/feed', RSSFeed); router.get('/news/feed', RSSFeed);
@ -56,6 +57,10 @@ module.exports = function(app) {
app.use(router); app.use(router);
function showNews(req, res) {
res.render('news/deprecated', { title: 'Camper News' });
}
function replaceStoryWithNews(req, res) { function replaceStoryWithNews(req, res) {
var url = req.originalUrl.replace(/^\/stories/, '/news'); var url = req.originalUrl.replace(/^\/stories/, '/news');
return res.redirect(url); return res.redirect(url);
@ -72,7 +77,7 @@ module.exports = function(app) {
storiesData$.subscribe( storiesData$.subscribe(
data => { data => {
res.set('Content-Type', 'text/xml'); res.set('Content-Type', 'text/xml');
res.render('feed', { res.render('news/feed', {
title: 'FreeCodeCamp Camper News RSS Feed', title: 'FreeCodeCamp Camper News RSS Feed',
description: 'RSS Feed for FreeCodeCamp Top 100 Hot Camper News', description: 'RSS Feed for FreeCodeCamp Top 100 Hot Camper News',
url: 'http://www.freecodecamp.com/news', url: 'http://www.freecodecamp.com/news',
@ -105,25 +110,16 @@ module.exports = function(app) {
return res.redirect('../stories/' + dashedNameFull); return res.redirect('../stories/' + dashedNameFull);
} }
var username = req.user ? req.user.username : ''; return res.render('news/index', {
// true if any of votes are made by user title: story.headline || 'news',
var userVoted = story.upVotes.some(function(upvote) {
return upvote.upVotedByUsername === username;
});
return res.render('stories/index', {
title: story.headline,
link: story.link, link: story.link,
originalStoryLink: dashedName, originalStoryLink: dashedName,
author: story.author, author: story.author,
rank: story.upVotes.length, rank: story.upVotes.length,
upVotes: story.upVotes,
id: story.id, id: story.id,
timeAgo: moment(story.timePosted).fromNow(), timeAgo: moment(story.timePosted).fromNow(),
image: story.image, image: story.image,
page: 'show', storyMetaDescription: story.metaDescription
storyMetaDescription: story.metaDescription,
hasUserVoted: userVoted
}); });
}, },
next next

View File

@ -0,0 +1,48 @@
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')
}

View File

@ -1,90 +0,0 @@
.spacer
.spacer
#story-list.story-list
script.
var getLinkedName = function getLinkedName(name) {
return name.trim().toLowerCase().replace(/\s/g, '-');
}
$.ajax({
url: '/news/hot',
type: 'GET'
})
.success(
function(data) {
for (var i = 0; i < data.length; i++) {
var div = document.createElement('div');
var linkedName = getLinkedName(data[i].storyLink);
var rank = data[i].rank;
var alreadyUpvoted = false;
if (typeof username !== 'undefined') {
alreadyUpvoted = data[i].upVotes.some(function(vote) {
return vote.upVotedByUsername === username
});
}
$(div)
.html(
"<div class='visible-xs row'>" +
"<div class='visible-xs col-sm-1 col-md-1'>" +
"<a href='" + data[i].link + "'>" +
"<img class='mobile-story-image img-responsive' src='" + (!!data[i].image ? data[i].image : data[i].author.picture) + "'/>" +
"</a>" +
"</div>" +
"<div class='col-xs-12 mobile-story-headline text-center'>" +
"<a href='" + data[i].link + "' target='_blank'>" +
data[i].headline +
"</a>" +
"</div>" +
"<div class='col-xs-12 text-center'>" +
rank + (rank > 1 ? " points" : " point") + " · posted " +
moment(data[i].timePosted).fromNow() +
" by <a href='/" + data[i].author.username + "'>@" + data[i].author.username + "</a> " +
"</div>" +
"<div class='col-xs-12'>" +
"<br>" +
(typeof username !== 'undefined' ?
"<button id='" + data[i].id + "' class='btn btn-no-shadow btn-primary btn-block btn-primary-ghost btn-upvote'>upvote</button>" :
"<a href='/signin' class='btn btn-no-shadow btn-primary btn-block btn-primary-ghost btn-upvote'>upvote</a>") +
"<a class='btn btn-no-shadow btn-primary btn-block btn-primary-ghost hidden' href='/news/" + linkedName + "'>more info</a>" +
"</div>" +
"</div>" +
"<div class='hidden-xs row media-stories'>" +
"<div class='media'>" +
"<div class='media-left'>" +
"<a href='/" + data[i].author.username + "'>" +
"<img class='img-news' src='" + data[i].author.picture + "'/>" +
"</a>" +
"</div>" +
"<h2 class='media-body'>" +
"<div class='media-body-wrapper'>" +
"<div class='story-headline'>" +
"<a href='" + data[i].link + "' target='_blank'>" +
data[i].headline +
"</a>" +
"</div>" +
"<div class='story-byline col-xs-12 wrappable'>" +
(typeof username !== 'undefined' ?
"<button id='" + data[i].id + "' class='btn btn-no-shadow btn-primary btn-xs btn-primary-ghost btn-upvote'>upvote</button>" :
"<a href='/signin' class='btn btn-no-shadow btn-primary btn-xs btn-primary-ghost'>upvote</a>") +
"<a class='btn btn-no-shadow btn-primary btn-xs btn-primary-ghost hidden' href='/news/" + linkedName + "'>more info</a> &nbsp; " +
rank + (rank > 1 ? " points" : " point") + " · posted " +
moment(data[i].timePosted).fromNow() +
" by <a href='/" + data[i].author.username + "'>@" + data[i].author.username + "</a> " +
"</div>" +
"</div>" +
"</h2>" +
"</div>" +
"</div>"
);
$(div).addClass('story-list news-box')
$(div).appendTo($('#story-list'));
$(div).find('.btn-upvote').each(function(idx, btn) {
var $btn = $(btn);
if (alreadyUpvoted) {
$btn.addClass('disabled');
$btn.text('upvoted!');
}
$btn.data('upVotes', data[i].upVotes);
});
}
});

View File

@ -1,32 +0,0 @@
extends ../layout
block content
if (user)
script.
var isLoggedIn = true;
var userId = !{JSON.stringify(user.id)};
var username = !{JSON.stringify(user.username)};
else
script.
var isLoggedIn = false;
script.
var challengeName = 'Camper News';
var page = !{JSON.stringify(page)};
h1.text-center Camper News
hr
.spacer
include news-nav
.spacer
if (page === 'hot')
include hot-stories
if (page === 'submit')
if (user)
include preliminary-submit
else
.spacer
.text-center
a.btn.btn-cta.signup-btn.btn-primary(href="/login") Sign in to post your story (it's free)
.spacer
if (page === 'storySubmission')
include submit-story
if (page === 'show')
include show

View File

@ -1,127 +0,0 @@
.row
.col-xs-12
h2 We are retiring 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. We will keep Camper News accessible until May. Our
a(href='http://reddit.com/r/freecodecamp') Subreddit
| &thinsp; is now the best place to share coding-related links.
.spacer
hr
.spacer
.col-xs-12.col-sm-3
span
a.btn.btn-primary.btn-bigger.btn-block.btn-responsive(href='/stories/submit' class="#{ page === 'hot' ? '' : 'hidden' }") Submit a link
span
a.btn.btn-success.btn-bigger.btn-block.btn-responsive(href='/news/' class="#{ (page !== 'hot') ? '' : 'hidden' }") All
.visible-xs
.button-spacer
.col-xs-12.col-sm-9
.input-group
input#searchArea.big-text-field.field-responsive.form-control(type='text', placeholder='Search term or @username')
span.input-group-btn
button#searchbutton.btn.btn-bigger.btn-primary.btn-responsive(type='button') Search
.spacer
#search-results
.spacer
#story-list
ul#stories
script.
$('#searchArea').keypress(function (event) {
if (event.keyCode === 13 || event.which === 13) {
executeSearch();
$('#searchArea').focus();
event.preventDefault();
}
});
$('#searchbutton').on('click', function () {
executeSearch();
});
function executeSearch() {
$('#stories').empty();
var searchTerm = $('#searchArea').val(),
url = '/stories/search';
if (searchTerm.match(/^\@\w+$/)) {
url = '/news/userstories';
searchTerm = searchTerm.match(/^\@\w+$/)[0].split('@')[1];
}
var getLinkedName = function getLinkedName(name) {
return name.toLowerCase().replace(/\s/g, '-');
}
$.post(url, { search: searchTerm })
.fail(function(xhr, textStatus, errorThrown) {
$('#search-results').empty();
var div = document.createElement("div");
$(div).html("<h3 class='text-center text-warning dotted-underline'><em>No Results Found</em></h3>");
$(div).appendTo($('#search-results'));
})
.done(function(data, textStatus, xhr) {
$('#search-results').empty();
var spacer = document.createElement('div');
$(spacer).html("<div class='spacer'></div>");
$(spacer).appendTo($('#search-results'));
for (var i = 0; i < data.length; i++) {
var div = document.createElement('div');
var linkedName = getLinkedName(data[i].storyLink);
var rank = data[i].rank;
$(div).html(
"<div class='visible-xs row'>" +
"<div class='visible-xs col-sm-1 col-md-1'>" +
"<a href='" + data[i].link + "'>" +
"<img class='mobile-story-image img-responsive' src='" + (!!data[i].image ? data[i].image : data[i].author.picture) + "'/>" +
"</a>" +
"</div>" +
"<div class='col-xs-12 mobile-story-headline text-center'>" +
"<a href='" + data[i].link + "' target='_blank'>" +
data[i].headline +
"</a>" +
"</div>" +
"<div class='visible-xs'>" +
"<div class='col-xs-12 text-center'>" +
rank + (rank > 1 ? " points" : " point") + " · posted " +
moment(data[i].timePosted).fromNow() +
" by " +
"<a href='/" + data[i].author.username + "'>@" + data[i].author.username +
"</a> " +
"</div>" +
"<div class='col-xs-12'>" +
"<br>" +
"<a class='btn btn-no-shadow btn-primary btn-block btn-primary-ghost' href='/news/" + linkedName + "'>more info</a>" +
"</div>" +
"</div>" +
"</div>" +
"<div class='hidden-xs row media-stories'>" +
"<div class='media'>" +
"<div class='media-left'>" +
"<a href='/" + data[i].author.username + "'>" +
"<img class='img-news' src='" + data[i].author.picture + "'/>" +
"</a>" +
"</div>" +
"<h2 class='media-body'>" +
"<div class='media-body-wrapper'>" +
"<div class='story-headline'>" +
"<a href='" + data[i].link + "' target='_blank'>" +
data[i].headline +
"</a>" +
"</div>" +
"<div class='story-byline col-xs-12 wrappable'>" +
"<a class='btn btn-no-shadow btn-primary btn-xs btn-primary-ghost' href='/news/" + linkedName + "'>more info</a> · " +
rank + (rank > 1 ? " points" : " point") + " · posted " +
moment(data[i].timePosted).fromNow() +
" by <a href='/" + data[i].author.username + "'>@" + data[i].author.username +
"</a> " +
"</div>" +
"</div>" +
"</h2>" +
"</div>" +
"</div>")
$(div).addClass('story-list news-box-search')
$(div).appendTo($('#search-results'));
}
var hr = document.createElement("div");
$(hr).html("<h3 class='text-center text-success dotted-underline'><em>End search results</em></h3>")
$(hr).appendTo($('#search-results'));
});
}

View File

@ -1,51 +0,0 @@
form.input-group(id='URLSubmit' name='URLSubmit')
input#story-url.big-text-field.field-responsive.form-control(placeholder='Paste your link here', name='link', type='url', required, autofocus)
span.input-group-btn
button#preliminary-story-submit.btn.btn-bigger.btn-primary.btn-responsive(type='submit') Submit
.spacer
script.
$('#story-url').on('keypress', function(e) {
if (e.keyCode === 13) {
$('#preliminary-story-submit').click();
}
});
function preliminaryStorySubmit(e) {
if (!$('#URLSubmit')[0].checkValidity()) {
return null;
}
e.preventDefault();
var storyURL = $('#story-url').val();
$('#preliminary-story-submit').attr('disabled', 'disabled');
$.post('/stories/preliminary',
{
data: {
url: storyURL
}
})
.fail(function (xhr, textStatus, errorThrown) {
$('#preliminary-story-submit').attr('disabled', false);
})
.done(function (data, textStatus, xhr) {
if (data.alreadyPosted) {
window.location = data.storyURL;
} else {
window.location = '/stories/submit/new-story?url=' +
encodeURIComponent(data.storyURL) +
'&title=' + encodeURIComponent(data.storyTitle) +
'&image=' + encodeURIComponent(data.storyImage) +
'&description=' + encodeURIComponent(data.storyMetaDescription);
}
});
}
$('#preliminary-story-submit').on('click', preliminaryStorySubmit);
arr = $( "h3 input:checked" )
.map(function() {
return this.id;
})
.get()
.join('&');

View File

@ -1,41 +0,0 @@
script.
var storyId = !{JSON.stringify(id)};
var originalStoryLink = !{JSON.stringify(originalStoryLink)};
var upVotes = !{JSON.stringify(upVotes)};
var image = !{JSON.stringify(image)};
var hasUserVoted = !{JSON.stringify(hasUserVoted)};
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
if !hasUserVoted
a#upvote.btn.btn-no-shadow.btn-primary.btn-xs.btn-primary-ghost Upvote
| &thinsp;·&thinsp;
else
a#upvote.btn.disabled.btn-no-shadow.btn-primary.btn-xs.btn-primary-ghost Upvoted!
| &thinsp;·&thinsp;
span#storyRank= rank + (rank > 1 ? " points" : " point")
| &thinsp;·&thinsp;
span Posted #{timeAgo}
span &thinsp;by&thinsp;
a(href="/" + author.username) @#{author.username}
script.
if (image) {
$('#image-display').removeClass('hidden-element')
}

View File

@ -1,41 +0,0 @@
.spacer
.col-xs-12
script.
var main = window.main || { init: [] };
main.storyURL = !{JSON.stringify(storyURL)};
main.storyTitle = !{JSON.stringify(storyTitle)};
main.storyImage = !{JSON.stringify(storyImage)};
main.storyMetaDescription = !{JSON.stringify(storyMetaDescription)};
form.form-horizontal.control-label-story-submission#story-submission-form(name="submitStory")
.col-xs-12
.form-group
.col-xs-12.col-md-1
label.control-label.control-label-story-submission(for='name') Link
.col-xs-12.col-md-11
input#story-url.form-control(name='Link', disabled, value='#{storyURL}')
.form-group
.col-xs-12.col-md-1
label.control-label.control-label-story-submission(for='name') Title
.col-xs-12.col-md-11
input#story-title.form-control(value='#{storyTitle}', name='Title', maxlength='90', autocomplete="off", autofocus, required)
.form-group
.col-xs-12.col-md-offset-1
span.pull-left#textarea_feedback
.form-group
.col-xs-11.col-md-offset-1
.hidden-element#image-display
.media
.media-left
img.url-preview.media-object(src="#{storyImage}", alt="#{storyMetaDescription}")
.media-body
.col-xs-12
p= storyMetaDescription
.spacer
.row
.form-group
button.btn.btn-bigger.btn-block.btn-primary#story-submit(type='submit', onclick="return false;") Submit
script.
if (main.storyImage) {
$('#image-display').removeClass('hidden-element');
}