Story submission now with a description, refactor show to display description above comment box
This commit is contained in:
5
app.js
5
app.js
@ -327,6 +327,11 @@ app.post(
|
|||||||
storyController.newStory
|
storyController.newStory
|
||||||
);
|
);
|
||||||
|
|
||||||
|
app.post(
|
||||||
|
'/stories/',
|
||||||
|
storyController.storySubmission
|
||||||
|
);
|
||||||
|
|
||||||
app.get(
|
app.get(
|
||||||
'/stories/hot',
|
'/stories/hot',
|
||||||
storyController.hot
|
storyController.hot
|
||||||
|
@ -54,12 +54,17 @@ exports.recent = function(req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.preSubmit = function(req, res, next) {
|
exports.preSubmit = function(req, res, next) {
|
||||||
|
debug('req params is', req.params);
|
||||||
var data = req.params.newStory;
|
var data = req.params.newStory;
|
||||||
debug('got presubmission with info', data.url, data.title);
|
|
||||||
|
data = data.replace(/url=/gi, '').replace(/&title=/gi, ',').split(',');
|
||||||
|
var url = data[0];
|
||||||
|
var title = data[1];
|
||||||
|
debug('result of really ugly string manipulation', url, title);
|
||||||
res.render('stories/index', {
|
res.render('stories/index', {
|
||||||
page: 'storySubmission',
|
page: 'storySubmission',
|
||||||
storyURL: data.url,
|
storyURL: url,
|
||||||
storyTitle: data.title
|
storyTitle: title
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -92,7 +97,7 @@ exports.returnIndividualStory = function(req, res, next) {
|
|||||||
}
|
}
|
||||||
debug('Story', story);
|
debug('Story', story);
|
||||||
|
|
||||||
res.render('stories/show', {
|
res.render('stories/index', {
|
||||||
title: story.headline,
|
title: story.headline,
|
||||||
link: story.link,
|
link: story.link,
|
||||||
author: story.author,
|
author: story.author,
|
||||||
@ -103,7 +108,8 @@ exports.returnIndividualStory = function(req, res, next) {
|
|||||||
id: story._id,
|
id: story._id,
|
||||||
user: req.user,
|
user: req.user,
|
||||||
timeAgo: moment(story.timePosted).fromNow(),
|
timeAgo: moment(story.timePosted).fromNow(),
|
||||||
image: story.image
|
image: story.image,
|
||||||
|
page: 'show'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -150,9 +150,11 @@ $(document).ready(function() {
|
|||||||
$('#upvote').on('click', upvoteHandler);
|
$('#upvote').on('click', upvoteHandler);
|
||||||
|
|
||||||
var storySubmitButtonHandler = function storySubmitButtonHandler() {
|
var storySubmitButtonHandler = function storySubmitButtonHandler() {
|
||||||
var data = $('#story-submission-form :input');
|
|
||||||
var link = $(data[0]).val();
|
var link = $('#story-url').val();
|
||||||
var headline = $(data[1]).val();
|
var headline = $('#story-title').val();
|
||||||
|
var description = $('#description-box').val();
|
||||||
|
console.log(link, headline, description);
|
||||||
var userDataForUpvote = {
|
var userDataForUpvote = {
|
||||||
upVotedBy: user._id,
|
upVotedBy: user._id,
|
||||||
upVotedByUsername: user.profile.username
|
upVotedByUsername: user.profile.username
|
||||||
@ -164,7 +166,7 @@ $(document).ready(function() {
|
|||||||
link: link,
|
link: link,
|
||||||
headline: headline,
|
headline: headline,
|
||||||
timePosted: Date.now(),
|
timePosted: Date.now(),
|
||||||
description: 'TODO',
|
description: description,
|
||||||
|
|
||||||
rank: 1,
|
rank: 1,
|
||||||
upVotes: [userDataForUpvote],
|
upVotes: [userDataForUpvote],
|
||||||
@ -174,7 +176,7 @@ $(document).ready(function() {
|
|||||||
username: user.profile.username
|
username: user.profile.username
|
||||||
},
|
},
|
||||||
comments: [],
|
comments: [],
|
||||||
image: 'http://rossmounce.co.uk/wp-content/uploads/2014/11/grumpy-cat-no-1.jpg'
|
image: ''
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.fail(function (xhr, textStatus, errorThrown) {
|
.fail(function (xhr, textStatus, errorThrown) {
|
||||||
|
@ -20,5 +20,5 @@ block content
|
|||||||
include ./search-stories
|
include ./search-stories
|
||||||
if (page === 'storySubmission')
|
if (page === 'storySubmission')
|
||||||
include ./submit-story
|
include ./submit-story
|
||||||
if (page === 'storyShow')
|
if (page === 'show')
|
||||||
include ./show
|
include ./show
|
@ -6,12 +6,13 @@
|
|||||||
label.btn.btn-primary.btn-big(class="#{ page === 'recent' ? 'active' : '' }")
|
label.btn.btn-primary.btn-big(class="#{ page === 'recent' ? 'active' : '' }")
|
||||||
input#option2(href='/stories/recent', type='radio', name='options')
|
input#option2(href='/stories/recent', type='radio', name='options')
|
||||||
| New
|
| New
|
||||||
label.btn.btn-primary.btn-big(class="#{ page === 'submit' ? 'active' : '' }")
|
label.btn.btn-primary.btn-big(class="#{ page === 'submit' ? 'active' : page === 'storySubmission' ? 'active' : '' }")
|
||||||
input#option3(href='/stories/submit', type='radio', name='options')
|
input#option3(href='/stories/submit', type='radio', name='options')
|
||||||
| Submit
|
| Submit
|
||||||
label.btn.btn-primary.btn-big(class="#{ page === 'search' ? 'active' : '' }")
|
label.btn.btn-primary.btn-big(class="#{ page === 'search' ? 'active' : '' }")
|
||||||
input#option4(href='/stories/search', type='radio', name='options')
|
input#option4(href='/stories/search', type='radio', name='options')
|
||||||
| Search
|
| Search
|
||||||
|
|
||||||
script.
|
script.
|
||||||
$('label').on('click', function() {
|
$('label').on('click', function() {
|
||||||
window.location = ($(this).children('input').attr('href'));
|
window.location = ($(this).children('input').attr('href'));
|
||||||
|
@ -6,35 +6,36 @@ block content
|
|||||||
var comments = !{JSON.stringify(comments)};
|
var comments = !{JSON.stringify(comments)};
|
||||||
var upVotes = !{JSON.stringify(upVotes)};
|
var upVotes = !{JSON.stringify(upVotes)};
|
||||||
var user = !{JSON.stringify(user)};
|
var user = !{JSON.stringify(user)};
|
||||||
|
.spacer
|
||||||
|
|
||||||
.panel.panel-info
|
.row.col-xs-12
|
||||||
.panel-heading.text-center Camper News
|
h3.row.text-left.negative-10
|
||||||
.panel-body
|
.col-xs-3.col-sm-1.text-center
|
||||||
h3.row.text-left.negative-10
|
.row.negative-5
|
||||||
.col-xs-3.col-sm-1.text-center
|
.col-xs-12.big-ion-up-arrow
|
||||||
.row.negative-5
|
a#upvote
|
||||||
.col-xs-12.big-ion-up-arrow
|
i.ion-arrow-up-b
|
||||||
a#upvote
|
h3.story-up-votes
|
||||||
i.ion-arrow-up-b
|
span#storyRank= rank
|
||||||
h3.story-up-votes
|
.col-xs-2.col-sm-1
|
||||||
span#storyRank= rank
|
img(src="#{author.picture}", class='img-responsive')
|
||||||
.col-xs-2.col-sm-1
|
.col-xs-7.col-sm-10
|
||||||
img(src="#{author.picture}", class='img-responsive')
|
.col-xs-12.negative-28
|
||||||
.col-xs-7.col-sm-10
|
a(href="#{link}")
|
||||||
.col-xs-12.negative-28
|
h3= title
|
||||||
a(href="#{link}")
|
h6
|
||||||
h3= title
|
|
||||||
.col-xs-12.negative-15
|
.col-xs-12.negative-15
|
||||||
span Posted #{timeAgo}
|
span Posted #{timeAgo}
|
||||||
span by
|
span by
|
||||||
a(href="/" + author.username)
|
a(href="/" + author.username)
|
||||||
@#{author.username}
|
@#{author.username}
|
||||||
|
.col-xs-10.col-xs-offset-1
|
||||||
|
p= description
|
||||||
|
|
||||||
|
|
||||||
.col-xs-12
|
.col-xs-12
|
||||||
h3.row
|
h3.row.col-xs-12
|
||||||
.col-xs-12
|
textarea#comment-box.form-control(name="comment-box", rows=5)
|
||||||
textarea#comment-box.form-control(name="comment-box", rows=5)
|
|
||||||
h3.row.btn-nav.text-center
|
h3.row.btn-nav.text-center
|
||||||
.col-xs-6.col-xs-offset-3
|
.col-xs-6.col-xs-offset-3
|
||||||
.btn.btn-block.btn-primary#comment-button Comment
|
.btn.btn-block.btn-primary#comment-button Comment
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
label.control-label.control-label-story-submission(for='name') Title
|
label.control-label.control-label-story-submission(for='name') Title
|
||||||
.col-xs-11
|
.col-xs-11
|
||||||
input#story-title.form-control(placeholder='Type a headline for your link here', name='Title')
|
input#story-title.form-control(placeholder='Type a headline for your link here', name='Title')
|
||||||
|
.form-group
|
||||||
|
.col-xs-1
|
||||||
|
label.control-label.control-label-story-submission(for='name')
|
||||||
|
.col-xs-11
|
||||||
|
textarea#description-box.form-control(name="comment-box", rows=5, placeholder="Start off the discussion with a description of your post")
|
||||||
|
|
||||||
.spacer
|
.spacer
|
||||||
.form-group
|
.form-group
|
||||||
.btn.btn-big.btn-block.btn-primary#story-submit Submit
|
.btn.btn-big.btn-block.btn-primary#story-submit Submit
|
||||||
|
Reference in New Issue
Block a user