mirror of
https://github.com/wassname/talk.git
synced 2026-06-30 08:11:21 +08:00
Merge branch 'master' into one-build
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
<p>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.</p>
|
||||
<p>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.</p>
|
||||
<div id='coralStreamEmbed'></div>
|
||||
<script type='text/javascript' src='http://pym.nprapps.org/pym.v1.min.js'></script>
|
||||
<script type='text/javascript' src='https://pym.nprapps.org/pym.v1.min.js'></script>
|
||||
<script>
|
||||
var pymParent = new pym.Parent('coralStreamEmbed', 'index.html', {title: 'comments'});
|
||||
pymParent.onMessage('height', function(height) {document.querySelector('#coralStreamEmbed iframe').height = height + 'px'})</script>
|
||||
|
||||
@@ -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 {
|
||||
<hr aria-hidden={true}/>
|
||||
<AuthorName name={comment.username}/>
|
||||
<PubDate created_at={comment.created_at}/>
|
||||
<Content content={comment.body}/>
|
||||
<Content body={comment.body}/>
|
||||
<div className="commentActions">
|
||||
<Flag
|
||||
addNotification={this.props.addNotification}
|
||||
id={commentId}
|
||||
flag={comment.flag}
|
||||
postAction={this.props.postAction}
|
||||
currentUser={this.props.auth.user}/>
|
||||
{
|
||||
// <Flag
|
||||
// addNotification={this.props.addNotification}
|
||||
// id={commentId}
|
||||
// flag={comment.flag}
|
||||
// postAction={this.props.postAction}
|
||||
// currentUser={this.props.auth.user}/>
|
||||
}
|
||||
<ReplyButton
|
||||
updateItem={this.props.updateItem}
|
||||
id={commentId}/>
|
||||
@@ -149,14 +151,16 @@ class CommentStream extends Component {
|
||||
<hr aria-hidden={true}/>
|
||||
<AuthorName name={reply.username}/>
|
||||
<PubDate created_at={reply.created_at}/>
|
||||
<Content content={reply.body}/>
|
||||
<Content body={reply.body}/>
|
||||
<div className="replyActions">
|
||||
<Flag
|
||||
addNotificiation={this.props.addNotification}
|
||||
id={replyId}
|
||||
flag={reply.flag}
|
||||
postAction={this.props.postAction}
|
||||
currentUser={this.props.auth.user}/>
|
||||
{
|
||||
// <Flag
|
||||
// addNotificiation={this.props.addNotification}
|
||||
// id={replyId}
|
||||
// flag={reply.flag}
|
||||
// postAction={this.props.postAction}
|
||||
// currentUser={this.props.auth.user}/>
|
||||
}
|
||||
<ReplyButton
|
||||
updateItem={this.props.updateItem}
|
||||
parent_id={reply.parent_id}/>
|
||||
|
||||
@@ -122,4 +122,5 @@ hr {
|
||||
|
||||
.coral-plugin-pubdate-text {
|
||||
color: #CCC;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
@@ -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')
|
||||
|
||||
@@ -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
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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: ''})
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
import React from 'react'
|
||||
const name = 'coral-plugin-replies'
|
||||
|
||||
const Content = (props) => <div
|
||||
className={name + '-text'}
|
||||
style={props.styles && props.styles.text}>
|
||||
{props.content}
|
||||
</div>
|
||||
const Content = ({body, styles}) => {
|
||||
const textbreaks = body.split('\n')
|
||||
return <div
|
||||
className={name + '-text'}
|
||||
style={styles && styles.text}>
|
||||
{
|
||||
textbreaks.map((line, i) => <span key={i} className={name+'-line'}>
|
||||
{line} <br className={name+'-linebreak'}/>
|
||||
</span>)
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
export default Content
|
||||
|
||||
Reference in New Issue
Block a user