From 626687f05b92115d44e470e6c25650f874fbc13e Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 7 Nov 2016 14:18:43 -0800 Subject: [PATCH 01/47] Adds moderations queues. --- routes/api/comments/index.js | 57 +++++++++++++++++++++---- tests/routes/api/comments/index.js | 68 ++++++++++++++++++++++++++++++ tests/routes/api/stream/index.js | 1 - 3 files changed, 116 insertions(+), 10 deletions(-) diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index 3acca5b3e..4753b0355 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -1,10 +1,11 @@ const express = require('express'); const Comment = require('../../../models/comment'); +const Action = require('../../../models/action'); const router = express.Router(); //============================================================================== -// Routes +// Get Routes //============================================================================== router.get('/', (req, res, next) => { @@ -23,6 +24,40 @@ router.get('/:comment_id', (req, res, next) => { }); }); +//============================================================================== +// Moderation Queues Routes +//============================================================================== + +router.get('/action/:action_type', (req, res, next) => { + Action.find({'action_type': req.params.action_type, 'item_type': 'comment'}).then((actions) => { + // search all the comments that are in actions by id: item_id + // populate user by user_id + res.status(200).json(actions); + }).catch(error => { + next(error); + }); +}); + +router.get('/status/rejected', (req, res, next) => { + Comment.find({'status': 'rejected'}).then((comments) => { + res.status(200).json(comments); + }).catch(error => { + next(error); + }); +}); + +router.get('/status/pending', (req, res, next) => { + Comment.find({'status': ''}).then((comments) => { + res.status(200).json(comments); + }).catch(error => { + next(error); + }); +}); + +//============================================================================== +// Post Routes +//============================================================================== + router.post('/', (req, res, next) => { const {body, author_id, asset_id, parent_id, status} = req.body; let comment = new Comment({body, author_id, asset_id, parent_id, status}); @@ -48,14 +83,6 @@ router.post('/:comment_id', (req, res, next) => { }); }); -router.delete('/:comment_id', (req, res, next) => { - Comment.remove(req.params.comment_id).then(() => { - res.status(201).send('OK. Deleted'); - }).catch(error => { - next(error); - }); -}); - router.post('/:comment_id/status', (req, res, next) => { Comment.changeStatus(req.params.comment_id, req.body.status).then((comment) => { res.status(200).send(comment); @@ -72,4 +99,16 @@ router.post('/:comment_id/actions', (req, res, next) => { }); }); +//============================================================================== +// Delete Routes +//============================================================================== + +router.delete('/:comment_id', (req, res, next) => { + Comment.remove(req.params.comment_id).then(() => { + res.status(201).send('OK. Deleted'); + }).catch(error => { + next(error); + }); +}); + module.exports = router; diff --git a/tests/routes/api/comments/index.js b/tests/routes/api/comments/index.js index 4fbe52e94..6416d1412 100644 --- a/tests/routes/api/comments/index.js +++ b/tests/routes/api/comments/index.js @@ -66,6 +66,74 @@ describe('Get /comments', () => { }); }); +describe('Get moderation queues rejected, pending', () => { + const comments = [{ + id: 'abc', + body: 'comment 10', + asset_id: 'asset', + author_id: '123', + status: 'rejected' + }, { + id: 'def', + body: 'comment 20', + asset_id: 'asset', + author_id: '456' + }, { + id: 'hij', + body: 'comment 30', + asset_id: '456', + status: 'accepted' + }]; + + const users = [{ + id: '123', + display_name: 'Ana', + }, { + id: '456', + display_name: 'Maria', + }]; + + const actions = [{ + action_type: 'flag', + item_id: 'abc' + }, { + action_type: 'like', + item_id: 'hij' + }]; + + beforeEach(() => { + return Comment.create(comments).then(() => { + return User.create(users); + }).then(() => { + return Action.create(actions); + }); + }); + + it('should return all the rejected comments', function(done){ + chai.request(app) + .get('/api/v1/comments/status/rejected') + .end(function(err, res){ + expect(err).to.be.null; + expect(res).to.have.status(200); + expect(res.body[0]).to.have.property('id'); + expect(res.body[0].id).to.equal('abc'); + done(); + }); + }); + + it('should return all the pending comments', function(done){ + chai.request(app) + .get('/api/v1/comments/status/pending') + .end(function(err, res){ + expect(err).to.be.null; + expect(res).to.have.status(200); + expect(res.body[0]).to.have.property('id'); + expect(res.body[0].id).to.equal('def'); + done(); + }); + }); +}); + describe('Post /comments', () => { const users = [{ id: '123', diff --git a/tests/routes/api/stream/index.js b/tests/routes/api/stream/index.js index 9744abb0c..b1348e88a 100644 --- a/tests/routes/api/stream/index.js +++ b/tests/routes/api/stream/index.js @@ -60,7 +60,6 @@ describe('api/stream: routes', () => { .end(function(err, res){ expect(err).to.be.null; expect(res).to.have.status(200); - if (err) {return done(err);} done(); }); }); From 0c04e765d683e97991845ff8fdce5e39f4887645 Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 7 Nov 2016 15:10:56 -0800 Subject: [PATCH 02/47] Moderation queue on flagged comments. --- routes/api/comments/index.js | 6 +++--- tests/routes/api/comments/index.js | 27 ++++++++++++++++++++++----- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index f2166d34e..e1f3ab9c9 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -30,9 +30,9 @@ router.get('/:comment_id', (req, res, next) => { router.get('/action/:action_type', (req, res, next) => { Action.find({'action_type': req.params.action_type, 'item_type': 'comment'}).then((actions) => { - // search all the comments that are in actions by id: item_id - // populate user by user_id - res.status(200).json(actions); + Comment.find({'id': {'$in': actions.map(function(a){return a.item_id;})}}).exec(function(err, comments){ + res.status(200).json(comments); + }); }).catch(error => { next(error); }); diff --git a/tests/routes/api/comments/index.js b/tests/routes/api/comments/index.js index 6416d1412..9b43a97c4 100644 --- a/tests/routes/api/comments/index.js +++ b/tests/routes/api/comments/index.js @@ -66,7 +66,7 @@ describe('Get /comments', () => { }); }); -describe('Get moderation queues rejected, pending', () => { +describe('Get moderation queues rejected, pending, flags', () => { const comments = [{ id: 'abc', body: 'comment 10', @@ -95,10 +95,12 @@ describe('Get moderation queues rejected, pending', () => { const actions = [{ action_type: 'flag', - item_id: 'abc' + item_id: 'abc', + item_type: 'comment' }, { action_type: 'like', - item_id: 'hij' + item_id: 'hij', + item_type: 'comment' }]; beforeEach(() => { @@ -132,6 +134,19 @@ describe('Get moderation queues rejected, pending', () => { done(); }); }); + + it('should return all the flagged comments', function(done){ + chai.request(app) + .get('/api/v1/comments/action/flag') + .end(function(err, res){ + expect(res).to.have.status(200); + expect(err).to.be.null; + expect(res.body.length).to.equal(1); + expect(res.body[0]).to.have.property('id'); + expect(res.body[0].id).to.equal('abc'); + done(); + }); + }); }); describe('Post /comments', () => { @@ -196,10 +211,12 @@ describe('Get /:comment_id', () => { const actions = [{ action_type: 'flag', - item_id: 'abc' + item_id: 'abc', + item_type: 'comment' }, { action_type: 'like', - item_id: 'hij' + item_id: 'hij', + item_type: 'comment' }]; beforeEach(() => { From c8c82fd03b21bbcd4f44b5d331eea2bef850d3c8 Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 7 Nov 2016 18:10:17 -0800 Subject: [PATCH 03/47] Move all DB functions into models. Clean up tests. --- models/action.js | 28 +++++++++++++++- models/comment.js | 52 ++++++++++++++++++++++++++++++ routes/api/comments/index.js | 27 +++++++++------- tests/routes/api/comments/index.js | 22 ++++++------- 4 files changed, 103 insertions(+), 26 deletions(-) diff --git a/models/action.js b/models/action.js index 27c63747a..1d75c483c 100644 --- a/models/action.js +++ b/models/action.js @@ -28,7 +28,7 @@ ActionSchema.statics.findById = function(id) { }; /** - * Finds users in an array of ids. + * Finds actions in an array of ids. * @param {String} ids array of user identifiers (uuid) */ ActionSchema.statics.findByItemIdArray = function(item_ids) { @@ -37,6 +37,32 @@ ActionSchema.statics.findByItemIdArray = function(item_ids) { }); }; +/** + * Finds all comments for a specific action. + * @param {String} action_type type of action + * @param {String} item_type type of item the action is on +*/ +ActionSchema.statics.findByType = function(action_type, item_type) { + return Action.find({ + 'action_type': action_type, + 'item_type': item_type + }); +}; + +/** + * Finds all comments ids for a specific action. + * @param {String} action_type type of action + * @param {String} item_type type of item the action is on +*/ +ActionSchema.statics.findCommentsIdByActionType = function(action_type, item_type) { + return Action.find({ + 'action_type': action_type, + 'item_type': item_type + }, + 'item_id' + ); +}; + const Action = mongoose.model('Action', ActionSchema); module.exports = Action; diff --git a/models/comment.js b/models/comment.js index 6ddc3b0ee..3aad5d978 100644 --- a/models/comment.js +++ b/models/comment.js @@ -31,6 +31,23 @@ const CommentSchema = new Schema({ } }); +//============================================================================== +// New Statics +//============================================================================== + +/** + * Create a comment. + * @param {String} body content of comment +*/ +CommentSchema.statics.new = function(body, author_id, asset_id, parent_id, status, username) { + let comment = new Comment({body, author_id, asset_id, parent_id, status, username}); + return comment.save(); +}; + +//============================================================================== +// Find Statics +//============================================================================== + /** * Finds a comment by the id. * @param {String} id identifier of comment (uuid) @@ -47,6 +64,28 @@ CommentSchema.statics.findByAssetId = function(asset_id) { return Comment.find({asset_id}); }; +/** + * Find comments by an action that was performed on them. + * @param {String} action_type the type of action that was performed on the comment +*/ +CommentSchema.statics.findByActionType = function(action_type) { + return Action.findCommentsIdByActionType(action_type, 'comment').then((actions) => { + return Comment.find({'id': {'$in': actions.map(function(a){return a.item_id;})}}); + }); +}; + +/** + * Find comments by their status. + * @param {String} status the status to search for +*/ +CommentSchema.statics.findByStatus = function(status) { + return Comment.find({'status': status}); +}; + +//============================================================================== +// Update Statics +//============================================================================== + /** * Change the status of a comment. * @param {String} id identifier of the comment (uuid) @@ -72,6 +111,19 @@ CommentSchema.statics.addAction = function(id, user_id, action_type) { return action.save(); }; +//============================================================================== +// Remove Statics +//============================================================================== + +/** + * Change the status of a comment. + * @param {String} id identifier of the comment (uuid) + * @param {String} status the new status of the comment +*/ +CommentSchema.statics.removeById = function(id) { + return Comment.remove({'id': id}); +}; + const Comment = mongoose.model('Comment', CommentSchema); module.exports = Comment; diff --git a/routes/api/comments/index.js b/routes/api/comments/index.js index e1f3ab9c9..b3e2bdee7 100644 --- a/routes/api/comments/index.js +++ b/routes/api/comments/index.js @@ -1,6 +1,5 @@ const express = require('express'); const Comment = require('../../../models/comment'); -const Action = require('../../../models/action'); const router = express.Router(); @@ -29,17 +28,15 @@ router.get('/:comment_id', (req, res, next) => { //============================================================================== router.get('/action/:action_type', (req, res, next) => { - Action.find({'action_type': req.params.action_type, 'item_type': 'comment'}).then((actions) => { - Comment.find({'id': {'$in': actions.map(function(a){return a.item_id;})}}).exec(function(err, comments){ - res.status(200).json(comments); - }); + Comment.findByActionType(req.params.action_type).then((comments) => { + res.status(200).json(comments); }).catch(error => { next(error); }); }); router.get('/status/rejected', (req, res, next) => { - Comment.find({'status': 'rejected'}).then((comments) => { + Comment.findByStatus('rejected').then((comments) => { res.status(200).json(comments); }).catch(error => { next(error); @@ -47,7 +44,7 @@ router.get('/status/rejected', (req, res, next) => { }); router.get('/status/pending', (req, res, next) => { - Comment.find({'status': ''}).then((comments) => { + Comment.findByStatus('').then((comments) => { res.status(200).json(comments); }).catch(error => { next(error); @@ -60,12 +57,18 @@ router.get('/status/pending', (req, res, next) => { router.post('/', (req, res, next) => { const {body, author_id, asset_id, parent_id, status, username} = req.body; - let comment = new Comment({body, author_id, asset_id, parent_id, status, username}); - comment.save().then(({id}) => { - res.status(200).send({'id': id}); + Comment.new(body, author_id, asset_id, parent_id, status, username).then((comment) => { + res.status(200).send({'id': comment.id}); }).catch(error => { next(error); }); + + // let comment = new Comment({body, author_id, asset_id, parent_id, status, username}); + // comment.save().then(({id}) => { + // res.status(200).send({'id': id}); + // }).catch(error => { + // next(error); + // }); }); router.post('/:comment_id', (req, res, next) => { @@ -104,8 +107,8 @@ router.post('/:comment_id/actions', (req, res, next) => { //============================================================================== router.delete('/:comment_id', (req, res, next) => { - Comment.remove(req.params.comment_id).then(() => { - res.status(201).send('OK. Deleted'); + Comment.removeById(req.params.comment_id).then(() => { + res.status(201).send('OK. Removed'); }).catch(error => { next(error); }); diff --git a/tests/routes/api/comments/index.js b/tests/routes/api/comments/index.js index 9b43a97c4..eaf32adee 100644 --- a/tests/routes/api/comments/index.js +++ b/tests/routes/api/comments/index.js @@ -297,7 +297,7 @@ describe('Put /:comment_id', () => { }); }); -describe('Delete /:comment_id', () => { +describe('Remove /:comment_id', () => { const comments = [{ id: 'abc', @@ -343,9 +343,10 @@ describe('Delete /:comment_id', () => { chai.request(app) .delete('/api/v1/comments/abc') .end(function(err, res){ + expect(err).to.be.null; expect(res).to.have.status(201); - Comment.findById({'id': 'abc'}).then((comment) => { - expect(comment).to.be.null; + Comment.findById('abc').then((comment) => { + expect(comment).to.be.empty; }); done(); }); @@ -405,8 +406,7 @@ describe('Post /:comment_id/status', () => { expect(err).to.be.null; expect(res).to.have.status(200); expect(res).to.have.body; - expect(res.body).to.have.property('status'); - expect(res.body.status).to.equal('accepted'); + expect(res.body).to.have.property('status', 'accepted'); done(); }); }); @@ -465,14 +465,10 @@ describe('Post /:comment_id/actions', () => { expect(err).to.be.null; expect(res).to.have.status(200); expect(res).to.have.body; - expect(res.body).to.have.property('item_type'); - expect(res.body.item_type).to.equal('comment'); - expect(res.body).to.have.property('action_type'); - expect(res.body.action_type).to.equal('flag'); - expect(res.body).to.have.property('item_id'); - expect(res.body.item_id).to.equal('abc'); - expect(res.body).to.have.property('user_id'); - expect(res.body.user_id).to.equal('456'); + expect(res.body).to.have.property('item_type', 'comment'); + expect(res.body).to.have.property('action_type', 'flag'); + expect(res.body).to.have.property('item_id', 'abc'); + expect(res.body).to.have.property('user_id', '456'); done(); }); }); From 588a8de489869b08ad3c198539363a444db2d231 Mon Sep 17 00:00:00 2001 From: gaba Date: Mon, 7 Nov 2016 18:16:04 -0800 Subject: [PATCH 04/47] MOve two lines into one. --- tests/routes/api/settings/index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tests/routes/api/settings/index.js b/tests/routes/api/settings/index.js index 8c2cd221e..985e0fe1c 100644 --- a/tests/routes/api/settings/index.js +++ b/tests/routes/api/settings/index.js @@ -24,8 +24,7 @@ describe('GET /settings', () => { expect(err).to.be.null; expect(res).to.have.status(200); expect(res).to.be.json; - expect(res.body).to.have.property('moderation'); - expect(res.body.moderation).to.equal('pre'); + expect(res.body).to.have.property('moderation', 'pre'); done(err); }); }); @@ -55,8 +54,7 @@ describe('update settings', () => { expect(err).to.be.null; expect(res).to.have.status(200); expect(res).to.be.json; - expect(res.body).to.have.property('moderation'); - expect(res.body.moderation).to.equal('post'); + expect(res.body).to.have.property('moderation', 'post'); }); }); }); From b10ae913abb4d768a5167468159ab488eed65807 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 8 Nov 2016 10:07:41 -0700 Subject: [PATCH 05/47] fix a race condition in the tests --- tests/routes/api/settings/index.js | 31 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/tests/routes/api/settings/index.js b/tests/routes/api/settings/index.js index 8c2cd221e..eebab69c9 100644 --- a/tests/routes/api/settings/index.js +++ b/tests/routes/api/settings/index.js @@ -38,25 +38,30 @@ describe('update settings', () => { return Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}); }); - it('should respond to a PUT with new settings', () => { + it('should respond ok to a PUT', () => { chai.request(app) .put('/api/v1/settings') .send({moderation: 'post'}, (err, res) => { expect(err).to.be.null; expect(res).to.have.status(204); - done(err); + + if (err) { + return done(err); + } + + // confirm have updated settings + chai.request(app) + .get('/api/v1/settings') + .end((err, res) => { + expect(err).to.be.null; + expect(res).to.have.status(200); + expect(res).to.be.json; + expect(res.body).to.have.property('moderation'); + expect(res.body.moderation).to.equal('post'); + + done(err); + }); }); }); - it('should have updates settings', () => { - chai.request(app) - .get('/api/v1/settings') - .end((err, res) => { - expect(err).to.be.null; - expect(res).to.have.status(200); - expect(res).to.be.json; - expect(res.body).to.have.property('moderation'); - expect(res.body.moderation).to.equal('post'); - }); - }); }); From 411e6e48f3471ceb0a5b7c1b01184a45ec3240f7 Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 8 Nov 2016 12:28:09 -0500 Subject: [PATCH 06/47] Removing unused copy from build process. --- client/coral-admin/webpack.config.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index 2c81bf4fc..8c224bcdb 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -23,10 +23,6 @@ module.exports = Object.assign({}, devConfig, { ] }, plugins: [ - new Copy([{ - from: path.join(__dirname, '..', 'coral-embed-stream', 'dist'), - to: './embed/comment-stream' - }]), autoprefixer, precss ] }) From 095f6a319eaf41396b62bea7d396c0fa897b55a1 Mon Sep 17 00:00:00 2001 From: riley Date: Tue, 8 Nov 2016 10:38:49 -0700 Subject: [PATCH 07/47] remove the 2 requests in settings tests. add Promises --- tests/routes/api/settings/index.js | 38 +++++++++++------------------- 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/tests/routes/api/settings/index.js b/tests/routes/api/settings/index.js index eebab69c9..f6d07c03e 100644 --- a/tests/routes/api/settings/index.js +++ b/tests/routes/api/settings/index.js @@ -34,34 +34,24 @@ describe('GET /settings', () => { // update the settings. describe('update settings', () => { - before(() => { - return Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}); - }); - it('should respond ok to a PUT', () => { - chai.request(app) - .put('/api/v1/settings') - .send({moderation: 'post'}, (err, res) => { - expect(err).to.be.null; - expect(res).to.have.status(204); + return Setting.update({id: '1'}, {$setOnInsert: defaults}, {upsert: true}) + .then(() => { + return chai.request(app) + .put('/api/v1/settings') + .send({moderation: 'post'}) + .then(res => { + expect(res).to.have.status(204); - if (err) { - return done(err); - } + return Setting.getSettings(); - // confirm have updated settings - chai.request(app) - .get('/api/v1/settings') - .end((err, res) => { - expect(err).to.be.null; - expect(res).to.have.status(200); - expect(res).to.be.json; - expect(res.body).to.have.property('moderation'); - expect(res.body.moderation).to.equal('post'); - - done(err); + }).then(settings => { + // confirm updated settings in db + expect(settings).to.have.property('moderation'); + expect(settings.moderation).to.equal('post'); + }).catch(err => { + throw err; }); }); }); - }); From 80754ee57b471092a840ccb2722f6a992b0b013f Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 8 Nov 2016 12:55:32 -0500 Subject: [PATCH 08/47] Updating build scripts for coral-admin --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0c7aab592..2ee7de0ab 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "pretest": "npm install", "test": "mocha tests --recursive", "test-watch": "mocha tests --recursive -w", - "embed-start": "./node_modules/webpack/bin/webpack.js --config ./client/coral-embed-stream/webpack.config.dev.js && ./bin/www" + "embed-start": "npm run build && ./bin/www" }, "config": { "pre-git": { From ee33b8445b08b0dcb946761fbc95b2e63d15a82b Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 8 Nov 2016 12:56:22 -0500 Subject: [PATCH 09/47] Adding embed script to appropriate screen in settings. --- .../coral-admin/src/containers/Configure.js | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/src/containers/Configure.js b/client/coral-admin/src/containers/Configure.js index 4a36e56e7..f90e8c747 100644 --- a/client/coral-admin/src/containers/Configure.js +++ b/client/coral-admin/src/containers/Configure.js @@ -12,6 +12,8 @@ import { } from 'react-mdl' import Page from 'components/Page' import styles from './Configure.css' +import I18n from 'coral-framework/i18n/i18n' +import translations from '../translations' class Configure extends React.Component { constructor (props) { @@ -40,12 +42,28 @@ class Configure extends React.Component { } + copyToClipBoard (event) { + const copyTextarea = document.querySelector('.' + styles.embedInput) + copyTextarea.select() + + try { + document.execCommand('copy') + } catch (err) { + console.error('Unable to copy') + } + } + getEmbed () { + const embedText = + `
` + return

Copy and paste code below into your CMS to embed your comment box in your articles

- - + +
} @@ -94,3 +112,5 @@ class Configure extends React.Component { } export default connect(x => x)(Configure) + +const lang = new I18n(translations) From 7e720464812cc4268cabc0679bd8cfd0ac281d21 Mon Sep 17 00:00:00 2001 From: David Jay Date: Tue, 8 Nov 2016 12:57:16 -0500 Subject: [PATCH 10/47] Adding npm install to build process for coral-admin so build works. --- client/coral-admin/config.sample.json | 3 --- client/coral-admin/package.json | 2 +- 2 files changed, 1 insertion(+), 4 deletions(-) delete mode 100644 client/coral-admin/config.sample.json diff --git a/client/coral-admin/config.sample.json b/client/coral-admin/config.sample.json deleted file mode 100644 index 55d39db05..000000000 --- a/client/coral-admin/config.sample.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "basePath": "client/coral-admin" -} diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json index 048359526..f7217952e 100644 --- a/client/coral-admin/package.json +++ b/client/coral-admin/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "build": "./node_modules/.bin/webpack --config webpack.config.js", + "build": "npm install && ./node_modules/.bin/webpack --config webpack.config.js", "start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --inline --hot --content-base public --port 3142" }, "keywords": [], From 242e64198ab4e705314a4dd770f2a7b3590a737a Mon Sep 17 00:00:00 2001 From: David Erwin Date: Tue, 8 Nov 2016 13:09:09 -0500 Subject: [PATCH 11/47] Add autoprefixer to dependencies --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 0c7aab592..45470f3c8 100644 --- a/package.json +++ b/package.json @@ -42,12 +42,13 @@ }, "homepage": "https://github.com/coralproject/talk#readme", "dependencies": { + "autoprefixer": "^6.5.2", "body-parser": "^1.15.2", "debug": "^2.2.0", "express": "^4.14.0", "mongoose": "^4.6.5", - "uuid": "^2.0.3", - "morgan": "^1.7.0" + "morgan": "^1.7.0", + "uuid": "^2.0.3" }, "devDependencies": { "babel-core": "6.14.0", From a15d2eade7b0af71177b3afe80c0e8c2a6ca83e9 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 8 Nov 2016 11:15:08 -0700 Subject: [PATCH 12/47] add ejs templating and serve coral-admin from /admin --- app.js | 7 +++++++ client/coral-admin/webpack.config.dev.js | 10 ---------- client/coral-admin/webpack.config.js | 9 --------- package.json | 5 +++-- client/coral-admin/index.ejs => views/admin.ejs | 0 5 files changed, 10 insertions(+), 21 deletions(-) rename client/coral-admin/index.ejs => views/admin.ejs (100%) diff --git a/app.js b/app.js index 838819e35..5d91243e8 100644 --- a/app.js +++ b/app.js @@ -3,11 +3,14 @@ const bodyParser = require('body-parser'); const morgan = require('morgan'); const path = require('path'); +const adminConfig = require('./client/coral-admin/config'); const app = express(); // Middleware declarations. app.use(morgan('dev')); app.use(bodyParser.json()); +app.set('views', path.join(__dirname, 'views')); +app.set('view engine', 'ejs'); // API Routes. app.use('/api/v1', require('./routes/api')); @@ -15,4 +18,8 @@ app.use('/api/v1', require('./routes/api')); // Static Routes. app.use('/client/', express.static(path.join(__dirname, 'dist'))); +app.get('/admin/*', (req, res) => { + res.render('admin', {basePath: '/client/coral-admin'}); +}); + module.exports = app; diff --git a/client/coral-admin/webpack.config.dev.js b/client/coral-admin/webpack.config.dev.js index bd5913b5a..1eba29d66 100644 --- a/client/coral-admin/webpack.config.dev.js +++ b/client/coral-admin/webpack.config.dev.js @@ -1,16 +1,6 @@ - const path = require('path') -const fs = require('fs') const autoprefixer = require('autoprefixer') const precss = require('precss') -const config = require('./config.json') - -// doing a string replace here because I spent a day trying to do it the "webpack" way -// ond nothing works. just trying to replace a string in an index.html file is -// apparently something no one has ever done in the js community. -let templateString = fs.readFileSync(path.join(__dirname, 'index.ejs')).toString() -templateString = templateString.replace('<%= basePath %>', config.basePath) -fs.writeFileSync(path.join(__dirname, 'public/index.html'), templateString) module.exports = { entry: { diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index 2c81bf4fc..10768b6e5 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -1,17 +1,8 @@ const path = require('path') -const fs = require('fs') const devConfig = require('./webpack.config.dev') const autoprefixer = require('autoprefixer') const precss = require('precss') const Copy = require('copy-webpack-plugin') -const config = require('./config.json') - -// doing a string replace here because I spent a day trying to do it the "webpack" way -// ond nothing works. just trying to replace a string in an index.html file is -// apparently something no one has ever done in the js community. -let templateString = fs.readFileSync(path.join(__dirname, 'index.ejs')).toString() -templateString = templateString.replace('<%= basePath %>', config.basePath) -fs.writeFileSync(path.join(__dirname, 'public/index.html'), templateString) module.exports = Object.assign({}, devConfig, { module: { diff --git a/package.json b/package.json index 0c7aab592..bbd097221 100644 --- a/package.json +++ b/package.json @@ -44,10 +44,11 @@ "dependencies": { "body-parser": "^1.15.2", "debug": "^2.2.0", + "ejs": "^2.5.2", "express": "^4.14.0", "mongoose": "^4.6.5", - "uuid": "^2.0.3", - "morgan": "^1.7.0" + "morgan": "^1.7.0", + "uuid": "^2.0.3" }, "devDependencies": { "babel-core": "6.14.0", diff --git a/client/coral-admin/index.ejs b/views/admin.ejs similarity index 100% rename from client/coral-admin/index.ejs rename to views/admin.ejs From b6355b06db8f95c1359c980acc3324b2ffed5e02 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 8 Nov 2016 11:24:46 -0700 Subject: [PATCH 13/47] remove unused var --- app.js | 1 - 1 file changed, 1 deletion(-) diff --git a/app.js b/app.js index 5d91243e8..76dba1c1a 100644 --- a/app.js +++ b/app.js @@ -3,7 +3,6 @@ const bodyParser = require('body-parser'); const morgan = require('morgan'); const path = require('path'); -const adminConfig = require('./client/coral-admin/config'); const app = express(); // Middleware declarations. From ed01d5441813160104789bd280863cc2c700826c Mon Sep 17 00:00:00 2001 From: gaba Date: Tue, 8 Nov 2016 10:23:59 -0800 Subject: [PATCH 14/47] It fixes random test on get comment by comment_id. --- tests/routes/api/comments/index.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/tests/routes/api/comments/index.js b/tests/routes/api/comments/index.js index eaf32adee..378860bcb 100644 --- a/tests/routes/api/comments/index.js +++ b/tests/routes/api/comments/index.js @@ -117,8 +117,7 @@ describe('Get moderation queues rejected, pending, flags', () => { .end(function(err, res){ expect(err).to.be.null; expect(res).to.have.status(200); - expect(res.body[0]).to.have.property('id'); - expect(res.body[0].id).to.equal('abc'); + expect(res.body[0]).to.have.property('id', 'abc'); done(); }); }); @@ -129,8 +128,7 @@ describe('Get moderation queues rejected, pending, flags', () => { .end(function(err, res){ expect(err).to.be.null; expect(res).to.have.status(200); - expect(res.body[0]).to.have.property('id'); - expect(res.body[0].id).to.equal('def'); + expect(res.body[0]).to.have.property('id', 'def'); done(); }); }); @@ -142,8 +140,7 @@ describe('Get moderation queues rejected, pending, flags', () => { expect(res).to.have.status(200); expect(err).to.be.null; expect(res.body.length).to.equal(1); - expect(res.body[0]).to.have.property('id'); - expect(res.body[0].id).to.equal('abc'); + expect(res.body[0]).to.have.property('id', 'abc'); done(); }); }); @@ -229,13 +226,12 @@ describe('Get /:comment_id', () => { it('should return the right comment for the comment_id', function(done){ chai.request(app) - .get('/api/v1/comments') - .query({'comment_id': 'abc'}) + .get('/api/v1/comments/abc') .end(function(err, res){ expect(err).to.be.null; expect(res).to.have.status(200); - expect(res.body[0]).to.have.property('body'); - expect(res.body[0].body).to.equal('comment 10'); + expect(res).to.have.property('body'); + expect(res.body).to.have.property('body', 'comment 10'); done(); }); }); @@ -290,8 +286,7 @@ describe('Put /:comment_id', () => { .end(function(err, res){ expect(err).to.be.null; expect(res).to.have.status(200); - expect(res.body).to.have.property('body'); - expect(res.body.body).to.equal('Something body.'); + expect(res.body).to.have.property('body', 'Something body.'); done(); }); }); From 6f6da144015a956e360125aa5dd034c61da2ca80 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 8 Nov 2016 11:27:47 -0700 Subject: [PATCH 15/47] fix build script a bit --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bbd097221..ee92db73f 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "main": "app.js", "scripts": { "start": "./bin/www", - "build": "./node_modules/webpack/bin/webpack.js --config ./client/coral-embed-stream/webpack.config.js && cd client/coral-admin && npm run build", + "build": "./node_modules/webpack/bin/webpack.js --config ./client/coral-embed-stream/webpack.config.js && cd client/coral-admin && npm install && npm run build", "lint": "eslint .", "pretest": "npm install", "test": "mocha tests --recursive", From 1508eac92de2f22087219b059e883f5971cbfbe8 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 15:51:43 -0300 Subject: [PATCH 16/47] Removing divs from routes --- client/coral-admin/index.ejs | 4 ++-- client/coral-admin/package.json | 1 + client/coral-admin/public/index.html | 4 ++-- client/coral-admin/src/components/App.js | 11 +++++------ client/coral-admin/src/components/Header.js | 9 +++++---- .../coral-admin/src/containers/CommunityContainer.js | 10 ++++++++++ client/coral-admin/webpack.config.dev.js | 6 ++++++ client/coral-admin/webpack.config.js | 8 +++++++- 8 files changed, 38 insertions(+), 15 deletions(-) create mode 100644 client/coral-admin/src/containers/CommunityContainer.js diff --git a/client/coral-admin/index.ejs b/client/coral-admin/index.ejs index 9b5fe84bf..038fb58d7 100644 --- a/client/coral-admin/index.ejs +++ b/client/coral-admin/index.ejs @@ -10,8 +10,8 @@ body, #root { width: 100%; height: 100%; - margin: 0; - background: #fff; + margin: 0; + background: #fff; } diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json index ced6a3512..26f355e3d 100644 --- a/client/coral-admin/package.json +++ b/client/coral-admin/package.json @@ -5,6 +5,7 @@ "main": "index.js", "scripts": { "build": "./node_modules/.bin/webpack --config webpack.config.js", + "watch": "./node_modules/.bin/webpack --config webpack.config.js --watch", "start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --inline --hot --content-base public --port 3142" }, "keywords": [], diff --git a/client/coral-admin/public/index.html b/client/coral-admin/public/index.html index c31c22a6d..daf7304c8 100644 --- a/client/coral-admin/public/index.html +++ b/client/coral-admin/public/index.html @@ -10,8 +10,8 @@ body, #root { width: 100%; height: 100%; - margin: 0; - background: #fff; + margin: 0; + background: #fff; } diff --git a/client/coral-admin/src/components/App.js b/client/coral-admin/src/components/App.js index 545cd80a4..ff1c8f1d0 100644 --- a/client/coral-admin/src/components/App.js +++ b/client/coral-admin/src/components/App.js @@ -18,14 +18,13 @@ export default class App extends React.Component {
-
- - - - + + + + + -
diff --git a/client/coral-admin/src/components/Header.js b/client/coral-admin/src/components/Header.js index 8aebe7864..88a92c7ef 100644 --- a/client/coral-admin/src/components/Header.js +++ b/client/coral-admin/src/components/Header.js @@ -9,14 +9,15 @@ export default (props) => (
- Moderate - Configure + Moderate + Community + Configure
- Moderate - Configure + Moderate + Configure {props.children} diff --git a/client/coral-admin/src/containers/CommunityContainer.js b/client/coral-admin/src/containers/CommunityContainer.js new file mode 100644 index 000000000..6eb673125 --- /dev/null +++ b/client/coral-admin/src/containers/CommunityContainer.js @@ -0,0 +1,10 @@ +import React, { Component } from 'react' +import { connect } from 'react-redux' +import I18n from 'coral-framework/i18n/i18n' +import translations from '../translations' + +export default class CommunityContainer extends Component { + render() { + return
Hello
+ } +} \ No newline at end of file diff --git a/client/coral-admin/webpack.config.dev.js b/client/coral-admin/webpack.config.dev.js index ca3b5cab5..277da1877 100644 --- a/client/coral-admin/webpack.config.dev.js +++ b/client/coral-admin/webpack.config.dev.js @@ -36,6 +36,12 @@ module.exports = { context: __dirname, postcss: [autoprefixer, precss] } + }), + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('development'), + 'VERSION': JSON.stringify(require("./package.json").version) + } }) ], resolve: { diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index 67d5aef22..92a758cce 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -35,6 +35,12 @@ module.exports = Object.assign({}, devConfig, { debug: false } }), - new webpack.optimize.UglifyJsPlugin() + new webpack.optimize.UglifyJsPlugin(), + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production'), + 'VERSION': JSON.stringify(require("./package.json").version) + } + }) ] }) From ef3a34680a3eccaa4dc730c13811bc5cb774d931 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 15:52:09 -0300 Subject: [PATCH 17/47] config for pre git --- client/coral-admin/package.json | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json index 26f355e3d..b8e147c48 100644 --- a/client/coral-admin/package.json +++ b/client/coral-admin/package.json @@ -39,5 +39,14 @@ "style-loader": "0.13.1", "webpack": "2.1.0-beta.25", "webpack-dev-server": "1.16.1" + }, + "config": { + "pre-git": { + "commit-msg": [], + "pre-commit": [], + "pre-push": [], + "post-commit": [], + "post-merge": [] + } } } From 80f1f70a2a76f3662b3623df79412390b873ed20 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 8 Nov 2016 12:03:49 -0700 Subject: [PATCH 18/47] hardcode routes in react app --- client/coral-admin/.gitignore | 1 - client/coral-admin/config.json | 5 +++++ client/coral-admin/src/components/App.js | 9 ++++----- client/coral-admin/src/components/Header.js | 8 ++++---- 4 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 client/coral-admin/config.json diff --git a/client/coral-admin/.gitignore b/client/coral-admin/.gitignore index c9c7cb580..707c890e5 100644 --- a/client/coral-admin/.gitignore +++ b/client/coral-admin/.gitignore @@ -3,5 +3,4 @@ public/bundle.js public/embed/comment-stream .DS_Store npm-debug.log -config.json yarn.lock diff --git a/client/coral-admin/config.json b/client/coral-admin/config.json new file mode 100644 index 000000000..c8f318cfc --- /dev/null +++ b/client/coral-admin/config.json @@ -0,0 +1,5 @@ +{ + "basePath": "admin", + "talkHost": "http://localhost:16180", + "xeniaHost": "http://localhost:16180" +} diff --git a/client/coral-admin/src/components/App.js b/client/coral-admin/src/components/App.js index 4b7c01e84..81eea850f 100644 --- a/client/coral-admin/src/components/App.js +++ b/client/coral-admin/src/components/App.js @@ -8,17 +8,16 @@ import store from 'services/store' import CommentStream from 'containers/CommentStream' import EmbedLink from 'components/EmbedLink' import Configure from 'containers/Configure' -import config from 'services/config' export default class App extends React.Component { render (props) { return ( - - - - + + + + ) diff --git a/client/coral-admin/src/components/Header.js b/client/coral-admin/src/components/Header.js index 0e52686d8..ea268108e 100644 --- a/client/coral-admin/src/components/Header.js +++ b/client/coral-admin/src/components/Header.js @@ -9,14 +9,14 @@ export default (props) => (
- Moderate - Configure + Moderate + Configure
- Moderate - Configure + Moderate + Configure {props.children} From b18104c8d9e0bf819bec210212ca8349729432e6 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 16:19:53 -0300 Subject: [PATCH 19/47] Layout Container and Route handling --- client/coral-admin/package.json | 2 +- client/coral-admin/src/AppRouter.js | 24 ++++++++++++++++++ client/coral-admin/src/components/App.js | 23 +++-------------- client/coral-admin/src/components/Header.js | 6 ++--- .../coral-admin/src/components/ui/Layout.js | 5 ++++ .../src/containers/LayoutContainer.js | 25 +++++++++++++++++++ 6 files changed, 62 insertions(+), 23 deletions(-) create mode 100644 client/coral-admin/src/AppRouter.js create mode 100644 client/coral-admin/src/components/ui/Layout.js create mode 100644 client/coral-admin/src/containers/LayoutContainer.js diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json index b8e147c48..3d82facbe 100644 --- a/client/coral-admin/package.json +++ b/client/coral-admin/package.json @@ -5,7 +5,7 @@ "main": "index.js", "scripts": { "build": "./node_modules/.bin/webpack --config webpack.config.js", - "watch": "./node_modules/.bin/webpack --config webpack.config.js --watch", + "watch": "./node_modules/.bin/webpack --config webpack.config.dev.js --watch", "start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --inline --hot --content-base public --port 3142" }, "keywords": [], diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js new file mode 100644 index 000000000..85bfbd49d --- /dev/null +++ b/client/coral-admin/src/AppRouter.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { Router, Route, Redirect, IndexRoute, IndexRedirect, browserHistory } from 'react-router'; + +import config from 'services/config' + +import ModerationQueue from 'containers/ModerationQueue' +import CommentStream from 'containers/CommentStream' +import EmbedLink from 'components/EmbedLink' +import Configure from 'containers/Configure' +import CommunityContainer from 'containers/CommunityContainer' + +const routes = ( + + + + + + + +); + +const AppRouter = () => ; + +export default AppRouter; diff --git a/client/coral-admin/src/components/App.js b/client/coral-admin/src/components/App.js index ff1c8f1d0..4e904257e 100644 --- a/client/coral-admin/src/components/App.js +++ b/client/coral-admin/src/components/App.js @@ -1,32 +1,17 @@ - import React from 'react' import { Provider } from 'react-redux' -import { Layout } from 'react-mdl' import 'material-design-lite' -import { Router, Route, browserHistory } from 'react-router' -import ModerationQueue from 'containers/ModerationQueue' +import { Layout } from 'react-mdl' import Header from 'components/Header' import store from 'services/store' -import CommentStream from 'containers/CommentStream' -import EmbedLink from 'components/EmbedLink' -import Configure from 'containers/Configure' -import config from 'services/config' + +import AppRouter from '../AppRouter' export default class App extends React.Component { render (props) { return ( - -
- - - - - - - -
-
+
) } diff --git a/client/coral-admin/src/components/Header.js b/client/coral-admin/src/components/Header.js index 88a92c7ef..6aed77913 100644 --- a/client/coral-admin/src/components/Header.js +++ b/client/coral-admin/src/components/Header.js @@ -9,9 +9,9 @@ export default (props) => (
- Moderate - Community - Configure + Moderate + Community + Configure
diff --git a/client/coral-admin/src/components/ui/Layout.js b/client/coral-admin/src/components/ui/Layout.js new file mode 100644 index 000000000..1daac2d8d --- /dev/null +++ b/client/coral-admin/src/components/ui/Layout.js @@ -0,0 +1,5 @@ +import React from 'react' + +export const Layout = () => ( + +) \ No newline at end of file diff --git a/client/coral-admin/src/containers/LayoutContainer.js b/client/coral-admin/src/containers/LayoutContainer.js new file mode 100644 index 000000000..1d0c0d4f5 --- /dev/null +++ b/client/coral-admin/src/containers/LayoutContainer.js @@ -0,0 +1,25 @@ +import React, { Component }from 'react' +import { connect } from 'react-redux' + +import Layout from '../components/ui/Layout' + +class LayoutContainer extends Component { + render () { + return + } +} + +LayoutContainer.propTypes = {}; + +const mapStateToProps = state => { + return { + data: {} + }; +}; + +const mapDispatchToProps = (dispatch, ownProps) => ({ + dispatch +}); + +export default connect(mapStateToProps, mapDispatchToProps, null)(LayoutContainer); + From c7cf2785fd841a1919dbb5ec0c5171b4047f3ea5 Mon Sep 17 00:00:00 2001 From: Kim Gardner Date: Mon, 7 Nov 2016 21:36:52 -0500 Subject: [PATCH 20/47] Update README --- README.md | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d295ef326..f3a2d55fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,12 @@ # Talk [![CircleCI](https://circleci.com/gh/coralproject/talk.svg?style=svg)](https://circleci.com/gh/coralproject/talk) A commenting platform from The Coral Project. [https://coralproject.net](https://coralproject.net) +## Contributing to Talk + +### Local Dependencies +Node +Mongo + ### Getting Started `npm install` Run it once to install the dependencies. @@ -8,16 +14,21 @@ Run it once to install the dependencies. `npm start` Runs Talk. +### Running with Docker +Make sure you have Docker running first and then run `docker-compose up -d` + ### Testing `npm test` ### Lint `npm run lint` +### Helpful URLs +Bare comment stream: http://localhost:5000/client/coral-embed-stream/ +Comment stream embedded on sample article: http://localhost:5000/client/coral-embed-stream/samplearticle.html + ### Docs `swagger.yaml` -### Mantainers - ### License **Apache-2.0** From e3074892ce8e1870cc7097245e58261f27c2ed97 Mon Sep 17 00:00:00 2001 From: Kim Gardner Date: Tue, 8 Nov 2016 11:56:55 -0500 Subject: [PATCH 21/47] Add moderator view URL --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f3a2d55fc..3408c9f11 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,7 @@ Make sure you have Docker running first and then run `docker-compose up -d` ### Helpful URLs Bare comment stream: http://localhost:5000/client/coral-embed-stream/ Comment stream embedded on sample article: http://localhost:5000/client/coral-embed-stream/samplearticle.html +Moderator view: http://localhost:5000/client/coral-admin/ ### Docs `swagger.yaml` From db66c66f3da9a84d162ce4ce9c97282273f57d77 Mon Sep 17 00:00:00 2001 From: Kim Gardner Date: Tue, 8 Nov 2016 14:23:24 -0500 Subject: [PATCH 22/47] Update admin route --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3408c9f11..103910d77 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ Make sure you have Docker running first and then run `docker-compose up -d` `npm run lint` ### Helpful URLs -Bare comment stream: http://localhost:5000/client/coral-embed-stream/ +Bare comment stream: http://localhost:5000/client/coral-embed-stream Comment stream embedded on sample article: http://localhost:5000/client/coral-embed-stream/samplearticle.html -Moderator view: http://localhost:5000/client/coral-admin/ +Moderator view: http://localhost:5000/admin ### Docs `swagger.yaml` From ff42d571e6396bbb8311f1d04a69af71c8240cda Mon Sep 17 00:00:00 2001 From: Kim Gardner Date: Tue, 8 Nov 2016 14:25:53 -0500 Subject: [PATCH 23/47] Add trailing slashes to URLs --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 103910d77..f4d8b31de 100644 --- a/README.md +++ b/README.md @@ -24,9 +24,9 @@ Make sure you have Docker running first and then run `docker-compose up -d` `npm run lint` ### Helpful URLs -Bare comment stream: http://localhost:5000/client/coral-embed-stream +Bare comment stream: http://localhost:5000/client/coral-embed-stream/ Comment stream embedded on sample article: http://localhost:5000/client/coral-embed-stream/samplearticle.html -Moderator view: http://localhost:5000/admin +Moderator view: http://localhost:5000/admin/ ### Docs `swagger.yaml` From b7c0602a2c4caba15cfe4d14711ae8052a1f7746 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 16:32:09 -0300 Subject: [PATCH 24/47] Header, Drawer, Layout --- client/coral-admin/src/AppRouter.js | 1 + client/coral-admin/src/components/Header.js | 15 ++------------- client/coral-admin/src/components/ui/Drawer.js | 14 ++++++++++++++ client/coral-admin/src/components/ui/Layout.js | 10 ++++++++-- .../coral-admin/src/containers/LayoutContainer.js | 2 +- 5 files changed, 26 insertions(+), 16 deletions(-) create mode 100644 client/coral-admin/src/components/ui/Drawer.js diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 85bfbd49d..55ff1a90f 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -8,6 +8,7 @@ import CommentStream from 'containers/CommentStream' import EmbedLink from 'components/EmbedLink' import Configure from 'containers/Configure' import CommunityContainer from 'containers/CommunityContainer' +import LayoutContainer from 'containers/LayoutContainer' const routes = ( diff --git a/client/coral-admin/src/components/Header.js b/client/coral-admin/src/components/Header.js index 6aed77913..ed60f497b 100644 --- a/client/coral-admin/src/components/Header.js +++ b/client/coral-admin/src/components/Header.js @@ -1,12 +1,9 @@ import React from 'react' -import { Layout, Navigation, Drawer, Header } from 'react-mdl' +import { Navigation, Header } from 'react-mdl' import { Link } from 'react-router' import styles from './Header.css' -import config from 'services/config' -// App header. If we add a navbar it should be here -export default (props) => ( - +export default () => (
Moderate @@ -14,12 +11,4 @@ export default (props) => ( Configure
- - - Moderate - Configure - - - {props.children} -
) diff --git a/client/coral-admin/src/components/ui/Drawer.js b/client/coral-admin/src/components/ui/Drawer.js new file mode 100644 index 000000000..ffb77fbfe --- /dev/null +++ b/client/coral-admin/src/components/ui/Drawer.js @@ -0,0 +1,14 @@ +import React from 'react' +import { Navigation, Drawer } from 'react-mdl' +import { Link } from 'react-router' +import styles from './Header.css' +import config from 'services/config' + +export default () => ( + + + Moderate + Configure + + +) diff --git a/client/coral-admin/src/components/ui/Layout.js b/client/coral-admin/src/components/ui/Layout.js index 1daac2d8d..cdc2f5b41 100644 --- a/client/coral-admin/src/components/ui/Layout.js +++ b/client/coral-admin/src/components/ui/Layout.js @@ -1,5 +1,11 @@ import React from 'react' +import { Layout as LayoutMDL} from 'react-mdl' +import Header from '../Header' -export const Layout = () => ( - +export const Layout = ({ children }) => ( + > +
+ + {children} + ) \ No newline at end of file diff --git a/client/coral-admin/src/containers/LayoutContainer.js b/client/coral-admin/src/containers/LayoutContainer.js index 1d0c0d4f5..a96d73505 100644 --- a/client/coral-admin/src/containers/LayoutContainer.js +++ b/client/coral-admin/src/containers/LayoutContainer.js @@ -1,7 +1,7 @@ import React, { Component }from 'react' import { connect } from 'react-redux' -import Layout from '../components/ui/Layout' +import { Layout } from '../components/ui/Layout' class LayoutContainer extends Component { render () { From c609e5b3bb5541dd5b0f9a7fa8a587372c4e5a61 Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 8 Nov 2016 12:35:37 -0700 Subject: [PATCH 25/47] enable css modules --- client/coral-admin/webpack.config.dev.js | 2 +- client/coral-admin/webpack.config.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/coral-admin/webpack.config.dev.js b/client/coral-admin/webpack.config.dev.js index 1eba29d66..e4d771e72 100644 --- a/client/coral-admin/webpack.config.dev.js +++ b/client/coral-admin/webpack.config.dev.js @@ -14,7 +14,7 @@ module.exports = { loaders: [ { test: /.js$/, loader: 'babel', include: path.join(__dirname, 'src'), exclude: /node_modules/ }, { test: /\.json$/, loaders: 'json', include: __dirname, exclude: /node_modules/ }, - { test: /.css$/, loaders: ['style-loader', 'css-loader?importLoaders=1', 'postcss-loader'] } + { test: /.css$/, loaders: ['style-loader', 'css-loader?modules&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader'] } ] }, plugins: [ autoprefixer, precss ], diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index 10768b6e5..1b6fc0962 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -10,7 +10,7 @@ module.exports = Object.assign({}, devConfig, { loaders: [ { test: /.js$/, loader: 'babel', include: [path.join(__dirname, 'src'), path.join(__dirname, '../', 'coral-framework')], exclude: /node_modules/ }, { test: /.json$/, loader: 'json', include: __dirname, exclude: /node_modules/ }, - { test: /.css$/, loaders: ['style-loader', 'css-loader?importLoaders=1', 'postcss-loader'] } + { test: /.css$/, loaders: ['style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader'] } ] }, plugins: [ From 6c9e31c52d6fa7ca9a0f92bbc45dfdb2e7a8639e Mon Sep 17 00:00:00 2001 From: David Erwin Date: Tue, 8 Nov 2016 14:36:40 -0500 Subject: [PATCH 26/47] Drop trailing slash requirement on admin route --- app.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app.js b/app.js index 76dba1c1a..d4041c93a 100644 --- a/app.js +++ b/app.js @@ -17,7 +17,7 @@ app.use('/api/v1', require('./routes/api')); // Static Routes. app.use('/client/', express.static(path.join(__dirname, 'dist'))); -app.get('/admin/*', (req, res) => { +app.get('/admin*', (req, res) => { res.render('admin', {basePath: '/client/coral-admin'}); }); From 130fc259bf11446a1dce631d260b86c7cedb8c7c Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 16:36:52 -0300 Subject: [PATCH 27/47] Cleanup --- client/coral-admin/src/components/App.js | 1 - client/coral-admin/src/components/Header.js | 14 -------------- .../coral-admin/src/components/{ => ui}/Header.css | 0 client/coral-admin/src/components/ui/Header.js | 14 ++++++++++++++ client/coral-admin/src/components/ui/Layout.js | 5 +++-- 5 files changed, 17 insertions(+), 17 deletions(-) delete mode 100644 client/coral-admin/src/components/Header.js rename client/coral-admin/src/components/{ => ui}/Header.css (100%) create mode 100644 client/coral-admin/src/components/ui/Header.js diff --git a/client/coral-admin/src/components/App.js b/client/coral-admin/src/components/App.js index 4e904257e..1fbbe1448 100644 --- a/client/coral-admin/src/components/App.js +++ b/client/coral-admin/src/components/App.js @@ -2,7 +2,6 @@ import React from 'react' import { Provider } from 'react-redux' import 'material-design-lite' import { Layout } from 'react-mdl' -import Header from 'components/Header' import store from 'services/store' import AppRouter from '../AppRouter' diff --git a/client/coral-admin/src/components/Header.js b/client/coral-admin/src/components/Header.js deleted file mode 100644 index ed60f497b..000000000 --- a/client/coral-admin/src/components/Header.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react' -import { Navigation, Header } from 'react-mdl' -import { Link } from 'react-router' -import styles from './Header.css' - -export default () => ( -
- - Moderate - Community - Configure - -
-) diff --git a/client/coral-admin/src/components/Header.css b/client/coral-admin/src/components/ui/Header.css similarity index 100% rename from client/coral-admin/src/components/Header.css rename to client/coral-admin/src/components/ui/Header.css diff --git a/client/coral-admin/src/components/ui/Header.js b/client/coral-admin/src/components/ui/Header.js new file mode 100644 index 000000000..0c2d8753f --- /dev/null +++ b/client/coral-admin/src/components/ui/Header.js @@ -0,0 +1,14 @@ +import React from 'react' +import { Navigation, Header } from 'react-mdl' +import { Link } from 'react-router' +import styles from './Header.css' + +export default () => ( +
+ + Moderate + Community + Configure + +
+) diff --git a/client/coral-admin/src/components/ui/Layout.js b/client/coral-admin/src/components/ui/Layout.js index cdc2f5b41..fd963b667 100644 --- a/client/coral-admin/src/components/ui/Layout.js +++ b/client/coral-admin/src/components/ui/Layout.js @@ -1,9 +1,10 @@ import React from 'react' import { Layout as LayoutMDL} from 'react-mdl' -import Header from '../Header' +import Header from './Header' +import Drawer from './Drawer' export const Layout = ({ children }) => ( - > +
{children} From 1874206dd76514534795961939a68a9c5f698e4a Mon Sep 17 00:00:00 2001 From: Riley Davis Date: Tue, 8 Nov 2016 12:38:16 -0700 Subject: [PATCH 28/47] update root package.json --- package.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/package.json b/package.json index bb62d4ca3..df096877d 100644 --- a/package.json +++ b/package.json @@ -52,6 +52,7 @@ "uuid": "^2.0.3" }, "devDependencies": { + "autoprefixer": "6.5.0", "babel-core": "6.14.0", "babel-jest": "^15.0.0", "babel-loader": "6.2.5", @@ -66,6 +67,7 @@ "chai": "^3.5.0", "chai-http": "^3.0.0", "copy-webpack-plugin": "^3.0.1", + "css-loader": "0.25.0", "eslint": "^3.9.1", "exports-loader": "^0.6.3", "immutable": "^3.8.1", @@ -73,6 +75,9 @@ "json-loader": "^0.5.4", "mocha": "^3.1.2", "mocha-junit-reporter": "^1.12.1", + "postcss-loader": "0.13.0", + "postcss-modules": "0.5.2", + "precss": "1.4.0", "pre-git": "^3.10.0", "pym.js": "^1.1.1", "react": "15.3.2", @@ -81,6 +86,7 @@ "redux": "^3.6.0", "redux-thunk": "^2.1.0", "regenerator": "^0.8.46", + "style-loader": "0.13.1", "supertest": "^2.0.1", "timeago.js": "^2.0.3", "webpack": "^1.13.2", From 24c9215dc281a6f06d9cc4cce64b0bae392d4430 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 8 Nov 2016 12:39:49 -0700 Subject: [PATCH 29/47] Added circle improvements --- Dockerfile | 8 +------- circle.yml | 1 + 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index 985e55159..3be5916a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,15 +11,9 @@ EXPOSE 5000 # Install app dependencies COPY package.json /usr/src/app/ -RUN npm install +RUN npm install --production # Bundle app source COPY . /usr/src/app -# Compile static assets -RUN npm run build - -# Prune development dependancies -RUN npm prune --production - CMD [ "npm", "start" ] diff --git a/circle.yml b/circle.yml index 9de9eae4c..b9cea6fed 100644 --- a/circle.yml +++ b/circle.yml @@ -8,6 +8,7 @@ test: override: - MOCHA_FILE=$CIRCLE_TEST_REPORTS/junit/test-results.xml ./node_modules/.bin/mocha tests --reporter mocha-junit-reporter - npm run lint + - npm run build deployment: release: From 661b402351c6a7eff9e7549762af39bc6f28e84b Mon Sep 17 00:00:00 2001 From: David Erwin Date: Tue, 8 Nov 2016 14:53:28 -0500 Subject: [PATCH 30/47] Remove npm install from coral-admin build --- client/coral-admin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json index f7217952e..048359526 100644 --- a/client/coral-admin/package.json +++ b/client/coral-admin/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "build": "npm install && ./node_modules/.bin/webpack --config webpack.config.js", + "build": "./node_modules/.bin/webpack --config webpack.config.js", "start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --inline --hot --content-base public --port 3142" }, "keywords": [], From a36524a55f1879f81d1f2fc6af12ac45d6d21feb Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 17:21:12 -0300 Subject: [PATCH 31/47] merge --- client/coral-admin/postcss.config.js | 7 +++++++ views/admin.ejs | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 client/coral-admin/postcss.config.js create mode 100644 views/admin.ejs diff --git a/client/coral-admin/postcss.config.js b/client/coral-admin/postcss.config.js new file mode 100644 index 000000000..d5267160a --- /dev/null +++ b/client/coral-admin/postcss.config.js @@ -0,0 +1,7 @@ +module.exports = { + plugins: [ + require('postcss-smart-import')({ /* ...options */ }), + require('precss')({ /* ...options */ }), + require('autoprefixer')({ /* ...options */ }) + ] +} diff --git a/views/admin.ejs b/views/admin.ejs new file mode 100644 index 000000000..038fb58d7 --- /dev/null +++ b/views/admin.ejs @@ -0,0 +1,22 @@ + + + + + + Talk - Coral Admin + + + + + +
+ + + From 551ba2ebb34862e4572410c3bfb0beb16d98f309 Mon Sep 17 00:00:00 2001 From: David Erwin Date: Tue, 8 Nov 2016 15:46:00 -0500 Subject: [PATCH 32/47] Add TERMINOLOGY.md --- TERMINOLOGY.md | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 TERMINOLOGY.md diff --git a/TERMINOLOGY.md b/TERMINOLOGY.md new file mode 100644 index 000000000..5c1e9aaa8 --- /dev/null +++ b/TERMINOLOGY.md @@ -0,0 +1,66 @@ +# Product's Terminology + +This is a guide to have a common language to talk about "Talk". + +## Definitions + +* Site - a top level site, aka nytimes.com +* Section - the section of a site, aka, Politics. +* Subsection - the section of a site, aka, Politics. +* Asset - An article/video/etc identified by URL. + +* Embed - Things we put on a asset: comment box, ToS, Stream, etc… +* Stream - All the activity on a certain asset. Container for Comments, actions, user +* Thread - defined by a parent and everything below. All replies to a comment and their replies, etc… +* Comment - a kind of user-generated content submitted by a comment author + * A parent comment has replies to it + * A child comments is a reply to another comment + * A comment can be both a parent comment and a child of another comment + * A top-level comment is a comment that is not a reply to any other comment + * A nth-level comment refers to the number of replies away from the top-level comment + +* User - an item to represent a person using Talk. It could be a moderator, reader, etc. +* User Roles: + * Active: some who takes action (logged in or not) + * Passive: some who just reads, no actions performed + * Comment Author: The user who wrote the comment + * Staff Member: someone who works for an organization (tagged for leverage in trust) + * Moderator: someone with the ability to access the moderation queue and perform moderation actions + * Administrator: has the ability to change the setup of their coral space +* Public Profile: information about users shown in public +* Private Profile: information about users shown only to user about themselves +* Protected Profile: information about users that only moderators and admins can see + +* Queue - Group of items based on a query, aka - moderation queue +* Target - The item/s on which an action is performed.. + +## Actions + +Actions are performed by users on items. Actions themselves are items. This requires two relationships: action on item, and user performs action. + +### Flag +* A Flagger(user) performs a Flag +* A Flag is performed on a Comment or a username or profile content + + +## Moderation Actions and Status + +Comments contain a field `status`. As moderation actions are peformed, the status changes. + +* Initial status is empty. +* When a moderator Approves, the status is set to 'approved'. +* When a moderator Rejects, the status is set to 'reject'. + +### Pre and post moderation + +Comments can be set to be premoderated or postmoderated. + +Premoderation means that moderation has to occur _before_ a comment is shown on the site: + +* New comments are shown in the moderator queues immediately. +* The are not shown to users until (aka in streams) until they are approved by a moderator. + +Postmoderation means that comments appear on the site _before_ any moderation action is taken. + +* New comments appear in comment streams immediately. +* New comments do not appear in moderation queues unless they are flagged by other users. From cba476edfe05e07367ba4bde02f71da1194f2110 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 17:49:48 -0300 Subject: [PATCH 33/47] removing watch adding webpack const for env vars --- client/coral-admin/package.json | 1 - client/coral-admin/webpack.config.dev.js | 41 ------------------------ client/coral-admin/webpack.config.js | 1 + 3 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 client/coral-admin/webpack.config.dev.js diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json index f19191581..190e6830b 100644 --- a/client/coral-admin/package.json +++ b/client/coral-admin/package.json @@ -5,7 +5,6 @@ "main": "index.js", "scripts": { "build": "./node_modules/.bin/webpack --config webpack.config.js", - "watch": "./node_modules/.bin/webpack --config webpack.config.dev.js --watch", "start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --inline --hot --content-base public --port 3142" }, "keywords": [], diff --git a/client/coral-admin/webpack.config.dev.js b/client/coral-admin/webpack.config.dev.js deleted file mode 100644 index ac4b6fe07..000000000 --- a/client/coral-admin/webpack.config.dev.js +++ /dev/null @@ -1,41 +0,0 @@ -const path = require('path') -const autoprefixer = require('autoprefixer') -const precss = require('precss') - -module.exports = { - entry: { - 'bundle': path.join(__dirname, 'src', 'index') - }, - output: { - path: path.join(__dirname, '..', '..', 'dist', 'coral-admin'), - filename: '[name].js' - }, - module: { - loaders: [ - { test: /.js$/, loader: 'babel', include: path.join(__dirname, 'src'), exclude: /node_modules/ }, - { test: /\.json$/, loaders: 'json', include: __dirname, exclude: /node_modules/ }, - { test: /.css$/, loaders: ['style-loader', 'css-loader?modules&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader'] } - ] - }, - plugins: [ - autoprefixer, - precss, - new webpack.DefinePlugin({ - 'process.env': { - 'NODE_ENV': JSON.stringify('development'), - 'VERSION': JSON.stringify(require("./package.json").version) - } - }) - ], - resolve: { - root: [ - path.resolve('./src'), - path.resolve('../') - ] - }, - devServer: { - historyApiFallback: { - index: '/' - } - } -} \ No newline at end of file diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index a92f5ec26..7b6f0ee5c 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -3,6 +3,7 @@ const devConfig = require('./webpack.config.dev') const autoprefixer = require('autoprefixer') const precss = require('precss') const Copy = require('copy-webpack-plugin') +const webpack = require('webpack') module.exports = Object.assign({}, devConfig, { module: { From ce31161ef942479dfbfb39174fabedba72b00c3a Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 18:22:27 -0300 Subject: [PATCH 34/47] Production webpack --- client/coral-admin/webpack.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index 7b6f0ee5c..8aa87e0b3 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -19,7 +19,7 @@ module.exports = Object.assign({}, devConfig, { precss, new webpack.DefinePlugin({ 'process.env': { - 'NODE_ENV': JSON.stringify('development'), + 'NODE_ENV': JSON.stringify('production'), 'VERSION': JSON.stringify(require("./package.json").version) } }) From 8920a59a92feef4c1e9cd3596152b1d1bce4371c Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 18:25:54 -0300 Subject: [PATCH 35/47] =?UTF-8?q?=C3=A1dding=20dev=20back?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/coral-admin/webpack.config.dev.js | 32 ++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 client/coral-admin/webpack.config.dev.js diff --git a/client/coral-admin/webpack.config.dev.js b/client/coral-admin/webpack.config.dev.js new file mode 100644 index 000000000..d58e33320 --- /dev/null +++ b/client/coral-admin/webpack.config.dev.js @@ -0,0 +1,32 @@ +const path = require('path') +const autoprefixer = require('autoprefixer') +const precss = require('precss') + +module.exports = { + entry: { + 'bundle': path.join(__dirname, 'src', 'index') + }, + output: { + path: path.join(__dirname, '..', '..', 'dist', 'coral-admin'), + filename: '[name].js' + }, + module: { + loaders: [ + { test: /.js$/, loader: 'babel', include: path.join(__dirname, 'src'), exclude: /node_modules/ }, + { test: /\.json$/, loaders: 'json', include: __dirname, exclude: /node_modules/ }, + { test: /.css$/, loaders: ['style-loader', 'css-loader?modules&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader'] } + ] + }, + plugins: [ autoprefixer, precss ], + resolve: { + root: [ + path.resolve('./src'), + path.resolve('../') + ] + }, + devServer: { + historyApiFallback: { + index: '/' + } + } +} \ No newline at end of file From 285830211fab16b8652a2daa4189ef61895c61bd Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 18:46:50 -0300 Subject: [PATCH 36/47] Updated Links --- client/coral-admin/package.json | 2 +- client/coral-admin/src/AppRouter.js | 11 +++++------ client/coral-admin/src/components/ui/Drawer.js | 6 +++--- client/coral-admin/src/components/ui/Header.js | 6 +++--- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json index 190e6830b..c04809b0f 100644 --- a/client/coral-admin/package.json +++ b/client/coral-admin/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "build": "./node_modules/.bin/webpack --config webpack.config.js", + "build": "./node_modules/.bin/webpack --config webpack.config.js --watch", "start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --inline --hot --content-base public --port 3142" }, "keywords": [], diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 55ff1a90f..673a368f8 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -11,12 +11,11 @@ import CommunityContainer from 'containers/CommunityContainer' import LayoutContainer from 'containers/LayoutContainer' const routes = ( - - - - - - + + + + + ); diff --git a/client/coral-admin/src/components/ui/Drawer.js b/client/coral-admin/src/components/ui/Drawer.js index ffb77fbfe..b1c87baaf 100644 --- a/client/coral-admin/src/components/ui/Drawer.js +++ b/client/coral-admin/src/components/ui/Drawer.js @@ -2,13 +2,13 @@ import React from 'react' import { Navigation, Drawer } from 'react-mdl' import { Link } from 'react-router' import styles from './Header.css' -import config from 'services/config' export default () => ( - Moderate - Configure + Moderate + Community + Configure ) diff --git a/client/coral-admin/src/components/ui/Header.js b/client/coral-admin/src/components/ui/Header.js index 0c2d8753f..1455721d8 100644 --- a/client/coral-admin/src/components/ui/Header.js +++ b/client/coral-admin/src/components/ui/Header.js @@ -6,9 +6,9 @@ import styles from './Header.css' export default () => (
- Moderate - Community - Configure + Moderate + Community + Configure
) From c9453c3c2af9846e79970b105974743763e84459 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 18:48:43 -0300 Subject: [PATCH 37/47] Route nesting --- client/coral-admin/src/AppRouter.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 673a368f8..3fa2f431d 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -1,7 +1,5 @@ import React from 'react'; -import { Router, Route, Redirect, IndexRoute, IndexRedirect, browserHistory } from 'react-router'; - -import config from 'services/config' +import { Router, Route, Redirect, IndexRoute, browserHistory } from 'react-router'; import ModerationQueue from 'containers/ModerationQueue' import CommentStream from 'containers/CommentStream' @@ -11,11 +9,11 @@ import CommunityContainer from 'containers/CommunityContainer' import LayoutContainer from 'containers/LayoutContainer' const routes = ( - - - - - + + + + + ); From 52fd6c1618b0d7283de719f9d479d85a720ab173 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 18:50:40 -0300 Subject: [PATCH 38/47] Community route --- client/coral-admin/src/AppRouter.js | 1 + client/coral-admin/src/containers/CommunityContainer.js | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 3fa2f431d..8f24093d4 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -13,6 +13,7 @@ const routes = ( + ); diff --git a/client/coral-admin/src/containers/CommunityContainer.js b/client/coral-admin/src/containers/CommunityContainer.js index 6eb673125..7aed080d4 100644 --- a/client/coral-admin/src/containers/CommunityContainer.js +++ b/client/coral-admin/src/containers/CommunityContainer.js @@ -5,6 +5,10 @@ import translations from '../translations' export default class CommunityContainer extends Component { render() { - return
Hello
+ return ( +
+

Community

+
+ ) } } \ No newline at end of file From ad1d55557488989fa220b8c307f8cc6be0eeb738 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 18:51:52 -0300 Subject: [PATCH 39/47] Removing the watch --- client/coral-admin/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json index c04809b0f..190e6830b 100644 --- a/client/coral-admin/package.json +++ b/client/coral-admin/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "build": "./node_modules/.bin/webpack --config webpack.config.js --watch", + "build": "./node_modules/.bin/webpack --config webpack.config.js", "start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --inline --hot --content-base public --port 3142" }, "keywords": [], From 8369f263fb0eaad6a9ce8d606b367a5ebf5d2de0 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 8 Nov 2016 15:00:19 -0700 Subject: [PATCH 40/47] Merged webpack files to unified --- client/coral-admin/.gitignore | 6 -- client/coral-admin/config.json | 4 +- client/coral-admin/package.json | 42 --------- client/coral-admin/postcss.config.js | 7 -- client/coral-admin/public/index.html | 22 ----- client/coral-admin/webpack.config.dev.js | 32 ------- client/coral-admin/webpack.config.js | 19 ---- client/coral-embed-stream/.gitignore | 0 client/coral-embed-stream/dev-server.js | 41 --------- client/coral-embed-stream/index.html | 13 --- .../src/{app.js => index.js} | 0 .../coral-embed-stream/webpack.config.dev.js | 70 --------------- client/coral-embed-stream/webpack.config.js | 73 --------------- dist/coral-admin/index.html | 23 ----- dist/coral-admin/manifest.json | 12 --- package.json | 20 +++-- webpack.config.dev.js | 90 +++++++++++++++++++ webpack.config.js | 22 +++++ 18 files changed, 126 insertions(+), 370 deletions(-) delete mode 100644 client/coral-admin/.gitignore delete mode 100644 client/coral-admin/package.json delete mode 100644 client/coral-admin/postcss.config.js delete mode 100644 client/coral-admin/public/index.html delete mode 100644 client/coral-admin/webpack.config.dev.js delete mode 100644 client/coral-admin/webpack.config.js delete mode 100644 client/coral-embed-stream/.gitignore delete mode 100644 client/coral-embed-stream/dev-server.js delete mode 100644 client/coral-embed-stream/index.html rename client/coral-embed-stream/src/{app.js => index.js} (100%) delete mode 100644 client/coral-embed-stream/webpack.config.dev.js delete mode 100644 client/coral-embed-stream/webpack.config.js delete mode 100644 dist/coral-admin/index.html delete mode 100644 dist/coral-admin/manifest.json create mode 100644 webpack.config.dev.js create mode 100644 webpack.config.js diff --git a/client/coral-admin/.gitignore b/client/coral-admin/.gitignore deleted file mode 100644 index 707c890e5..000000000 --- a/client/coral-admin/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -node_modules -public/bundle.js -public/embed/comment-stream -.DS_Store -npm-debug.log -yarn.lock diff --git a/client/coral-admin/config.json b/client/coral-admin/config.json index c8f318cfc..156740de5 100644 --- a/client/coral-admin/config.json +++ b/client/coral-admin/config.json @@ -1,5 +1,3 @@ { - "basePath": "admin", - "talkHost": "http://localhost:16180", - "xeniaHost": "http://localhost:16180" + "basePath": "admin" } diff --git a/client/coral-admin/package.json b/client/coral-admin/package.json deleted file mode 100644 index 048359526..000000000 --- a/client/coral-admin/package.json +++ /dev/null @@ -1,42 +0,0 @@ -{ - "name": "coral-admin", - "version": "1.0.0", - "description": "", - "main": "index.js", - "scripts": { - "build": "./node_modules/.bin/webpack --config webpack.config.js", - "start": "./node_modules/.bin/webpack-dev-server --config webpack.config.dev.js --inline --hot --content-base public --port 3142" - }, - "keywords": [], - "author": "", - "license": "ISC", - "dependencies": { - "hammerjs": "2.0.8", - "immutable": "3.8.1", - "keymaster": "1.6.2", - "material-design-lite": "1.2.1", - "react": "^15.3.2", - "react-dom": "^15.3.2", - "react-mdl": "^1.7.2", - "react-redux": "^4.4.5", - "react-router": "^3.0.0", - "redux": "3.6.0", - "redux-thunk": "2.1.0", - "timeago.js": "2.0.2" - }, - "devDependencies": { - "autoprefixer": "6.5.0", - "babel-core": "^6.18.2", - "babel-loader": "^6.2.7", - "copy-webpack-plugin": "3.0.1", - "css-loader": "0.25.0", - "json-loader": "0.5.4", - "postcss-loader": "0.13.0", - "postcss-modules": "0.5.2", - "precss": "1.4.0", - "standard": "8.2.0", - "style-loader": "0.13.1", - "webpack": "^1.13.3", - "webpack-dev-server": "1.16.1" - } -} diff --git a/client/coral-admin/postcss.config.js b/client/coral-admin/postcss.config.js deleted file mode 100644 index d5267160a..000000000 --- a/client/coral-admin/postcss.config.js +++ /dev/null @@ -1,7 +0,0 @@ -module.exports = { - plugins: [ - require('postcss-smart-import')({ /* ...options */ }), - require('precss')({ /* ...options */ }), - require('autoprefixer')({ /* ...options */ }) - ] -} diff --git a/client/coral-admin/public/index.html b/client/coral-admin/public/index.html deleted file mode 100644 index ef1adffec..000000000 --- a/client/coral-admin/public/index.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - Talk - Coral Admin - - - - - -
- - - diff --git a/client/coral-admin/webpack.config.dev.js b/client/coral-admin/webpack.config.dev.js deleted file mode 100644 index e4d771e72..000000000 --- a/client/coral-admin/webpack.config.dev.js +++ /dev/null @@ -1,32 +0,0 @@ -const path = require('path') -const autoprefixer = require('autoprefixer') -const precss = require('precss') - -module.exports = { - entry: { - 'bundle': path.join(__dirname, 'src', 'index') - }, - output: { - path: path.join(__dirname, '..', '..', 'dist', 'coral-admin'), - filename: '[name].js' - }, - module: { - loaders: [ - { test: /.js$/, loader: 'babel', include: path.join(__dirname, 'src'), exclude: /node_modules/ }, - { test: /\.json$/, loaders: 'json', include: __dirname, exclude: /node_modules/ }, - { test: /.css$/, loaders: ['style-loader', 'css-loader?modules&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader'] } - ] - }, - plugins: [ autoprefixer, precss ], - resolve: { - root: [ - path.resolve('./src'), - path.resolve('../') - ] - }, - devServer: { - historyApiFallback: { - index: '/' - } - } -} diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js deleted file mode 100644 index 0cceded4b..000000000 --- a/client/coral-admin/webpack.config.js +++ /dev/null @@ -1,19 +0,0 @@ -const path = require('path') -const devConfig = require('./webpack.config.dev') -const autoprefixer = require('autoprefixer') -const precss = require('precss') -const Copy = require('copy-webpack-plugin') - -module.exports = Object.assign({}, devConfig, { - module: { - context: __dirname, - loaders: [ - { test: /.js$/, loader: 'babel', include: [path.join(__dirname, 'src'), path.join(__dirname, '../', 'coral-framework')], exclude: /node_modules/ }, - { test: /.json$/, loader: 'json', include: __dirname, exclude: /node_modules/ }, - { test: /.css$/, loaders: ['style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader'] } - ] - }, - plugins: [ - autoprefixer, precss - ] -}) diff --git a/client/coral-embed-stream/.gitignore b/client/coral-embed-stream/.gitignore deleted file mode 100644 index e69de29bb..000000000 diff --git a/client/coral-embed-stream/dev-server.js b/client/coral-embed-stream/dev-server.js deleted file mode 100644 index 926033fda..000000000 --- a/client/coral-embed-stream/dev-server.js +++ /dev/null @@ -1,41 +0,0 @@ -var path = require('path') -var express = require('express') -var http = require('http') -var webpack = require('webpack') -var config = require('./webpack.config.dev') -var Dashboard = require('webpack-dashboard') -var DashboardPlugin = require('webpack-dashboard/plugin') - -var app = express() -var server = http.Server(app) - -var compiler = webpack(config) -var dashboard = new Dashboard() -compiler.apply(new DashboardPlugin(dashboard.setData)) - -app.use(express.static('public')) - -app.use(require('webpack-dev-middleware')(compiler, { - noInfo: true, - quiet: true, - publicPath: config.output.publicPath -})) - -app.use(require('webpack-hot-middleware')(compiler, {log: () => {}})) - -app.get('/default.css', function (req, res) { - res.sendFile(path.join(__dirname, '/style/default.css')) -}) - -app.get('*', function (req, res) { - res.sendFile(path.join(__dirname, 'index.html')) -}) - -server.listen(6182, 'localhost', function (err) { - if (err) { - console.log(err) - return - } - - console.log('Listening at http://localhost:6182') -}) diff --git a/client/coral-embed-stream/index.html b/client/coral-embed-stream/index.html deleted file mode 100644 index 6e15cba9f..000000000 --- a/client/coral-embed-stream/index.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - -
- - - diff --git a/client/coral-embed-stream/src/app.js b/client/coral-embed-stream/src/index.js similarity index 100% rename from client/coral-embed-stream/src/app.js rename to client/coral-embed-stream/src/index.js diff --git a/client/coral-embed-stream/webpack.config.dev.js b/client/coral-embed-stream/webpack.config.dev.js deleted file mode 100644 index dd5534529..000000000 --- a/client/coral-embed-stream/webpack.config.dev.js +++ /dev/null @@ -1,70 +0,0 @@ -var path = require('path') -var webpack = require('webpack') -const Copy = require('copy-webpack-plugin') - -module.exports = { - devtool: 'eval', - entry: [ - 'babel-polyfill', - 'webpack-hot-middleware/client', - path.join(__dirname, 'src', 'app') - ], - output: { - path: path.join(__dirname, '..', '..','dist', 'coral-embed-stream'), - filename: 'bundle.js', - publicPath: '/' - }, - resolve: { - root: [ - path.resolve(__dirname, 'src'), - path.resolve(__dirname, '..') - ], - 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') - } - }), - new webpack.HotModuleReplacementPlugin(), - new webpack.ProvidePlugin({ - 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch' - }), - new webpack.NoErrorsPlugin() - ], - module: { - loaders: [{ - test: /\.(js|jsx)$/, - - loaders: ['babel'], - exclude: /node_modules/, - include: path.join(__dirname, '../') - }, { - test: /\.css$/, - loader: 'style-loader!css-loader' - }, { - test: /\.png$/, - loader: 'url-loader?limit=100000' - }, { - test: /\.(jpg|png|gif|svg)$/, - loader: 'file-loader' - }, { - test: /\.json$/, - loader: 'json-loader' - }, { - test: /\.woff$/, - loader: 'url?limit=100000' - }] - } -} diff --git a/client/coral-embed-stream/webpack.config.js b/client/coral-embed-stream/webpack.config.js deleted file mode 100644 index 2db94e6af..000000000 --- a/client/coral-embed-stream/webpack.config.js +++ /dev/null @@ -1,73 +0,0 @@ -const path = require('path') -const webpack = require('webpack') -const Copy = require('copy-webpack-plugin') - -//Keeping this file for reference, it should move to a global webpack. - -module.exports = { - devtool: 'source-map', - entry: [ - 'babel-polyfill', - path.join(__dirname, 'src', 'app') - ], - output: { - path: path.join(__dirname, '..', '..','dist', 'coral-embed-stream'), - filename: 'bundle.js', - publicPath: '/dist/' - }, - resolve: { - root: [ - path.resolve(__dirname, 'src') - ], - 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: './' - }, - { - from: path.resolve(__dirname, '..', 'coral-framework', 'i18n', 'translations'), - to: './translations' - }]), - new webpack.optimize.OccurenceOrderPlugin(), - new webpack.DefinePlugin({ - 'process.env': { - 'NODE_ENV': JSON.stringify('production') - } - }), - new webpack.ProvidePlugin({ - 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch' - }), - new webpack.ExtendedAPIPlugin() - ], - module: { - loaders: [{ - test: /\.(js|jsx)$/, - loaders: ['babel'], - exclude: /node_modules/, - include: path.join(__dirname, '../') - }, { - test: /\.css$/, - loader: 'style-loader!css-loader' - }, { - test: /\.png$/, - loader: 'url-loader?limit=100000' - }, { - test: /\.jpg$/, - loader: 'file-loader' - }, { - test: /\.json$/, - loader: 'json-loader' - }, { - test: /\.woff$/, - loader: 'url?limit=100000' - }] - } -} diff --git a/dist/coral-admin/index.html b/dist/coral-admin/index.html deleted file mode 100644 index 3be58a0c8..000000000 --- a/dist/coral-admin/index.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - Talk - Coral Admin - - - - - - -
- - - diff --git a/dist/coral-admin/manifest.json b/dist/coral-admin/manifest.json deleted file mode 100644 index 5da846121..000000000 --- a/dist/coral-admin/manifest.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "short_name": "Talk", - "name": "Talk", - "icons": [ - { - "src": "https://coralproject.net/images/icon-coral-white.svg", - "sizes": "150x150" - } - ], - "start_url": "./", - "display": "standalone" -} diff --git a/package.json b/package.json index dd22a5f8c..02bd7bbe7 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "app.js", "scripts": { "start": "./bin/www", - "build": "./node_modules/webpack/bin/webpack.js --config ./client/coral-embed-stream/webpack.config.js && cd client/coral-admin && npm install && npm run build", + "build": "webpack --config webpack.config.js --bail", + "build-watch": "webpack --config webpack.config.dev.js --watch", "lint": "eslint .", "pretest": "npm install", "test": "mocha tests --recursive", @@ -53,9 +54,9 @@ }, "devDependencies": { "autoprefixer": "6.5.0", - "babel-core": "6.14.0", + "babel-core": "^6.14.0", "babel-jest": "^15.0.0", - "babel-loader": "6.2.5", + "babel-loader": "^6.2.5", "babel-plugin-transform-async-to-generator": "^6.8.0", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-object-assign": "^6.8.0", @@ -67,26 +68,31 @@ "chai": "^3.5.0", "chai-http": "^3.0.0", "copy-webpack-plugin": "^3.0.1", - "css-loader": "0.25.0", + "css-loader": "^0.25.0", "eslint": "^3.9.1", "exports-loader": "^0.6.3", + "hammerjs": "^2.0.8", "immutable": "^3.8.1", "imports-loader": "^0.6.5", "json-loader": "^0.5.4", + "keymaster": "^1.6.2", + "material-design-lite": "^1.2.1", "mocha": "^3.1.2", "mocha-junit-reporter": "^1.12.1", - "postcss-loader": "0.13.0", + "postcss-loader": "^0.13.0", "postcss-modules": "0.5.2", - "precss": "1.4.0", "pre-git": "^3.10.0", + "precss": "^1.4.0", "pym.js": "^1.1.1", "react": "15.3.2", "react-dom": "15.3.2", + "react-mdl": "^1.7.2", "react-redux": "^4.4.5", + "react-router": "^3.0.0", "redux": "^3.6.0", "redux-thunk": "^2.1.0", "regenerator": "^0.8.46", - "style-loader": "0.13.1", + "style-loader": "^0.13.1", "supertest": "^2.0.1", "timeago.js": "^2.0.3", "webpack": "^1.13.2", diff --git a/webpack.config.dev.js b/webpack.config.dev.js new file mode 100644 index 000000000..73662d409 --- /dev/null +++ b/webpack.config.dev.js @@ -0,0 +1,90 @@ +const path = require('path'); +const autoprefixer = require('autoprefixer'); +const precss = require('precss'); +const Copy = require('copy-webpack-plugin'); +const webpack = require('webpack'); + +// Edit the build targets and embeds below. + +const buildTargets = [ + 'coral-admin' +]; + +const buildEmbeds = [ + 'stream' +]; + +module.exports = { + devtool: 'inline-source-map', + entry: buildTargets.reduce((entry, target) => { + + // Add the entry for the bundle. + entry[`${target}/bundle`] = [ + 'babel-polyfill', + path.join(__dirname, 'client/', target, '/src/index') + ]; + + return entry; + }, buildEmbeds.reduce((entry, embed) => { + + // Add the entry for the bundle. + entry[`embed/${embed}/bundle`] = [ + 'babel-polyfill', + path.join(__dirname, 'client/', `coral-embed-${embed}`, '/src/index') + ]; + + return entry; + }, {})), + output: { + path: path.join(__dirname, 'dist'), + filename: '[name].js' + }, + module: { + loaders: [ + { + loader: 'babel', + exclude: /node_modules/, + test: /\.js$/ + }, + { + loader: 'json', + test: /\.json$/, + exclude: /node_modules/ + }, + { + loaders: ['style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader'], + test: /.css$/, + }, + { + loader: 'url-loader?limit=100000', + test: /\.png$/ + }, + { + loader: 'file-loader', + test: /\.(jpg|png|gif|svg)$/ + }, + { + loader: 'url?limit=100000', + test: /\.woff$/ + } + ] + }, + plugins: [ + new Copy(buildEmbeds.map(embed => ({ + from: path.join(__dirname, 'client', `coral-embed-${embed}`, 'style'), + to: path.join(__dirname, 'dist', 'embed', embed) + }))), + autoprefixer, + precss, + new webpack.ProvidePlugin({ + 'fetch': 'imports?this=>global!exports?global.fetch!whatwg-fetch' + }) + ], + resolve: { + root: [ + path.join(__dirname, 'client'), + ...buildTargets.map(target => path.join(__dirname, 'client', target, 'src')), + ...buildEmbeds.map(embed => path.join(__dirname, 'client', `coral-embed-${embed}`, 'src')) + ] + } +}; diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 000000000..d28ca9d14 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,22 @@ +const webpack = require('webpack'); +const devConfig = require('./webpack.config.dev'); + +// Disable source maps. +devConfig.devtool = null; + +devConfig.plugins = devConfig.plugins.concat([ + new webpack.DefinePlugin({ + 'process.env': { + 'NODE_ENV': JSON.stringify('production') + } + }), + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + } + }), + new webpack.optimize.OccurrenceOrderPlugin(), + new webpack.optimize.DedupePlugin() +]); + +module.exports = devConfig; From 6738ff86e15d709515a46c4379e2f2dc20b6345f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 19:35:56 -0300 Subject: [PATCH 41/47] changes --- client/coral-admin/src/AppRouter.js | 10 +++++----- .../src/containers/CommunityContainer.js | 2 +- .../coral-admin/src/containers/LayoutContainer.js | 14 ++++---------- .../coral-admin/src/containers/ModerationQueue.js | 4 +--- 4 files changed, 11 insertions(+), 19 deletions(-) diff --git a/client/coral-admin/src/AppRouter.js b/client/coral-admin/src/AppRouter.js index 8f24093d4..40465bd19 100644 --- a/client/coral-admin/src/AppRouter.js +++ b/client/coral-admin/src/AppRouter.js @@ -1,5 +1,5 @@ -import React from 'react'; -import { Router, Route, Redirect, IndexRoute, browserHistory } from 'react-router'; +import React from 'react' +import { Router, Route, Redirect, IndexRoute, browserHistory } from 'react-router' import ModerationQueue from 'containers/ModerationQueue' import CommentStream from 'containers/CommentStream' @@ -16,8 +16,8 @@ const routes = ( -); +) -const AppRouter = () => ; +const AppRouter = () => -export default AppRouter; +export default AppRouter diff --git a/client/coral-admin/src/containers/CommunityContainer.js b/client/coral-admin/src/containers/CommunityContainer.js index 7aed080d4..bd13ca04b 100644 --- a/client/coral-admin/src/containers/CommunityContainer.js +++ b/client/coral-admin/src/containers/CommunityContainer.js @@ -7,7 +7,7 @@ export default class CommunityContainer extends Component { render() { return (
-

Community

+

Community

) } diff --git a/client/coral-admin/src/containers/LayoutContainer.js b/client/coral-admin/src/containers/LayoutContainer.js index a96d73505..7373c30c2 100644 --- a/client/coral-admin/src/containers/LayoutContainer.js +++ b/client/coral-admin/src/containers/LayoutContainer.js @@ -9,17 +9,11 @@ class LayoutContainer extends Component { } } -LayoutContainer.propTypes = {}; +LayoutContainer.propTypes = {} -const mapStateToProps = state => { - return { - data: {} - }; -}; +const mapStateToProps = state => ({ data: {} }) -const mapDispatchToProps = (dispatch, ownProps) => ({ - dispatch -}); +const mapDispatchToProps = (dispatch, ownProps) => ({ dispatch }) -export default connect(mapStateToProps, mapDispatchToProps, null)(LayoutContainer); +export default connect(mapStateToProps, mapDispatchToProps)(LayoutContainer) diff --git a/client/coral-admin/src/containers/ModerationQueue.js b/client/coral-admin/src/containers/ModerationQueue.js index ba388b83f..8de522930 100644 --- a/client/coral-admin/src/containers/ModerationQueue.js +++ b/client/coral-admin/src/containers/ModerationQueue.js @@ -18,9 +18,7 @@ class ModerationQueue extends React.Component { constructor (props) { super(props) - - console.log('ModerationQueue', props) - + this.state = { activeTab: 'pending', singleView: false, modalOpen: false } } From 4b7b8336ad9153007d674520e537a78d1e251b16 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 19:42:58 -0300 Subject: [PATCH 42/47] Env vars --- client/coral-admin/src/containers/ModerationQueue.js | 2 +- client/coral-admin/webpack.config.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/client/coral-admin/src/containers/ModerationQueue.js b/client/coral-admin/src/containers/ModerationQueue.js index 8de522930..f35a69b02 100644 --- a/client/coral-admin/src/containers/ModerationQueue.js +++ b/client/coral-admin/src/containers/ModerationQueue.js @@ -18,7 +18,7 @@ class ModerationQueue extends React.Component { constructor (props) { super(props) - + this.state = { activeTab: 'pending', singleView: false, modalOpen: false } } diff --git a/client/coral-admin/webpack.config.js b/client/coral-admin/webpack.config.js index 8aa87e0b3..7e74fc08c 100644 --- a/client/coral-admin/webpack.config.js +++ b/client/coral-admin/webpack.config.js @@ -19,8 +19,8 @@ module.exports = Object.assign({}, devConfig, { precss, new webpack.DefinePlugin({ 'process.env': { - 'NODE_ENV': JSON.stringify('production'), - 'VERSION': JSON.stringify(require("./package.json").version) + 'NODE_ENV': `"${`production`}"`, + 'VERSION': `"${require("./package.json").version})"` } }) ] From 8fd7a46d372583dbd5a699b68fd261bed5c6a1ab Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Tue, 8 Nov 2016 19:52:37 -0300 Subject: [PATCH 43/47] removed log --- client/coral-admin/src/containers/ModerationQueue.js | 1 - 1 file changed, 1 deletion(-) diff --git a/client/coral-admin/src/containers/ModerationQueue.js b/client/coral-admin/src/containers/ModerationQueue.js index f35a69b02..d051e5639 100644 --- a/client/coral-admin/src/containers/ModerationQueue.js +++ b/client/coral-admin/src/containers/ModerationQueue.js @@ -57,7 +57,6 @@ class ModerationQueue extends React.Component { render () { const { comments } = this.props const { activeTab, singleView, modalOpen } = this.state - console.log('moderation queue', styles) return (
From a1fd4d32baf1612d1db933563a954a9bbdb33d26 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 8 Nov 2016 15:53:26 -0700 Subject: [PATCH 44/47] Added error middleware --- .eslintrc.json | 1 + app.js | 53 +++++++++++++++++++++++++++++++++++++++---- routes/admin/index.js | 9 ++++++++ views/error.ejs | 20 ++++++++++++++++ 4 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 routes/admin/index.js create mode 100644 views/error.ejs diff --git a/.eslintrc.json b/.eslintrc.json index 5df3444a6..23bdea410 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -55,6 +55,7 @@ "no-var": [2], "no-lonely-if": [2], "curly": [2], + "no-unused-vars": ["error", { "argsIgnorePattern": "next" }], "no-multiple-empty-lines": [ "error", {"max": 1} diff --git a/app.js b/app.js index d4041c93a..29817c970 100644 --- a/app.js +++ b/app.js @@ -11,14 +11,57 @@ app.use(bodyParser.json()); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); -// API Routes. +// Routes. app.use('/api/v1', require('./routes/api')); +app.use('/client', express.static(path.join(__dirname, 'dist'))); +app.use('/admin', require('./routes/admin')); -// Static Routes. -app.use('/client/', express.static(path.join(__dirname, 'dist'))); +//============================================================================== +// ERROR HANDLING +//============================================================================== -app.get('/admin*', (req, res) => { - res.render('admin', {basePath: '/client/coral-admin'}); +const ErrNotFound = new Error('Not Found'); +ErrNotFound.status = 404; + +// Catch 404 and forward to error handler. +app.use((req, res, next) => { + next(ErrNotFound); +}); + +// General error handler. Respond with the message and error if we have it while +// returning a status code that makes sense. +if (app.get('env') === 'development') { + app.use('/api', (err, req, res, next) => { + res.status(err.status || 500); + res.json({ + message: err.message, + error: err + }); + }); + + app.use('/', (err, req, res, next) => { + res.status(err.status || 500); + res.render('error', { + message: err.message, + error: err + }); + }); +} + +app.use('/api', (err, req, res, next) => { + res.status(err.status || 500); + res.json({ + message: err.message, + error: {} + }); +}); + +app.use('/', (err, req, res, next) => { + res.status(err.status || 500); + res.render('error', { + message: err.message, + error: {} + }); }); module.exports = app; diff --git a/routes/admin/index.js b/routes/admin/index.js new file mode 100644 index 000000000..86fcb018f --- /dev/null +++ b/routes/admin/index.js @@ -0,0 +1,9 @@ +const express = require('express'); + +const router = express.Router(); + +router.get('*', (req, res) => { + res.render('admin', {basePath: '/client/coral-admin'}); +}); + +module.exports = router; diff --git a/views/error.ejs b/views/error.ejs new file mode 100644 index 000000000..18d70b831 --- /dev/null +++ b/views/error.ejs @@ -0,0 +1,20 @@ + + + + + + + Error + + + + +
+ +
<%= message %>
+ +
<%= error.stack %>
+ +
+ + From 7d5eae2e2f198f0c4ab5ebc5e97070fdc44b4a4e Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Tue, 8 Nov 2016 16:21:50 -0700 Subject: [PATCH 45/47] Added embed stream preview --- routes/admin/index.js | 4 ++++ views/embed-stream.ejs | 23 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 views/embed-stream.ejs diff --git a/routes/admin/index.js b/routes/admin/index.js index 86fcb018f..52957f54a 100644 --- a/routes/admin/index.js +++ b/routes/admin/index.js @@ -2,6 +2,10 @@ const express = require('express'); const router = express.Router(); +router.get('/embed/stream/preview', (req, res) => { + res.render('embed-stream', {basePath: '/client/embed/stream'}); +}); + router.get('*', (req, res) => { res.render('admin', {basePath: '/client/coral-admin'}); }); diff --git a/views/embed-stream.ejs b/views/embed-stream.ejs new file mode 100644 index 000000000..47bda6bee --- /dev/null +++ b/views/embed-stream.ejs @@ -0,0 +1,23 @@ + + + + + + Talk - Coral Admin + + + + + + +
+ + + From 72d01539fa5b1056639f94a7a48d8a8c026cb898 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Wed, 9 Nov 2016 10:16:07 -0300 Subject: [PATCH 46/47] Adding version and env --- webpack.config.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webpack.config.js b/webpack.config.js index d28ca9d14..434da160d 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -7,7 +7,8 @@ devConfig.devtool = null; devConfig.plugins = devConfig.plugins.concat([ new webpack.DefinePlugin({ 'process.env': { - 'NODE_ENV': JSON.stringify('production') + 'NODE_ENV': `"${'production'}"`, + 'VERSION': `"${require('./package.json')}"` } }), new webpack.optimize.UglifyJsPlugin({ From e638d2785bd1b16338f1e9f1edc08fed29f968a6 Mon Sep 17 00:00:00 2001 From: Wyatt Johnson Date: Wed, 9 Nov 2016 07:53:34 -0700 Subject: [PATCH 47/47] Some dep fixes which will hopefully resolve the CI issues --- package.json | 27 +++++++++++---------------- postcss.config.js | 7 +++++++ webpack.config.dev.js | 9 +++++++-- 3 files changed, 25 insertions(+), 18 deletions(-) create mode 100644 postcss.config.js diff --git a/package.json b/package.json index 02bd7bbe7..979475b5b 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,6 @@ }, "homepage": "https://github.com/coralproject/talk#readme", "dependencies": { - "autoprefixer": "^6.5.2", "body-parser": "^1.15.2", "debug": "^2.2.0", "ejs": "^2.5.2", @@ -53,21 +52,20 @@ "uuid": "^2.0.3" }, "devDependencies": { - "autoprefixer": "6.5.0", - "babel-core": "^6.14.0", - "babel-jest": "^15.0.0", - "babel-loader": "^6.2.5", - "babel-plugin-transform-async-to-generator": "^6.8.0", + "autoprefixer": "^6.5.0", + "babel-core": "^6.18.2", + "babel-loader": "^6.2.7", + "babel-plugin-transform-async-to-generator": "^6.16.0", "babel-plugin-transform-decorators-legacy": "^1.3.4", "babel-plugin-transform-object-assign": "^6.8.0", "babel-plugin-transform-react-jsx": "^6.8.0", - "babel-polyfill": "^6.13.0", - "babel-preset-es2015": "6.13.0", + "babel-polyfill": "^6.16.0", + "babel-preset-es2015": "^6.18.0", "babel-preset-es2015-minimal": "^2.1.0", "babel-preset-stage-0": "^6.16.0", "chai": "^3.5.0", "chai-http": "^3.0.0", - "copy-webpack-plugin": "^3.0.1", + "copy-webpack-plugin": "^4.0.0", "css-loader": "^0.25.0", "eslint": "^3.9.1", "exports-loader": "^0.6.3", @@ -79,8 +77,9 @@ "material-design-lite": "^1.2.1", "mocha": "^3.1.2", "mocha-junit-reporter": "^1.12.1", - "postcss-loader": "^0.13.0", - "postcss-modules": "0.5.2", + "postcss-loader": "^1.1.0", + "postcss-modules": "^0.5.2", + "postcss-smart-import": "^0.5.1", "pre-git": "^3.10.0", "precss": "^1.4.0", "pym.js": "^1.1.1", @@ -95,11 +94,7 @@ "style-loader": "^0.13.1", "supertest": "^2.0.1", "timeago.js": "^2.0.3", - "webpack": "^1.13.2", - "webpack-dashboard": "^0.2.0", - "webpack-dev-middleware": "^1.8.3", - "webpack-hot-middleware": "^2.12.2", - "webpack-module-hot-accept": "^1.0.4", + "webpack": "^1.13.3", "whatwg-fetch": "^1.0.0" }, "engines": { diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 000000000..79fae36cb --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,7 @@ +module.exports = { + plugins: [ + require('postcss-smart-import')({ /* ...options */ }), + require('precss')({ /* ...options */ }), + require('autoprefixer')({ /* ...options */ }) + ] +}; diff --git a/webpack.config.dev.js b/webpack.config.dev.js index 73662d409..e2c92b396 100644 --- a/webpack.config.dev.js +++ b/webpack.config.dev.js @@ -52,7 +52,11 @@ module.exports = { exclude: /node_modules/ }, { - loaders: ['style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', 'postcss-loader'], + loaders: [ + 'style-loader', + 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]', + 'postcss-loader' + ], test: /.css$/, }, { @@ -86,5 +90,6 @@ module.exports = { ...buildTargets.map(target => path.join(__dirname, 'client', target, 'src')), ...buildEmbeds.map(embed => path.join(__dirname, 'client', `coral-embed-${embed}`, 'src')) ] - } + }, + postcss: require('./postcss.config.js') };