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.

- + diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index b8ec5c762..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)) } } } @@ -121,14 +121,16 @@ class CommentStream extends Component {
- +
- + { + // + } @@ -149,14 +151,16 @@ class CommentStream extends Component {
- +
- + { + // + } diff --git a/client/coral-embed-stream/style/default.css b/client/coral-embed-stream/style/default.css index 9cf0fa3e8..e1c730bfc 100644 --- a/client/coral-embed-stream/style/default.css +++ b/client/coral-embed-stream/style/default.css @@ -122,4 +122,5 @@ hr { .coral-plugin-pubdate-text { color: #CCC; + display: inline-block; } 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') diff --git a/client/coral-framework/store/actions/items.js b/client/coral-framework/store/actions/items.js index 443a41e94..8b30e2548 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 } } @@ -91,8 +92,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. */ @@ -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) @@ -185,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-framework/store/reducers/items.js b/client/coral-framework/store/reducers/items.js index 2bba3bf1b..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.push(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-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 } } diff --git a/client/coral-plugin-commentbox/CommentBox.js b/client/coral-plugin-commentbox/CommentBox.js index b7d282f10..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) + 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: ''}) diff --git a/client/coral-plugin-commentcontent/CommentContent.js b/client/coral-plugin-commentcontent/CommentContent.js index ed3865f8a..7cf2e1652 100644 --- a/client/coral-plugin-commentcontent/CommentContent.js +++ b/client/coral-plugin-commentcontent/CommentContent.js @@ -1,10 +1,17 @@ import React from 'react' const name = 'coral-plugin-replies' -const Content = (props) =>
- {props.content} -
+const Content = ({body, styles}) => { + const textbreaks = body.split('\n') + return
+ { + textbreaks.map((line, i) => + {line}
+
) + } +
+} export default Content