From 9c3957ad4097475a882da4c18551d4ce888b6530 Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 16:47:03 -0500 Subject: [PATCH 1/9] Getting pym via https --- client/coral-embed-stream/public/samplearticle.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-embed-stream/public/samplearticle.html b/client/coral-embed-stream/public/samplearticle.html index e973ee9be..64c3fd0f8 100644 --- a/client/coral-embed-stream/public/samplearticle.html +++ b/client/coral-embed-stream/public/samplearticle.html @@ -7,7 +7,7 @@

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut lobortis sollicitudin eros a ornare. Curabitur dignissim vestibulum massa non rhoncus. Cras laoreet ante vel nunc hendrerit, ac imperdiet neque egestas. Suspendisse aliquet iaculis fermentum. Pellentesque interdum nec elit sed tincidunt. Donec volutpat, tellus posuere laoreet consequat, mi lacus laoreet massa, sed vehicula mauris velit non lectus. Integer non enim nec neque congue faucibus porttitor sit amet dui.

Nunc pharetra orci id diam feugiat, vitae rutrum magna efficitur. Morbi porttitor blandit lorem, et facilisis tellus luctus at. Morbi tincidunt eget nisl id placerat. Nullam consectetur quam vel mauris lacinia, non consectetur est faucibus. Duis cursus auctor nulla nec sagittis. Aenean sem erat, ultrices a hendrerit consectetur, accumsan non lorem. Integer ac neque sed magna sodales vulputate at quis neque. Praesent eget ornare lacus. Donec ultricies, dolor eget commodo faucibus, arcu velit ullamcorper tellus, in cursus tellus elit sed urna. Suspendisse in consequat magna. Duis vel ullamcorper tortor, vel cursus libero. Proin et nisi luctus ligula faucibus luctus. Morbi pulvinar, justo ac feugiat elementum, libero tellus congue justo, pharetra ultrices felis felis id leo. Integer mattis quam tempus libero porta, ac pretium ligula elementum.

