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