- + From 3bdd1893e035cb309edf5c3afbbb6f41e520348a Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 16:48:57 -0500 Subject: [PATCH 2/9] Commenting out flag button. --- .../coral-embed-stream/src/CommentStream.js | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index b8ec5c762..47a57200e 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -123,12 +123,14 @@ class CommentStream extends Component {
- + { + // + } @@ -151,12 +153,14 @@ class CommentStream extends Component {
- + { + // + } From c5d15eed779ba6400a9b58b5727bcfd8f4903dca Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 16:54:52 -0500 Subject: [PATCH 3/9] Fixing bug in reply counting. --- client/coral-plugin-comment-count/CommentCount.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-plugin-comment-count/CommentCount.js b/client/coral-plugin-comment-count/CommentCount.js index 6c3b2e5eb..01a5c602b 100644 --- a/client/coral-plugin-comment-count/CommentCount.js +++ b/client/coral-plugin-comment-count/CommentCount.js @@ -10,7 +10,7 @@ const CommentCount = ({items, id}) => { const itemKeys = Object.keys(items) for (var i=0; i < itemKeys.length; i++) { const item = items[itemKeys[i]] - if (item.type === 'comment' && item.children) { + if (item.children) { count += item.children.length } } From 4f3381815365afecc43efd7cf850bce82b69988f Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 17:12:20 -0500 Subject: [PATCH 4/9] Posting items in reverse chronological order. --- client/coral-framework/store/actions/items.js | 4 ++-- client/coral-framework/store/reducers/items.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index 443a41e94..351986ce2 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -91,8 +91,8 @@ export function getStream (assetId) { /* Sort comments by date*/ let rootComments = [] let childComments = {} - const sorted = json.sort((a,b) => b.created_at - a.created_at) - sorted.reduce((prev, item) => { + json.sort((a,b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()) + json.reduce((prev, item) => { dispatch(addItem(item)) /* Check for root and child comments. */ diff --git a/client/coral-framework/store/reducers/items.js b/client/coral-framework/store/reducers/items.js index 2bba3bf1b..8242ddcb3 100644 --- a/client/coral-framework/store/reducers/items.js +++ b/client/coral-framework/store/reducers/items.js @@ -15,7 +15,7 @@ export default (state = initialState, action) => { ) case actions.APPEND_ITEM_ARRAY: return state.updateIn([action.id, action.property], (prop) => { - return prop ? prop.push(action.value) : fromJS([action.value]) + return prop ? prop.unshift(action.value) : fromJS([action.value]) } ) default: From f1f051e63f928072a7d157b04f54cd6b33bda486 Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 17:29:49 -0500 Subject: [PATCH 5/9] Copying over files in dev webpack --- client/coral-embed-stream/webpack.config.dev.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/client/coral-embed-stream/webpack.config.dev.js b/client/coral-embed-stream/webpack.config.dev.js index 250276915..dd5534529 100644 --- a/client/coral-embed-stream/webpack.config.dev.js +++ b/client/coral-embed-stream/webpack.config.dev.js @@ -1,5 +1,6 @@ var path = require('path') var webpack = require('webpack') +const Copy = require('copy-webpack-plugin') module.exports = { devtool: 'eval', @@ -21,6 +22,16 @@ module.exports = { extensions: ['', '.js', '.jsx'] }, plugins: [ + new Copy([{ + from: path.join(__dirname, 'index.html') + }, + { + from: path.join(__dirname, 'style', 'default.css') + }, + { + from: path.join(__dirname, 'public'), + to: './' + }]), new webpack.DefinePlugin({ 'process.env': { 'NODE_ENV': JSON.stringify('development') From 47bcd163b18f9c9aa9336f5d06f0b5342dfef6f7 Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 17:56:44 -0500 Subject: [PATCH 6/9] Showing comments in chronological order. --- client/coral-framework/store/actions/items.js | 7 ++++--- client/coral-framework/store/reducers/items.js | 7 ++++++- client/coral-plugin-commentbox/CommentBox.js | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index 351986ce2..0b23098bb 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -56,12 +56,13 @@ export const updateItem = (id, property, value) => { } } -export const appendItemArray = (id, property, value) => { +export const appendItemArray = (id, property, value, addToFront) => { return { type: APPEND_ITEM_ARRAY, id, property, - value + value, + addToFront } } @@ -115,7 +116,7 @@ export function getStream (assetId) { const keys = Object.keys(childComments) for (var i=0; i < keys.length; i++ ) { - dispatch(updateItem(keys[i], 'children', childComments[keys[i]])) + dispatch(updateItem(keys[i], 'children', childComments[keys[i]].reverse())) } return (json) diff --git a/client/coral-framework/store/reducers/items.js b/client/coral-framework/store/reducers/items.js index 8242ddcb3..d3eb4d3af 100644 --- a/client/coral-framework/store/reducers/items.js +++ b/client/coral-framework/store/reducers/items.js @@ -15,7 +15,12 @@ export default (state = initialState, action) => { ) case actions.APPEND_ITEM_ARRAY: return state.updateIn([action.id, action.property], (prop) => { - return prop ? prop.unshift(action.value) : fromJS([action.value]) + if (action.addToFront) { + return prop ? prop.unshift(action.value) : fromJS([action.value]) + } else { + return prop ? prop.push(action.value) : fromJS([action.value]) + } + } ) default: diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index b7d282f10..c763cb82a 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -35,7 +35,7 @@ class CommentBox extends Component { updateItem(parent_id, 'showReply', false) postItem(comment, 'comments') .then((comment_id) => { - appendItemArray(parent_id || id, related, comment_id) + appendItemArray(parent_id || id, related, comment_id, parent_id ? true : false) addNotification('success', 'Your comment has been posted.') }).catch((err) => console.error(err)) this.setState({body: ''}) From 456524e4ee022f877e56fbd6ad1be74c8c6c0bdb Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 18:09:26 -0500 Subject: [PATCH 7/9] Adding multiline comments. --- client/coral-embed-stream/src/CommentStream.js | 4 ++-- client/coral-embed-stream/style/default.css | 1 + .../CommentContent.js | 17 ++++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 47a57200e..29b9e8361 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -121,7 +121,7 @@ class CommentStream extends Component {
- +
{ // - +
{ //
- {props.content} -
+const Content = ({body, styles}) => { + const textbreaks = body.split('\n') + return
+ { + textbreaks.map((line, i) => + {line}
+
) + } +
+} export default Content From e7f4f82f66c5b1d16f41bc18fed64007c0924729 Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 18:41:07 -0500 Subject: [PATCH 8/9] Fixing comment post order bug. --- client/coral-embed-stream/src/CommentStream.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 29b9e8361..cda7ffd57 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -54,8 +54,8 @@ const {setLoggedInUser} = authActions postAction: (item, action, user) => { return dispatch(postAction(item, action, user)) }, - appendItemArray: (item, property, value) => { - return dispatch(appendItemArray(item, property, value)) + appendItemArray: (item, property, value, addToFront) => { + return dispatch(appendItemArray(item, property, value, addToFront)) } } } From 33c77178a90bf276c50acddbe040b39ae8d8072a Mon Sep 17 00:00:00 2001 From: David Jay Date: Mon, 7 Nov 2016 18:41:23 -0500 Subject: [PATCH 9/9] Fixing id bug in redux store. --- client/coral-framework/store/actions/items.js | 8 ++++---- client/coral-plugin-commentbox/CommentBox.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index 0b23098bb..8b30e2548 100644 --- a/client/coral-framework/store/actions/items.js +++ b/client/coral-framework/store/actions/items.js @@ -186,13 +186,13 @@ export function postItem (item, type, id) { return fetch('/api/v1/' + type, options) .then( response => { - return response.ok ? response.text() + return response.ok ? response.json() : Promise.reject(response.status + ' ' + response.statusText) } ) - .then((id) => { - dispatch(addItem({...item, id})) - return id + .then((json) => { + dispatch(addItem({...item, id:json.id})) + return json.id }) } } diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index c763cb82a..0f1578859 100644 --- a/client/coral-plugin-commentbox/CommentBox.js +++ b/client/coral-plugin-commentbox/CommentBox.js @@ -35,7 +35,7 @@ class CommentBox extends Component { updateItem(parent_id, 'showReply', false) postItem(comment, 'comments') .then((comment_id) => { - appendItemArray(parent_id || id, related, comment_id, parent_id ? true : false) + appendItemArray(parent_id || id, related, comment_id, parent_id ? false : true) addNotification('success', 'Your comment has been posted.') }).catch((err) => console.error(err)) this.setState({body: ''})